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 typedef HashMap<WorkerThread*, WorkerDebuggerAgent*> WorkerDebuggerAgents; | 49 typedef HashMap<WorkerThread*, WorkerDebuggerAgent*> WorkerDebuggerAgents; |
wibling-chromium
2014/06/02 08:15:16
Don't you need to make this a WillBePersistentHeap
| |
50 | 50 |
51 WorkerDebuggerAgents& workerDebuggerAgents() | 51 WorkerDebuggerAgents& workerDebuggerAgents() |
52 { | 52 { |
53 DEFINE_STATIC_LOCAL(WorkerDebuggerAgents, agents, ()); | 53 DEFINE_STATIC_LOCAL(WorkerDebuggerAgents, agents, ()); |
54 return agents; | 54 return agents; |
55 } | 55 } |
56 | 56 |
57 #if ENABLE(OILPAN) | |
58 class WorkerDebuggerAgentRemover { | |
59 public: | |
60 WorkerDebuggerAgentRemover(WorkerThread* thread) | |
61 { | |
62 m_thread = thread; | |
63 } | |
64 ~WorkerDebuggerAgentRemover() | |
65 { | |
66 MutexLocker lock(workerDebuggerAgentsMutex()); | |
67 workerDebuggerAgents().remove(m_thread); | |
haraken
2014/05/30 03:24:12
If you insert printf to ~WorkerDebuggerAgentRemove
| |
68 } | |
69 | |
70 private: | |
71 WorkerThread* m_thread; | |
72 }; | |
73 | |
74 typedef WillBePersistentHeapHashMap<WeakMember<WorkerDebuggerAgent>, OwnPtr<Work erDebuggerAgentRemover> > WorkerDebuggerAgentRemovers; | |
haraken
2014/06/02 04:51:14
mads@, erik@: I'm guessing that this issue might b
Mads Ager (chromium)
2014/06/02 09:00:59
That does not work, no. If you need to do somethin
| |
75 | |
76 WorkerDebuggerAgentRemovers& workerDebuggerAgentRemovers() | |
77 { | |
78 DEFINE_STATIC_LOCAL(WorkerDebuggerAgentRemovers, removers, ()); | |
haraken
2014/05/30 03:24:12
I don't think it's related, but what happens if yo
| |
79 return removers; | |
80 } | |
81 #endif | |
57 | 82 |
58 class RunInspectorCommandsTask FINAL : public ScriptDebugServer::Task { | 83 class RunInspectorCommandsTask FINAL : public ScriptDebugServer::Task { |
59 public: | 84 public: |
60 explicit RunInspectorCommandsTask(WorkerThread* thread) | 85 explicit RunInspectorCommandsTask(WorkerThread* thread) |
61 : m_thread(thread) { } | 86 : m_thread(thread) { } |
62 virtual ~RunInspectorCommandsTask() { } | 87 virtual ~RunInspectorCommandsTask() { } |
63 virtual void run() OVERRIDE | 88 virtual void run() OVERRIDE |
64 { | 89 { |
65 // Process all queued debugger commands. WorkerThread is certainly | 90 // Process all queued debugger commands. WorkerThread is certainly |
66 // alive if this task is being executed. | 91 // alive if this task is being executed. |
67 while (MessageQueueMessageReceived == m_thread->runLoop().runDebuggerTas k(WorkerRunLoop::DontWaitForMessage)) { } | 92 while (MessageQueueMessageReceived == m_thread->runLoop().runDebuggerTas k(WorkerRunLoop::DontWaitForMessage)) { } |
68 } | 93 } |
69 | 94 |
70 private: | 95 private: |
71 WorkerThread* m_thread; | 96 WorkerThread* m_thread; |
72 }; | 97 }; |
73 | 98 |
74 } // namespace | 99 } // namespace |
75 | 100 |
76 PassOwnPtr<WorkerDebuggerAgent> WorkerDebuggerAgent::create(WorkerScriptDebugSer ver* scriptDebugServer, WorkerGlobalScope* inspectedWorkerGlobalScope, InjectedS criptManager* injectedScriptManager) | 101 PassOwnPtrWillBeRawPtr<WorkerDebuggerAgent> WorkerDebuggerAgent::create(WorkerSc riptDebugServer* scriptDebugServer, WorkerGlobalScope* inspectedWorkerGlobalScop e, InjectedScriptManager* injectedScriptManager) |
77 { | 102 { |
78 return adoptPtr(new WorkerDebuggerAgent(scriptDebugServer, inspectedWorkerGl obalScope, injectedScriptManager)); | 103 return adoptPtrWillBeNoop(new WorkerDebuggerAgent(scriptDebugServer, inspect edWorkerGlobalScope, injectedScriptManager)); |
79 } | 104 } |
80 | 105 |
81 WorkerDebuggerAgent::WorkerDebuggerAgent(WorkerScriptDebugServer* scriptDebugSer ver, WorkerGlobalScope* inspectedWorkerGlobalScope, InjectedScriptManager* injec tedScriptManager) | 106 WorkerDebuggerAgent::WorkerDebuggerAgent(WorkerScriptDebugServer* scriptDebugSer ver, WorkerGlobalScope* inspectedWorkerGlobalScope, InjectedScriptManager* injec tedScriptManager) |
82 : InspectorDebuggerAgent(injectedScriptManager) | 107 : InspectorDebuggerAgent(injectedScriptManager) |
83 , m_scriptDebugServer(scriptDebugServer) | 108 , m_scriptDebugServer(scriptDebugServer) |
84 , m_inspectedWorkerGlobalScope(inspectedWorkerGlobalScope) | 109 , m_inspectedWorkerGlobalScope(inspectedWorkerGlobalScope) |
85 { | 110 { |
86 MutexLocker lock(workerDebuggerAgentsMutex()); | 111 MutexLocker lock(workerDebuggerAgentsMutex()); |
87 workerDebuggerAgents().set(inspectedWorkerGlobalScope->thread(), this); | 112 WorkerThread* thread = inspectedWorkerGlobalScope->thread(); |
113 ASSERT(!workerDebuggerAgents().contains(thread)); | |
114 ASSERT(!workerDebuggerAgentRemovers().contains(this)); | |
115 workerDebuggerAgents().set(thread, this); | |
116 workerDebuggerAgentRemovers().set(this, adoptPtr(new WorkerDebuggerAgentRemo ver(thread))); | |
haraken
2014/05/30 01:13:20
The line 113 and 115 need to be removed in oilpan
keishi
2014/05/30 02:01:07
Won't line 79 in ~WorkerDebuggerAgentRemover work
haraken
2014/05/30 03:24:12
oh, line 67 should work.
| |
88 } | 117 } |
89 | 118 |
90 WorkerDebuggerAgent::~WorkerDebuggerAgent() | 119 WorkerDebuggerAgent::~WorkerDebuggerAgent() |
91 { | 120 { |
121 #if !ENABLE(OILPAN) | |
92 MutexLocker lock(workerDebuggerAgentsMutex()); | 122 MutexLocker lock(workerDebuggerAgentsMutex()); |
93 ASSERT(workerDebuggerAgents().contains(m_inspectedWorkerGlobalScope->thread( ))); | 123 ASSERT(workerDebuggerAgents().contains(m_inspectedWorkerGlobalScope->thread( ))); |
94 workerDebuggerAgents().remove(m_inspectedWorkerGlobalScope->thread()); | 124 workerDebuggerAgents().remove(m_inspectedWorkerGlobalScope->thread()); |
125 #endif | |
126 } | |
127 | |
128 void WorkerDebuggerAgent::trace(Visitor* visitor) | |
129 { | |
130 visitor->trace(m_inspectedWorkerGlobalScope); | |
131 InspectorDebuggerAgent::trace(visitor); | |
95 } | 132 } |
96 | 133 |
97 void WorkerDebuggerAgent::interruptAndDispatchInspectorCommands(WorkerThread* th read) | 134 void WorkerDebuggerAgent::interruptAndDispatchInspectorCommands(WorkerThread* th read) |
98 { | 135 { |
99 MutexLocker lock(workerDebuggerAgentsMutex()); | 136 MutexLocker lock(workerDebuggerAgentsMutex()); |
100 WorkerDebuggerAgent* agent = workerDebuggerAgents().get(thread); | 137 WorkerDebuggerAgent* agent = workerDebuggerAgents().get(thread); |
101 if (agent) | 138 if (agent) |
102 agent->m_scriptDebugServer->interruptAndRunTask(adoptPtr(new RunInspecto rCommandsTask(thread))); | 139 agent->m_scriptDebugServer->interruptAndRunTask(adoptPtr(new RunInspecto rCommandsTask(thread))); |
103 } | 140 } |
104 | 141 |
(...skipping 25 matching lines...) Expand all Loading... | |
130 { | 167 { |
131 // We don't need to mute console for workers. | 168 // We don't need to mute console for workers. |
132 } | 169 } |
133 | 170 |
134 void WorkerDebuggerAgent::unmuteConsole() | 171 void WorkerDebuggerAgent::unmuteConsole() |
135 { | 172 { |
136 // We don't need to mute console for workers. | 173 // We don't need to mute console for workers. |
137 } | 174 } |
138 | 175 |
139 } // namespace WebCore | 176 } // namespace WebCore |
OLD | NEW |