Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(94)

Unified Diff: src/inspector/inspected-context.cc

Issue 2558913004: [inspector] Store interger in context embedder data instead of a string. (Closed)
Patch Set: review comments Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/inspector/inspected-context.h ('k') | src/inspector/v8-debugger.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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());
}
« no previous file with comments | « src/inspector/inspected-context.h ('k') | src/inspector/v8-debugger.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698