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

Side by Side Diff: src/inspector/inspected-context.cc

Issue 2785293002: [inspector] move console to builtins (Closed)
Patch Set: removed unused variable Created 3 years, 8 months 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 unified diff | Download patch
« no previous file with comments | « src/debug/interface-types.h ('k') | src/inspector/v8-console.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 the V8 project authors. All rights reserved. 1 // Copyright 2016 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/inspector/inspected-context.h" 5 #include "src/inspector/inspected-context.h"
6 6
7 #include "src/debug/debug-interface.h" 7 #include "src/debug/debug-interface.h"
8 #include "src/inspector/injected-script.h" 8 #include "src/inspector/injected-script.h"
9 #include "src/inspector/string-util.h" 9 #include "src/inspector/string-util.h"
10 #include "src/inspector/v8-console.h" 10 #include "src/inspector/v8-console.h"
11 #include "src/inspector/v8-inspector-impl.h" 11 #include "src/inspector/v8-inspector-impl.h"
12 #include "src/inspector/v8-value-copier.h" 12 #include "src/inspector/v8-value-copier.h"
13 13
14 #include "include/v8-inspector.h" 14 #include "include/v8-inspector.h"
15 15
16 namespace v8_inspector { 16 namespace v8_inspector {
17 17
18 InspectedContext::InspectedContext(V8InspectorImpl* inspector, 18 InspectedContext::InspectedContext(V8InspectorImpl* inspector,
19 const V8ContextInfo& info, int contextId) 19 const V8ContextInfo& info, int contextId)
20 : m_inspector(inspector), 20 : m_inspector(inspector),
21 m_context(info.context->GetIsolate(), info.context), 21 m_context(info.context->GetIsolate(), info.context),
22 m_contextId(contextId), 22 m_contextId(contextId),
23 m_contextGroupId(info.contextGroupId), 23 m_contextGroupId(info.contextGroupId),
24 m_origin(toString16(info.origin)), 24 m_origin(toString16(info.origin)),
25 m_humanReadableName(toString16(info.humanReadableName)), 25 m_humanReadableName(toString16(info.humanReadableName)),
26 m_auxData(toString16(info.auxData)), 26 m_auxData(toString16(info.auxData)),
27 m_reported(false) { 27 m_reported(false) {
28 v8::Isolate* isolate = m_inspector->isolate();
29 v8::debug::SetContextId(info.context, contextId); 28 v8::debug::SetContextId(info.context, contextId);
29 if (!info.hasMemoryOnConsole) return;
30 v8::Context::Scope contextScope(info.context);
30 v8::Local<v8::Object> global = info.context->Global(); 31 v8::Local<v8::Object> global = info.context->Global();
31 v8::Local<v8::Object> console = 32 v8::Local<v8::Value> console;
32 m_inspector->console()->createConsole(info.context); 33 if (global->Get(info.context, toV8String(m_inspector->isolate(), "console"))
33 if (info.hasMemoryOnConsole) { 34 .ToLocal(&console) &&
34 m_inspector->console()->installMemoryGetter(info.context, console); 35 console->IsObject()) {
35 } 36 m_inspector->console()->installMemoryGetter(
36 if (!global 37 info.context, v8::Local<v8::Object>::Cast(console));
37 ->Set(info.context, toV8StringInternalized(isolate, "console"),
38 console)
39 .FromMaybe(false)) {
40 return;
41 } 38 }
42 } 39 }
43 40
44 InspectedContext::~InspectedContext() { 41 InspectedContext::~InspectedContext() {
45 } 42 }
46 43
47 // static 44 // static
48 int InspectedContext::contextId(v8::Local<v8::Context> context) { 45 int InspectedContext::contextId(v8::Local<v8::Context> context) {
49 return v8::debug::GetContextId(context); 46 return v8::debug::GetContextId(context);
50 } 47 }
(...skipping 11 matching lines...) Expand all
62 std::unique_ptr<InjectedScript> injectedScript = InjectedScript::create(this); 59 std::unique_ptr<InjectedScript> injectedScript = InjectedScript::create(this);
63 // InjectedScript::create can destroy |this|. 60 // InjectedScript::create can destroy |this|.
64 if (!injectedScript) return false; 61 if (!injectedScript) return false;
65 m_injectedScript = std::move(injectedScript); 62 m_injectedScript = std::move(injectedScript);
66 return true; 63 return true;
67 } 64 }
68 65
69 void InspectedContext::discardInjectedScript() { m_injectedScript.reset(); } 66 void InspectedContext::discardInjectedScript() { m_injectedScript.reset(); }
70 67
71 } // namespace v8_inspector 68 } // namespace v8_inspector
OLDNEW
« no previous file with comments | « src/debug/interface-types.h ('k') | src/inspector/v8-console.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698