| 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 #include "core/inspector/WorkerThreadDebugger.h" | 52 #include "core/inspector/WorkerThreadDebugger.h" |
| 53 #include "core/workers/WorkerGlobalScope.h" | 53 #include "core/workers/WorkerGlobalScope.h" |
| 54 #include "core/workers/WorkerReportingProxy.h" | 54 #include "core/workers/WorkerReportingProxy.h" |
| 55 #include "core/workers/WorkerThread.h" | 55 #include "core/workers/WorkerThread.h" |
| 56 #include "wtf/PassOwnPtr.h" | 56 #include "wtf/PassOwnPtr.h" |
| 57 | 57 |
| 58 namespace blink { | 58 namespace blink { |
| 59 | 59 |
| 60 namespace { | 60 namespace { |
| 61 | 61 |
| 62 class PageInspectorProxy final : public InspectorFrontendChannel { | |
| 63 USING_FAST_MALLOC(PageInspectorProxy); | |
| 64 public: | |
| 65 explicit PageInspectorProxy(WorkerGlobalScope* workerGlobalScope) : m_worker
GlobalScope(workerGlobalScope) { } | |
| 66 ~PageInspectorProxy() override { } | |
| 67 private: | |
| 68 void sendProtocolResponse(int callId, PassRefPtr<JSONObject> message) overri
de | |
| 69 { | |
| 70 // Worker messages are wrapped, no need to handle callId. | |
| 71 m_workerGlobalScope->thread()->workerReportingProxy().postMessageToPageI
nspector(message->toJSONString()); | |
| 72 } | |
| 73 void sendProtocolNotification(PassRefPtr<JSONObject> message) override | |
| 74 { | |
| 75 m_workerGlobalScope->thread()->workerReportingProxy().postMessageToPageI
nspector(message->toJSONString()); | |
| 76 } | |
| 77 void flush() override { } | |
| 78 WorkerGlobalScope* m_workerGlobalScope; | |
| 79 }; | |
| 80 | |
| 81 class WorkerStateClient final : public InspectorStateClient { | 62 class WorkerStateClient final : public InspectorStateClient { |
| 82 USING_FAST_MALLOC(WorkerStateClient); | 63 USING_FAST_MALLOC(WorkerStateClient); |
| 83 public: | 64 public: |
| 84 WorkerStateClient(WorkerGlobalScope* context) { } | 65 WorkerStateClient(WorkerGlobalScope* context) { } |
| 85 ~WorkerStateClient() override { } | 66 ~WorkerStateClient() override { } |
| 86 | 67 |
| 87 private: | 68 private: |
| 88 void updateInspectorStateCookie(const String& cookie) override { } | 69 void updateInspectorStateCookie(const String& cookie) override { } |
| 89 }; | 70 }; |
| 90 | 71 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 101 while (WorkerThread::TaskReceived == m_thread->runDebuggerTask(WorkerThr
ead::DontWaitForTask)) { } | 82 while (WorkerThread::TaskReceived == m_thread->runDebuggerTask(WorkerThr
ead::DontWaitForTask)) { } |
| 102 m_thread->didRunDebuggerTasks(); | 83 m_thread->didRunDebuggerTasks(); |
| 103 } | 84 } |
| 104 | 85 |
| 105 private: | 86 private: |
| 106 WorkerThread* m_thread; | 87 WorkerThread* m_thread; |
| 107 }; | 88 }; |
| 108 | 89 |
| 109 } | 90 } |
| 110 | 91 |
| 92 class WorkerInspectorController::PageInspectorProxy final : public NoBaseWillBeG
arbageCollectedFinalized<WorkerInspectorController::PageInspectorProxy>, public
InspectorFrontendChannel { |
| 93 USING_FAST_MALLOC_WILL_BE_REMOVED(PageInspectorProxy); |
| 94 public: |
| 95 static PassOwnPtrWillBeRawPtr<PageInspectorProxy> create(WorkerGlobalScope*
workerGlobalScope) |
| 96 { |
| 97 return adoptPtrWillBeNoop(new PageInspectorProxy(workerGlobalScope)); |
| 98 } |
| 99 ~PageInspectorProxy() override { } |
| 100 |
| 101 DEFINE_INLINE_TRACE() |
| 102 { |
| 103 visitor->trace(m_workerGlobalScope); |
| 104 } |
| 105 |
| 106 private: |
| 107 explicit PageInspectorProxy(WorkerGlobalScope* workerGlobalScope) |
| 108 : m_workerGlobalScope(workerGlobalScope) |
| 109 { |
| 110 } |
| 111 |
| 112 void sendProtocolResponse(int callId, PassRefPtr<JSONObject> message) overri
de |
| 113 { |
| 114 // Worker messages are wrapped, no need to handle callId. |
| 115 m_workerGlobalScope->thread()->workerReportingProxy().postMessageToPageI
nspector(message->toJSONString()); |
| 116 } |
| 117 void sendProtocolNotification(PassRefPtr<JSONObject> message) override |
| 118 { |
| 119 m_workerGlobalScope->thread()->workerReportingProxy().postMessageToPageI
nspector(message->toJSONString()); |
| 120 } |
| 121 void flush() override { } |
| 122 |
| 123 RawPtrWillBeMember<WorkerGlobalScope> m_workerGlobalScope; |
| 124 }; |
| 125 |
| 111 class WorkerInjectedScriptHostClient: public InjectedScriptHostClient { | 126 class WorkerInjectedScriptHostClient: public InjectedScriptHostClient { |
| 112 public: | 127 public: |
| 113 WorkerInjectedScriptHostClient() { } | 128 WorkerInjectedScriptHostClient() { } |
| 114 | 129 |
| 115 ~WorkerInjectedScriptHostClient() override { } | 130 ~WorkerInjectedScriptHostClient() override { } |
| 116 }; | 131 }; |
| 117 | 132 |
| 118 WorkerInspectorController::WorkerInspectorController(WorkerGlobalScope* workerGl
obalScope) | 133 WorkerInspectorController::WorkerInspectorController(WorkerGlobalScope* workerGl
obalScope) |
| 119 : m_workerGlobalScope(workerGlobalScope) | 134 : m_workerGlobalScope(workerGlobalScope) |
| 120 , m_stateClient(adoptPtr(new WorkerStateClient(workerGlobalScope))) | 135 , m_stateClient(adoptPtr(new WorkerStateClient(workerGlobalScope))) |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 | 170 |
| 156 void WorkerInspectorController::registerModuleAgent(PassOwnPtrWillBeRawPtr<Inspe
ctorAgent> agent) | 171 void WorkerInspectorController::registerModuleAgent(PassOwnPtrWillBeRawPtr<Inspe
ctorAgent> agent) |
| 157 { | 172 { |
| 158 m_agents.append(agent); | 173 m_agents.append(agent); |
| 159 } | 174 } |
| 160 | 175 |
| 161 void WorkerInspectorController::connectFrontend() | 176 void WorkerInspectorController::connectFrontend() |
| 162 { | 177 { |
| 163 ASSERT(!m_frontend); | 178 ASSERT(!m_frontend); |
| 164 m_state->unmute(); | 179 m_state->unmute(); |
| 165 m_frontendChannel = adoptPtr(new PageInspectorProxy(m_workerGlobalScope)); | 180 m_pageInspectorProxy = PageInspectorProxy::create(m_workerGlobalScope); |
| 166 m_frontend = adoptPtr(new InspectorFrontend(m_frontendChannel.get())); | 181 m_frontend = adoptPtr(new InspectorFrontend(frontendChannel())); |
| 167 m_backendDispatcher = InspectorBackendDispatcher::create(m_frontendChannel.g
et()); | 182 m_backendDispatcher = InspectorBackendDispatcher::create(frontendChannel()); |
| 168 m_agents.registerInDispatcher(m_backendDispatcher.get()); | 183 m_agents.registerInDispatcher(m_backendDispatcher.get()); |
| 169 m_agents.setFrontend(m_frontend.get()); | 184 m_agents.setFrontend(m_frontend.get()); |
| 170 InspectorInstrumentation::frontendCreated(); | 185 InspectorInstrumentation::frontendCreated(); |
| 171 } | 186 } |
| 172 | 187 |
| 173 void WorkerInspectorController::disconnectFrontend() | 188 void WorkerInspectorController::disconnectFrontend() |
| 174 { | 189 { |
| 175 if (!m_frontend) | 190 if (!m_frontend) |
| 176 return; | 191 return; |
| 177 m_backendDispatcher->clearFrontend(); | 192 m_backendDispatcher->clearFrontend(); |
| 178 m_backendDispatcher.clear(); | 193 m_backendDispatcher.clear(); |
| 179 // Destroying agents would change the state, but we don't want that. | 194 // Destroying agents would change the state, but we don't want that. |
| 180 // Pre-disconnect state will be used to restore inspector agents. | 195 // Pre-disconnect state will be used to restore inspector agents. |
| 181 m_state->mute(); | 196 m_state->mute(); |
| 182 m_agents.clearFrontend(); | 197 m_agents.clearFrontend(); |
| 183 m_frontend.clear(); | 198 m_frontend.clear(); |
| 184 InspectorInstrumentation::frontendDeleted(); | 199 InspectorInstrumentation::frontendDeleted(); |
| 185 m_frontendChannel.clear(); | 200 m_pageInspectorProxy.clear(); |
| 186 } | 201 } |
| 187 | 202 |
| 188 void WorkerInspectorController::restoreInspectorStateFromCookie(const String& in
spectorCookie) | 203 void WorkerInspectorController::restoreInspectorStateFromCookie(const String& in
spectorCookie) |
| 189 { | 204 { |
| 190 ASSERT(!m_frontend); | 205 ASSERT(!m_frontend); |
| 191 connectFrontend(); | 206 connectFrontend(); |
| 192 m_state->loadFromCookie(inspectorCookie); | 207 m_state->loadFromCookie(inspectorCookie); |
| 193 | 208 |
| 194 m_agents.restore(); | 209 m_agents.restore(); |
| 195 } | 210 } |
| (...skipping 20 matching lines...) Expand all Loading... |
| 216 { | 231 { |
| 217 if (m_paused) | 232 if (m_paused) |
| 218 m_workerThreadDebugger->quitMessageLoopOnPause(); | 233 m_workerThreadDebugger->quitMessageLoopOnPause(); |
| 219 } | 234 } |
| 220 | 235 |
| 221 bool WorkerInspectorController::isRunRequired() | 236 bool WorkerInspectorController::isRunRequired() |
| 222 { | 237 { |
| 223 return m_paused; | 238 return m_paused; |
| 224 } | 239 } |
| 225 | 240 |
| 241 InspectorFrontendChannel* WorkerInspectorController::frontendChannel() const |
| 242 { |
| 243 return static_cast<InspectorFrontendChannel*>(m_pageInspectorProxy.get()); |
| 244 } |
| 245 |
| 226 void WorkerInspectorController::workerContextInitialized(bool shouldPauseOnStart
) | 246 void WorkerInspectorController::workerContextInitialized(bool shouldPauseOnStart
) |
| 227 { | 247 { |
| 228 m_beforeInitlizedScope.clear(); | 248 m_beforeInitlizedScope.clear(); |
| 229 if (shouldPauseOnStart) | 249 if (shouldPauseOnStart) |
| 230 pauseOnStart(); | 250 pauseOnStart(); |
| 231 } | 251 } |
| 232 | 252 |
| 233 void WorkerInspectorController::pauseOnStart() | 253 void WorkerInspectorController::pauseOnStart() |
| 234 { | 254 { |
| 235 m_paused = true; | 255 m_paused = true; |
| 236 m_workerThreadDebugger->runMessageLoopOnPause(WorkerThreadDebugger::contextG
roupId()); | 256 m_workerThreadDebugger->runMessageLoopOnPause(WorkerThreadDebugger::contextG
roupId()); |
| 237 m_paused = false; | 257 m_paused = false; |
| 238 } | 258 } |
| 239 | 259 |
| 240 DEFINE_TRACE(WorkerInspectorController) | 260 DEFINE_TRACE(WorkerInspectorController) |
| 241 { | 261 { |
| 242 visitor->trace(m_workerGlobalScope); | 262 visitor->trace(m_workerGlobalScope); |
| 243 visitor->trace(m_state); | 263 visitor->trace(m_state); |
| 244 visitor->trace(m_instrumentingAgents); | 264 visitor->trace(m_instrumentingAgents); |
| 245 visitor->trace(m_injectedScriptManager); | 265 visitor->trace(m_injectedScriptManager); |
| 246 visitor->trace(m_backendDispatcher); | 266 visitor->trace(m_backendDispatcher); |
| 247 visitor->trace(m_agents); | 267 visitor->trace(m_agents); |
| 268 visitor->trace(m_pageInspectorProxy); |
| 248 visitor->trace(m_workerDebuggerAgent); | 269 visitor->trace(m_workerDebuggerAgent); |
| 249 visitor->trace(m_workerRuntimeAgent); | 270 visitor->trace(m_workerRuntimeAgent); |
| 250 } | 271 } |
| 251 | 272 |
| 252 } // namespace blink | 273 } // namespace blink |
| OLD | NEW |