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

Side by Side Diff: third_party/WebKit/Source/platform/v8_inspector/V8InspectorSessionImpl.cpp

Issue 2035653006: [DevTools] Move Console to v8 inspector. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: improved api a bit Created 4 years, 5 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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium 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 "platform/v8_inspector/V8InspectorSessionImpl.h" 5 #include "platform/v8_inspector/V8InspectorSessionImpl.h"
6 6
7 #include "platform/inspector_protocol/Parser.h" 7 #include "platform/inspector_protocol/Parser.h"
8 #include "platform/v8_inspector/InjectedScript.h" 8 #include "platform/v8_inspector/InjectedScript.h"
9 #include "platform/v8_inspector/InspectedContext.h" 9 #include "platform/v8_inspector/InspectedContext.h"
10 #include "platform/v8_inspector/RemoteObjectId.h" 10 #include "platform/v8_inspector/RemoteObjectId.h"
11 #include "platform/v8_inspector/V8ConsoleAgentImpl.h"
11 #include "platform/v8_inspector/V8DebuggerAgentImpl.h" 12 #include "platform/v8_inspector/V8DebuggerAgentImpl.h"
12 #include "platform/v8_inspector/V8DebuggerImpl.h" 13 #include "platform/v8_inspector/V8DebuggerImpl.h"
13 #include "platform/v8_inspector/V8HeapProfilerAgentImpl.h" 14 #include "platform/v8_inspector/V8HeapProfilerAgentImpl.h"
14 #include "platform/v8_inspector/V8ProfilerAgentImpl.h" 15 #include "platform/v8_inspector/V8ProfilerAgentImpl.h"
15 #include "platform/v8_inspector/V8RuntimeAgentImpl.h" 16 #include "platform/v8_inspector/V8RuntimeAgentImpl.h"
16 #include "platform/v8_inspector/public/V8ContextInfo.h" 17 #include "platform/v8_inspector/public/V8ContextInfo.h"
17 #include "platform/v8_inspector/public/V8DebuggerClient.h" 18 #include "platform/v8_inspector/public/V8DebuggerClient.h"
18 19
19 namespace blink { 20 namespace blink {
20 21
21 const char V8InspectorSession::backtraceObjectGroup[] = "backtrace"; 22 const char V8InspectorSession::backtraceObjectGroup[] = "backtrace";
22 23
23 // static 24 // static
24 bool V8InspectorSession::isV8ProtocolMethod(const String16& method) 25 bool V8InspectorSession::isV8ProtocolMethod(const String16& method)
25 { 26 {
26 return method.startWith("Debugger.") || method.startWith("HeapProfiler.") || method.startWith("Profiler.") || method.startWith("Runtime."); 27 return method.startWith("Debugger.") || method.startWith("HeapProfiler.") || method.startWith("Profiler.") || method.startWith("Runtime.") || method.startWi th("Console.");
27 } 28 }
28 29
29 std::unique_ptr<V8InspectorSessionImpl> V8InspectorSessionImpl::create(V8Debugge rImpl* debugger, int contextGroupId, protocol::FrontendChannel* channel, V8Inspe ctorSessionClient* client, const String16* state) 30 std::unique_ptr<V8InspectorSessionImpl> V8InspectorSessionImpl::create(V8Debugge rImpl* debugger, int contextGroupId, protocol::FrontendChannel* channel, V8Inspe ctorSessionClient* client, const String16* state)
30 { 31 {
31 return wrapUnique(new V8InspectorSessionImpl(debugger, contextGroupId, chann el, client, state)); 32 return wrapUnique(new V8InspectorSessionImpl(debugger, contextGroupId, chann el, client, state));
32 } 33 }
33 34
34 V8InspectorSessionImpl::V8InspectorSessionImpl(V8DebuggerImpl* debugger, int con textGroupId, protocol::FrontendChannel* channel, V8InspectorSessionClient* clien t, const String16* savedState) 35 V8InspectorSessionImpl::V8InspectorSessionImpl(V8DebuggerImpl* debugger, int con textGroupId, protocol::FrontendChannel* channel, V8InspectorSessionClient* clien t, const String16* savedState)
35 : m_contextGroupId(contextGroupId) 36 : m_contextGroupId(contextGroupId)
36 , m_debugger(debugger) 37 , m_debugger(debugger)
37 , m_client(client) 38 , m_client(client)
38 , m_customObjectFormatterEnabled(false) 39 , m_customObjectFormatterEnabled(false)
39 , m_instrumentationCounter(0) 40 , m_instrumentationCounter(0)
40 , m_dispatcher(channel) 41 , m_dispatcher(channel)
41 , m_state(nullptr) 42 , m_state(nullptr)
42 , m_runtimeAgent(nullptr) 43 , m_runtimeAgent(nullptr)
43 , m_debuggerAgent(nullptr) 44 , m_debuggerAgent(nullptr)
44 , m_heapProfilerAgent(nullptr) 45 , m_heapProfilerAgent(nullptr)
45 , m_profilerAgent(nullptr) 46 , m_profilerAgent(nullptr)
47 , m_consoleAgent(nullptr)
46 { 48 {
47 if (savedState) { 49 if (savedState) {
48 std::unique_ptr<protocol::Value> state = protocol::parseJSON(*savedState ); 50 std::unique_ptr<protocol::Value> state = protocol::parseJSON(*savedState );
49 if (state) 51 if (state)
50 m_state = protocol::DictionaryValue::cast(std::move(state)); 52 m_state = protocol::DictionaryValue::cast(std::move(state));
51 if (!m_state) 53 if (!m_state)
52 m_state = protocol::DictionaryValue::create(); 54 m_state = protocol::DictionaryValue::create();
53 } else { 55 } else {
54 m_state = protocol::DictionaryValue::create(); 56 m_state = protocol::DictionaryValue::create();
55 } 57 }
56 58
57 m_runtimeAgent = wrapUnique(new V8RuntimeAgentImpl(this, channel, agentState (protocol::Runtime::Metainfo::domainName))); 59 m_runtimeAgent = wrapUnique(new V8RuntimeAgentImpl(this, channel, agentState (protocol::Runtime::Metainfo::domainName)));
58 protocol::Runtime::Dispatcher::wire(&m_dispatcher, m_runtimeAgent.get()); 60 protocol::Runtime::Dispatcher::wire(&m_dispatcher, m_runtimeAgent.get());
59 61
60 m_debuggerAgent = wrapUnique(new V8DebuggerAgentImpl(this, channel, agentSta te(protocol::Debugger::Metainfo::domainName))); 62 m_debuggerAgent = wrapUnique(new V8DebuggerAgentImpl(this, channel, agentSta te(protocol::Debugger::Metainfo::domainName)));
61 protocol::Debugger::Dispatcher::wire(&m_dispatcher, m_debuggerAgent.get()); 63 protocol::Debugger::Dispatcher::wire(&m_dispatcher, m_debuggerAgent.get());
62 64
63 m_profilerAgent = wrapUnique(new V8ProfilerAgentImpl(this, channel, agentSta te(protocol::Profiler::Metainfo::domainName))); 65 m_profilerAgent = wrapUnique(new V8ProfilerAgentImpl(this, channel, agentSta te(protocol::Profiler::Metainfo::domainName)));
64 protocol::Profiler::Dispatcher::wire(&m_dispatcher, m_profilerAgent.get()); 66 protocol::Profiler::Dispatcher::wire(&m_dispatcher, m_profilerAgent.get());
65 67
66 m_heapProfilerAgent = wrapUnique(new V8HeapProfilerAgentImpl(this, channel, agentState(protocol::HeapProfiler::Metainfo::domainName))); 68 m_heapProfilerAgent = wrapUnique(new V8HeapProfilerAgentImpl(this, channel, agentState(protocol::HeapProfiler::Metainfo::domainName)));
67 protocol::HeapProfiler::Dispatcher::wire(&m_dispatcher, m_heapProfilerAgent. get()); 69 protocol::HeapProfiler::Dispatcher::wire(&m_dispatcher, m_heapProfilerAgent. get());
68 70
71 m_consoleAgent = wrapUnique(new V8ConsoleAgentImpl(this, channel, agentState (protocol::Console::Metainfo::domainName)));
72 protocol::Console::Dispatcher::wire(&m_dispatcher, m_consoleAgent.get());
73
69 if (savedState) { 74 if (savedState) {
70 m_runtimeAgent->restore(); 75 m_runtimeAgent->restore();
71 m_debuggerAgent->restore(); 76 m_debuggerAgent->restore();
72 m_heapProfilerAgent->restore(); 77 m_heapProfilerAgent->restore();
73 m_profilerAgent->restore(); 78 m_profilerAgent->restore();
79 m_consoleAgent->restore();
74 } 80 }
75 } 81 }
76 82
77 V8InspectorSessionImpl::~V8InspectorSessionImpl() 83 V8InspectorSessionImpl::~V8InspectorSessionImpl()
78 { 84 {
79 ErrorString errorString; 85 ErrorString errorString;
86 m_consoleAgent->disable(&errorString);
80 m_profilerAgent->disable(&errorString); 87 m_profilerAgent->disable(&errorString);
81 m_heapProfilerAgent->disable(&errorString); 88 m_heapProfilerAgent->disable(&errorString);
82 m_debuggerAgent->disable(&errorString); 89 m_debuggerAgent->disable(&errorString);
83 m_runtimeAgent->disable(&errorString); 90 m_runtimeAgent->disable(&errorString);
84 91
85 discardInjectedScripts(); 92 discardInjectedScripts();
86 m_debugger->disconnect(this); 93 m_debugger->disconnect(this);
87 } 94 }
88 95
89 protocol::DictionaryValue* V8InspectorSessionImpl::agentState(const String16& na me) 96 protocol::DictionaryValue* V8InspectorSessionImpl::agentState(const String16& na me)
90 { 97 {
91 protocol::DictionaryValue* state = m_state->getObject(name); 98 protocol::DictionaryValue* state = m_state->getObject(name);
92 if (!state) { 99 if (!state) {
93 std::unique_ptr<protocol::DictionaryValue> newState = protocol::Dictiona ryValue::create(); 100 std::unique_ptr<protocol::DictionaryValue> newState = protocol::Dictiona ryValue::create();
94 state = newState.get(); 101 state = newState.get();
95 m_state->setObject(name, std::move(newState)); 102 m_state->setObject(name, std::move(newState));
96 } 103 }
97 return state; 104 return state;
98 } 105 }
99 106
100 void V8InspectorSessionImpl::reset() 107 void V8InspectorSessionImpl::reset()
101 { 108 {
102 m_debuggerAgent->reset(); 109 m_debuggerAgent->reset();
103 m_runtimeAgent->reset(); 110 m_runtimeAgent->reset();
111 m_consoleAgent->reset();
104 discardInjectedScripts(); 112 discardInjectedScripts();
105 } 113 }
106 114
107 void V8InspectorSessionImpl::discardInjectedScripts() 115 void V8InspectorSessionImpl::discardInjectedScripts()
108 { 116 {
109 m_inspectedObjects.clear(); 117 m_inspectedObjects.clear();
110 const V8DebuggerImpl::ContextByIdMap* contexts = m_debugger->contextGroup(m_ contextGroupId); 118 const V8DebuggerImpl::ContextByIdMap* contexts = m_debugger->contextGroup(m_ contextGroupId);
111 if (!contexts) 119 if (!contexts)
112 return; 120 return;
113 121
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 if (context) 202 if (context)
195 *context = injectedScript->context()->context(); 203 *context = injectedScript->context()->context();
196 if (groupName) 204 if (groupName)
197 *groupName = injectedScript->objectGroupName(*remoteId); 205 *groupName = injectedScript->objectGroupName(*remoteId);
198 return objectValue; 206 return objectValue;
199 } 207 }
200 208
201 std::unique_ptr<protocol::Runtime::RemoteObject> V8InspectorSessionImpl::wrapObj ect(v8::Local<v8::Context> context, v8::Local<v8::Value> value, const String16& groupName, bool generatePreview) 209 std::unique_ptr<protocol::Runtime::RemoteObject> V8InspectorSessionImpl::wrapObj ect(v8::Local<v8::Context> context, v8::Local<v8::Value> value, const String16& groupName, bool generatePreview)
202 { 210 {
203 ErrorString errorString; 211 ErrorString errorString;
204 InjectedScript* injectedScript = findInjectedScript(&errorString, V8Debugger ::contextId(context)); 212 InjectedScript* injectedScript = findInjectedScript(&errorString, V8Debugger Impl::contextId(context));
205 if (!injectedScript) 213 if (!injectedScript)
206 return nullptr; 214 return nullptr;
207 return injectedScript->wrapObject(&errorString, value, groupName, false, gen eratePreview); 215 return injectedScript->wrapObject(&errorString, value, groupName, false, gen eratePreview);
208 } 216 }
209 217
210 std::unique_ptr<protocol::Runtime::RemoteObject> V8InspectorSessionImpl::wrapTab le(v8::Local<v8::Context> context, v8::Local<v8::Value> table, v8::Local<v8::Val ue> columns) 218 std::unique_ptr<protocol::Runtime::RemoteObject> V8InspectorSessionImpl::wrapTab le(v8::Local<v8::Context> context, v8::Local<v8::Value> table, v8::Local<v8::Val ue> columns)
211 { 219 {
212 ErrorString errorString; 220 ErrorString errorString;
213 InjectedScript* injectedScript = findInjectedScript(&errorString, V8Debugger ::contextId(context)); 221 InjectedScript* injectedScript = findInjectedScript(&errorString, V8Debugger Impl::contextId(context));
214 if (!injectedScript) 222 if (!injectedScript)
215 return nullptr; 223 return nullptr;
216 return injectedScript->wrapTable(table, columns); 224 return injectedScript->wrapTable(table, columns);
217 } 225 }
218 226
219 void V8InspectorSessionImpl::setCustomObjectFormatterEnabled(bool enabled) 227 void V8InspectorSessionImpl::setCustomObjectFormatterEnabled(bool enabled)
220 { 228 {
221 m_customObjectFormatterEnabled = enabled; 229 m_customObjectFormatterEnabled = enabled;
222 const V8DebuggerImpl::ContextByIdMap* contexts = m_debugger->contextGroup(m_ contextGroupId); 230 const V8DebuggerImpl::ContextByIdMap* contexts = m_debugger->contextGroup(m_ contextGroupId);
223 if (!contexts) 231 if (!contexts)
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 m_debuggerAgent->resume(&errorString); 312 m_debuggerAgent->resume(&errorString);
305 } 313 }
306 314
307 void V8InspectorSessionImpl::stepOver() 315 void V8InspectorSessionImpl::stepOver()
308 { 316 {
309 ErrorString errorString; 317 ErrorString errorString;
310 m_debuggerAgent->stepOver(&errorString); 318 m_debuggerAgent->stepOver(&errorString);
311 } 319 }
312 320
313 } // namespace blink 321 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698