Revert "[inspector] support for cases when embedder doesn't call contextDestroyed"
This reverts commit 87aae715df
.
Reason for revert: Speculative revert because of ASAN leaks in https://chromium-review.googlesource.com/584488
Original change's description:
> [inspector] support for cases when embedder doesn't call contextDestroyed
>
> Node.js doesn't have good place to call contextDestroyed.
> We need to cleanup everything on our side to allow clients to not call
> contextDestroyed method.
>
> R=dgozman@chromium.org,eostroukhov@google.com
>
> Bug: none
> Cq-Include-Trybots: master.tryserver.blink:linux_trusty_blink_rel;master.tryserver.chromium.linux:linux_chromium_rel_ng
> Change-Id: I6bfd4d6039f53eb994a2d20ecbca650744564e29
> Reviewed-on: https://chromium-review.googlesource.com/575519
> Reviewed-by: Dmitry Gozman <dgozman@chromium.org>
> Commit-Queue: Aleksey Kozyatinskiy <kozyatinskiy@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#46849}
TBR=dgozman@chromium.org,kozyatinskiy@chromium.org,eostroukhov@google.com,eostroukhov@chromium.org
Change-Id: Ic3c2764159f809536670f73ab0cd5ea37317d400
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: none
Cq-Include-Trybots: master.tryserver.blink:linux_trusty_blink_rel;master.tryserver.chromium.linux:linux_chromium_rel_ng
Reviewed-on: https://chromium-review.googlesource.com/584767
Reviewed-by: Michael Hablich <hablich@chromium.org>
Commit-Queue: Michael Hablich <hablich@chromium.org>
Cr-Commit-Position: refs/heads/master@{#46865}
This commit is contained in:
parent
6e3d7ee6cb
commit
4f2e6e9ddd
@ -15,38 +15,6 @@
|
||||
|
||||
namespace v8_inspector {
|
||||
|
||||
class InspectedContext::WeakCallbackData {
|
||||
public:
|
||||
WeakCallbackData(InspectedContext* context, V8InspectorImpl* inspector,
|
||||
int groupId, int contextId)
|
||||
: m_context(context),
|
||||
m_inspector(inspector),
|
||||
m_groupId(groupId),
|
||||
m_contextId(contextId) {}
|
||||
|
||||
static void resetContext(const v8::WeakCallbackInfo<WeakCallbackData>& data) {
|
||||
// InspectedContext is alive here because weak handler is still alive.
|
||||
data.GetParameter()->m_context->m_context.Reset();
|
||||
data.SetSecondPassCallback(&callContextCollected);
|
||||
}
|
||||
|
||||
static void callContextCollected(
|
||||
const v8::WeakCallbackInfo<WeakCallbackData>& data) {
|
||||
// InspectedContext can be dead here since anything can happen between first
|
||||
// and second pass callback.
|
||||
WeakCallbackData* callbackData = data.GetParameter();
|
||||
callbackData->m_inspector->contextCollected(callbackData->m_groupId,
|
||||
callbackData->m_contextId);
|
||||
delete callbackData;
|
||||
}
|
||||
|
||||
private:
|
||||
InspectedContext* m_context;
|
||||
V8InspectorImpl* m_inspector;
|
||||
int m_groupId;
|
||||
int m_contextId;
|
||||
};
|
||||
|
||||
InspectedContext::InspectedContext(V8InspectorImpl* inspector,
|
||||
const V8ContextInfo& info, int contextId)
|
||||
: m_inspector(inspector),
|
||||
@ -67,10 +35,6 @@ InspectedContext::InspectedContext(V8InspectorImpl* inspector,
|
||||
m_inspector->console()->installMemoryGetter(
|
||||
info.context, v8::Local<v8::Object>::Cast(console));
|
||||
}
|
||||
m_context.SetWeak(
|
||||
new WeakCallbackData(this, m_inspector, m_contextGroupId, m_contextId),
|
||||
&InspectedContext::WeakCallbackData::resetContext,
|
||||
v8::WeakCallbackType::kParameter);
|
||||
}
|
||||
|
||||
InspectedContext::~InspectedContext() {
|
||||
|
@ -47,8 +47,6 @@ class InspectedContext {
|
||||
friend class V8InspectorImpl;
|
||||
InspectedContext(V8InspectorImpl*, const V8ContextInfo&, int contextId);
|
||||
|
||||
class WeakCallbackData;
|
||||
|
||||
V8InspectorImpl* m_inspector;
|
||||
v8::Global<v8::Context> m_context;
|
||||
int m_contextId;
|
||||
|
@ -203,10 +203,6 @@ void V8InspectorImpl::contextCreated(const V8ContextInfo& info) {
|
||||
void V8InspectorImpl::contextDestroyed(v8::Local<v8::Context> context) {
|
||||
int contextId = InspectedContext::contextId(context);
|
||||
int groupId = contextGroupId(context);
|
||||
contextCollected(groupId, contextId);
|
||||
}
|
||||
|
||||
void V8InspectorImpl::contextCollected(int groupId, int contextId) {
|
||||
m_contextIdToGroupIdMap.erase(contextId);
|
||||
|
||||
ConsoleStorageMap::iterator storageIt = m_consoleStorageMap.find(groupId);
|
||||
|
@ -74,7 +74,6 @@ class V8InspectorImpl : public V8Inspector {
|
||||
const StringView& state) override;
|
||||
void contextCreated(const V8ContextInfo&) override;
|
||||
void contextDestroyed(v8::Local<v8::Context>) override;
|
||||
void contextCollected(int contextGroupId, int contextId);
|
||||
void resetContextGroup(int contextGroupId) override;
|
||||
void idleStarted() override;
|
||||
void idleFinished() override;
|
||||
|
@ -642,9 +642,6 @@ class InspectorExtension : public IsolateData::SetupGlobalTask {
|
||||
inspector->Set(ToV8String(isolate, "fireContextDestroyed"),
|
||||
v8::FunctionTemplate::New(
|
||||
isolate, &InspectorExtension::FireContextDestroyed));
|
||||
inspector->Set(
|
||||
ToV8String(isolate, "freeContext"),
|
||||
v8::FunctionTemplate::New(isolate, &InspectorExtension::FreeContext));
|
||||
inspector->Set(ToV8String(isolate, "addInspectedObject"),
|
||||
v8::FunctionTemplate::New(
|
||||
isolate, &InspectorExtension::AddInspectedObject));
|
||||
@ -686,12 +683,6 @@ class InspectorExtension : public IsolateData::SetupGlobalTask {
|
||||
data->FireContextDestroyed(context);
|
||||
}
|
||||
|
||||
static void FreeContext(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
v8::Local<v8::Context> context = args.GetIsolate()->GetCurrentContext();
|
||||
IsolateData* data = IsolateData::FromContext(context);
|
||||
data->FreeContext(context);
|
||||
}
|
||||
|
||||
static void AddInspectedObject(
|
||||
const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||
if (args.Length() != 2 || !args[0]->IsInt32()) {
|
||||
|
@ -303,13 +303,6 @@ void IsolateData::FireContextDestroyed(v8::Local<v8::Context> context) {
|
||||
inspector_->contextDestroyed(context);
|
||||
}
|
||||
|
||||
void IsolateData::FreeContext(v8::Local<v8::Context> context) {
|
||||
int context_group_id = GetContextGroupId(context);
|
||||
auto it = contexts_.find(context_group_id);
|
||||
if (it == contexts_.end()) return;
|
||||
contexts_.erase(it);
|
||||
}
|
||||
|
||||
std::vector<int> IsolateData::GetSessionIds(int context_group_id) {
|
||||
std::vector<int> result;
|
||||
for (auto& it : sessions_) {
|
||||
|
@ -68,7 +68,6 @@ class IsolateData : public v8_inspector::V8InspectorClient {
|
||||
void DumpAsyncTaskStacksStateForTest();
|
||||
void FireContextCreated(v8::Local<v8::Context> context, int context_group_id);
|
||||
void FireContextDestroyed(v8::Local<v8::Context> context);
|
||||
void FreeContext(v8::Local<v8::Context> context);
|
||||
|
||||
private:
|
||||
struct VectorCompare {
|
||||
|
@ -1,7 +0,0 @@
|
||||
Tests that contextDesrtoyed nofitication is fired when context is collected.
|
||||
{
|
||||
method : Runtime.executionContextDestroyed
|
||||
params : {
|
||||
executionContextId : <executionContextId>
|
||||
}
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
// Copyright 2017 the V8 project authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
let {session, contextGroup, Protocol} =
|
||||
InspectorTest.start('Tests that contextDesrtoyed nofitication is fired when context is collected.');
|
||||
|
||||
(async function test() {
|
||||
await Protocol.Runtime.enable();
|
||||
Protocol.Runtime.onExecutionContextDestroyed(InspectorTest.logMessage);
|
||||
contextGroup.addScript('inspector.freeContext()');
|
||||
await Protocol.HeapProfiler.collectGarbage();
|
||||
InspectorTest.completeTest();
|
||||
})();
|
Loading…
Reference in New Issue
Block a user