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

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

Issue 2139363003: [DevTools] Cleanup v8_inspector API part 1. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebased Created 4 years, 5 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 16 matching lines...) Expand all
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #include "core/inspector/WorkerThreadDebugger.h" 31 #include "core/inspector/WorkerThreadDebugger.h"
32 32
33 #include "bindings/core/v8/ScriptState.h" 33 #include "bindings/core/v8/ScriptState.h"
34 #include "bindings/core/v8/SourceLocation.h" 34 #include "bindings/core/v8/SourceLocation.h"
35 #include "bindings/core/v8/V8ScriptRunner.h" 35 #include "bindings/core/v8/V8ScriptRunner.h"
36 #include "core/inspector/ConsoleMessage.h" 36 #include "core/inspector/ConsoleMessage.h"
37 #include "core/inspector/IdentifiersFactory.h"
37 #include "core/workers/WorkerReportingProxy.h" 38 #include "core/workers/WorkerReportingProxy.h"
38 #include "core/workers/WorkerThread.h" 39 #include "core/workers/WorkerThread.h"
39 #include <v8.h> 40 #include <v8.h>
40 41
41 namespace blink { 42 namespace blink {
42 43
43 static const int workerContextGroupId = 1; 44 static const int workerContextGroupId = 1;
44 45
45 WorkerThreadDebugger* WorkerThreadDebugger::from(v8::Isolate* isolate) 46 WorkerThreadDebugger* WorkerThreadDebugger::from(v8::Isolate* isolate)
46 { 47 {
47 V8PerIsolateData* data = V8PerIsolateData::from(isolate); 48 V8PerIsolateData* data = V8PerIsolateData::from(isolate);
48 if (!data->threadDebugger()) 49 if (!data->threadDebugger())
49 return nullptr; 50 return nullptr;
50 ASSERT(data->threadDebugger()->isWorker()); 51 ASSERT(data->threadDebugger()->isWorker());
51 return static_cast<WorkerThreadDebugger*>(data->threadDebugger()); 52 return static_cast<WorkerThreadDebugger*>(data->threadDebugger());
52 } 53 }
53 54
54 WorkerThreadDebugger::WorkerThreadDebugger(WorkerThread* workerThread, v8::Isola te* isolate) 55 WorkerThreadDebugger::WorkerThreadDebugger(WorkerThread* workerThread, v8::Isola te* isolate)
55 : ThreadDebugger(isolate) 56 : ThreadDebugger(isolate)
56 , m_workerThread(workerThread) 57 , m_workerThread(workerThread)
58 , m_muteConsoleCount(0)
57 { 59 {
58 } 60 }
59 61
60 WorkerThreadDebugger::~WorkerThreadDebugger() 62 WorkerThreadDebugger::~WorkerThreadDebugger()
61 { 63 {
62 } 64 }
63 65
64 void WorkerThreadDebugger::contextCreated(v8::Local<v8::Context> context) 66 void WorkerThreadDebugger::contextCreated(v8::Local<v8::Context> context)
65 { 67 {
66 debugger()->contextCreated(V8ContextInfo(context, workerContextGroupId, true , m_workerThread->workerGlobalScope()->url().getString(), "", "", false)); 68 debugger()->contextCreated(V8ContextInfo(context, workerContextGroupId, true , m_workerThread->workerGlobalScope()->url().getString(), "", "", false));
67 } 69 }
68 70
69 void WorkerThreadDebugger::contextWillBeDestroyed(v8::Local<v8::Context> context ) 71 void WorkerThreadDebugger::contextWillBeDestroyed(v8::Local<v8::Context> context )
70 { 72 {
71 debugger()->contextDestroyed(context); 73 debugger()->contextDestroyed(context);
72 } 74 }
73 75
74 void WorkerThreadDebugger::exceptionThrown(const String& errorMessage, std::uniq ue_ptr<SourceLocation> location) 76 void WorkerThreadDebugger::exceptionThrown(const String& errorMessage, std::uniq ue_ptr<SourceLocation> location)
75 { 77 {
78 if (m_muteConsoleCount)
79 return;
76 debugger()->exceptionThrown(workerContextGroupId, errorMessage, location->ur l(), location->lineNumber(), location->columnNumber(), location->cloneStackTrace (), location->scriptId()); 80 debugger()->exceptionThrown(workerContextGroupId, errorMessage, location->ur l(), location->lineNumber(), location->columnNumber(), location->cloneStackTrace (), location->scriptId());
77 } 81 }
78 82
83 void WorkerThreadDebugger::addConsoleMessage(ConsoleMessage* consoleMessage)
84 {
85 if (m_muteConsoleCount)
86 return;
87 debugger()->addConsoleMessage(
88 workerContextGroupId,
89 consoleMessage->source(),
90 consoleMessage->level(),
91 consoleMessage->message(),
92 consoleMessage->location()->url(),
93 consoleMessage->location()->lineNumber(),
94 consoleMessage->location()->columnNumber(),
95 consoleMessage->location()->cloneStackTrace(),
96 consoleMessage->location()->scriptId(),
97 IdentifiersFactory::requestId(consoleMessage->requestIdentifier()),
98 consoleMessage->workerId());
99 }
100
79 int WorkerThreadDebugger::contextGroupId() 101 int WorkerThreadDebugger::contextGroupId()
80 { 102 {
81 return workerContextGroupId; 103 return workerContextGroupId;
82 } 104 }
83 105
84 void WorkerThreadDebugger::runMessageLoopOnPause(int contextGroupId) 106 void WorkerThreadDebugger::runMessageLoopOnPause(int contextGroupId)
85 { 107 {
86 ASSERT(contextGroupId == workerContextGroupId); 108 ASSERT(contextGroupId == workerContextGroupId);
87 m_workerThread->startRunningDebuggerTasksOnPauseOnWorkerThread(); 109 m_workerThread->startRunningDebuggerTasksOnPauseOnWorkerThread();
88 } 110 }
89 111
90 void WorkerThreadDebugger::quitMessageLoopOnPause() 112 void WorkerThreadDebugger::quitMessageLoopOnPause()
91 { 113 {
92 m_workerThread->stopRunningDebuggerTasksOnPauseOnWorkerThread(); 114 m_workerThread->stopRunningDebuggerTasksOnPauseOnWorkerThread();
93 } 115 }
94 116
117 void WorkerThreadDebugger::muteWarningsAndDeprecations()
118 {
119 m_muteConsoleCount++;
120 }
121
122 void WorkerThreadDebugger::unmuteWarningsAndDeprecations()
123 {
124 m_muteConsoleCount--;
125 }
126
95 bool WorkerThreadDebugger::callingContextCanAccessContext(v8::Local<v8::Context> calling, v8::Local<v8::Context> target) 127 bool WorkerThreadDebugger::callingContextCanAccessContext(v8::Local<v8::Context> calling, v8::Local<v8::Context> target)
96 { 128 {
97 return true; 129 return true;
98 } 130 }
99 131
100 v8::Local<v8::Context> WorkerThreadDebugger::ensureDefaultContextInGroup(int con textGroupId) 132 v8::Local<v8::Context> WorkerThreadDebugger::ensureDefaultContextInGroup(int con textGroupId)
101 { 133 {
102 ASSERT(contextGroupId == workerContextGroupId); 134 ASSERT(contextGroupId == workerContextGroupId);
103 ScriptState* scriptState = m_workerThread->workerGlobalScope()->scriptContro ller()->getScriptState(); 135 ScriptState* scriptState = m_workerThread->workerGlobalScope()->scriptContro ller()->getScriptState();
104 return scriptState ? scriptState->context() : v8::Local<v8::Context>(); 136 return scriptState ? scriptState->context() : v8::Local<v8::Context>();
105 } 137 }
106 138
107 void WorkerThreadDebugger::messageAddedToConsole(int contextGroupId, MessageSour ce source, MessageLevel level, const String16& message, const String16& url, uns igned lineNumber, unsigned columnNumber, V8StackTrace* stackTrace) 139 void WorkerThreadDebugger::messageAddedToConsole(int contextGroupId, MessageSour ce source, MessageLevel level, const String16& message, const String16& url, uns igned lineNumber, unsigned columnNumber, V8StackTrace* stackTrace)
108 { 140 {
109 DCHECK(contextGroupId == workerContextGroupId); 141 DCHECK(contextGroupId == workerContextGroupId);
110 ConsoleMessage* consoleMessage = ConsoleMessage::create(source, level, messa ge, SourceLocation::create(url, lineNumber, columnNumber, stackTrace ? stackTrac e->clone() : nullptr, 0)); 142 ConsoleMessage* consoleMessage = ConsoleMessage::create(source, level, messa ge, SourceLocation::create(url, lineNumber, columnNumber, stackTrace ? stackTrac e->clone() : nullptr, 0));
111 m_workerThread->workerReportingProxy().reportConsoleMessage(consoleMessage); 143 m_workerThread->workerReportingProxy().reportConsoleMessage(consoleMessage);
112 } 144 }
113 145
114 v8::MaybeLocal<v8::Value> WorkerThreadDebugger::memoryInfo(v8::Isolate*, v8::Loc al<v8::Context>) 146 v8::MaybeLocal<v8::Value> WorkerThreadDebugger::memoryInfo(v8::Isolate*, v8::Loc al<v8::Context>)
115 { 147 {
116 ASSERT_NOT_REACHED(); 148 ASSERT_NOT_REACHED();
117 return v8::MaybeLocal<v8::Value>(); 149 return v8::MaybeLocal<v8::Value>();
118 } 150 }
119 151
120 } // namespace blink 152 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698