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

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

Issue 2260233002: [DevTools] Migrate v8_inspector/public from String16 to String{View,Buffer}. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: better 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/V8InspectorStringView.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(toV8InspectorStringView(operationName), ta sk, 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 String url = location->url();
123 return v8Inspector()->exceptionThrown(context, toV8InspectorStringView(defau ltMessage), exception, toV8InspectorStringView(message), toV8InspectorStringView (url), location->lineNumber(), location->columnNumber(), location->takeStackTrac e(), location->scriptId());
122 } 124 }
123 125
124 void ThreadDebugger::promiseRejectionRevoked(v8::Local<v8::Context> context, uns igned promiseRejectionId) 126 void ThreadDebugger::promiseRejectionRevoked(v8::Local<v8::Context> context, uns igned promiseRejectionId)
125 { 127 {
126 const String message = "Handler added to rejected promise"; 128 const String message = "Handler added to rejected promise";
127 v8Inspector()->exceptionRevoked(context, promiseRejectionId, message); 129 v8Inspector()->exceptionRevoked(context, promiseRejectionId, toV8InspectorSt ringView(message));
128 } 130 }
129 131
130 void ThreadDebugger::beginUserGesture() 132 void ThreadDebugger::beginUserGesture()
131 { 133 {
132 m_userGestureIndicator = wrapUnique(new UserGestureIndicator(DefinitelyProce ssingNewUserGesture)); 134 m_userGestureIndicator = wrapUnique(new UserGestureIndicator(DefinitelyProce ssingNewUserGesture));
133 } 135 }
134 136
135 void ThreadDebugger::endUserGesture() 137 void ThreadDebugger::endUserGesture()
136 { 138 {
137 m_userGestureIndicator.reset(); 139 m_userGestureIndicator.reset();
138 } 140 }
139 141
140 String16 ThreadDebugger::valueSubtype(v8::Local<v8::Value> value) 142 v8_inspector::StringView ThreadDebugger::valueSubtype(v8::Local<v8::Value> value )
141 { 143 {
144 static const char kNode[] = "node";
145 static const char kArray[] = "array";
146 static const char kError[] = "error";
142 if (V8Node::hasInstance(value, m_isolate)) 147 if (V8Node::hasInstance(value, m_isolate))
143 return "node"; 148 return toV8InspectorStringView(kNode);
144 if (V8NodeList::hasInstance(value, m_isolate) 149 if (V8NodeList::hasInstance(value, m_isolate)
145 || V8DOMTokenList::hasInstance(value, m_isolate) 150 || V8DOMTokenList::hasInstance(value, m_isolate)
146 || V8HTMLCollection::hasInstance(value, m_isolate) 151 || V8HTMLCollection::hasInstance(value, m_isolate)
147 || V8HTMLAllCollection::hasInstance(value, m_isolate)) { 152 || V8HTMLAllCollection::hasInstance(value, m_isolate)) {
148 return "array"; 153 return toV8InspectorStringView(kArray);
149 } 154 }
150 if (V8DOMException::hasInstance(value, m_isolate)) 155 if (V8DOMException::hasInstance(value, m_isolate))
151 return "error"; 156 return toV8InspectorStringView(kError);
152 return String(); 157 return v8_inspector::StringView();
153 } 158 }
154 159
155 bool ThreadDebugger::formatAccessorsAsProperties(v8::Local<v8::Value> value) 160 bool ThreadDebugger::formatAccessorsAsProperties(v8::Local<v8::Value> value)
156 { 161 {
157 return V8DOMWrapper::isWrapper(m_isolate, value); 162 return V8DOMWrapper::isWrapper(m_isolate, value);
158 } 163 }
159 164
160 double ThreadDebugger::currentTimeMS() 165 double ThreadDebugger::currentTimeMS()
161 { 166 {
162 return WTF::currentTimeMS(); 167 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)); 325 listenerObject->Set(v8String(isolate, "passive"), v8::Boolean::New(isola te, info.passive));
321 listenerObject->Set(v8String(isolate, "type"), v8String(isolate, current EventType)); 326 listenerObject->Set(v8String(isolate, "type"), v8String(isolate, current EventType));
322 v8::Local<v8::Function> removeFunction; 327 v8::Local<v8::Function> removeFunction;
323 if (info.removeFunction.ToLocal(&removeFunction)) 328 if (info.removeFunction.ToLocal(&removeFunction))
324 listenerObject->Set(v8String(isolate, "remove"), removeFunction); 329 listenerObject->Set(v8String(isolate, "remove"), removeFunction);
325 listeners->Set(outputIndex++, listenerObject); 330 listeners->Set(outputIndex++, listenerObject);
326 } 331 }
327 info.GetReturnValue().Set(result); 332 info.GetReturnValue().Set(result);
328 } 333 }
329 334
330 void ThreadDebugger::consoleTime(const String16& title) 335 void ThreadDebugger::consoleTime(const v8_inspector::StringView& title)
331 { 336 {
332 TRACE_EVENT_COPY_ASYNC_BEGIN0("blink.console", String(title).utf8().data(), this); 337 TRACE_EVENT_COPY_ASYNC_BEGIN0("blink.console", toCoreString(title).utf8().da ta(), this);
333 } 338 }
334 339
335 void ThreadDebugger::consoleTimeEnd(const String16& title) 340 void ThreadDebugger::consoleTimeEnd(const v8_inspector::StringView& title)
336 { 341 {
337 TRACE_EVENT_COPY_ASYNC_END0("blink.console", String(title).utf8().data(), th is); 342 TRACE_EVENT_COPY_ASYNC_END0("blink.console", toCoreString(title).utf8().data (), this);
338 } 343 }
339 344
340 void ThreadDebugger::consoleTimeStamp(const String16& title) 345 void ThreadDebugger::consoleTimeStamp(const v8_inspector::StringView& title)
341 { 346 {
342 v8::Isolate* isolate = m_isolate; 347 v8::Isolate* isolate = m_isolate;
343 TRACE_EVENT_INSTANT1("devtools.timeline", "TimeStamp", TRACE_EVENT_SCOPE_THR EAD, "data", InspectorTimeStampEvent::data(currentExecutionContext(isolate), tit le)); 348 TRACE_EVENT_INSTANT1("devtools.timeline", "TimeStamp", TRACE_EVENT_SCOPE_THR EAD, "data", InspectorTimeStampEvent::data(currentExecutionContext(isolate), toC oreString(title)));
344 } 349 }
345 350
346 void ThreadDebugger::startRepeatingTimer(double interval, V8InspectorClient::Tim erCallback callback, void* data) 351 void ThreadDebugger::startRepeatingTimer(double interval, V8InspectorClient::Tim erCallback callback, void* data)
347 { 352 {
348 m_timerData.append(data); 353 m_timerData.append(data);
349 m_timerCallbacks.append(callback); 354 m_timerCallbacks.append(callback);
350 355
351 std::unique_ptr<Timer<ThreadDebugger>> timer = wrapUnique(new Timer<ThreadDe bugger>(this, &ThreadDebugger::onTimer)); 356 std::unique_ptr<Timer<ThreadDebugger>> timer = wrapUnique(new Timer<ThreadDe bugger>(this, &ThreadDebugger::onTimer));
352 Timer<ThreadDebugger>* timerPtr = timer.get(); 357 Timer<ThreadDebugger>* timerPtr = timer.get();
353 m_timers.append(std::move(timer)); 358 m_timers.append(std::move(timer));
(...skipping 17 matching lines...) Expand all
371 { 376 {
372 for (size_t index = 0; index < m_timers.size(); ++index) { 377 for (size_t index = 0; index < m_timers.size(); ++index) {
373 if (m_timers[index].get() == timer) { 378 if (m_timers[index].get() == timer) {
374 m_timerCallbacks[index](m_timerData[index]); 379 m_timerCallbacks[index](m_timerData[index]);
375 return; 380 return;
376 } 381 }
377 } 382 }
378 } 383 }
379 384
380 } // namespace blink 385 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698