Index: src/inspector/inspected-context.cc |
diff --git a/src/inspector/inspected-context.cc b/src/inspector/inspected-context.cc |
index dab3bba0509a193c34da7206fe921d10243633bd..6d9f51ed3fd987bf1d94b585bf3faba54fbe4e5e 100644 |
--- a/src/inspector/inspected-context.cc |
+++ b/src/inspector/inspected-context.cc |
@@ -41,10 +41,12 @@ InspectedContext::InspectedContext(V8InspectorImpl* inspector, |
m_humanReadableName(toString16(info.humanReadableName)), |
m_auxData(toString16(info.auxData)), |
m_reported(false) { |
+ v8::Isolate* isolate = m_inspector->isolate(); |
+ info.context->SetEmbedderData(static_cast<int>(v8::Context::kDebugIdIndex), |
+ v8::Int32::New(isolate, contextId)); |
m_context.SetWeak(&m_context, &clearContext, |
v8::WeakCallbackType::kParameter); |
- v8::Isolate* isolate = m_inspector->isolate(); |
v8::Local<v8::Object> global = info.context->Global(); |
v8::Local<v8::Object> console = |
V8Console::createConsole(this, info.hasMemoryOnConsole); |
@@ -65,6 +67,14 @@ InspectedContext::~InspectedContext() { |
} |
} |
+// static |
+int InspectedContext::contextId(v8::Local<v8::Context> context) { |
+ v8::Local<v8::Value> data = |
+ context->GetEmbedderData(static_cast<int>(v8::Context::kDebugIdIndex)); |
+ if (data.IsEmpty() || !data->IsInt32()) return 0; |
+ return static_cast<int>(data.As<v8::Int32>()->Value()); |
+} |
+ |
v8::Local<v8::Context> InspectedContext::context() const { |
return m_context.Get(isolate()); |
} |