| Index: src/inspector/inspected-context.cc
|
| diff --git a/src/inspector/inspected-context.cc b/src/inspector/inspected-context.cc
|
| index 3fdb0846f3c05384a55e249c1f2ab2803898e71d..39ddf29e1da4003501742cfb228db7098e418e04 100644
|
| --- a/src/inspector/inspected-context.cc
|
| +++ b/src/inspector/inspected-context.cc
|
| @@ -14,23 +14,23 @@
|
|
|
| namespace v8_inspector {
|
|
|
| -void InspectedContext::weakCallback(
|
| - const v8::WeakCallbackInfo<InspectedContext>& data) {
|
| - InspectedContext* context = data.GetParameter();
|
| - if (!context->m_context.IsEmpty()) {
|
| - context->m_context.Reset();
|
| - data.SetSecondPassCallback(&InspectedContext::weakCallback);
|
| - } else {
|
| - context->m_inspector->discardInspectedContext(context->m_contextGroupId,
|
| - context->m_contextId);
|
| - }
|
| -}
|
| +namespace {
|
|
|
| -void InspectedContext::consoleWeakCallback(
|
| - const v8::WeakCallbackInfo<InspectedContext>& data) {
|
| - data.GetParameter()->m_console.Reset();
|
| +void clearContext(const v8::WeakCallbackInfo<v8::Global<v8::Context>>& data) {
|
| + // Inspected context is created in V8InspectorImpl::contextCreated method
|
| + // and destroyed in V8InspectorImpl::contextDestroyed.
|
| + // Both methods takes valid v8::Local<v8::Context> handle to the same context,
|
| + // it means that context is created before InspectedContext constructor and is
|
| + // always destroyed after InspectedContext destructor therefore this callback
|
| + // should be never called.
|
| + // It's possible only if inspector client doesn't call contextDestroyed which
|
| + // is considered an error.
|
| + CHECK(false);
|
| + data.GetParameter()->Reset();
|
| }
|
|
|
| +} // namespace
|
| +
|
| InspectedContext::InspectedContext(V8InspectorImpl* inspector,
|
| const V8ContextInfo& info, int contextId)
|
| : m_inspector(inspector),
|
| @@ -41,7 +41,7 @@ InspectedContext::InspectedContext(V8InspectorImpl* inspector,
|
| m_humanReadableName(toString16(info.humanReadableName)),
|
| m_auxData(toString16(info.auxData)),
|
| m_reported(false) {
|
| - m_context.SetWeak(this, &InspectedContext::weakCallback,
|
| + m_context.SetWeak(&m_context, &clearContext,
|
| v8::WeakCallbackType::kParameter);
|
|
|
| v8::Isolate* isolate = m_inspector->isolate();
|
| @@ -54,12 +54,11 @@ InspectedContext::InspectedContext(V8InspectorImpl* inspector,
|
| .FromMaybe(false))
|
| return;
|
| m_console.Reset(isolate, console);
|
| - m_console.SetWeak(this, &InspectedContext::consoleWeakCallback,
|
| - v8::WeakCallbackType::kParameter);
|
| + m_console.SetWeak();
|
| }
|
|
|
| InspectedContext::~InspectedContext() {
|
| - if (!m_context.IsEmpty() && !m_console.IsEmpty()) {
|
| + if (!m_console.IsEmpty()) {
|
| v8::HandleScope scope(isolate());
|
| V8Console::clearInspectedContextIfNeeded(context(),
|
| m_console.Get(isolate()));
|
|
|