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/v8_inspector/InjectedScript.h" | 7 #include "platform/v8_inspector/InjectedScript.h" |
8 #include "platform/v8_inspector/InspectedContext.h" | 8 #include "platform/v8_inspector/InspectedContext.h" |
9 #include "platform/v8_inspector/RemoteObjectId.h" | 9 #include "platform/v8_inspector/RemoteObjectId.h" |
10 #include "platform/v8_inspector/V8ConsoleAgentImpl.h" | 10 #include "platform/v8_inspector/V8ConsoleAgentImpl.h" |
11 #include "platform/v8_inspector/V8Debugger.h" | 11 #include "platform/v8_inspector/V8Debugger.h" |
12 #include "platform/v8_inspector/V8DebuggerAgentImpl.h" | 12 #include "platform/v8_inspector/V8DebuggerAgentImpl.h" |
13 #include "platform/v8_inspector/V8HeapProfilerAgentImpl.h" | 13 #include "platform/v8_inspector/V8HeapProfilerAgentImpl.h" |
14 #include "platform/v8_inspector/V8InspectorImpl.h" | 14 #include "platform/v8_inspector/V8InspectorImpl.h" |
15 #include "platform/v8_inspector/V8ProfilerAgentImpl.h" | 15 #include "platform/v8_inspector/V8ProfilerAgentImpl.h" |
16 #include "platform/v8_inspector/V8RuntimeAgentImpl.h" | 16 #include "platform/v8_inspector/V8RuntimeAgentImpl.h" |
| 17 #include "platform/v8_inspector/V8SchemaAgentImpl.h" |
17 #include "platform/v8_inspector/V8StringUtil.h" | 18 #include "platform/v8_inspector/V8StringUtil.h" |
18 #include "platform/v8_inspector/public/V8ContextInfo.h" | 19 #include "platform/v8_inspector/public/V8ContextInfo.h" |
19 #include "platform/v8_inspector/public/V8InspectorClient.h" | 20 #include "platform/v8_inspector/public/V8InspectorClient.h" |
20 | 21 |
21 namespace v8_inspector { | 22 namespace v8_inspector { |
22 | 23 |
23 // static | 24 // static |
24 bool V8InspectorSession::canDispatchMethod(const String16& method) | 25 bool V8InspectorSession::canDispatchMethod(const String16& method) |
25 { | 26 { |
26 return method.startsWith(protocol::Runtime::Metainfo::commandPrefix) | 27 return method.startsWith(protocol::Runtime::Metainfo::commandPrefix) |
27 || method.startsWith(protocol::Debugger::Metainfo::commandPrefix) | 28 || method.startsWith(protocol::Debugger::Metainfo::commandPrefix) |
28 || method.startsWith(protocol::Profiler::Metainfo::commandPrefix) | 29 || method.startsWith(protocol::Profiler::Metainfo::commandPrefix) |
29 || method.startsWith(protocol::HeapProfiler::Metainfo::commandPrefix) | 30 || method.startsWith(protocol::HeapProfiler::Metainfo::commandPrefix) |
30 || method.startsWith(protocol::Console::Metainfo::commandPrefix); | 31 || method.startsWith(protocol::Console::Metainfo::commandPrefix) |
| 32 || method.startsWith(protocol::Schema::Metainfo::commandPrefix); |
31 } | 33 } |
32 | 34 |
33 std::unique_ptr<V8InspectorSessionImpl> V8InspectorSessionImpl::create(V8Inspect
orImpl* inspector, int contextGroupId, protocol::FrontendChannel* channel, const
String16* state) | 35 std::unique_ptr<V8InspectorSessionImpl> V8InspectorSessionImpl::create(V8Inspect
orImpl* inspector, int contextGroupId, protocol::FrontendChannel* channel, const
String16* state) |
34 { | 36 { |
35 return wrapUnique(new V8InspectorSessionImpl(inspector, contextGroupId, chan
nel, state)); | 37 return wrapUnique(new V8InspectorSessionImpl(inspector, contextGroupId, chan
nel, state)); |
36 } | 38 } |
37 | 39 |
38 V8InspectorSessionImpl::V8InspectorSessionImpl(V8InspectorImpl* inspector, int c
ontextGroupId, protocol::FrontendChannel* channel, const String16* savedState) | 40 V8InspectorSessionImpl::V8InspectorSessionImpl(V8InspectorImpl* inspector, int c
ontextGroupId, protocol::FrontendChannel* channel, const String16* savedState) |
39 : m_contextGroupId(contextGroupId) | 41 : m_contextGroupId(contextGroupId) |
40 , m_inspector(inspector) | 42 , m_inspector(inspector) |
41 , m_customObjectFormatterEnabled(false) | 43 , m_customObjectFormatterEnabled(false) |
42 , m_dispatcher(channel) | 44 , m_dispatcher(channel) |
43 , m_state(nullptr) | 45 , m_state(nullptr) |
44 , m_runtimeAgent(nullptr) | 46 , m_runtimeAgent(nullptr) |
45 , m_debuggerAgent(nullptr) | 47 , m_debuggerAgent(nullptr) |
46 , m_heapProfilerAgent(nullptr) | 48 , m_heapProfilerAgent(nullptr) |
47 , m_profilerAgent(nullptr) | 49 , m_profilerAgent(nullptr) |
48 , m_consoleAgent(nullptr) | 50 , m_consoleAgent(nullptr) |
| 51 , m_schemaAgent(nullptr) |
49 { | 52 { |
50 if (savedState) { | 53 if (savedState) { |
51 std::unique_ptr<protocol::Value> state = protocol::parseJSON(*savedState
); | 54 std::unique_ptr<protocol::Value> state = protocol::parseJSON(*savedState
); |
52 if (state) | 55 if (state) |
53 m_state = protocol::DictionaryValue::cast(std::move(state)); | 56 m_state = protocol::DictionaryValue::cast(std::move(state)); |
54 if (!m_state) | 57 if (!m_state) |
55 m_state = protocol::DictionaryValue::create(); | 58 m_state = protocol::DictionaryValue::create(); |
56 } else { | 59 } else { |
57 m_state = protocol::DictionaryValue::create(); | 60 m_state = protocol::DictionaryValue::create(); |
58 } | 61 } |
59 | 62 |
60 m_runtimeAgent = wrapUnique(new V8RuntimeAgentImpl(this, channel, agentState
(protocol::Runtime::Metainfo::domainName))); | 63 m_runtimeAgent = wrapUnique(new V8RuntimeAgentImpl(this, channel, agentState
(protocol::Runtime::Metainfo::domainName))); |
61 protocol::Runtime::Dispatcher::wire(&m_dispatcher, m_runtimeAgent.get()); | 64 protocol::Runtime::Dispatcher::wire(&m_dispatcher, m_runtimeAgent.get()); |
62 | 65 |
63 m_debuggerAgent = wrapUnique(new V8DebuggerAgentImpl(this, channel, agentSta
te(protocol::Debugger::Metainfo::domainName))); | 66 m_debuggerAgent = wrapUnique(new V8DebuggerAgentImpl(this, channel, agentSta
te(protocol::Debugger::Metainfo::domainName))); |
64 protocol::Debugger::Dispatcher::wire(&m_dispatcher, m_debuggerAgent.get()); | 67 protocol::Debugger::Dispatcher::wire(&m_dispatcher, m_debuggerAgent.get()); |
65 | 68 |
66 m_profilerAgent = wrapUnique(new V8ProfilerAgentImpl(this, channel, agentSta
te(protocol::Profiler::Metainfo::domainName))); | 69 m_profilerAgent = wrapUnique(new V8ProfilerAgentImpl(this, channel, agentSta
te(protocol::Profiler::Metainfo::domainName))); |
67 protocol::Profiler::Dispatcher::wire(&m_dispatcher, m_profilerAgent.get()); | 70 protocol::Profiler::Dispatcher::wire(&m_dispatcher, m_profilerAgent.get()); |
68 | 71 |
69 m_heapProfilerAgent = wrapUnique(new V8HeapProfilerAgentImpl(this, channel,
agentState(protocol::HeapProfiler::Metainfo::domainName))); | 72 m_heapProfilerAgent = wrapUnique(new V8HeapProfilerAgentImpl(this, channel,
agentState(protocol::HeapProfiler::Metainfo::domainName))); |
70 protocol::HeapProfiler::Dispatcher::wire(&m_dispatcher, m_heapProfilerAgent.
get()); | 73 protocol::HeapProfiler::Dispatcher::wire(&m_dispatcher, m_heapProfilerAgent.
get()); |
71 | 74 |
72 m_consoleAgent = wrapUnique(new V8ConsoleAgentImpl(this, channel, agentState
(protocol::Console::Metainfo::domainName))); | 75 m_consoleAgent = wrapUnique(new V8ConsoleAgentImpl(this, channel, agentState
(protocol::Console::Metainfo::domainName))); |
73 protocol::Console::Dispatcher::wire(&m_dispatcher, m_consoleAgent.get()); | 76 protocol::Console::Dispatcher::wire(&m_dispatcher, m_consoleAgent.get()); |
74 | 77 |
| 78 m_schemaAgent = wrapUnique(new V8SchemaAgentImpl(this, channel, agentState(p
rotocol::Schema::Metainfo::domainName))); |
| 79 protocol::Schema::Dispatcher::wire(&m_dispatcher, m_schemaAgent.get()); |
| 80 |
75 if (savedState) { | 81 if (savedState) { |
76 m_runtimeAgent->restore(); | 82 m_runtimeAgent->restore(); |
77 m_debuggerAgent->restore(); | 83 m_debuggerAgent->restore(); |
78 m_heapProfilerAgent->restore(); | 84 m_heapProfilerAgent->restore(); |
79 m_profilerAgent->restore(); | 85 m_profilerAgent->restore(); |
80 m_consoleAgent->restore(); | 86 m_consoleAgent->restore(); |
81 } | 87 } |
82 } | 88 } |
83 | 89 |
84 V8InspectorSessionImpl::~V8InspectorSessionImpl() | 90 V8InspectorSessionImpl::~V8InspectorSessionImpl() |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 void V8InspectorSessionImpl::dispatchProtocolMessage(const String16& message) | 261 void V8InspectorSessionImpl::dispatchProtocolMessage(const String16& message) |
256 { | 262 { |
257 m_dispatcher.dispatch(message); | 263 m_dispatcher.dispatch(message); |
258 } | 264 } |
259 | 265 |
260 String16 V8InspectorSessionImpl::stateJSON() | 266 String16 V8InspectorSessionImpl::stateJSON() |
261 { | 267 { |
262 return m_state->toJSONString(); | 268 return m_state->toJSONString(); |
263 } | 269 } |
264 | 270 |
| 271 std::unique_ptr<protocol::Array<protocol::Schema::API::Domain>> V8InspectorSessi
onImpl::supportedDomains() |
| 272 { |
| 273 std::vector<std::unique_ptr<protocol::Schema::Domain>> domains = supportedDo
mainsImpl(); |
| 274 std::unique_ptr<protocol::Array<protocol::Schema::API::Domain>> result = pro
tocol::Array<protocol::Schema::API::Domain>::create(); |
| 275 for (size_t i = 0; i < domains.size(); ++i) |
| 276 result->addItem(std::move(domains[i])); |
| 277 return result; |
| 278 } |
| 279 |
| 280 std::vector<std::unique_ptr<protocol::Schema::Domain>> V8InspectorSessionImpl::s
upportedDomainsImpl() |
| 281 { |
| 282 std::vector<std::unique_ptr<protocol::Schema::Domain>> result; |
| 283 result.push_back(protocol::Schema::Domain::create().setName(protocol::Runtim
e::Metainfo::domainName).setVersion(protocol::Runtime::Metainfo::version).build(
)); |
| 284 result.push_back(protocol::Schema::Domain::create().setName(protocol::Debugg
er::Metainfo::domainName).setVersion(protocol::Debugger::Metainfo::version).buil
d()); |
| 285 result.push_back(protocol::Schema::Domain::create().setName(protocol::Profil
er::Metainfo::domainName).setVersion(protocol::Profiler::Metainfo::version).buil
d()); |
| 286 result.push_back(protocol::Schema::Domain::create().setName(protocol::HeapPr
ofiler::Metainfo::domainName).setVersion(protocol::HeapProfiler::Metainfo::versi
on).build()); |
| 287 result.push_back(protocol::Schema::Domain::create().setName(protocol::Schema
::Metainfo::domainName).setVersion(protocol::Schema::Metainfo::version).build())
; |
| 288 return result; |
| 289 } |
| 290 |
265 void V8InspectorSessionImpl::addInspectedObject(std::unique_ptr<V8InspectorSessi
on::Inspectable> inspectable) | 291 void V8InspectorSessionImpl::addInspectedObject(std::unique_ptr<V8InspectorSessi
on::Inspectable> inspectable) |
266 { | 292 { |
267 m_inspectedObjects.insert(m_inspectedObjects.begin(), std::move(inspectable)
); | 293 m_inspectedObjects.insert(m_inspectedObjects.begin(), std::move(inspectable)
); |
268 if (m_inspectedObjects.size() > kInspectedObjectBufferSize) | 294 if (m_inspectedObjects.size() > kInspectedObjectBufferSize) |
269 m_inspectedObjects.resize(kInspectedObjectBufferSize); | 295 m_inspectedObjects.resize(kInspectedObjectBufferSize); |
270 } | 296 } |
271 | 297 |
272 V8InspectorSession::Inspectable* V8InspectorSessionImpl::inspectedObject(unsigne
d num) | 298 V8InspectorSession::Inspectable* V8InspectorSessionImpl::inspectedObject(unsigne
d num) |
273 { | 299 { |
274 if (num >= m_inspectedObjects.size()) | 300 if (num >= m_inspectedObjects.size()) |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
312 std::unique_ptr<protocol::Array<protocol::Debugger::API::SearchMatch>> V8Inspect
orSessionImpl::searchInTextByLines(const String16& text, const String16& query,
bool caseSensitive, bool isRegex) | 338 std::unique_ptr<protocol::Array<protocol::Debugger::API::SearchMatch>> V8Inspect
orSessionImpl::searchInTextByLines(const String16& text, const String16& query,
bool caseSensitive, bool isRegex) |
313 { | 339 { |
314 std::vector<std::unique_ptr<protocol::Debugger::SearchMatch>> matches = sear
chInTextByLinesImpl(this, text, query, caseSensitive, isRegex); | 340 std::vector<std::unique_ptr<protocol::Debugger::SearchMatch>> matches = sear
chInTextByLinesImpl(this, text, query, caseSensitive, isRegex); |
315 std::unique_ptr<protocol::Array<protocol::Debugger::API::SearchMatch>> resul
t = protocol::Array<protocol::Debugger::API::SearchMatch>::create(); | 341 std::unique_ptr<protocol::Array<protocol::Debugger::API::SearchMatch>> resul
t = protocol::Array<protocol::Debugger::API::SearchMatch>::create(); |
316 for (size_t i = 0; i < matches.size(); ++i) | 342 for (size_t i = 0; i < matches.size(); ++i) |
317 result->addItem(std::move(matches[i])); | 343 result->addItem(std::move(matches[i])); |
318 return result; | 344 return result; |
319 } | 345 } |
320 | 346 |
321 } // namespace v8_inspector | 347 } // namespace v8_inspector |
OLD | NEW |