Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 = std::unique_ptr<V8RuntimeAgentImpl>(new V8RuntimeAgentImpl( |
|
dgozman
2016/11/22 18:12:48
.reset
kozy
2016/11/22 18:24:31
Done.
| |
| 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 = |
| 77 this, this, agentState(protocol::Debugger::Metainfo::domainName))); | 77 std::unique_ptr<V8DebuggerAgentImpl>(new V8DebuggerAgentImpl( |
| 78 this, this, agentState(protocol::Debugger::Metainfo::domainName))); | |
| 78 protocol::Debugger::Dispatcher::wire(&m_dispatcher, m_debuggerAgent.get()); | 79 protocol::Debugger::Dispatcher::wire(&m_dispatcher, m_debuggerAgent.get()); |
| 79 | 80 |
| 80 m_profilerAgent = wrapUnique(new V8ProfilerAgentImpl( | 81 m_profilerAgent = |
| 81 this, this, agentState(protocol::Profiler::Metainfo::domainName))); | 82 std::unique_ptr<V8ProfilerAgentImpl>(new V8ProfilerAgentImpl( |
| 83 this, this, agentState(protocol::Profiler::Metainfo::domainName))); | |
| 82 protocol::Profiler::Dispatcher::wire(&m_dispatcher, m_profilerAgent.get()); | 84 protocol::Profiler::Dispatcher::wire(&m_dispatcher, m_profilerAgent.get()); |
| 83 | 85 |
| 84 m_heapProfilerAgent = wrapUnique(new V8HeapProfilerAgentImpl( | 86 m_heapProfilerAgent = |
| 85 this, this, agentState(protocol::HeapProfiler::Metainfo::domainName))); | 87 std::unique_ptr<V8HeapProfilerAgentImpl>(new V8HeapProfilerAgentImpl( |
| 88 this, this, | |
| 89 agentState(protocol::HeapProfiler::Metainfo::domainName))); | |
| 86 protocol::HeapProfiler::Dispatcher::wire(&m_dispatcher, | 90 protocol::HeapProfiler::Dispatcher::wire(&m_dispatcher, |
| 87 m_heapProfilerAgent.get()); | 91 m_heapProfilerAgent.get()); |
| 88 | 92 |
| 89 m_consoleAgent = wrapUnique(new V8ConsoleAgentImpl( | 93 m_consoleAgent = std::unique_ptr<V8ConsoleAgentImpl>(new V8ConsoleAgentImpl( |
| 90 this, this, agentState(protocol::Console::Metainfo::domainName))); | 94 this, this, agentState(protocol::Console::Metainfo::domainName))); |
| 91 protocol::Console::Dispatcher::wire(&m_dispatcher, m_consoleAgent.get()); | 95 protocol::Console::Dispatcher::wire(&m_dispatcher, m_consoleAgent.get()); |
| 92 | 96 |
| 93 m_schemaAgent = wrapUnique(new V8SchemaAgentImpl( | 97 m_schemaAgent = std::unique_ptr<V8SchemaAgentImpl>(new V8SchemaAgentImpl( |
| 94 this, this, agentState(protocol::Schema::Metainfo::domainName))); | 98 this, this, agentState(protocol::Schema::Metainfo::domainName))); |
| 95 protocol::Schema::Dispatcher::wire(&m_dispatcher, m_schemaAgent.get()); | 99 protocol::Schema::Dispatcher::wire(&m_dispatcher, m_schemaAgent.get()); |
| 96 | 100 |
| 97 if (savedState.length()) { | 101 if (savedState.length()) { |
| 98 m_runtimeAgent->restore(); | 102 m_runtimeAgent->restore(); |
| 99 m_debuggerAgent->restore(); | 103 m_debuggerAgent->restore(); |
| 100 m_heapProfilerAgent->restore(); | 104 m_heapProfilerAgent->restore(); |
| 101 m_profilerAgent->restore(); | 105 m_profilerAgent->restore(); |
| 102 m_consoleAgent->restore(); | 106 m_consoleAgent->restore(); |
| 103 } | 107 } |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 298 void V8InspectorSessionImpl::reportAllContexts(V8RuntimeAgentImpl* agent) { | 302 void V8InspectorSessionImpl::reportAllContexts(V8RuntimeAgentImpl* agent) { |
| 299 const V8InspectorImpl::ContextByIdMap* contexts = | 303 const V8InspectorImpl::ContextByIdMap* contexts = |
| 300 m_inspector->contextGroup(m_contextGroupId); | 304 m_inspector->contextGroup(m_contextGroupId); |
| 301 if (!contexts) return; | 305 if (!contexts) return; |
| 302 for (auto& idContext : *contexts) | 306 for (auto& idContext : *contexts) |
| 303 agent->reportExecutionContextCreated(idContext.second.get()); | 307 agent->reportExecutionContextCreated(idContext.second.get()); |
| 304 } | 308 } |
| 305 | 309 |
| 306 void V8InspectorSessionImpl::dispatchProtocolMessage( | 310 void V8InspectorSessionImpl::dispatchProtocolMessage( |
| 307 const StringView& message) { | 311 const StringView& message) { |
| 308 m_dispatcher.dispatch(protocol::parseJSON(message)); | 312 m_dispatcher.dispatch(protocol::StringUtil::parseJSON(message)); |
| 309 } | 313 } |
| 310 | 314 |
| 311 std::unique_ptr<StringBuffer> V8InspectorSessionImpl::stateJSON() { | 315 std::unique_ptr<StringBuffer> V8InspectorSessionImpl::stateJSON() { |
| 312 String16 json = m_state->toJSONString(); | 316 String16 json = m_state->toJSONString(); |
| 313 return StringBufferImpl::adopt(json); | 317 return StringBufferImpl::adopt(json); |
| 314 } | 318 } |
| 315 | 319 |
| 316 std::vector<std::unique_ptr<protocol::Schema::API::Domain>> | 320 std::vector<std::unique_ptr<protocol::Schema::API::Domain>> |
| 317 V8InspectorSessionImpl::supportedDomains() { | 321 V8InspectorSessionImpl::supportedDomains() { |
| 318 std::vector<std::unique_ptr<protocol::Schema::Domain>> domains = | 322 std::vector<std::unique_ptr<protocol::Schema::Domain>> domains = |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 359 V8InspectorSession::Inspectable* V8InspectorSessionImpl::inspectedObject( | 363 V8InspectorSession::Inspectable* V8InspectorSessionImpl::inspectedObject( |
| 360 unsigned num) { | 364 unsigned num) { |
| 361 if (num >= m_inspectedObjects.size()) return nullptr; | 365 if (num >= m_inspectedObjects.size()) return nullptr; |
| 362 return m_inspectedObjects[num].get(); | 366 return m_inspectedObjects[num].get(); |
| 363 } | 367 } |
| 364 | 368 |
| 365 void V8InspectorSessionImpl::schedulePauseOnNextStatement( | 369 void V8InspectorSessionImpl::schedulePauseOnNextStatement( |
| 366 const StringView& breakReason, const StringView& breakDetails) { | 370 const StringView& breakReason, const StringView& breakDetails) { |
| 367 m_debuggerAgent->schedulePauseOnNextStatement( | 371 m_debuggerAgent->schedulePauseOnNextStatement( |
| 368 toString16(breakReason), | 372 toString16(breakReason), |
| 369 protocol::DictionaryValue::cast(protocol::parseJSON(breakDetails))); | 373 protocol::DictionaryValue::cast( |
| 374 protocol::StringUtil::parseJSON(breakDetails))); | |
| 370 } | 375 } |
| 371 | 376 |
| 372 void V8InspectorSessionImpl::cancelPauseOnNextStatement() { | 377 void V8InspectorSessionImpl::cancelPauseOnNextStatement() { |
| 373 m_debuggerAgent->cancelPauseOnNextStatement(); | 378 m_debuggerAgent->cancelPauseOnNextStatement(); |
| 374 } | 379 } |
| 375 | 380 |
| 376 void V8InspectorSessionImpl::breakProgram(const StringView& breakReason, | 381 void V8InspectorSessionImpl::breakProgram(const StringView& breakReason, |
| 377 const StringView& breakDetails) { | 382 const StringView& breakDetails) { |
| 378 m_debuggerAgent->breakProgram( | 383 m_debuggerAgent->breakProgram( |
| 379 toString16(breakReason), | 384 toString16(breakReason), |
| 380 protocol::DictionaryValue::cast(protocol::parseJSON(breakDetails))); | 385 protocol::DictionaryValue::cast( |
| 386 protocol::StringUtil::parseJSON(breakDetails))); | |
| 381 } | 387 } |
| 382 | 388 |
| 383 void V8InspectorSessionImpl::setSkipAllPauses(bool skip) { | 389 void V8InspectorSessionImpl::setSkipAllPauses(bool skip) { |
| 384 m_debuggerAgent->setSkipAllPauses(skip); | 390 m_debuggerAgent->setSkipAllPauses(skip); |
| 385 } | 391 } |
| 386 | 392 |
| 387 void V8InspectorSessionImpl::resume() { m_debuggerAgent->resume(); } | 393 void V8InspectorSessionImpl::resume() { m_debuggerAgent->resume(); } |
| 388 | 394 |
| 389 void V8InspectorSessionImpl::stepOver() { m_debuggerAgent->stepOver(); } | 395 void V8InspectorSessionImpl::stepOver() { m_debuggerAgent->stepOver(); } |
| 390 | 396 |
| 391 std::vector<std::unique_ptr<protocol::Debugger::API::SearchMatch>> | 397 std::vector<std::unique_ptr<protocol::Debugger::API::SearchMatch>> |
| 392 V8InspectorSessionImpl::searchInTextByLines(const StringView& text, | 398 V8InspectorSessionImpl::searchInTextByLines(const StringView& text, |
| 393 const StringView& query, | 399 const StringView& query, |
| 394 bool caseSensitive, bool isRegex) { | 400 bool caseSensitive, bool isRegex) { |
| 395 // TODO(dgozman): search may operate on StringView and avoid copying |text|. | 401 // TODO(dgozman): search may operate on StringView and avoid copying |text|. |
| 396 std::vector<std::unique_ptr<protocol::Debugger::SearchMatch>> matches = | 402 std::vector<std::unique_ptr<protocol::Debugger::SearchMatch>> matches = |
| 397 searchInTextByLinesImpl(this, toString16(text), toString16(query), | 403 searchInTextByLinesImpl(this, toString16(text), toString16(query), |
| 398 caseSensitive, isRegex); | 404 caseSensitive, isRegex); |
| 399 std::vector<std::unique_ptr<protocol::Debugger::API::SearchMatch>> result; | 405 std::vector<std::unique_ptr<protocol::Debugger::API::SearchMatch>> result; |
| 400 for (size_t i = 0; i < matches.size(); ++i) | 406 for (size_t i = 0; i < matches.size(); ++i) |
| 401 result.push_back(std::move(matches[i])); | 407 result.push_back(std::move(matches[i])); |
| 402 return result; | 408 return result; |
| 403 } | 409 } |
| 404 | 410 |
| 405 } // namespace v8_inspector | 411 } // namespace v8_inspector |
| OLD | NEW |