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

Side by Side Diff: third_party/WebKit/Source/core/inspector/MainThreadDebugger.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: styling Created 4 years, 3 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 /* 1 /*
2 * Copyright (c) 2011 Google Inc. All rights reserved. 2 * Copyright (c) 2011 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 #include "core/frame/FrameHost.h" 49 #include "core/frame/FrameHost.h"
50 #include "core/frame/LocalDOMWindow.h" 50 #include "core/frame/LocalDOMWindow.h"
51 #include "core/frame/LocalFrame.h" 51 #include "core/frame/LocalFrame.h"
52 #include "core/frame/Settings.h" 52 #include "core/frame/Settings.h"
53 #include "core/frame/UseCounter.h" 53 #include "core/frame/UseCounter.h"
54 #include "core/inspector/ConsoleMessage.h" 54 #include "core/inspector/ConsoleMessage.h"
55 #include "core/inspector/ConsoleMessageStorage.h" 55 #include "core/inspector/ConsoleMessageStorage.h"
56 #include "core/inspector/IdentifiersFactory.h" 56 #include "core/inspector/IdentifiersFactory.h"
57 #include "core/inspector/InspectedFrames.h" 57 #include "core/inspector/InspectedFrames.h"
58 #include "core/inspector/InspectorTaskRunner.h" 58 #include "core/inspector/InspectorTaskRunner.h"
59 #include "core/inspector/V8InspectorString.h"
59 #include "core/timing/MemoryInfo.h" 60 #include "core/timing/MemoryInfo.h"
60 #include "core/workers/MainThreadWorkletGlobalScope.h" 61 #include "core/workers/MainThreadWorkletGlobalScope.h"
61 #include "core/xml/XPathEvaluator.h" 62 #include "core/xml/XPathEvaluator.h"
62 #include "core/xml/XPathResult.h" 63 #include "core/xml/XPathResult.h"
63 #include "platform/UserGestureIndicator.h" 64 #include "platform/UserGestureIndicator.h"
64 #include "platform/v8_inspector/public/V8Inspector.h" 65 #include "platform/v8_inspector/public/V8Inspector.h"
65 #include "wtf/PtrUtil.h" 66 #include "wtf/PtrUtil.h"
66 #include "wtf/ThreadingPrimitives.h" 67 #include "wtf/ThreadingPrimitives.h"
67 #include <memory> 68 #include <memory>
68 69
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 DCHECK(isMainThread()); 139 DCHECK(isMainThread());
139 if (frame->localFrameRoot() == frame) 140 if (frame->localFrameRoot() == frame)
140 v8Inspector()->resetContextGroup(contextGroupId(frame)); 141 v8Inspector()->resetContextGroup(contextGroupId(frame));
141 } 142 }
142 143
143 void MainThreadDebugger::contextCreated(ScriptState* scriptState, LocalFrame* fr ame, SecurityOrigin* origin) 144 void MainThreadDebugger::contextCreated(ScriptState* scriptState, LocalFrame* fr ame, SecurityOrigin* origin)
144 { 145 {
145 ASSERT(isMainThread()); 146 ASSERT(isMainThread());
146 v8::HandleScope handles(scriptState->isolate()); 147 v8::HandleScope handles(scriptState->isolate());
147 DOMWrapperWorld& world = scriptState->world(); 148 DOMWrapperWorld& world = scriptState->world();
148 std::unique_ptr<protocol::DictionaryValue> auxData = protocol::DictionaryVal ue::create(); 149 std::unique_ptr<protocol::DictionaryValue> auxDataValue = protocol::Dictiona ryValue::create();
149 auxData->setBoolean("isDefault", world.isMainWorld()); 150 auxDataValue->setBoolean("isDefault", world.isMainWorld());
150 auxData->setString("frameId", IdentifiersFactory::frameId(frame)); 151 auxDataValue->setString("frameId", IdentifiersFactory::frameId(frame));
151 v8_inspector::V8ContextInfo contextInfo(scriptState->context(), contextGroup Id(frame), world.isIsolatedWorld() ? world.isolatedWorldHumanReadableName() : "" ); 152 String auxData = auxDataValue->toJSONString();
152 if (origin) 153 String humanReadableName = world.isIsolatedWorld() ? world.isolatedWorldHuma nReadableName() : String();
153 contextInfo.origin = origin->toRawString(); 154 String originString = origin ? origin->toRawString() : String();
154 contextInfo.auxData = auxData->toJSONString(); 155 v8_inspector::V8ContextInfo contextInfo(scriptState->context(), contextGroup Id(frame), toV8InspectorStringView(humanReadableName));
156 contextInfo.origin = toV8InspectorStringView(originString);
157 contextInfo.auxData = toV8InspectorStringView(auxData);
155 contextInfo.hasMemoryOnConsole = scriptState->getExecutionContext()->isDocum ent(); 158 contextInfo.hasMemoryOnConsole = scriptState->getExecutionContext()->isDocum ent();
156 v8Inspector()->contextCreated(contextInfo); 159 v8Inspector()->contextCreated(contextInfo);
157 } 160 }
158 161
159 void MainThreadDebugger::contextWillBeDestroyed(ScriptState* scriptState) 162 void MainThreadDebugger::contextWillBeDestroyed(ScriptState* scriptState)
160 { 163 {
161 v8::HandleScope handles(scriptState->isolate()); 164 v8::HandleScope handles(scriptState->isolate());
162 v8Inspector()->contextDestroyed(scriptState->context()); 165 v8Inspector()->contextDestroyed(scriptState->context());
163 } 166 }
164 167
(...skipping 10 matching lines...) Expand all
175 frame = toMainThreadWorkletGlobalScope(context)->frame(); 178 frame = toMainThreadWorkletGlobalScope(context)->frame();
176 if (!frame) 179 if (!frame)
177 return; 180 return;
178 scriptState = toMainThreadWorkletGlobalScope(context)->scriptController( )->getScriptState(); 181 scriptState = toMainThreadWorkletGlobalScope(context)->scriptController( )->getScriptState();
179 } else { 182 } else {
180 NOTREACHED(); 183 NOTREACHED();
181 } 184 }
182 185
183 frame->console().reportMessageToClient(JSMessageSource, ErrorMessageLevel, e vent->messageForConsole(), event->location()); 186 frame->console().reportMessageToClient(JSMessageSource, ErrorMessageLevel, e vent->messageForConsole(), event->location());
184 187
185 const String16 defaultMessage = "Uncaught"; 188 const String defaultMessage = "Uncaught";
186 if (scriptState && scriptState->contextIsValid()) { 189 if (scriptState && scriptState->contextIsValid()) {
187 ScriptState::Scope scope(scriptState); 190 ScriptState::Scope scope(scriptState);
188 v8::Local<v8::Value> exception = V8ErrorHandler::loadExceptionFromErrorE ventWrapper(scriptState, event, scriptState->context()->Global()); 191 v8::Local<v8::Value> exception = V8ErrorHandler::loadExceptionFromErrorE ventWrapper(scriptState, event, scriptState->context()->Global());
189 SourceLocation* location = event->location(); 192 SourceLocation* location = event->location();
190 v8Inspector()->exceptionThrown(scriptState->context(), defaultMessage, e xception, event->messageForConsole(), location->url(), location->lineNumber(), l ocation->columnNumber(), location->takeStackTrace(), location->scriptId()); 193 String message = event->messageForConsole();
194 String url = location->url();
195 v8Inspector()->exceptionThrown(scriptState->context(), toV8InspectorStri ngView(defaultMessage), exception, toV8InspectorStringView(message), toV8Inspect orStringView(url), location->lineNumber(), location->columnNumber(), location->t akeStackTrace(), location->scriptId());
191 } 196 }
192 } 197 }
193 198
194 int MainThreadDebugger::contextGroupId(LocalFrame* frame) 199 int MainThreadDebugger::contextGroupId(LocalFrame* frame)
195 { 200 {
196 LocalFrame* localFrameRoot = frame->localFrameRoot(); 201 LocalFrame* localFrameRoot = frame->localFrameRoot();
197 return frameId(localFrameRoot); 202 return frameId(localFrameRoot);
198 } 203 }
199 204
200 MainThreadDebugger* MainThreadDebugger::instance() 205 MainThreadDebugger* MainThreadDebugger::instance()
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 return frame->script().canExecuteScripts(NotAboutToExecuteScript); 285 return frame->script().canExecuteScripts(NotAboutToExecuteScript);
281 } 286 }
282 287
283 void MainThreadDebugger::runIfWaitingForDebugger(int contextGroupId) 288 void MainThreadDebugger::runIfWaitingForDebugger(int contextGroupId)
284 { 289 {
285 LocalFrame* frame = WeakIdentifierMap<LocalFrame>::lookup(contextGroupId); 290 LocalFrame* frame = WeakIdentifierMap<LocalFrame>::lookup(contextGroupId);
286 if (m_clientMessageLoop) 291 if (m_clientMessageLoop)
287 m_clientMessageLoop->runIfWaitingForDebugger(frame); 292 m_clientMessageLoop->runIfWaitingForDebugger(frame);
288 } 293 }
289 294
290 void MainThreadDebugger::consoleAPIMessage(int contextGroupId, v8_inspector::V8C onsoleAPIType type, const String16& message, const String16& url, unsigned lineN umber, unsigned columnNumber, v8_inspector::V8StackTrace* stackTrace) 295 void MainThreadDebugger::consoleAPIMessage(int contextGroupId, v8_inspector::V8C onsoleAPIType type, const v8_inspector::StringView& message, const v8_inspector: :StringView& url, unsigned lineNumber, unsigned columnNumber, v8_inspector::V8St ackTrace* stackTrace)
291 { 296 {
292 LocalFrame* frame = WeakIdentifierMap<LocalFrame>::lookup(contextGroupId); 297 LocalFrame* frame = WeakIdentifierMap<LocalFrame>::lookup(contextGroupId);
293 if (!frame) 298 if (!frame)
294 return; 299 return;
295 if (type == v8_inspector::V8ConsoleAPIType::kClear && frame->host()) 300 if (type == v8_inspector::V8ConsoleAPIType::kClear && frame->host())
296 frame->host()->consoleMessageStorage().clear(); 301 frame->host()->consoleMessageStorage().clear();
297 std::unique_ptr<SourceLocation> location = SourceLocation::create(url, lineN umber, columnNumber, stackTrace ? stackTrace->clone() : nullptr, 0); 302 // TODO(dgozman): we can save a copy of message and url here by making Frame Console work with StringView.
298 frame->console().reportMessageToClient(ConsoleAPIMessageSource, consoleAPITy peToMessageLevel(type), message, location.get()); 303 std::unique_ptr<SourceLocation> location = SourceLocation::create(toCoreStri ng(url), lineNumber, columnNumber, stackTrace ? stackTrace->clone() : nullptr, 0 );
304 frame->console().reportMessageToClient(ConsoleAPIMessageSource, consoleAPITy peToMessageLevel(type), toCoreString(message), location.get());
299 } 305 }
300 306
301 v8::MaybeLocal<v8::Value> MainThreadDebugger::memoryInfo(v8::Isolate* isolate, v 8::Local<v8::Context> context) 307 v8::MaybeLocal<v8::Value> MainThreadDebugger::memoryInfo(v8::Isolate* isolate, v 8::Local<v8::Context> context)
302 { 308 {
303 ExecutionContext* executionContext = toExecutionContext(context); 309 ExecutionContext* executionContext = toExecutionContext(context);
304 ASSERT_UNUSED(executionContext, executionContext); 310 ASSERT_UNUSED(executionContext, executionContext);
305 ASSERT(executionContext->isDocument()); 311 ASSERT(executionContext->isDocument());
306 return toV8(MemoryInfo::create(), context->Global(), isolate); 312 return toV8(MemoryInfo::create(), context->Global(), isolate);
307 } 313 }
308 314
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 return; 409 return;
404 if (!createDataPropertyInArray(context, nodes, index++, toV8(node, i nfo.Holder(), info.GetIsolate())).FromMaybe(false)) 410 if (!createDataPropertyInArray(context, nodes, index++, toV8(node, i nfo.Holder(), info.GetIsolate())).FromMaybe(false))
405 return; 411 return;
406 } 412 }
407 info.GetReturnValue().Set(nodes); 413 info.GetReturnValue().Set(nodes);
408 } 414 }
409 exceptionState.throwIfNeeded(); 415 exceptionState.throwIfNeeded();
410 } 416 }
411 417
412 } // namespace blink 418 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698