OLD | NEW |
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" |
(...skipping 19 matching lines...) Expand all Loading... |
30 { | 30 { |
31 return wrapUnique(new V8InspectorSessionImpl(debugger, contextGroupId, clien
t, state)); | 31 return wrapUnique(new V8InspectorSessionImpl(debugger, contextGroupId, clien
t, state)); |
32 } | 32 } |
33 | 33 |
34 V8InspectorSessionImpl::V8InspectorSessionImpl(V8DebuggerImpl* debugger, int con
textGroupId, V8InspectorSessionClient* client, const String16* savedState) | 34 V8InspectorSessionImpl::V8InspectorSessionImpl(V8DebuggerImpl* debugger, int con
textGroupId, V8InspectorSessionClient* client, const String16* savedState) |
35 : m_contextGroupId(contextGroupId) | 35 : m_contextGroupId(contextGroupId) |
36 , m_debugger(debugger) | 36 , m_debugger(debugger) |
37 , m_client(client) | 37 , m_client(client) |
38 , m_customObjectFormatterEnabled(false) | 38 , m_customObjectFormatterEnabled(false) |
39 , m_instrumentationCounter(0) | 39 , m_instrumentationCounter(0) |
40 , m_frontend(new protocol::Frontend(client)) | 40 , m_dispatcher(client) |
41 , m_dispatcher(protocol::Dispatcher::create(client)) | |
42 , m_state(nullptr) | 41 , m_state(nullptr) |
43 , m_runtimeAgent(nullptr) | 42 , m_runtimeAgent(nullptr) |
44 , m_debuggerAgent(nullptr) | 43 , m_debuggerAgent(nullptr) |
45 , m_heapProfilerAgent(nullptr) | 44 , m_heapProfilerAgent(nullptr) |
46 , m_profilerAgent(nullptr) | 45 , m_profilerAgent(nullptr) |
47 { | 46 { |
48 if (savedState) { | 47 if (savedState) { |
49 std::unique_ptr<protocol::Value> state = protocol::parseJSON(*savedState
); | 48 std::unique_ptr<protocol::Value> state = protocol::parseJSON(*savedState
); |
50 if (state) | 49 if (state) |
51 m_state = protocol::DictionaryValue::cast(std::move(state)); | 50 m_state = protocol::DictionaryValue::cast(std::move(state)); |
52 if (!m_state) | 51 if (!m_state) |
53 m_state = protocol::DictionaryValue::create(); | 52 m_state = protocol::DictionaryValue::create(); |
54 } else { | 53 } else { |
55 m_state = protocol::DictionaryValue::create(); | 54 m_state = protocol::DictionaryValue::create(); |
56 } | 55 } |
57 | 56 |
58 m_runtimeAgent = wrapUnique(new V8RuntimeAgentImpl(this, protocol::Runtime::
Frontend::from(m_frontend.get()), agentState("Runtime"))); | 57 m_runtimeAgent = wrapUnique(new V8RuntimeAgentImpl(this, client, agentState(
protocol::Runtime::Metainfo::domainName))); |
59 m_dispatcher->registerAgent(static_cast<protocol::Runtime::Backend*>(m_runti
meAgent.get())); | 58 protocol::Runtime::Dispatcher::wire(&m_dispatcher, m_runtimeAgent.get()); |
60 | 59 |
61 m_debuggerAgent = wrapUnique(new V8DebuggerAgentImpl(this, protocol::Debugge
r::Frontend::from(m_frontend.get()), agentState("Debugger"))); | 60 m_debuggerAgent = wrapUnique(new V8DebuggerAgentImpl(this, client, agentStat
e(protocol::Debugger::Metainfo::domainName))); |
62 m_dispatcher->registerAgent(static_cast<protocol::Debugger::Backend*>(m_debu
ggerAgent.get())); | 61 protocol::Debugger::Dispatcher::wire(&m_dispatcher, m_debuggerAgent.get()); |
63 | 62 |
64 m_heapProfilerAgent = wrapUnique(new V8HeapProfilerAgentImpl(this, protocol:
:HeapProfiler::Frontend::from(m_frontend.get()), agentState("HeapProfiler"))); | 63 m_profilerAgent = wrapUnique(new V8ProfilerAgentImpl(this, client, agentStat
e(protocol::Profiler::Metainfo::domainName))); |
65 m_dispatcher->registerAgent(static_cast<protocol::HeapProfiler::Backend*>(m_
heapProfilerAgent.get())); | 64 protocol::Profiler::Dispatcher::wire(&m_dispatcher, m_profilerAgent.get()); |
66 | 65 |
67 m_profilerAgent = wrapUnique(new V8ProfilerAgentImpl(this, protocol::Profile
r::Frontend::from(m_frontend.get()), agentState("Profiler"))); | 66 m_heapProfilerAgent = wrapUnique(new V8HeapProfilerAgentImpl(this, client, a
gentState(protocol::HeapProfiler::Metainfo::domainName))); |
68 m_dispatcher->registerAgent(static_cast<protocol::Profiler::Backend*>(m_prof
ilerAgent.get())); | 67 protocol::HeapProfiler::Dispatcher::wire(&m_dispatcher, m_heapProfilerAgent.
get()); |
69 | 68 |
70 if (savedState) { | 69 if (savedState) { |
71 m_runtimeAgent->restore(); | 70 m_runtimeAgent->restore(); |
72 m_debuggerAgent->restore(); | 71 m_debuggerAgent->restore(); |
73 m_heapProfilerAgent->restore(); | 72 m_heapProfilerAgent->restore(); |
74 m_profilerAgent->restore(); | 73 m_profilerAgent->restore(); |
75 } | 74 } |
76 } | 75 } |
77 | 76 |
78 V8InspectorSessionImpl::~V8InspectorSessionImpl() | 77 V8InspectorSessionImpl::~V8InspectorSessionImpl() |
79 { | 78 { |
80 m_dispatcher->clearFrontend(); | |
81 m_dispatcher.reset(); | |
82 | |
83 ErrorString errorString; | 79 ErrorString errorString; |
84 m_profilerAgent->disable(&errorString); | 80 m_profilerAgent->disable(&errorString); |
85 m_heapProfilerAgent->disable(&errorString); | 81 m_heapProfilerAgent->disable(&errorString); |
86 m_debuggerAgent->disable(&errorString); | 82 m_debuggerAgent->disable(&errorString); |
87 m_runtimeAgent->disable(&errorString); | 83 m_runtimeAgent->disable(&errorString); |
88 | 84 |
89 m_frontend.reset(); | |
90 discardInjectedScripts(); | 85 discardInjectedScripts(); |
91 m_debugger->disconnect(this); | 86 m_debugger->disconnect(this); |
92 } | 87 } |
93 | 88 |
94 protocol::DictionaryValue* V8InspectorSessionImpl::agentState(const String16& na
me) | 89 protocol::DictionaryValue* V8InspectorSessionImpl::agentState(const String16& na
me) |
95 { | 90 { |
96 protocol::DictionaryValue* state = m_state->getObject(name); | 91 protocol::DictionaryValue* state = m_state->getObject(name); |
97 if (!state) { | 92 if (!state) { |
98 std::unique_ptr<protocol::DictionaryValue> newState = protocol::Dictiona
ryValue::create(); | 93 std::unique_ptr<protocol::DictionaryValue> newState = protocol::Dictiona
ryValue::create(); |
99 state = newState.get(); | 94 state = newState.get(); |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 DCHECK_GE(m_instrumentationCounter + delta, 0); | 235 DCHECK_GE(m_instrumentationCounter + delta, 0); |
241 if (!m_instrumentationCounter) | 236 if (!m_instrumentationCounter) |
242 m_client->startInstrumenting(); | 237 m_client->startInstrumenting(); |
243 m_instrumentationCounter += delta; | 238 m_instrumentationCounter += delta; |
244 if (!m_instrumentationCounter) | 239 if (!m_instrumentationCounter) |
245 m_client->stopInstrumenting(); | 240 m_client->stopInstrumenting(); |
246 } | 241 } |
247 | 242 |
248 void V8InspectorSessionImpl::dispatchProtocolMessage(const String16& message) | 243 void V8InspectorSessionImpl::dispatchProtocolMessage(const String16& message) |
249 { | 244 { |
250 m_dispatcher->dispatch(message); | 245 m_dispatcher.dispatch(message); |
251 } | 246 } |
252 | 247 |
253 String16 V8InspectorSessionImpl::stateJSON() | 248 String16 V8InspectorSessionImpl::stateJSON() |
254 { | 249 { |
255 return m_state->toJSONString(); | 250 return m_state->toJSONString(); |
256 } | 251 } |
257 | 252 |
258 void V8InspectorSessionImpl::addInspectedObject(std::unique_ptr<V8InspectorSessi
on::Inspectable> inspectable) | 253 void V8InspectorSessionImpl::addInspectedObject(std::unique_ptr<V8InspectorSessi
on::Inspectable> inspectable) |
259 { | 254 { |
260 m_inspectedObjects.prepend(std::move(inspectable)); | 255 m_inspectedObjects.prepend(std::move(inspectable)); |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
326 { | 321 { |
327 m_debuggerAgent->asyncTaskFinished(task); | 322 m_debuggerAgent->asyncTaskFinished(task); |
328 } | 323 } |
329 | 324 |
330 void V8InspectorSessionImpl::allAsyncTasksCanceled() | 325 void V8InspectorSessionImpl::allAsyncTasksCanceled() |
331 { | 326 { |
332 m_debuggerAgent->allAsyncTasksCanceled(); | 327 m_debuggerAgent->allAsyncTasksCanceled(); |
333 } | 328 } |
334 | 329 |
335 } // namespace blink | 330 } // namespace blink |
OLD | NEW |