| 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 "core/inspector/InspectorSession.h" | 5 #include "core/inspector/InspectorSession.h" |
| 6 | 6 |
| 7 #include "bindings/core/v8/ScriptController.h" | 7 #include "bindings/core/v8/ScriptController.h" |
| 8 #include "core/frame/LocalFrame.h" | 8 #include "core/frame/LocalFrame.h" |
| 9 #include "core/frame/UseCounter.h" | 9 #include "core/frame/UseCounter.h" |
| 10 #include "core/inspector/InspectorBaseAgent.h" | 10 #include "core/inspector/InspectorBaseAgent.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 v8_inspector::V8Inspector* inspector, | 24 v8_inspector::V8Inspector* inspector, |
| 25 int contextGroupId, | 25 int contextGroupId, |
| 26 const String* savedState) | 26 const String* savedState) |
| 27 : m_client(client), | 27 : m_client(client), |
| 28 m_v8Session(nullptr), | 28 m_v8Session(nullptr), |
| 29 m_sessionId(sessionId), | 29 m_sessionId(sessionId), |
| 30 m_disposed(false), | 30 m_disposed(false), |
| 31 m_instrumentingAgents(instrumentingAgents), | 31 m_instrumentingAgents(instrumentingAgents), |
| 32 m_inspectorBackendDispatcher(new protocol::UberDispatcher(this)) { | 32 m_inspectorBackendDispatcher(new protocol::UberDispatcher(this)) { |
| 33 if (savedState) { | 33 if (savedState) { |
| 34 std::unique_ptr<protocol::Value> state = protocol::parseJSON(*savedState); | 34 std::unique_ptr<protocol::Value> state = |
| 35 protocol::StringUtil::parseJSON(*savedState); |
| 35 if (state) | 36 if (state) |
| 36 m_state = protocol::DictionaryValue::cast(std::move(state)); | 37 m_state = protocol::DictionaryValue::cast(std::move(state)); |
| 37 if (!m_state) | 38 if (!m_state) |
| 38 m_state = protocol::DictionaryValue::create(); | 39 m_state = protocol::DictionaryValue::create(); |
| 39 } else { | 40 } else { |
| 40 m_state = protocol::DictionaryValue::create(); | 41 m_state = protocol::DictionaryValue::create(); |
| 41 } | 42 } |
| 42 | 43 |
| 43 String v8State; | 44 String v8State; |
| 44 if (savedState) | 45 if (savedState) |
| (...skipping 25 matching lines...) Expand all Loading... |
| 70 for (size_t i = m_agents.size(); i > 0; i--) | 71 for (size_t i = m_agents.size(); i > 0; i--) |
| 71 m_agents[i - 1]->dispose(); | 72 m_agents[i - 1]->dispose(); |
| 72 m_agents.clear(); | 73 m_agents.clear(); |
| 73 m_v8Session.reset(); | 74 m_v8Session.reset(); |
| 74 } | 75 } |
| 75 | 76 |
| 76 void InspectorSession::dispatchProtocolMessage(const String& method, | 77 void InspectorSession::dispatchProtocolMessage(const String& method, |
| 77 const String& message) { | 78 const String& message) { |
| 78 DCHECK(!m_disposed); | 79 DCHECK(!m_disposed); |
| 79 if (v8_inspector::V8InspectorSession::canDispatchMethod( | 80 if (v8_inspector::V8InspectorSession::canDispatchMethod( |
| 80 toV8InspectorStringView(method))) | 81 toV8InspectorStringView(method))) { |
| 81 m_v8Session->dispatchProtocolMessage(toV8InspectorStringView(message)); | 82 m_v8Session->dispatchProtocolMessage(toV8InspectorStringView(message)); |
| 82 else | 83 } else { |
| 83 m_inspectorBackendDispatcher->dispatch(protocol::parseJSON(message)); | 84 m_inspectorBackendDispatcher->dispatch( |
| 85 protocol::StringUtil::parseJSON(message)); |
| 86 } |
| 84 } | 87 } |
| 85 | 88 |
| 86 void InspectorSession::didCommitLoadForLocalFrame(LocalFrame* frame) { | 89 void InspectorSession::didCommitLoadForLocalFrame(LocalFrame* frame) { |
| 87 for (size_t i = 0; i < m_agents.size(); i++) | 90 for (size_t i = 0; i < m_agents.size(); i++) |
| 88 m_agents[i]->didCommitLoadForLocalFrame(frame); | 91 m_agents[i]->didCommitLoadForLocalFrame(frame); |
| 89 } | 92 } |
| 90 | 93 |
| 91 void InspectorSession::sendProtocolResponse(int callId, const String& message) { | 94 void InspectorSession::sendProtocolResponse(int callId, const String& message) { |
| 92 if (m_disposed) | 95 if (m_disposed) |
| 93 return; | 96 return; |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 String()); | 134 String()); |
| 132 m_notificationQueue.clear(); | 135 m_notificationQueue.clear(); |
| 133 } | 136 } |
| 134 | 137 |
| 135 DEFINE_TRACE(InspectorSession) { | 138 DEFINE_TRACE(InspectorSession) { |
| 136 visitor->trace(m_instrumentingAgents); | 139 visitor->trace(m_instrumentingAgents); |
| 137 visitor->trace(m_agents); | 140 visitor->trace(m_agents); |
| 138 } | 141 } |
| 139 | 142 |
| 140 } // namespace blink | 143 } // namespace blink |
| OLD | NEW |