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

Side by Side Diff: Source/bindings/core/v8/WorkerThreadDebugger.cpp

Issue 1216863004: [DevTools] Move debugger classes to core/inspector. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 /*
2 * Copyright (c) 2011 Google Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above
11 * copyright notice, this list of conditions and the following disclaimer
12 * in the documentation and/or other materials provided with the
13 * distribution.
14 * * Neither the name of Google Inc. nor the names of its
15 * contributors may be used to endorse or promote products derived from
16 * this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
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.
29 */
30
31 #include "config.h"
32 #include "bindings/core/v8/WorkerThreadDebugger.h"
33
34 #include "bindings/core/v8/V8ScriptRunner.h"
35 #include "core/inspector/ScriptDebugListener.h"
36 #include "core/inspector/WorkerDebuggerAgent.h"
37 #include "core/workers/WorkerGlobalScope.h"
38 #include "core/workers/WorkerThread.h"
39 #include "wtf/MessageQueue.h"
40 #include <v8.h>
41
42 namespace blink {
43
44 static const char* workerContextDebugId = "[worker]";
45
46 WorkerThreadDebugger::WorkerThreadDebugger(WorkerGlobalScope* workerGlobalScope)
47 : ScriptDebuggerBase(v8::Isolate::GetCurrent(), V8Debugger::create(v8::Isola te::GetCurrent(), this))
48 , m_listener(nullptr)
49 , m_workerGlobalScope(workerGlobalScope)
50 {
51 }
52
53 WorkerThreadDebugger::~WorkerThreadDebugger()
54 {
55 }
56
57 DEFINE_TRACE(WorkerThreadDebugger)
58 {
59 visitor->trace(m_workerGlobalScope);
60 ScriptDebuggerBase::trace(visitor);
61 }
62
63 void WorkerThreadDebugger::setContextDebugData(v8::Local<v8::Context> context)
64 {
65 V8Debugger::setContextDebugData(context, workerContextDebugId);
66 }
67
68 void WorkerThreadDebugger::addListener(ScriptDebugListener* listener)
69 {
70 ASSERT(!m_listener);
71 debugger()->enable();
72 m_listener = listener;
73 debugger()->reportCompiledScripts(workerContextDebugId, listener);
74 }
75
76 void WorkerThreadDebugger::removeListener(ScriptDebugListener* listener)
77 {
78 ASSERT(m_listener == listener);
79 debugger()->continueProgram();
80 m_listener = 0;
81 debugger()->disable();
82 }
83
84 ScriptDebugListener* WorkerThreadDebugger::getDebugListenerForContext(v8::Local< v8::Context>)
85 {
86 // There is only one worker context in isolate.
87 return m_listener;
88 }
89
90 void WorkerThreadDebugger::runMessageLoopOnPause(v8::Local<v8::Context>)
91 {
92 MessageQueueWaitResult result;
93 m_workerGlobalScope->thread()->willEnterNestedLoop();
94 do {
95 result = m_workerGlobalScope->thread()->runDebuggerTask();
96 // Keep waiting until execution is resumed.
97 } while (result == MessageQueueMessageReceived && debugger()->isPaused());
98 m_workerGlobalScope->thread()->didLeaveNestedLoop();
99
100 // The listener may have been removed in the nested loop.
101 if (m_listener)
102 m_listener->didContinue();
103 }
104
105 void WorkerThreadDebugger::quitMessageLoopOnPause()
106 {
107 // Nothing to do here in case of workers since runMessageLoopOnPause will ch eck for paused state after each debugger command.
108 }
109
110 } // namespace blink
OLDNEW
« no previous file with comments | « Source/bindings/core/v8/WorkerThreadDebugger.h ('k') | Source/bindings/core/v8/inspector/V8InjectedScriptHost.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698