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

Side by Side Diff: third_party/WebKit/Source/platform/v8_inspector/V8InspectorSessionImpl.cpp

Issue 2199943004: [DevTools] Rename V8Debugger to V8Inspector. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 months 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
OLDNEW
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"
11 #include "platform/v8_inspector/V8ConsoleAgentImpl.h" 11 #include "platform/v8_inspector/V8ConsoleAgentImpl.h"
12 #include "platform/v8_inspector/V8DebuggerAgentImpl.h" 12 #include "platform/v8_inspector/V8DebuggerAgentImpl.h"
13 #include "platform/v8_inspector/V8DebuggerImpl.h"
14 #include "platform/v8_inspector/V8HeapProfilerAgentImpl.h" 13 #include "platform/v8_inspector/V8HeapProfilerAgentImpl.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/V8StringUtil.h" 17 #include "platform/v8_inspector/V8StringUtil.h"
18 #include "platform/v8_inspector/public/V8ContextInfo.h" 18 #include "platform/v8_inspector/public/V8ContextInfo.h"
19 #include "platform/v8_inspector/public/V8DebuggerClient.h" 19 #include "platform/v8_inspector/public/V8InspectorClient.h"
20 20
21 namespace blink { 21 namespace blink {
22 22
23 // static 23 // static
24 bool V8InspectorSession::canDispatchMethod(const String16& method) 24 bool V8InspectorSession::canDispatchMethod(const String16& method)
25 { 25 {
26 return method.startWith(protocol::Runtime::Metainfo::commandPrefix) 26 return method.startWith(protocol::Runtime::Metainfo::commandPrefix)
27 || method.startWith(protocol::Debugger::Metainfo::commandPrefix) 27 || method.startWith(protocol::Debugger::Metainfo::commandPrefix)
28 || method.startWith(protocol::Profiler::Metainfo::commandPrefix) 28 || method.startWith(protocol::Profiler::Metainfo::commandPrefix)
29 || method.startWith(protocol::HeapProfiler::Metainfo::commandPrefix) 29 || method.startWith(protocol::HeapProfiler::Metainfo::commandPrefix)
30 || method.startWith(protocol::Console::Metainfo::commandPrefix); 30 || method.startWith(protocol::Console::Metainfo::commandPrefix);
31 } 31 }
32 32
33 std::unique_ptr<V8InspectorSessionImpl> V8InspectorSessionImpl::create(V8Debugge rImpl* debugger, int contextGroupId, protocol::FrontendChannel* channel, V8Inspe ctorSessionClient* client, const String16* state) 33 std::unique_ptr<V8InspectorSessionImpl> V8InspectorSessionImpl::create(V8Inspect orImpl* inspector, int contextGroupId, protocol::FrontendChannel* channel, V8Ins pectorSessionClient* client, const String16* state)
34 { 34 {
35 return wrapUnique(new V8InspectorSessionImpl(debugger, contextGroupId, chann el, client, state)); 35 return wrapUnique(new V8InspectorSessionImpl(inspector, contextGroupId, chan nel, client, state));
36 } 36 }
37 37
38 V8InspectorSessionImpl::V8InspectorSessionImpl(V8DebuggerImpl* debugger, int con textGroupId, protocol::FrontendChannel* channel, V8InspectorSessionClient* clien t, const String16* savedState) 38 V8InspectorSessionImpl::V8InspectorSessionImpl(V8InspectorImpl* inspector, int c ontextGroupId, protocol::FrontendChannel* channel, V8InspectorSessionClient* cli ent, const String16* savedState)
39 : m_contextGroupId(contextGroupId) 39 : m_contextGroupId(contextGroupId)
40 , m_debugger(debugger) 40 , m_inspector(inspector)
41 , m_client(client) 41 , m_client(client)
42 , m_customObjectFormatterEnabled(false) 42 , m_customObjectFormatterEnabled(false)
43 , m_dispatcher(channel) 43 , m_dispatcher(channel)
44 , m_state(nullptr) 44 , m_state(nullptr)
45 , m_runtimeAgent(nullptr) 45 , m_runtimeAgent(nullptr)
46 , m_debuggerAgent(nullptr) 46 , m_debuggerAgent(nullptr)
47 , m_heapProfilerAgent(nullptr) 47 , m_heapProfilerAgent(nullptr)
48 , m_profilerAgent(nullptr) 48 , m_profilerAgent(nullptr)
49 , m_consoleAgent(nullptr) 49 , m_consoleAgent(nullptr)
50 { 50 {
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 V8InspectorSessionImpl::~V8InspectorSessionImpl() 85 V8InspectorSessionImpl::~V8InspectorSessionImpl()
86 { 86 {
87 ErrorString errorString; 87 ErrorString errorString;
88 m_consoleAgent->disable(&errorString); 88 m_consoleAgent->disable(&errorString);
89 m_profilerAgent->disable(&errorString); 89 m_profilerAgent->disable(&errorString);
90 m_heapProfilerAgent->disable(&errorString); 90 m_heapProfilerAgent->disable(&errorString);
91 m_debuggerAgent->disable(&errorString); 91 m_debuggerAgent->disable(&errorString);
92 m_runtimeAgent->disable(&errorString); 92 m_runtimeAgent->disable(&errorString);
93 93
94 discardInjectedScripts(); 94 discardInjectedScripts();
95 m_debugger->disconnect(this); 95 m_inspector->disconnect(this);
96 } 96 }
97 97
98 protocol::DictionaryValue* V8InspectorSessionImpl::agentState(const String16& na me) 98 protocol::DictionaryValue* V8InspectorSessionImpl::agentState(const String16& na me)
99 { 99 {
100 protocol::DictionaryValue* state = m_state->getObject(name); 100 protocol::DictionaryValue* state = m_state->getObject(name);
101 if (!state) { 101 if (!state) {
102 std::unique_ptr<protocol::DictionaryValue> newState = protocol::Dictiona ryValue::create(); 102 std::unique_ptr<protocol::DictionaryValue> newState = protocol::Dictiona ryValue::create();
103 state = newState.get(); 103 state = newState.get();
104 m_state->setObject(name, std::move(newState)); 104 m_state->setObject(name, std::move(newState));
105 } 105 }
106 return state; 106 return state;
107 } 107 }
108 108
109 void V8InspectorSessionImpl::reset() 109 void V8InspectorSessionImpl::reset()
110 { 110 {
111 m_debuggerAgent->reset(); 111 m_debuggerAgent->reset();
112 m_runtimeAgent->reset(); 112 m_runtimeAgent->reset();
113 discardInjectedScripts(); 113 discardInjectedScripts();
114 } 114 }
115 115
116 void V8InspectorSessionImpl::discardInjectedScripts() 116 void V8InspectorSessionImpl::discardInjectedScripts()
117 { 117 {
118 m_inspectedObjects.clear(); 118 m_inspectedObjects.clear();
119 const V8DebuggerImpl::ContextByIdMap* contexts = m_debugger->contextGroup(m_ contextGroupId); 119 const V8InspectorImpl::ContextByIdMap* contexts = m_inspector->contextGroup( m_contextGroupId);
120 if (!contexts) 120 if (!contexts)
121 return; 121 return;
122 122
123 std::vector<int> keys; 123 std::vector<int> keys;
124 keys.reserve(contexts->size()); 124 keys.reserve(contexts->size());
125 for (auto& idContext : *contexts) 125 for (auto& idContext : *contexts)
126 keys.push_back(idContext.first); 126 keys.push_back(idContext.first);
127 for (auto& key : keys) { 127 for (auto& key : keys) {
128 contexts = m_debugger->contextGroup(m_contextGroupId); 128 contexts = m_inspector->contextGroup(m_contextGroupId);
129 if (!contexts) 129 if (!contexts)
130 continue; 130 continue;
131 auto contextIt = contexts->find(key); 131 auto contextIt = contexts->find(key);
132 if (contextIt != contexts->end()) 132 if (contextIt != contexts->end())
133 contextIt->second->discardInjectedScript(); // This may destroy some contexts. 133 contextIt->second->discardInjectedScript(); // This may destroy some contexts.
134 } 134 }
135 } 135 }
136 136
137 InjectedScript* V8InspectorSessionImpl::findInjectedScript(ErrorString* errorStr ing, int contextId) 137 InjectedScript* V8InspectorSessionImpl::findInjectedScript(ErrorString* errorStr ing, int contextId)
138 { 138 {
139 if (!contextId) { 139 if (!contextId) {
140 *errorString = "Cannot find context with specified id"; 140 *errorString = "Cannot find context with specified id";
141 return nullptr; 141 return nullptr;
142 } 142 }
143 143
144 const V8DebuggerImpl::ContextByIdMap* contexts = m_debugger->contextGroup(m_ contextGroupId); 144 const V8InspectorImpl::ContextByIdMap* contexts = m_inspector->contextGroup( m_contextGroupId);
145 if (!contexts) { 145 if (!contexts) {
146 *errorString = "Cannot find context with specified id"; 146 *errorString = "Cannot find context with specified id";
147 return nullptr; 147 return nullptr;
148 } 148 }
149 149
150 auto contextsIt = contexts->find(contextId); 150 auto contextsIt = contexts->find(contextId);
151 if (contextsIt == contexts->end()) { 151 if (contextsIt == contexts->end()) {
152 *errorString = "Cannot find context with specified id"; 152 *errorString = "Cannot find context with specified id";
153 return nullptr; 153 return nullptr;
154 } 154 }
(...skipping 11 matching lines...) Expand all
166 return context->getInjectedScript(); 166 return context->getInjectedScript();
167 } 167 }
168 168
169 InjectedScript* V8InspectorSessionImpl::findInjectedScript(ErrorString* errorStr ing, RemoteObjectIdBase* objectId) 169 InjectedScript* V8InspectorSessionImpl::findInjectedScript(ErrorString* errorStr ing, RemoteObjectIdBase* objectId)
170 { 170 {
171 return objectId ? findInjectedScript(errorString, objectId->contextId()) : n ullptr; 171 return objectId ? findInjectedScript(errorString, objectId->contextId()) : n ullptr;
172 } 172 }
173 173
174 void V8InspectorSessionImpl::releaseObjectGroup(const String16& objectGroup) 174 void V8InspectorSessionImpl::releaseObjectGroup(const String16& objectGroup)
175 { 175 {
176 const V8DebuggerImpl::ContextByIdMap* contexts = m_debugger->contextGroup(m_ contextGroupId); 176 const V8InspectorImpl::ContextByIdMap* contexts = m_inspector->contextGroup( m_contextGroupId);
177 if (!contexts) 177 if (!contexts)
178 return; 178 return;
179 179
180 std::vector<int> keys; 180 std::vector<int> keys;
181 for (auto& idContext : *contexts) 181 for (auto& idContext : *contexts)
182 keys.push_back(idContext.first); 182 keys.push_back(idContext.first);
183 for (auto& key : keys) { 183 for (auto& key : keys) {
184 contexts = m_debugger->contextGroup(m_contextGroupId); 184 contexts = m_inspector->contextGroup(m_contextGroupId);
185 if (!contexts) 185 if (!contexts)
186 continue; 186 continue;
187 auto contextsIt = contexts->find(key); 187 auto contextsIt = contexts->find(key);
188 if (contextsIt == contexts->end()) 188 if (contextsIt == contexts->end())
189 continue; 189 continue;
190 InjectedScript* injectedScript = contextsIt->second->getInjectedScript() ; 190 InjectedScript* injectedScript = contextsIt->second->getInjectedScript() ;
191 if (injectedScript) 191 if (injectedScript)
192 injectedScript->releaseObjectGroup(objectGroup); // This may destroy some contexts. 192 injectedScript->releaseObjectGroup(objectGroup); // This may destroy some contexts.
193 } 193 }
194 } 194 }
(...skipping 14 matching lines...) Expand all
209 } 209 }
210 210
211 std::unique_ptr<protocol::Runtime::API::RemoteObject> V8InspectorSessionImpl::wr apObject(v8::Local<v8::Context> context, v8::Local<v8::Value> value, const Strin g16& groupName) 211 std::unique_ptr<protocol::Runtime::API::RemoteObject> V8InspectorSessionImpl::wr apObject(v8::Local<v8::Context> context, v8::Local<v8::Value> value, const Strin g16& groupName)
212 { 212 {
213 return wrapObject(context, value, groupName, false); 213 return wrapObject(context, value, groupName, false);
214 } 214 }
215 215
216 std::unique_ptr<protocol::Runtime::RemoteObject> V8InspectorSessionImpl::wrapObj ect(v8::Local<v8::Context> context, v8::Local<v8::Value> value, const String16& groupName, bool generatePreview) 216 std::unique_ptr<protocol::Runtime::RemoteObject> V8InspectorSessionImpl::wrapObj ect(v8::Local<v8::Context> context, v8::Local<v8::Value> value, const String16& groupName, bool generatePreview)
217 { 217 {
218 ErrorString errorString; 218 ErrorString errorString;
219 InjectedScript* injectedScript = findInjectedScript(&errorString, V8Debugger Impl::contextId(context)); 219 InjectedScript* injectedScript = findInjectedScript(&errorString, V8Inspecto rImpl::contextId(context));
220 if (!injectedScript) 220 if (!injectedScript)
221 return nullptr; 221 return nullptr;
222 return injectedScript->wrapObject(&errorString, value, groupName, false, gen eratePreview); 222 return injectedScript->wrapObject(&errorString, value, groupName, false, gen eratePreview);
223 } 223 }
224 224
225 std::unique_ptr<protocol::Runtime::RemoteObject> V8InspectorSessionImpl::wrapTab le(v8::Local<v8::Context> context, v8::Local<v8::Value> table, v8::Local<v8::Val ue> columns) 225 std::unique_ptr<protocol::Runtime::RemoteObject> V8InspectorSessionImpl::wrapTab le(v8::Local<v8::Context> context, v8::Local<v8::Value> table, v8::Local<v8::Val ue> columns)
226 { 226 {
227 ErrorString errorString; 227 ErrorString errorString;
228 InjectedScript* injectedScript = findInjectedScript(&errorString, V8Debugger Impl::contextId(context)); 228 InjectedScript* injectedScript = findInjectedScript(&errorString, V8Inspecto rImpl::contextId(context));
229 if (!injectedScript) 229 if (!injectedScript)
230 return nullptr; 230 return nullptr;
231 return injectedScript->wrapTable(table, columns); 231 return injectedScript->wrapTable(table, columns);
232 } 232 }
233 233
234 void V8InspectorSessionImpl::setCustomObjectFormatterEnabled(bool enabled) 234 void V8InspectorSessionImpl::setCustomObjectFormatterEnabled(bool enabled)
235 { 235 {
236 m_customObjectFormatterEnabled = enabled; 236 m_customObjectFormatterEnabled = enabled;
237 const V8DebuggerImpl::ContextByIdMap* contexts = m_debugger->contextGroup(m_ contextGroupId); 237 const V8InspectorImpl::ContextByIdMap* contexts = m_inspector->contextGroup( m_contextGroupId);
238 if (!contexts) 238 if (!contexts)
239 return; 239 return;
240 for (auto& idContext : *contexts) { 240 for (auto& idContext : *contexts) {
241 InjectedScript* injectedScript = idContext.second->getInjectedScript(); 241 InjectedScript* injectedScript = idContext.second->getInjectedScript();
242 if (injectedScript) 242 if (injectedScript)
243 injectedScript->setCustomObjectFormatterEnabled(enabled); 243 injectedScript->setCustomObjectFormatterEnabled(enabled);
244 } 244 }
245 } 245 }
246 246
247 void V8InspectorSessionImpl::reportAllContexts(V8RuntimeAgentImpl* agent) 247 void V8InspectorSessionImpl::reportAllContexts(V8RuntimeAgentImpl* agent)
248 { 248 {
249 const V8DebuggerImpl::ContextByIdMap* contexts = m_debugger->contextGroup(m_ contextGroupId); 249 const V8InspectorImpl::ContextByIdMap* contexts = m_inspector->contextGroup( m_contextGroupId);
250 if (!contexts) 250 if (!contexts)
251 return; 251 return;
252 for (auto& idContext : *contexts) 252 for (auto& idContext : *contexts)
253 agent->reportExecutionContextCreated(idContext.second.get()); 253 agent->reportExecutionContextCreated(idContext.second.get());
254 } 254 }
255 255
256 void V8InspectorSessionImpl::dispatchProtocolMessage(const String16& message) 256 void V8InspectorSessionImpl::dispatchProtocolMessage(const String16& message)
257 { 257 {
258 m_dispatcher.dispatch(message); 258 m_dispatcher.dispatch(message);
259 } 259 }
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 std::unique_ptr<protocol::Array<protocol::Debugger::API::SearchMatch>> V8Inspect orSessionImpl::searchInTextByLines(const String16& text, const String16& query, bool caseSensitive, bool isRegex) 313 std::unique_ptr<protocol::Array<protocol::Debugger::API::SearchMatch>> V8Inspect orSessionImpl::searchInTextByLines(const String16& text, const String16& query, bool caseSensitive, bool isRegex)
314 { 314 {
315 std::vector<std::unique_ptr<protocol::Debugger::SearchMatch>> matches = sear chInTextByLinesImpl(this, text, query, caseSensitive, isRegex); 315 std::vector<std::unique_ptr<protocol::Debugger::SearchMatch>> matches = sear chInTextByLinesImpl(this, text, query, caseSensitive, isRegex);
316 std::unique_ptr<protocol::Array<protocol::Debugger::API::SearchMatch>> resul t = protocol::Array<protocol::Debugger::API::SearchMatch>::create(); 316 std::unique_ptr<protocol::Array<protocol::Debugger::API::SearchMatch>> resul t = protocol::Array<protocol::Debugger::API::SearchMatch>::create();
317 for (size_t i = 0; i < matches.size(); ++i) 317 for (size_t i = 0; i < matches.size(); ++i)
318 result->addItem(std::move(matches[i])); 318 result->addItem(std::move(matches[i]));
319 return result; 319 return result;
320 } 320 }
321 321
322 } // namespace blink 322 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698