OLD | NEW |
---|---|
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 28 matching lines...) Expand all Loading... | |
39 namespace WebCore { | 39 namespace WebCore { |
40 | 40 |
41 namespace { | 41 namespace { |
42 | 42 |
43 Mutex& workerDebuggerAgentsMutex() | 43 Mutex& workerDebuggerAgentsMutex() |
44 { | 44 { |
45 AtomicallyInitializedStatic(Mutex&, mutex = *new Mutex); | 45 AtomicallyInitializedStatic(Mutex&, mutex = *new Mutex); |
46 return mutex; | 46 return mutex; |
47 } | 47 } |
48 | 48 |
49 #if ENABLE(OILPAN) | |
50 typedef HashMap<WorkerThread*, OwnPtr<CrossThreadPersistent<WorkerDebuggerAgent> > > WorkerDebuggerAgents; | |
haraken
2014/06/12 08:40:25
Why does this need to be OwnPtr<CrossThreadPersist
keishi
2014/06/13 03:37:34
I get this error because CrossThreadPersistent doe
haraken
2014/06/13 08:02:53
I'm not quite sure what you're planning, but if yo
keishi
2014/06/17 03:13:22
I've already removed the map in my CL.
| |
51 #else | |
49 typedef HashMap<WorkerThread*, WorkerDebuggerAgent*> WorkerDebuggerAgents; | 52 typedef HashMap<WorkerThread*, WorkerDebuggerAgent*> WorkerDebuggerAgents; |
53 #endif | |
50 | 54 |
51 WorkerDebuggerAgents& workerDebuggerAgents() | 55 WorkerDebuggerAgents& workerDebuggerAgents() |
52 { | 56 { |
53 DEFINE_STATIC_LOCAL(WorkerDebuggerAgents, agents, ()); | 57 DEFINE_STATIC_LOCAL(WorkerDebuggerAgents, agents, ()); |
54 return agents; | 58 return agents; |
55 } | 59 } |
56 | 60 |
57 | |
58 class RunInspectorCommandsTask FINAL : public ScriptDebugServer::Task { | 61 class RunInspectorCommandsTask FINAL : public ScriptDebugServer::Task { |
59 public: | 62 public: |
60 explicit RunInspectorCommandsTask(WorkerThread* thread) | 63 explicit RunInspectorCommandsTask(WorkerThread* thread) |
61 : m_thread(thread) { } | 64 : m_thread(thread) { } |
62 virtual ~RunInspectorCommandsTask() { } | 65 virtual ~RunInspectorCommandsTask() { } |
63 virtual void run() OVERRIDE | 66 virtual void run() OVERRIDE |
64 { | 67 { |
65 // Process all queued debugger commands. WorkerThread is certainly | 68 // Process all queued debugger commands. WorkerThread is certainly |
66 // alive if this task is being executed. | 69 // alive if this task is being executed. |
67 while (MessageQueueMessageReceived == m_thread->runLoop().runDebuggerTas k(WorkerRunLoop::DontWaitForMessage)) { } | 70 while (MessageQueueMessageReceived == m_thread->runLoop().runDebuggerTas k(WorkerRunLoop::DontWaitForMessage)) { } |
68 } | 71 } |
69 | 72 |
70 private: | 73 private: |
71 WorkerThread* m_thread; | 74 WorkerThread* m_thread; |
72 }; | 75 }; |
73 | 76 |
74 } // namespace | 77 } // namespace |
75 | 78 |
76 PassOwnPtr<WorkerDebuggerAgent> WorkerDebuggerAgent::create(WorkerScriptDebugSer ver* scriptDebugServer, WorkerGlobalScope* inspectedWorkerGlobalScope, InjectedS criptManager* injectedScriptManager) | 79 PassOwnPtrWillBeRawPtr<WorkerDebuggerAgent> WorkerDebuggerAgent::create(WorkerSc riptDebugServer* scriptDebugServer, WorkerGlobalScope* inspectedWorkerGlobalScop e, InjectedScriptManager* injectedScriptManager) |
77 { | 80 { |
78 return adoptPtr(new WorkerDebuggerAgent(scriptDebugServer, inspectedWorkerGl obalScope, injectedScriptManager)); | 81 return adoptPtrWillBeNoop(new WorkerDebuggerAgent(scriptDebugServer, inspect edWorkerGlobalScope, injectedScriptManager)); |
79 } | 82 } |
80 | 83 |
81 WorkerDebuggerAgent::WorkerDebuggerAgent(WorkerScriptDebugServer* scriptDebugSer ver, WorkerGlobalScope* inspectedWorkerGlobalScope, InjectedScriptManager* injec tedScriptManager) | 84 WorkerDebuggerAgent::WorkerDebuggerAgent(WorkerScriptDebugServer* scriptDebugSer ver, WorkerGlobalScope* inspectedWorkerGlobalScope, InjectedScriptManager* injec tedScriptManager) |
82 : InspectorDebuggerAgent(injectedScriptManager) | 85 : InspectorDebuggerAgent(injectedScriptManager) |
83 , m_scriptDebugServer(scriptDebugServer) | 86 , m_scriptDebugServer(scriptDebugServer) |
84 , m_inspectedWorkerGlobalScope(inspectedWorkerGlobalScope) | 87 , m_inspectedWorkerGlobalScope(inspectedWorkerGlobalScope) |
88 , m_thread(inspectedWorkerGlobalScope->thread()) | |
85 { | 89 { |
86 MutexLocker lock(workerDebuggerAgentsMutex()); | 90 MutexLocker lock(workerDebuggerAgentsMutex()); |
87 workerDebuggerAgents().set(inspectedWorkerGlobalScope->thread(), this); | 91 #if ENABLE(OILPAN) |
92 workerDebuggerAgents().set(m_thread, adoptPtr(new CrossThreadPersistent<Work erDebuggerAgent>(this))); | |
93 #else | |
94 workerDebuggerAgents().set(m_thread, this); | |
95 #endif | |
88 } | 96 } |
89 | 97 |
90 WorkerDebuggerAgent::~WorkerDebuggerAgent() | 98 WorkerDebuggerAgent::~WorkerDebuggerAgent() |
91 { | 99 { |
92 MutexLocker lock(workerDebuggerAgentsMutex()); | 100 } |
93 ASSERT(workerDebuggerAgents().contains(m_inspectedWorkerGlobalScope->thread( ))); | 101 |
94 workerDebuggerAgents().remove(m_inspectedWorkerGlobalScope->thread()); | 102 void WorkerDebuggerAgent::trace(Visitor* visitor) |
103 { | |
104 visitor->trace(m_inspectedWorkerGlobalScope); | |
105 InspectorDebuggerAgent::trace(visitor); | |
95 } | 106 } |
96 | 107 |
97 void WorkerDebuggerAgent::interruptAndDispatchInspectorCommands(WorkerThread* th read) | 108 void WorkerDebuggerAgent::interruptAndDispatchInspectorCommands(WorkerThread* th read) |
98 { | 109 { |
99 MutexLocker lock(workerDebuggerAgentsMutex()); | 110 MutexLocker lock(workerDebuggerAgentsMutex()); |
111 #if ENABLE(OILPAN) | |
112 CrossThreadPersistent<WorkerDebuggerAgent>* agentHandle = workerDebuggerAgen ts().get(thread); | |
113 if (!agentHandle) | |
114 return; | |
115 WorkerDebuggerAgent* agent = agentHandle->get(); | |
116 #else | |
100 WorkerDebuggerAgent* agent = workerDebuggerAgents().get(thread); | 117 WorkerDebuggerAgent* agent = workerDebuggerAgents().get(thread); |
118 #endif | |
101 if (agent) | 119 if (agent) |
102 agent->m_scriptDebugServer->interruptAndRunTask(adoptPtr(new RunInspecto rCommandsTask(thread))); | 120 agent->m_scriptDebugServer->interruptAndRunTask(adoptPtr(new RunInspecto rCommandsTask(thread))); |
103 } | 121 } |
104 | 122 |
123 void WorkerDebuggerAgent::discard() | |
124 { | |
125 MutexLocker lock(workerDebuggerAgentsMutex()); | |
126 ASSERT(workerDebuggerAgents().contains(m_thread)); | |
127 workerDebuggerAgents().remove(m_thread); | |
128 } | |
129 | |
105 void WorkerDebuggerAgent::startListeningScriptDebugServer() | 130 void WorkerDebuggerAgent::startListeningScriptDebugServer() |
106 { | 131 { |
107 scriptDebugServer().addListener(this); | 132 scriptDebugServer().addListener(this); |
108 } | 133 } |
109 | 134 |
110 void WorkerDebuggerAgent::stopListeningScriptDebugServer() | 135 void WorkerDebuggerAgent::stopListeningScriptDebugServer() |
111 { | 136 { |
112 scriptDebugServer().removeListener(this); | 137 scriptDebugServer().removeListener(this); |
113 } | 138 } |
114 | 139 |
(...skipping 15 matching lines...) Expand all Loading... | |
130 { | 155 { |
131 // We don't need to mute console for workers. | 156 // We don't need to mute console for workers. |
132 } | 157 } |
133 | 158 |
134 void WorkerDebuggerAgent::unmuteConsole() | 159 void WorkerDebuggerAgent::unmuteConsole() |
135 { | 160 { |
136 // We don't need to mute console for workers. | 161 // We don't need to mute console for workers. |
137 } | 162 } |
138 | 163 |
139 } // namespace WebCore | 164 } // namespace WebCore |
OLD | NEW |