Chromium Code Reviews| 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*, OwnPtr<Persistent<WorkerDebuggerAgent> > > Worker DebuggerAgents; |
| 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 | |
| 58 class RunInspectorCommandsTask FINAL : public ScriptDebugServer::Task { | 57 class RunInspectorCommandsTask FINAL : public ScriptDebugServer::Task { |
| 59 public: | 58 public: |
| 60 explicit RunInspectorCommandsTask(WorkerThread* thread) | 59 explicit RunInspectorCommandsTask(WorkerThread* thread) |
| 61 : m_thread(thread) { } | 60 : m_thread(thread) { } |
| 62 virtual ~RunInspectorCommandsTask() { } | 61 virtual ~RunInspectorCommandsTask() { } |
| 63 virtual void run() OVERRIDE | 62 virtual void run() OVERRIDE |
| 64 { | 63 { |
| 65 // Process all queued debugger commands. WorkerThread is certainly | 64 // Process all queued debugger commands. WorkerThread is certainly |
| 66 // alive if this task is being executed. | 65 // alive if this task is being executed. |
| 67 while (MessageQueueMessageReceived == m_thread->runLoop().runDebuggerTas k(WorkerRunLoop::DontWaitForMessage)) { } | 66 while (MessageQueueMessageReceived == m_thread->runLoop().runDebuggerTas k(WorkerRunLoop::DontWaitForMessage)) { } |
| 68 } | 67 } |
| 69 | 68 |
| 70 private: | 69 private: |
| 71 WorkerThread* m_thread; | 70 WorkerThread* m_thread; |
| 72 }; | 71 }; |
| 73 | 72 |
| 74 } // namespace | 73 } // namespace |
| 75 | 74 |
| 76 PassOwnPtr<WorkerDebuggerAgent> WorkerDebuggerAgent::create(WorkerScriptDebugSer ver* scriptDebugServer, WorkerGlobalScope* inspectedWorkerGlobalScope, InjectedS criptManager* injectedScriptManager) | 75 PassOwnPtrWillBeRawPtr<WorkerDebuggerAgent> WorkerDebuggerAgent::create(WorkerSc riptDebugServer* scriptDebugServer, WorkerGlobalScope* inspectedWorkerGlobalScop e, InjectedScriptManager* injectedScriptManager) |
| 77 { | 76 { |
| 78 return adoptPtr(new WorkerDebuggerAgent(scriptDebugServer, inspectedWorkerGl obalScope, injectedScriptManager)); | 77 return adoptPtrWillBeNoop(new WorkerDebuggerAgent(scriptDebugServer, inspect edWorkerGlobalScope, injectedScriptManager)); |
| 79 } | 78 } |
| 80 | 79 |
| 81 WorkerDebuggerAgent::WorkerDebuggerAgent(WorkerScriptDebugServer* scriptDebugSer ver, WorkerGlobalScope* inspectedWorkerGlobalScope, InjectedScriptManager* injec tedScriptManager) | 80 WorkerDebuggerAgent::WorkerDebuggerAgent(WorkerScriptDebugServer* scriptDebugSer ver, WorkerGlobalScope* inspectedWorkerGlobalScope, InjectedScriptManager* injec tedScriptManager) |
| 82 : InspectorDebuggerAgent(injectedScriptManager) | 81 : InspectorDebuggerAgent(injectedScriptManager) |
| 83 , m_scriptDebugServer(scriptDebugServer) | 82 , m_scriptDebugServer(scriptDebugServer) |
| 84 , m_inspectedWorkerGlobalScope(inspectedWorkerGlobalScope) | 83 , m_inspectedWorkerGlobalScope(inspectedWorkerGlobalScope) |
| 84 , m_thread(inspectedWorkerGlobalScope->thread()) | |
| 85 { | 85 { |
| 86 MutexLocker lock(workerDebuggerAgentsMutex()); | 86 MutexLocker lock(workerDebuggerAgentsMutex()); |
| 87 workerDebuggerAgents().set(inspectedWorkerGlobalScope->thread(), this); | 87 ASSERT(!workerDebuggerAgents().contains(m_thread)); |
| 88 //#if ENABLE(OILPAN) | |
| 89 workerDebuggerAgents().add(m_thread, nullptr/*adoptPtr(new Persistent<Worker DebuggerAgent>(this))*/); | |
|
keishi
2014/06/02 12:06:31
I tried to do the same thing that DatabaseManager
Mads Ager (chromium)
2014/06/03 10:19:35
I don't use lldb but I think your debugger is play
| |
| 90 //#else | |
| 91 // workerDebuggerAgents().set(m_thread, this); | |
| 92 //#endif | |
| 88 } | 93 } |
| 89 | 94 |
| 90 WorkerDebuggerAgent::~WorkerDebuggerAgent() | 95 WorkerDebuggerAgent::~WorkerDebuggerAgent() |
| 91 { | 96 { |
| 92 MutexLocker lock(workerDebuggerAgentsMutex()); | 97 //MutexLocker lock(workerDebuggerAgentsMutex()); |
| 93 ASSERT(workerDebuggerAgents().contains(m_inspectedWorkerGlobalScope->thread( ))); | 98 //ASSERT(workerDebuggerAgents().contains(m_thread)); |
| 94 workerDebuggerAgents().remove(m_inspectedWorkerGlobalScope->thread()); | 99 //workerDebuggerAgents().remove(m_thread); |
| 100 } | |
| 101 | |
| 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 Persistent<WorkerDebuggerAgent>* agentHandle = workerDebuggerAgents().get(th read); | |
| 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 |
| 105 void WorkerDebuggerAgent::startListeningScriptDebugServer() | 123 void WorkerDebuggerAgent::startListeningScriptDebugServer() |
| 106 { | 124 { |
| 107 scriptDebugServer().addListener(this); | 125 scriptDebugServer().addListener(this); |
| 108 } | 126 } |
| 109 | 127 |
| 110 void WorkerDebuggerAgent::stopListeningScriptDebugServer() | 128 void WorkerDebuggerAgent::stopListeningScriptDebugServer() |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 130 { | 148 { |
| 131 // We don't need to mute console for workers. | 149 // We don't need to mute console for workers. |
| 132 } | 150 } |
| 133 | 151 |
| 134 void WorkerDebuggerAgent::unmuteConsole() | 152 void WorkerDebuggerAgent::unmuteConsole() |
| 135 { | 153 { |
| 136 // We don't need to mute console for workers. | 154 // We don't need to mute console for workers. |
| 137 } | 155 } |
| 138 | 156 |
| 139 } // namespace WebCore | 157 } // namespace WebCore |
| OLD | NEW |