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

Side by Side Diff: src/inspector/v8-inspector-session-impl.cc

Issue 2523743003: Roll third_party/inspector_protocol to 73028acaa3646789fd2a3bfd0d79eb2d91b696b3 (Closed)
Patch Set: addressed 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 unified diff | Download patch
« no previous file with comments | « src/inspector/v8-inspector-impl.cc ('k') | src/inspector/v8-internal-value-type.cc » ('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/v8-inspector-session-impl.h" 5 #include "src/inspector/v8-inspector-session-impl.h"
6 6
7 #include "src/inspector/injected-script.h" 7 #include "src/inspector/injected-script.h"
8 #include "src/inspector/inspected-context.h" 8 #include "src/inspector/inspected-context.h"
9 #include "src/inspector/protocol/Protocol.h" 9 #include "src/inspector/protocol/Protocol.h"
10 #include "src/inspector/remote-object-id.h" 10 #include "src/inspector/remote-object-id.h"
(...skipping 22 matching lines...) Expand all
33 method, protocol::HeapProfiler::Metainfo::commandPrefix) || 33 method, protocol::HeapProfiler::Metainfo::commandPrefix) ||
34 stringViewStartsWith(method, 34 stringViewStartsWith(method,
35 protocol::Console::Metainfo::commandPrefix) || 35 protocol::Console::Metainfo::commandPrefix) ||
36 stringViewStartsWith(method, 36 stringViewStartsWith(method,
37 protocol::Schema::Metainfo::commandPrefix); 37 protocol::Schema::Metainfo::commandPrefix);
38 } 38 }
39 39
40 std::unique_ptr<V8InspectorSessionImpl> V8InspectorSessionImpl::create( 40 std::unique_ptr<V8InspectorSessionImpl> V8InspectorSessionImpl::create(
41 V8InspectorImpl* inspector, int contextGroupId, 41 V8InspectorImpl* inspector, int contextGroupId,
42 V8Inspector::Channel* channel, const StringView& state) { 42 V8Inspector::Channel* channel, const StringView& state) {
43 return wrapUnique( 43 return std::unique_ptr<V8InspectorSessionImpl>(
44 new V8InspectorSessionImpl(inspector, contextGroupId, channel, state)); 44 new V8InspectorSessionImpl(inspector, contextGroupId, channel, state));
45 } 45 }
46 46
47 V8InspectorSessionImpl::V8InspectorSessionImpl(V8InspectorImpl* inspector, 47 V8InspectorSessionImpl::V8InspectorSessionImpl(V8InspectorImpl* inspector,
48 int contextGroupId, 48 int contextGroupId,
49 V8Inspector::Channel* channel, 49 V8Inspector::Channel* channel,
50 const StringView& savedState) 50 const StringView& savedState)
51 : m_contextGroupId(contextGroupId), 51 : m_contextGroupId(contextGroupId),
52 m_inspector(inspector), 52 m_inspector(inspector),
53 m_channel(channel), 53 m_channel(channel),
54 m_customObjectFormatterEnabled(false), 54 m_customObjectFormatterEnabled(false),
55 m_dispatcher(this), 55 m_dispatcher(this),
56 m_state(nullptr), 56 m_state(nullptr),
57 m_runtimeAgent(nullptr), 57 m_runtimeAgent(nullptr),
58 m_debuggerAgent(nullptr), 58 m_debuggerAgent(nullptr),
59 m_heapProfilerAgent(nullptr), 59 m_heapProfilerAgent(nullptr),
60 m_profilerAgent(nullptr), 60 m_profilerAgent(nullptr),
61 m_consoleAgent(nullptr), 61 m_consoleAgent(nullptr),
62 m_schemaAgent(nullptr) { 62 m_schemaAgent(nullptr) {
63 if (savedState.length()) { 63 if (savedState.length()) {
64 std::unique_ptr<protocol::Value> state = 64 std::unique_ptr<protocol::Value> state =
65 protocol::parseJSON(toString16(savedState)); 65 protocol::StringUtil::parseJSON(toString16(savedState));
66 if (state) m_state = protocol::DictionaryValue::cast(std::move(state)); 66 if (state) m_state = protocol::DictionaryValue::cast(std::move(state));
67 if (!m_state) m_state = protocol::DictionaryValue::create(); 67 if (!m_state) m_state = protocol::DictionaryValue::create();
68 } else { 68 } else {
69 m_state = protocol::DictionaryValue::create(); 69 m_state = protocol::DictionaryValue::create();
70 } 70 }
71 71
72 m_runtimeAgent = wrapUnique(new V8RuntimeAgentImpl( 72 m_runtimeAgent.reset(new V8RuntimeAgentImpl(
73 this, this, agentState(protocol::Runtime::Metainfo::domainName))); 73 this, this, agentState(protocol::Runtime::Metainfo::domainName)));
74 protocol::Runtime::Dispatcher::wire(&m_dispatcher, m_runtimeAgent.get()); 74 protocol::Runtime::Dispatcher::wire(&m_dispatcher, m_runtimeAgent.get());
75 75
76 m_debuggerAgent = wrapUnique(new V8DebuggerAgentImpl( 76 m_debuggerAgent.reset(new V8DebuggerAgentImpl(
77 this, this, agentState(protocol::Debugger::Metainfo::domainName))); 77 this, this, agentState(protocol::Debugger::Metainfo::domainName)));
78 protocol::Debugger::Dispatcher::wire(&m_dispatcher, m_debuggerAgent.get()); 78 protocol::Debugger::Dispatcher::wire(&m_dispatcher, m_debuggerAgent.get());
79 79
80 m_profilerAgent = wrapUnique(new V8ProfilerAgentImpl( 80 m_profilerAgent.reset(new V8ProfilerAgentImpl(
81 this, this, agentState(protocol::Profiler::Metainfo::domainName))); 81 this, this, agentState(protocol::Profiler::Metainfo::domainName)));
82 protocol::Profiler::Dispatcher::wire(&m_dispatcher, m_profilerAgent.get()); 82 protocol::Profiler::Dispatcher::wire(&m_dispatcher, m_profilerAgent.get());
83 83
84 m_heapProfilerAgent = wrapUnique(new V8HeapProfilerAgentImpl( 84 m_heapProfilerAgent.reset(new V8HeapProfilerAgentImpl(
85 this, this, agentState(protocol::HeapProfiler::Metainfo::domainName))); 85 this, this, agentState(protocol::HeapProfiler::Metainfo::domainName)));
86 protocol::HeapProfiler::Dispatcher::wire(&m_dispatcher, 86 protocol::HeapProfiler::Dispatcher::wire(&m_dispatcher,
87 m_heapProfilerAgent.get()); 87 m_heapProfilerAgent.get());
88 88
89 m_consoleAgent = wrapUnique(new V8ConsoleAgentImpl( 89 m_consoleAgent.reset(new V8ConsoleAgentImpl(
90 this, this, agentState(protocol::Console::Metainfo::domainName))); 90 this, this, agentState(protocol::Console::Metainfo::domainName)));
91 protocol::Console::Dispatcher::wire(&m_dispatcher, m_consoleAgent.get()); 91 protocol::Console::Dispatcher::wire(&m_dispatcher, m_consoleAgent.get());
92 92
93 m_schemaAgent = wrapUnique(new V8SchemaAgentImpl( 93 m_schemaAgent.reset(new V8SchemaAgentImpl(
94 this, this, agentState(protocol::Schema::Metainfo::domainName))); 94 this, this, agentState(protocol::Schema::Metainfo::domainName)));
95 protocol::Schema::Dispatcher::wire(&m_dispatcher, m_schemaAgent.get()); 95 protocol::Schema::Dispatcher::wire(&m_dispatcher, m_schemaAgent.get());
96 96
97 if (savedState.length()) { 97 if (savedState.length()) {
98 m_runtimeAgent->restore(); 98 m_runtimeAgent->restore();
99 m_debuggerAgent->restore(); 99 m_debuggerAgent->restore();
100 m_heapProfilerAgent->restore(); 100 m_heapProfilerAgent->restore();
101 m_profilerAgent->restore(); 101 m_profilerAgent->restore();
102 m_consoleAgent->restore(); 102 m_consoleAgent->restore();
103 } 103 }
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 void V8InspectorSessionImpl::reportAllContexts(V8RuntimeAgentImpl* agent) { 298 void V8InspectorSessionImpl::reportAllContexts(V8RuntimeAgentImpl* agent) {
299 const V8InspectorImpl::ContextByIdMap* contexts = 299 const V8InspectorImpl::ContextByIdMap* contexts =
300 m_inspector->contextGroup(m_contextGroupId); 300 m_inspector->contextGroup(m_contextGroupId);
301 if (!contexts) return; 301 if (!contexts) return;
302 for (auto& idContext : *contexts) 302 for (auto& idContext : *contexts)
303 agent->reportExecutionContextCreated(idContext.second.get()); 303 agent->reportExecutionContextCreated(idContext.second.get());
304 } 304 }
305 305
306 void V8InspectorSessionImpl::dispatchProtocolMessage( 306 void V8InspectorSessionImpl::dispatchProtocolMessage(
307 const StringView& message) { 307 const StringView& message) {
308 m_dispatcher.dispatch(protocol::parseJSON(message)); 308 m_dispatcher.dispatch(protocol::StringUtil::parseJSON(message));
309 } 309 }
310 310
311 std::unique_ptr<StringBuffer> V8InspectorSessionImpl::stateJSON() { 311 std::unique_ptr<StringBuffer> V8InspectorSessionImpl::stateJSON() {
312 String16 json = m_state->toJSONString(); 312 String16 json = m_state->toJSONString();
313 return StringBufferImpl::adopt(json); 313 return StringBufferImpl::adopt(json);
314 } 314 }
315 315
316 std::vector<std::unique_ptr<protocol::Schema::API::Domain>> 316 std::vector<std::unique_ptr<protocol::Schema::API::Domain>>
317 V8InspectorSessionImpl::supportedDomains() { 317 V8InspectorSessionImpl::supportedDomains() {
318 std::vector<std::unique_ptr<protocol::Schema::Domain>> domains = 318 std::vector<std::unique_ptr<protocol::Schema::Domain>> domains =
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 V8InspectorSession::Inspectable* V8InspectorSessionImpl::inspectedObject( 359 V8InspectorSession::Inspectable* V8InspectorSessionImpl::inspectedObject(
360 unsigned num) { 360 unsigned num) {
361 if (num >= m_inspectedObjects.size()) return nullptr; 361 if (num >= m_inspectedObjects.size()) return nullptr;
362 return m_inspectedObjects[num].get(); 362 return m_inspectedObjects[num].get();
363 } 363 }
364 364
365 void V8InspectorSessionImpl::schedulePauseOnNextStatement( 365 void V8InspectorSessionImpl::schedulePauseOnNextStatement(
366 const StringView& breakReason, const StringView& breakDetails) { 366 const StringView& breakReason, const StringView& breakDetails) {
367 m_debuggerAgent->schedulePauseOnNextStatement( 367 m_debuggerAgent->schedulePauseOnNextStatement(
368 toString16(breakReason), 368 toString16(breakReason),
369 protocol::DictionaryValue::cast(protocol::parseJSON(breakDetails))); 369 protocol::DictionaryValue::cast(
370 protocol::StringUtil::parseJSON(breakDetails)));
370 } 371 }
371 372
372 void V8InspectorSessionImpl::cancelPauseOnNextStatement() { 373 void V8InspectorSessionImpl::cancelPauseOnNextStatement() {
373 m_debuggerAgent->cancelPauseOnNextStatement(); 374 m_debuggerAgent->cancelPauseOnNextStatement();
374 } 375 }
375 376
376 void V8InspectorSessionImpl::breakProgram(const StringView& breakReason, 377 void V8InspectorSessionImpl::breakProgram(const StringView& breakReason,
377 const StringView& breakDetails) { 378 const StringView& breakDetails) {
378 m_debuggerAgent->breakProgram( 379 m_debuggerAgent->breakProgram(
379 toString16(breakReason), 380 toString16(breakReason),
380 protocol::DictionaryValue::cast(protocol::parseJSON(breakDetails))); 381 protocol::DictionaryValue::cast(
382 protocol::StringUtil::parseJSON(breakDetails)));
381 } 383 }
382 384
383 void V8InspectorSessionImpl::setSkipAllPauses(bool skip) { 385 void V8InspectorSessionImpl::setSkipAllPauses(bool skip) {
384 m_debuggerAgent->setSkipAllPauses(skip); 386 m_debuggerAgent->setSkipAllPauses(skip);
385 } 387 }
386 388
387 void V8InspectorSessionImpl::resume() { m_debuggerAgent->resume(); } 389 void V8InspectorSessionImpl::resume() { m_debuggerAgent->resume(); }
388 390
389 void V8InspectorSessionImpl::stepOver() { m_debuggerAgent->stepOver(); } 391 void V8InspectorSessionImpl::stepOver() { m_debuggerAgent->stepOver(); }
390 392
391 std::vector<std::unique_ptr<protocol::Debugger::API::SearchMatch>> 393 std::vector<std::unique_ptr<protocol::Debugger::API::SearchMatch>>
392 V8InspectorSessionImpl::searchInTextByLines(const StringView& text, 394 V8InspectorSessionImpl::searchInTextByLines(const StringView& text,
393 const StringView& query, 395 const StringView& query,
394 bool caseSensitive, bool isRegex) { 396 bool caseSensitive, bool isRegex) {
395 // TODO(dgozman): search may operate on StringView and avoid copying |text|. 397 // TODO(dgozman): search may operate on StringView and avoid copying |text|.
396 std::vector<std::unique_ptr<protocol::Debugger::SearchMatch>> matches = 398 std::vector<std::unique_ptr<protocol::Debugger::SearchMatch>> matches =
397 searchInTextByLinesImpl(this, toString16(text), toString16(query), 399 searchInTextByLinesImpl(this, toString16(text), toString16(query),
398 caseSensitive, isRegex); 400 caseSensitive, isRegex);
399 std::vector<std::unique_ptr<protocol::Debugger::API::SearchMatch>> result; 401 std::vector<std::unique_ptr<protocol::Debugger::API::SearchMatch>> result;
400 for (size_t i = 0; i < matches.size(); ++i) 402 for (size_t i = 0; i < matches.size(); ++i)
401 result.push_back(std::move(matches[i])); 403 result.push_back(std::move(matches[i]));
402 return result; 404 return result;
403 } 405 }
404 406
405 } // namespace v8_inspector 407 } // namespace v8_inspector
OLDNEW
« no previous file with comments | « src/inspector/v8-inspector-impl.cc ('k') | src/inspector/v8-internal-value-type.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698