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 16 matching lines...) Expand all Loading... |
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 "core/inspector/WorkerInspectorController.h" | 31 #include "core/inspector/WorkerInspectorController.h" |
32 | 32 |
33 #include "core/InstrumentingAgents.h" | 33 #include "core/InstrumentingAgents.h" |
34 #include "core/inspector/InspectorInstrumentation.h" | 34 #include "core/inspector/InspectorInstrumentation.h" |
35 #include "core/inspector/InspectorLogAgent.h" | 35 #include "core/inspector/InspectorLogAgent.h" |
36 #include "core/inspector/WorkerThreadDebugger.h" | 36 #include "core/inspector/WorkerThreadDebugger.h" |
37 #include "core/workers/WorkerGlobalScope.h" | |
38 #include "core/workers/WorkerReportingProxy.h" | 37 #include "core/workers/WorkerReportingProxy.h" |
39 #include "core/workers/WorkerThread.h" | 38 #include "core/workers/WorkerThread.h" |
40 #include "platform/inspector_protocol/DispatcherBase.h" | 39 #include "platform/inspector_protocol/DispatcherBase.h" |
41 #include "platform/v8_inspector/public/V8Debugger.h" | 40 #include "platform/v8_inspector/public/V8Debugger.h" |
42 #include "platform/v8_inspector/public/V8InspectorSession.h" | 41 #include "platform/v8_inspector/public/V8InspectorSession.h" |
43 | 42 |
44 namespace blink { | 43 namespace blink { |
45 | 44 |
46 WorkerInspectorController* WorkerInspectorController::create(WorkerGlobalScope*
workerGlobalScope) | 45 WorkerInspectorController* WorkerInspectorController::create(WorkerThread* threa
d) |
47 { | 46 { |
48 WorkerThreadDebugger* debugger = WorkerThreadDebugger::from(workerGlobalScop
e->thread()->isolate()); | 47 WorkerThreadDebugger* debugger = WorkerThreadDebugger::from(thread->isolate(
)); |
49 return debugger ? new WorkerInspectorController(workerGlobalScope, debugger)
: nullptr; | 48 return debugger ? new WorkerInspectorController(thread, debugger) : nullptr; |
50 } | 49 } |
51 | 50 |
52 WorkerInspectorController::WorkerInspectorController(WorkerGlobalScope* workerGl
obalScope, WorkerThreadDebugger* debugger) | 51 WorkerInspectorController::WorkerInspectorController(WorkerThread* thread, Worke
rThreadDebugger* debugger) |
53 : m_debugger(debugger) | 52 : m_debugger(debugger) |
54 , m_workerGlobalScope(workerGlobalScope) | 53 , m_thread(thread) |
55 , m_instrumentingAgents(new InstrumentingAgents()) | 54 , m_instrumentingAgents(new InstrumentingAgents()) |
56 , m_logAgent(nullptr) | 55 , m_logAgent(nullptr) |
57 { | 56 { |
58 } | 57 } |
59 | 58 |
60 WorkerInspectorController::~WorkerInspectorController() | 59 WorkerInspectorController::~WorkerInspectorController() |
61 { | 60 { |
| 61 DCHECK(!m_thread); |
62 } | 62 } |
63 | 63 |
64 void WorkerInspectorController::connectFrontend() | 64 void WorkerInspectorController::connectFrontend() |
65 { | 65 { |
66 if (m_session) | 66 if (m_session) |
67 return; | 67 return; |
68 | 68 |
69 // sessionId will be overwritten by WebDevToolsAgent::sendProtocolNotificati
on call. | 69 // sessionId will be overwritten by WebDevToolsAgent::sendProtocolNotificati
on call. |
70 m_session = new InspectorSession(this, nullptr, m_instrumentingAgents.get(),
0, true /* autoFlush */, m_debugger->debugger(), m_debugger->contextGroupId(),
nullptr); | 70 m_session = new InspectorSession(this, nullptr, m_instrumentingAgents.get(),
0, true /* autoFlush */, m_debugger->debugger(), m_debugger->contextGroupId(),
nullptr); |
71 m_logAgent = new InspectorLogAgent(m_workerGlobalScope->consoleMessageStorag
e()); | 71 m_logAgent = new InspectorLogAgent(m_thread->consoleMessageStorage()); |
72 m_session->append(m_logAgent.get()); | 72 m_session->append(m_logAgent.get()); |
73 } | 73 } |
74 | 74 |
75 void WorkerInspectorController::disconnectFrontend() | 75 void WorkerInspectorController::disconnectFrontend() |
76 { | 76 { |
77 if (!m_session) | 77 if (!m_session) |
78 return; | 78 return; |
79 m_session->dispose(); | 79 m_session->dispose(); |
80 m_session.clear(); | 80 m_session.clear(); |
81 } | 81 } |
82 | 82 |
83 void WorkerInspectorController::dispatchMessageFromFrontend(const String& messag
e) | 83 void WorkerInspectorController::dispatchMessageFromFrontend(const String& messag
e) |
84 { | 84 { |
85 if (!m_session) | 85 if (!m_session) |
86 return; | 86 return; |
87 protocol::String16 method; | 87 protocol::String16 method; |
88 if (!protocol::DispatcherBase::getCommandName(message, &method)) | 88 if (!protocol::DispatcherBase::getCommandName(message, &method)) |
89 return; | 89 return; |
90 m_session->dispatchProtocolMessage(method, message); | 90 m_session->dispatchProtocolMessage(method, message); |
91 } | 91 } |
92 | 92 |
93 void WorkerInspectorController::dispose() | 93 void WorkerInspectorController::dispose() |
94 { | 94 { |
95 disconnectFrontend(); | 95 disconnectFrontend(); |
| 96 m_thread = nullptr; |
96 } | 97 } |
97 | 98 |
98 void WorkerInspectorController::resumeStartup() | 99 void WorkerInspectorController::resumeStartup() |
99 { | 100 { |
100 m_workerGlobalScope->thread()->stopRunningDebuggerTasksOnPauseOnWorkerThread
(); | 101 m_thread->stopRunningDebuggerTasksOnPauseOnWorkerThread(); |
101 } | 102 } |
102 | 103 |
103 void WorkerInspectorController::sendProtocolMessage(int sessionId, int callId, c
onst String& response, const String& state) | 104 void WorkerInspectorController::sendProtocolMessage(int sessionId, int callId, c
onst String& response, const String& state) |
104 { | 105 { |
105 // Worker messages are wrapped, no need to handle callId or state. | 106 // Worker messages are wrapped, no need to handle callId or state. |
106 m_workerGlobalScope->thread()->workerReportingProxy().postMessageToPageInspe
ctor(response); | 107 m_thread->workerReportingProxy().postMessageToPageInspector(response); |
107 } | 108 } |
108 | 109 |
109 void WorkerInspectorController::consoleCleared() | 110 void WorkerInspectorController::consoleCleared() |
110 { | 111 { |
111 if (m_logAgent) | 112 if (m_logAgent) |
112 m_logAgent->clear(nullptr); | 113 m_logAgent->clear(nullptr); |
113 } | 114 } |
114 | 115 |
115 DEFINE_TRACE(WorkerInspectorController) | 116 DEFINE_TRACE(WorkerInspectorController) |
116 { | 117 { |
117 visitor->trace(m_workerGlobalScope); | |
118 visitor->trace(m_instrumentingAgents); | 118 visitor->trace(m_instrumentingAgents); |
119 visitor->trace(m_session); | 119 visitor->trace(m_session); |
120 visitor->trace(m_logAgent); | 120 visitor->trace(m_logAgent); |
121 } | 121 } |
122 | 122 |
123 } // namespace blink | 123 } // namespace blink |
OLD | NEW |