| 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 17 matching lines...) Expand all  Loading... | 
| 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/core/v8/ScriptDebugServer.h" | 34 #include "bindings/core/v8/ScriptDebugServer.h" | 
| 35 #include "core/inspector/InjectedScript.h" | 35 #include "core/inspector/InjectedScript.h" | 
| 36 #include "core/inspector/WorkerInspectorController.h" | 36 #include "core/inspector/WorkerInspectorController.h" | 
| 37 #include "core/workers/WorkerGlobalScope.h" | 37 #include "core/workers/WorkerGlobalScope.h" | 
| 38 #include "core/workers/WorkerThread.h" | 38 #include "core/workers/WorkerScript.h" | 
| 39 #include "wtf/MessageQueue.h" | 39 #include "wtf/MessageQueue.h" | 
| 40 | 40 | 
| 41 namespace blink { | 41 namespace blink { | 
| 42 | 42 | 
| 43 namespace { | 43 namespace { | 
| 44 | 44 | 
| 45 class RunInspectorCommandsTask final : public ScriptDebugServer::Task { | 45 class RunInspectorCommandsTask final : public ScriptDebugServer::Task { | 
| 46 public: | 46 public: | 
| 47     explicit RunInspectorCommandsTask(WorkerThread* thread) | 47     explicit RunInspectorCommandsTask(WorkerScript* script) | 
| 48         : m_thread(thread) { } | 48         : m_script(script) { } | 
| 49     virtual ~RunInspectorCommandsTask() { } | 49     virtual ~RunInspectorCommandsTask() { } | 
| 50     virtual void run() override | 50     virtual void run() override | 
| 51     { | 51     { | 
| 52         // Process all queued debugger commands. WorkerThread is certainly | 52         // Process all queued debugger commands. WorkerScript is certainly | 
| 53         // alive if this task is being executed. | 53         // alive if this task is being executed. | 
| 54         m_thread->willEnterNestedLoop(); | 54         m_script->willEnterNestedLoop(); | 
| 55         while (MessageQueueMessageReceived == m_thread->runDebuggerTask(WorkerTh
     read::DontWaitForMessage)) { } | 55         while (MessageQueueMessageReceived == m_script->runDebuggerTask(WorkerSc
     ript::DontWaitForMessage)) { } | 
| 56         m_thread->didLeaveNestedLoop(); | 56         m_script->didLeaveNestedLoop(); | 
| 57     } | 57     } | 
| 58 | 58 | 
| 59 private: | 59 private: | 
| 60     WorkerThread* m_thread; | 60     WorkerScript* m_script; | 
| 61 }; | 61 }; | 
| 62 | 62 | 
| 63 } // namespace | 63 } // namespace | 
| 64 | 64 | 
| 65 PassOwnPtrWillBeRawPtr<WorkerDebuggerAgent> WorkerDebuggerAgent::create(WorkerSc
     riptDebugServer* scriptDebugServer, WorkerGlobalScope* inspectedWorkerGlobalScop
     e, InjectedScriptManager* injectedScriptManager) | 65 PassOwnPtrWillBeRawPtr<WorkerDebuggerAgent> WorkerDebuggerAgent::create(WorkerSc
     riptDebugServer* scriptDebugServer, WorkerGlobalScope* inspectedWorkerGlobalScop
     e, InjectedScriptManager* injectedScriptManager) | 
| 66 { | 66 { | 
| 67     return adoptPtrWillBeNoop(new WorkerDebuggerAgent(scriptDebugServer, inspect
     edWorkerGlobalScope, injectedScriptManager)); | 67     return adoptPtrWillBeNoop(new WorkerDebuggerAgent(scriptDebugServer, inspect
     edWorkerGlobalScope, injectedScriptManager)); | 
| 68 } | 68 } | 
| 69 | 69 | 
| 70 WorkerDebuggerAgent::WorkerDebuggerAgent(WorkerScriptDebugServer* scriptDebugSer
     ver, WorkerGlobalScope* inspectedWorkerGlobalScope, InjectedScriptManager* injec
     tedScriptManager) | 70 WorkerDebuggerAgent::WorkerDebuggerAgent(WorkerScriptDebugServer* scriptDebugSer
     ver, WorkerGlobalScope* inspectedWorkerGlobalScope, InjectedScriptManager* injec
     tedScriptManager) | 
| 71     : InspectorDebuggerAgent(injectedScriptManager) | 71     : InspectorDebuggerAgent(injectedScriptManager) | 
| 72     , m_scriptDebugServer(scriptDebugServer) | 72     , m_scriptDebugServer(scriptDebugServer) | 
| 73     , m_inspectedWorkerGlobalScope(inspectedWorkerGlobalScope) | 73     , m_inspectedWorkerGlobalScope(inspectedWorkerGlobalScope) | 
| 74 { | 74 { | 
| 75 } | 75 } | 
| 76 | 76 | 
| 77 WorkerDebuggerAgent::~WorkerDebuggerAgent() | 77 WorkerDebuggerAgent::~WorkerDebuggerAgent() | 
| 78 { | 78 { | 
| 79 } | 79 } | 
| 80 | 80 | 
| 81 DEFINE_TRACE(WorkerDebuggerAgent) | 81 DEFINE_TRACE(WorkerDebuggerAgent) | 
| 82 { | 82 { | 
| 83     visitor->trace(m_inspectedWorkerGlobalScope); | 83     visitor->trace(m_inspectedWorkerGlobalScope); | 
| 84     InspectorDebuggerAgent::trace(visitor); | 84     InspectorDebuggerAgent::trace(visitor); | 
| 85 } | 85 } | 
| 86 | 86 | 
| 87 void WorkerDebuggerAgent::interruptAndDispatchInspectorCommands() | 87 void WorkerDebuggerAgent::interruptAndDispatchInspectorCommands() | 
| 88 { | 88 { | 
| 89     scriptDebugServer().interruptAndRun(adoptPtr(new RunInspectorCommandsTask(m_
     inspectedWorkerGlobalScope->thread()))); | 89     scriptDebugServer().interruptAndRun(adoptPtr(new RunInspectorCommandsTask(m_
     inspectedWorkerGlobalScope->script()))); | 
| 90 } | 90 } | 
| 91 | 91 | 
| 92 void WorkerDebuggerAgent::startListeningScriptDebugServer() | 92 void WorkerDebuggerAgent::startListeningScriptDebugServer() | 
| 93 { | 93 { | 
| 94     scriptDebugServer().addListener(this); | 94     scriptDebugServer().addListener(this); | 
| 95 } | 95 } | 
| 96 | 96 | 
| 97 void WorkerDebuggerAgent::stopListeningScriptDebugServer() | 97 void WorkerDebuggerAgent::stopListeningScriptDebugServer() | 
| 98 { | 98 { | 
| 99     scriptDebugServer().removeListener(this); | 99     scriptDebugServer().removeListener(this); | 
| 100 } | 100 } | 
| 101 | 101 | 
| 102 WorkerScriptDebugServer& WorkerDebuggerAgent::scriptDebugServer() | 102 WorkerScriptDebugServer& WorkerDebuggerAgent::scriptDebugServer() | 
| 103 { | 103 { | 
| 104     return *m_scriptDebugServer; | 104     return *m_scriptDebugServer; | 
| 105 } | 105 } | 
| 106 | 106 | 
| 107 InjectedScript WorkerDebuggerAgent::injectedScriptForEval(ErrorString* error, co
     nst int* executionContextId) | 107 InjectedScript WorkerDebuggerAgent::injectedScriptForEval(ErrorString* error, co
     nst int* executionContextId) | 
| 108 { | 108 { | 
| 109     if (!executionContextId) | 109     if (!executionContextId) | 
| 110         return injectedScriptManager()->injectedScriptFor(m_inspectedWorkerGloba
     lScope->script()->scriptState()); | 110         return injectedScriptManager()->injectedScriptFor(m_inspectedWorkerGloba
     lScope->scriptController()->scriptState()); | 
| 111 | 111 | 
| 112     InjectedScript injectedScript = injectedScriptManager()->injectedScriptForId
     (*executionContextId); | 112     InjectedScript injectedScript = injectedScriptManager()->injectedScriptForId
     (*executionContextId); | 
| 113     if (injectedScript.isEmpty()) | 113     if (injectedScript.isEmpty()) | 
| 114         *error = "Execution context with given id not found."; | 114         *error = "Execution context with given id not found."; | 
| 115     return injectedScript; | 115     return injectedScript; | 
| 116 } | 116 } | 
| 117 | 117 | 
| 118 void WorkerDebuggerAgent::muteConsole() | 118 void WorkerDebuggerAgent::muteConsole() | 
| 119 { | 119 { | 
| 120     // We don't need to mute console for workers. | 120     // We don't need to mute console for workers. | 
| 121 } | 121 } | 
| 122 | 122 | 
| 123 void WorkerDebuggerAgent::unmuteConsole() | 123 void WorkerDebuggerAgent::unmuteConsole() | 
| 124 { | 124 { | 
| 125     // We don't need to mute console for workers. | 125     // We don't need to mute console for workers. | 
| 126 } | 126 } | 
| 127 | 127 | 
| 128 } // namespace blink | 128 } // namespace blink | 
| OLD | NEW | 
|---|