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

Side by Side Diff: third_party/WebKit/Source/core/inspector/ThreadDebugger.cpp

Issue 2251343003: [DevTools] Generate separate copies of inspector_protocol. (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 "core/inspector/ThreadDebugger.h" 5 #include "core/inspector/ThreadDebugger.h"
6 6
7 #include "bindings/core/v8/SourceLocation.h" 7 #include "bindings/core/v8/SourceLocation.h"
8 #include "bindings/core/v8/V8Binding.h" 8 #include "bindings/core/v8/V8Binding.h"
9 #include "bindings/core/v8/V8DOMException.h" 9 #include "bindings/core/v8/V8DOMException.h"
10 #include "bindings/core/v8/V8DOMTokenList.h" 10 #include "bindings/core/v8/V8DOMTokenList.h"
11 #include "bindings/core/v8/V8Event.h" 11 #include "bindings/core/v8/V8Event.h"
12 #include "bindings/core/v8/V8EventListener.h" 12 #include "bindings/core/v8/V8EventListener.h"
13 #include "bindings/core/v8/V8EventListenerInfo.h" 13 #include "bindings/core/v8/V8EventListenerInfo.h"
14 #include "bindings/core/v8/V8EventListenerList.h" 14 #include "bindings/core/v8/V8EventListenerList.h"
15 #include "bindings/core/v8/V8HTMLAllCollection.h" 15 #include "bindings/core/v8/V8HTMLAllCollection.h"
16 #include "bindings/core/v8/V8HTMLCollection.h" 16 #include "bindings/core/v8/V8HTMLCollection.h"
17 #include "bindings/core/v8/V8Node.h" 17 #include "bindings/core/v8/V8Node.h"
18 #include "bindings/core/v8/V8NodeList.h" 18 #include "bindings/core/v8/V8NodeList.h"
19 #include "bindings/core/v8/V8ScriptRunner.h" 19 #include "bindings/core/v8/V8ScriptRunner.h"
20 #include "core/inspector/ConsoleMessage.h" 20 #include "core/inspector/ConsoleMessage.h"
21 #include "core/inspector/InspectorDOMDebuggerAgent.h" 21 #include "core/inspector/InspectorDOMDebuggerAgent.h"
22 #include "core/inspector/InspectorTraceEvents.h" 22 #include "core/inspector/InspectorTraceEvents.h"
23 #include "core/inspector/V8InspectorStringConversion.h"
23 #include "platform/ScriptForbiddenScope.h" 24 #include "platform/ScriptForbiddenScope.h"
24 #include "wtf/CurrentTime.h" 25 #include "wtf/CurrentTime.h"
25 #include "wtf/PtrUtil.h" 26 #include "wtf/PtrUtil.h"
26 #include <memory> 27 #include <memory>
27 28
28 namespace blink { 29 namespace blink {
29 30
30 ThreadDebugger::ThreadDebugger(v8::Isolate* isolate) 31 ThreadDebugger::ThreadDebugger(v8::Isolate* isolate)
31 : m_isolate(isolate) 32 : m_isolate(isolate)
32 , m_v8Inspector(v8_inspector::V8Inspector::create(isolate, this)) 33 , m_v8Inspector(v8_inspector::V8Inspector::create(isolate, this))
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 } 79 }
79 80
80 void ThreadDebugger::idleFinished(v8::Isolate* isolate) 81 void ThreadDebugger::idleFinished(v8::Isolate* isolate)
81 { 82 {
82 if (ThreadDebugger* debugger = ThreadDebugger::from(isolate)) 83 if (ThreadDebugger* debugger = ThreadDebugger::from(isolate))
83 debugger->v8Inspector()->idleFinished(); 84 debugger->v8Inspector()->idleFinished();
84 } 85 }
85 86
86 void ThreadDebugger::asyncTaskScheduled(const String& operationName, void* task, bool recurring) 87 void ThreadDebugger::asyncTaskScheduled(const String& operationName, void* task, bool recurring)
87 { 88 {
88 m_v8Inspector->asyncTaskScheduled(operationName, task, recurring); 89 m_v8Inspector->asyncTaskScheduled(toV8InspectorString(operationName), task, recurring);
89 } 90 }
90 91
91 void ThreadDebugger::asyncTaskCanceled(void* task) 92 void ThreadDebugger::asyncTaskCanceled(void* task)
92 { 93 {
93 m_v8Inspector->asyncTaskCanceled(task); 94 m_v8Inspector->asyncTaskCanceled(task);
94 } 95 }
95 96
96 void ThreadDebugger::allAsyncTasksCanceled() 97 void ThreadDebugger::allAsyncTasksCanceled()
97 { 98 {
98 m_v8Inspector->allAsyncTasksCanceled(); 99 m_v8Inspector->allAsyncTasksCanceled();
(...skipping 12 matching lines...) Expand all
111 unsigned ThreadDebugger::promiseRejected(v8::Local<v8::Context> context, const S tring& errorMessage, v8::Local<v8::Value> exception, std::unique_ptr<SourceLocat ion> location) 112 unsigned ThreadDebugger::promiseRejected(v8::Local<v8::Context> context, const S tring& errorMessage, v8::Local<v8::Value> exception, std::unique_ptr<SourceLocat ion> location)
112 { 113 {
113 const String defaultMessage = "Uncaught (in promise)"; 114 const String defaultMessage = "Uncaught (in promise)";
114 String message = errorMessage; 115 String message = errorMessage;
115 if (message.isEmpty()) 116 if (message.isEmpty())
116 message = defaultMessage; 117 message = defaultMessage;
117 else if (message.startsWith("Uncaught ")) 118 else if (message.startsWith("Uncaught "))
118 message = message.substring(0, 8) + " (in promise)" + message.substring( 8); 119 message = message.substring(0, 8) + " (in promise)" + message.substring( 8);
119 120
120 reportConsoleMessage(toExecutionContext(context), JSMessageSource, ErrorMess ageLevel, message, location.get()); 121 reportConsoleMessage(toExecutionContext(context), JSMessageSource, ErrorMess ageLevel, message, location.get());
121 return v8Inspector()->exceptionThrown(context, defaultMessage, exception, me ssage, location->url(), location->lineNumber(), location->columnNumber(), locati on->takeStackTrace(), location->scriptId()); 122 return v8Inspector()->exceptionThrown(context, toV8InspectorString(defaultMe ssage), exception, toV8InspectorString(message), toV8InspectorString(location->u rl()), location->lineNumber(), location->columnNumber(), location->takeStackTrac e(), location->scriptId());
122 } 123 }
123 124
124 void ThreadDebugger::promiseRejectionRevoked(v8::Local<v8::Context> context, uns igned promiseRejectionId) 125 void ThreadDebugger::promiseRejectionRevoked(v8::Local<v8::Context> context, uns igned promiseRejectionId)
125 { 126 {
126 const String message = "Handler added to rejected promise"; 127 const String message = "Handler added to rejected promise";
127 v8Inspector()->exceptionRevoked(context, promiseRejectionId, message); 128 v8Inspector()->exceptionRevoked(context, promiseRejectionId, toV8InspectorSt ring(message));
128 } 129 }
129 130
130 void ThreadDebugger::beginUserGesture() 131 void ThreadDebugger::beginUserGesture()
131 { 132 {
132 m_userGestureIndicator = wrapUnique(new UserGestureIndicator(DefinitelyProce ssingNewUserGesture)); 133 m_userGestureIndicator = wrapUnique(new UserGestureIndicator(DefinitelyProce ssingNewUserGesture));
133 } 134 }
134 135
135 void ThreadDebugger::endUserGesture() 136 void ThreadDebugger::endUserGesture()
136 { 137 {
137 m_userGestureIndicator.reset(); 138 m_userGestureIndicator.reset();
138 } 139 }
139 140
140 String16 ThreadDebugger::valueSubtype(v8::Local<v8::Value> value) 141 v8_inspector::String16 ThreadDebugger::valueSubtype(v8::Local<v8::Value> value)
141 { 142 {
142 if (V8Node::hasInstance(value, m_isolate)) 143 if (V8Node::hasInstance(value, m_isolate))
143 return "node"; 144 return "node";
144 if (V8NodeList::hasInstance(value, m_isolate) 145 if (V8NodeList::hasInstance(value, m_isolate)
145 || V8DOMTokenList::hasInstance(value, m_isolate) 146 || V8DOMTokenList::hasInstance(value, m_isolate)
146 || V8HTMLCollection::hasInstance(value, m_isolate) 147 || V8HTMLCollection::hasInstance(value, m_isolate)
147 || V8HTMLAllCollection::hasInstance(value, m_isolate)) { 148 || V8HTMLAllCollection::hasInstance(value, m_isolate)) {
148 return "array"; 149 return "array";
149 } 150 }
150 if (V8DOMException::hasInstance(value, m_isolate)) 151 if (V8DOMException::hasInstance(value, m_isolate))
151 return "error"; 152 return "error";
152 return String(); 153 return v8_inspector::String16();
153 } 154 }
154 155
155 bool ThreadDebugger::formatAccessorsAsProperties(v8::Local<v8::Value> value) 156 bool ThreadDebugger::formatAccessorsAsProperties(v8::Local<v8::Value> value)
156 { 157 {
157 return V8DOMWrapper::isWrapper(m_isolate, value); 158 return V8DOMWrapper::isWrapper(m_isolate, value);
158 } 159 }
159 160
160 double ThreadDebugger::currentTimeMS() 161 double ThreadDebugger::currentTimeMS()
161 { 162 {
162 return WTF::currentTimeMS(); 163 return WTF::currentTimeMS();
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 listenerObject->Set(v8String(isolate, "passive"), v8::Boolean::New(isola te, info.passive)); 321 listenerObject->Set(v8String(isolate, "passive"), v8::Boolean::New(isola te, info.passive));
321 listenerObject->Set(v8String(isolate, "type"), v8String(isolate, current EventType)); 322 listenerObject->Set(v8String(isolate, "type"), v8String(isolate, current EventType));
322 v8::Local<v8::Function> removeFunction; 323 v8::Local<v8::Function> removeFunction;
323 if (info.removeFunction.ToLocal(&removeFunction)) 324 if (info.removeFunction.ToLocal(&removeFunction))
324 listenerObject->Set(v8String(isolate, "remove"), removeFunction); 325 listenerObject->Set(v8String(isolate, "remove"), removeFunction);
325 listeners->Set(outputIndex++, listenerObject); 326 listeners->Set(outputIndex++, listenerObject);
326 } 327 }
327 info.GetReturnValue().Set(result); 328 info.GetReturnValue().Set(result);
328 } 329 }
329 330
330 void ThreadDebugger::consoleTime(const String16& title) 331 void ThreadDebugger::consoleTime(const v8_inspector::String16& title)
331 { 332 {
332 TRACE_EVENT_COPY_ASYNC_BEGIN0("blink.console", String(title).utf8().data(), this); 333 TRACE_EVENT_COPY_ASYNC_BEGIN0("blink.console", toCoreString(title).utf8().da ta(), this);
caseq 2016/08/19 02:50:36 This and the two below are kinda time-sensitive, i
333 } 334 }
334 335
335 void ThreadDebugger::consoleTimeEnd(const String16& title) 336 void ThreadDebugger::consoleTimeEnd(const v8_inspector::String16& title)
336 { 337 {
337 TRACE_EVENT_COPY_ASYNC_END0("blink.console", String(title).utf8().data(), th is); 338 TRACE_EVENT_COPY_ASYNC_END0("blink.console", toCoreString(title).utf8().data (), this);
338 } 339 }
339 340
340 void ThreadDebugger::consoleTimeStamp(const String16& title) 341 void ThreadDebugger::consoleTimeStamp(const v8_inspector::String16& title)
341 { 342 {
342 v8::Isolate* isolate = m_isolate; 343 v8::Isolate* isolate = m_isolate;
343 TRACE_EVENT_INSTANT1("devtools.timeline", "TimeStamp", TRACE_EVENT_SCOPE_THR EAD, "data", InspectorTimeStampEvent::data(currentExecutionContext(isolate), tit le)); 344 TRACE_EVENT_INSTANT1("devtools.timeline", "TimeStamp", TRACE_EVENT_SCOPE_THR EAD, "data", InspectorTimeStampEvent::data(currentExecutionContext(isolate), toC oreString(title)));
344 } 345 }
345 346
346 void ThreadDebugger::startRepeatingTimer(double interval, V8InspectorClient::Tim erCallback callback, void* data) 347 void ThreadDebugger::startRepeatingTimer(double interval, V8InspectorClient::Tim erCallback callback, void* data)
347 { 348 {
348 m_timerData.append(data); 349 m_timerData.append(data);
349 m_timerCallbacks.append(callback); 350 m_timerCallbacks.append(callback);
350 351
351 std::unique_ptr<Timer<ThreadDebugger>> timer = wrapUnique(new Timer<ThreadDe bugger>(this, &ThreadDebugger::onTimer)); 352 std::unique_ptr<Timer<ThreadDebugger>> timer = wrapUnique(new Timer<ThreadDe bugger>(this, &ThreadDebugger::onTimer));
352 Timer<ThreadDebugger>* timerPtr = timer.get(); 353 Timer<ThreadDebugger>* timerPtr = timer.get();
353 m_timers.append(std::move(timer)); 354 m_timers.append(std::move(timer));
(...skipping 17 matching lines...) Expand all
371 { 372 {
372 for (size_t index = 0; index < m_timers.size(); ++index) { 373 for (size_t index = 0; index < m_timers.size(); ++index) {
373 if (m_timers[index].get() == timer) { 374 if (m_timers[index].get() == timer) {
374 m_timerCallbacks[index](m_timerData[index]); 375 m_timerCallbacks[index](m_timerData[index]);
375 return; 376 return;
376 } 377 }
377 } 378 }
378 } 379 }
379 380
380 } // namespace blink 381 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698