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

Side by Side Diff: Source/core/inspector/WorkerDebuggerAgent.cpp

Issue 307943002: Oilpan: Prepare moving InspectorController and InspectorAgents to oilpan. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 6 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
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 14 matching lines...) Expand all
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
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 "config.h" 31 #include "config.h"
32 #include "core/inspector/WorkerDebuggerAgent.h" 32 #include "core/inspector/WorkerDebuggerAgent.h"
33 33
34 #include "bindings/v8/ScriptDebugServer.h" 34 #include "bindings/v8/ScriptDebugServer.h"
35 #include "core/inspector/WorkerInspectorController.h"
35 #include "core/workers/WorkerGlobalScope.h" 36 #include "core/workers/WorkerGlobalScope.h"
36 #include "core/workers/WorkerThread.h" 37 #include "core/workers/WorkerThread.h"
37 #include "wtf/MessageQueue.h" 38 #include "wtf/MessageQueue.h"
38 39
39 namespace WebCore { 40 namespace WebCore {
40 41
41 namespace { 42 namespace {
42 43
43 Mutex& workerDebuggerAgentsMutex()
44 {
45 AtomicallyInitializedStatic(Mutex&, mutex = *new Mutex);
46 return mutex;
47 }
48
49 typedef HashMap<WorkerThread*, WorkerDebuggerAgent*> WorkerDebuggerAgents;
50
51 WorkerDebuggerAgents& workerDebuggerAgents()
52 {
53 DEFINE_STATIC_LOCAL(WorkerDebuggerAgents, agents, ());
54 return agents;
55 }
56
57
58 class RunInspectorCommandsTask FINAL : public ScriptDebugServer::Task { 44 class RunInspectorCommandsTask FINAL : public ScriptDebugServer::Task {
59 public: 45 public:
60 explicit RunInspectorCommandsTask(WorkerThread* thread) 46 explicit RunInspectorCommandsTask(WorkerThread* thread)
61 : m_thread(thread) { } 47 : m_thread(thread) { }
62 virtual ~RunInspectorCommandsTask() { } 48 virtual ~RunInspectorCommandsTask() { }
63 virtual void run() OVERRIDE 49 virtual void run() OVERRIDE
64 { 50 {
65 // Process all queued debugger commands. WorkerThread is certainly 51 // Process all queued debugger commands. WorkerThread is certainly
66 // alive if this task is being executed. 52 // alive if this task is being executed.
67 while (MessageQueueMessageReceived == m_thread->runLoop().runDebuggerTas k(WorkerRunLoop::DontWaitForMessage)) { } 53 while (MessageQueueMessageReceived == m_thread->runLoop().runDebuggerTas k(WorkerRunLoop::DontWaitForMessage)) { }
68 } 54 }
69 55
70 private: 56 private:
71 WorkerThread* m_thread; 57 WorkerThread* m_thread;
72 }; 58 };
73 59
74 } // namespace 60 } // namespace
75 61
76 PassOwnPtr<WorkerDebuggerAgent> WorkerDebuggerAgent::create(WorkerScriptDebugSer ver* scriptDebugServer, WorkerGlobalScope* inspectedWorkerGlobalScope, InjectedS criptManager* injectedScriptManager) 62 PassOwnPtrWillBeRawPtr<WorkerDebuggerAgent> WorkerDebuggerAgent::create(WorkerSc riptDebugServer* scriptDebugServer, WorkerGlobalScope* inspectedWorkerGlobalScop e, InjectedScriptManager* injectedScriptManager)
77 { 63 {
78 return adoptPtr(new WorkerDebuggerAgent(scriptDebugServer, inspectedWorkerGl obalScope, injectedScriptManager)); 64 return adoptPtrWillBeNoop(new WorkerDebuggerAgent(scriptDebugServer, inspect edWorkerGlobalScope, injectedScriptManager));
79 } 65 }
80 66
81 WorkerDebuggerAgent::WorkerDebuggerAgent(WorkerScriptDebugServer* scriptDebugSer ver, WorkerGlobalScope* inspectedWorkerGlobalScope, InjectedScriptManager* injec tedScriptManager) 67 WorkerDebuggerAgent::WorkerDebuggerAgent(WorkerScriptDebugServer* scriptDebugSer ver, WorkerGlobalScope* inspectedWorkerGlobalScope, InjectedScriptManager* injec tedScriptManager)
82 : InspectorDebuggerAgent(injectedScriptManager) 68 : InspectorDebuggerAgent(injectedScriptManager)
83 , m_scriptDebugServer(scriptDebugServer) 69 , m_scriptDebugServer(scriptDebugServer)
84 , m_inspectedWorkerGlobalScope(inspectedWorkerGlobalScope) 70 , m_inspectedWorkerGlobalScope(inspectedWorkerGlobalScope)
85 { 71 {
86 MutexLocker lock(workerDebuggerAgentsMutex());
87 workerDebuggerAgents().set(inspectedWorkerGlobalScope->thread(), this);
88 } 72 }
89 73
90 WorkerDebuggerAgent::~WorkerDebuggerAgent() 74 WorkerDebuggerAgent::~WorkerDebuggerAgent()
91 { 75 {
92 MutexLocker lock(workerDebuggerAgentsMutex()); 76 MutexLocker locker(m_mutex);
yurys 2014/06/19 13:23:55 I don't think it does what you expect it to do. Th
93 ASSERT(workerDebuggerAgents().contains(m_inspectedWorkerGlobalScope->thread( ))); 77 }
94 workerDebuggerAgents().remove(m_inspectedWorkerGlobalScope->thread()); 78
79 void WorkerDebuggerAgent::trace(Visitor* visitor)
80 {
81 visitor->trace(m_inspectedWorkerGlobalScope);
82 InspectorDebuggerAgent::trace(visitor);
95 } 83 }
96 84
97 void WorkerDebuggerAgent::interruptAndDispatchInspectorCommands(WorkerThread* th read) 85 void WorkerDebuggerAgent::interruptAndDispatchInspectorCommands(WorkerThread* th read)
98 { 86 {
99 MutexLocker lock(workerDebuggerAgentsMutex()); 87 MutexLocker locker(m_mutex);
100 WorkerDebuggerAgent* agent = workerDebuggerAgents().get(thread); 88 scriptDebugServer().interruptAndRunTask(adoptPtr(new RunInspectorCommandsTas k(thread)));
101 if (agent)
102 agent->m_scriptDebugServer->interruptAndRunTask(adoptPtr(new RunInspecto rCommandsTask(thread)));
103 } 89 }
104 90
105 void WorkerDebuggerAgent::startListeningScriptDebugServer() 91 void WorkerDebuggerAgent::startListeningScriptDebugServer()
106 { 92 {
107 scriptDebugServer().addListener(this); 93 scriptDebugServer().addListener(this);
108 } 94 }
109 95
110 void WorkerDebuggerAgent::stopListeningScriptDebugServer() 96 void WorkerDebuggerAgent::stopListeningScriptDebugServer()
111 { 97 {
112 scriptDebugServer().removeListener(this); 98 scriptDebugServer().removeListener(this);
(...skipping 17 matching lines...) Expand all
130 { 116 {
131 // We don't need to mute console for workers. 117 // We don't need to mute console for workers.
132 } 118 }
133 119
134 void WorkerDebuggerAgent::unmuteConsole() 120 void WorkerDebuggerAgent::unmuteConsole()
135 { 121 {
136 // We don't need to mute console for workers. 122 // We don't need to mute console for workers.
137 } 123 }
138 124
139 } // namespace WebCore 125 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698