| 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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 | 88 |
| 89 } | 89 } |
| 90 | 90 |
| 91 WorkerInspectorController::WorkerInspectorController(WorkerGlobalScope* workerGl
obalScope) | 91 WorkerInspectorController::WorkerInspectorController(WorkerGlobalScope* workerGl
obalScope) |
| 92 : m_workerGlobalScope(workerGlobalScope) | 92 : m_workerGlobalScope(workerGlobalScope) |
| 93 , m_stateClient(adoptPtr(new WorkerStateClient(workerGlobalScope))) | 93 , m_stateClient(adoptPtr(new WorkerStateClient(workerGlobalScope))) |
| 94 , m_state(adoptPtr(new InspectorCompositeState(m_stateClient.get()))) | 94 , m_state(adoptPtr(new InspectorCompositeState(m_stateClient.get()))) |
| 95 , m_instrumentingAgents(InstrumentingAgents::create()) | 95 , m_instrumentingAgents(InstrumentingAgents::create()) |
| 96 , m_injectedScriptManager(InjectedScriptManager::createForWorker()) | 96 , m_injectedScriptManager(InjectedScriptManager::createForWorker()) |
| 97 , m_debugServer(adoptPtr(new WorkerScriptDebugServer(workerGlobalScope))) | 97 , m_debugServer(adoptPtr(new WorkerScriptDebugServer(workerGlobalScope))) |
| 98 , m_agents(m_instrumentingAgents.get(), m_state.get()) | 98 , m_agents(adoptPtrWillBeNoop(new InspectorAgentRegistry(m_instrumentingAgen
ts.get(), m_state.get()))) |
| 99 { | 99 { |
| 100 m_agents.append(WorkerRuntimeAgent::create(m_injectedScriptManager.get(), m_
debugServer.get(), workerGlobalScope)); | 100 m_agents->append(WorkerRuntimeAgent::create(m_injectedScriptManager.get(), m
_debugServer.get(), workerGlobalScope)); |
| 101 | 101 |
| 102 OwnPtr<InspectorTimelineAgent> timelineAgent = InspectorTimelineAgent::creat
e(0, 0, 0, InspectorTimelineAgent::WorkerInspector, 0); | 102 OwnPtrWillBeRawPtr<InspectorTimelineAgent> timelineAgent = InspectorTimeline
Agent::create(0, 0, 0, InspectorTimelineAgent::WorkerInspector, 0); |
| 103 m_agents.append(WorkerDebuggerAgent::create(m_debugServer.get(), workerGloba
lScope, m_injectedScriptManager.get())); | 103 m_agents->append(WorkerDebuggerAgent::create(m_debugServer.get(), workerGlob
alScope, m_injectedScriptManager.get())); |
| 104 | 104 |
| 105 m_agents.append(InspectorProfilerAgent::create(m_injectedScriptManager.get()
, 0)); | 105 m_agents->append(InspectorProfilerAgent::create(m_injectedScriptManager.get(
), 0)); |
| 106 m_agents.append(InspectorHeapProfilerAgent::create(m_injectedScriptManager.g
et())); | 106 m_agents->append(InspectorHeapProfilerAgent::create(m_injectedScriptManager.
get())); |
| 107 m_agents.append(WorkerConsoleAgent::create(timelineAgent.get(), m_injectedSc
riptManager.get())); | 107 m_agents->append(WorkerConsoleAgent::create(timelineAgent.get(), m_injectedS
criptManager.get())); |
| 108 m_agents.append(timelineAgent.release()); | 108 m_agents->append(timelineAgent.release()); |
| 109 | 109 |
| 110 m_injectedScriptManager->injectedScriptHost()->init(m_instrumentingAgents.ge
t(), m_debugServer.get()); | 110 m_injectedScriptManager->injectedScriptHost()->init(m_instrumentingAgents.ge
t(), m_debugServer.get()); |
| 111 } | 111 } |
| 112 | 112 |
| 113 WorkerInspectorController::~WorkerInspectorController() | 113 WorkerInspectorController::~WorkerInspectorController() |
| 114 { | 114 { |
| 115 m_instrumentingAgents->reset(); | 115 m_instrumentingAgents->reset(); |
| 116 disconnectFrontend(); | 116 disconnectFrontend(); |
| 117 } | 117 } |
| 118 | 118 |
| 119 void WorkerInspectorController::connectFrontend() | 119 void WorkerInspectorController::connectFrontend() |
| 120 { | 120 { |
| 121 ASSERT(!m_frontend); | 121 ASSERT(!m_frontend); |
| 122 m_state->unmute(); | 122 m_state->unmute(); |
| 123 m_frontendChannel = adoptPtr(new PageInspectorProxy(m_workerGlobalScope)); | 123 m_frontendChannel = adoptPtr(new PageInspectorProxy(m_workerGlobalScope)); |
| 124 m_frontend = adoptPtr(new InspectorFrontend(m_frontendChannel.get())); | 124 m_frontend = adoptPtr(new InspectorFrontend(m_frontendChannel.get())); |
| 125 m_backendDispatcher = InspectorBackendDispatcher::create(m_frontendChannel.g
et()); | 125 m_backendDispatcher = InspectorBackendDispatcher::create(m_frontendChannel.g
et()); |
| 126 m_agents.registerInDispatcher(m_backendDispatcher.get()); | 126 m_agents->registerInDispatcher(m_backendDispatcher.get()); |
| 127 m_agents.setFrontend(m_frontend.get()); | 127 m_agents->setFrontend(m_frontend.get()); |
| 128 InspectorInstrumentation::frontendCreated(); | 128 InspectorInstrumentation::frontendCreated(); |
| 129 } | 129 } |
| 130 | 130 |
| 131 void WorkerInspectorController::disconnectFrontend() | 131 void WorkerInspectorController::disconnectFrontend() |
| 132 { | 132 { |
| 133 if (!m_frontend) | 133 if (!m_frontend) |
| 134 return; | 134 return; |
| 135 m_backendDispatcher->clearFrontend(); | 135 m_backendDispatcher->clearFrontend(); |
| 136 m_backendDispatcher.clear(); | 136 m_backendDispatcher.clear(); |
| 137 // Destroying agents would change the state, but we don't want that. | 137 // Destroying agents would change the state, but we don't want that. |
| 138 // Pre-disconnect state will be used to restore inspector agents. | 138 // Pre-disconnect state will be used to restore inspector agents. |
| 139 m_state->mute(); | 139 m_state->mute(); |
| 140 m_agents.clearFrontend(); | 140 m_agents->clearFrontend(); |
| 141 m_frontend.clear(); | 141 m_frontend.clear(); |
| 142 InspectorInstrumentation::frontendDeleted(); | 142 InspectorInstrumentation::frontendDeleted(); |
| 143 m_frontendChannel.clear(); | 143 m_frontendChannel.clear(); |
| 144 } | 144 } |
| 145 | 145 |
| 146 void WorkerInspectorController::restoreInspectorStateFromCookie(const String& in
spectorCookie) | 146 void WorkerInspectorController::restoreInspectorStateFromCookie(const String& in
spectorCookie) |
| 147 { | 147 { |
| 148 ASSERT(!m_frontend); | 148 ASSERT(!m_frontend); |
| 149 connectFrontend(); | 149 connectFrontend(); |
| 150 m_state->loadFromCookie(inspectorCookie); | 150 m_state->loadFromCookie(inspectorCookie); |
| 151 | 151 |
| 152 m_agents.restore(); | 152 m_agents->restore(); |
| 153 } | 153 } |
| 154 | 154 |
| 155 void WorkerInspectorController::dispatchMessageFromFrontend(const String& messag
e) | 155 void WorkerInspectorController::dispatchMessageFromFrontend(const String& messag
e) |
| 156 { | 156 { |
| 157 if (m_backendDispatcher) | 157 if (m_backendDispatcher) |
| 158 m_backendDispatcher->dispatch(message); | 158 m_backendDispatcher->dispatch(message); |
| 159 } | 159 } |
| 160 | 160 |
| 161 void WorkerInspectorController::resume() | 161 void WorkerInspectorController::resume() |
| 162 { | 162 { |
| 163 if (WorkerRuntimeAgent* runtimeAgent = m_instrumentingAgents->workerRuntimeA
gent()) { | 163 if (WorkerRuntimeAgent* runtimeAgent = m_instrumentingAgents->workerRuntimeA
gent()) { |
| 164 ErrorString unused; | 164 ErrorString unused; |
| 165 runtimeAgent->run(&unused); | 165 runtimeAgent->run(&unused); |
| 166 } | 166 } |
| 167 } | 167 } |
| 168 | 168 |
| 169 } | 169 } |
| OLD | NEW |