| 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 WorkerInspectorController::WorkerInspectorController(WorkerContext* workerContex
t) | 90 WorkerInspectorController::WorkerInspectorController(WorkerContext* workerContex
t) |
| 91 : m_workerContext(workerContext) | 91 : m_workerContext(workerContext) |
| 92 , m_stateClient(adoptPtr(new WorkerStateClient(workerContext))) | 92 , m_stateClient(adoptPtr(new WorkerStateClient(workerContext))) |
| 93 , m_state(adoptPtr(new InspectorCompositeState(m_stateClient.get()))) | 93 , m_state(adoptPtr(new InspectorCompositeState(m_stateClient.get()))) |
| 94 , m_instrumentingAgents(InstrumentingAgents::create()) | 94 , m_instrumentingAgents(InstrumentingAgents::create()) |
| 95 , m_injectedScriptManager(InjectedScriptManager::createForWorker()) | 95 , m_injectedScriptManager(InjectedScriptManager::createForWorker()) |
| 96 , m_debugServer(adoptPtr(new WorkerScriptDebugServer(workerContext, WorkerDe
buggerAgent::debuggerTaskMode))) | 96 , m_debugServer(adoptPtr(new WorkerScriptDebugServer(workerContext, WorkerDe
buggerAgent::debuggerTaskMode))) |
| 97 { | 97 { |
| 98 m_agents.append(WorkerRuntimeAgent::create(m_instrumentingAgents.get(), m_st
ate.get(), m_injectedScriptManager.get(), m_debugServer.get(), workerContext)); | 98 m_agentFactories.append(WorkerRuntimeFactory::create(m_instrumentingAgents.g
et(), m_state.get(), m_injectedScriptManager.get(), m_debugServer.get(), workerC
ontext)); |
| 99 | 99 |
| 100 OwnPtr<InspectorConsoleAgent> consoleAgent = WorkerConsoleAgent::create(m_in
strumentingAgents.get(), m_state.get(), m_injectedScriptManager.get()); | 100 OwnPtr<WorkerConsoleFactory> consoleFactory = WorkerConsoleFactory::create(m
_instrumentingAgents.get(), m_state.get(), m_injectedScriptManager.get()); |
| 101 m_agents.append(WorkerDebuggerAgent::create(m_instrumentingAgents.get(), m_s
tate.get(), m_debugServer.get(), workerContext, m_injectedScriptManager.get())); | 101 m_agentFactories.append(WorkerDebuggerFactory::create(m_instrumentingAgents.
get(), m_state.get(), m_debugServer.get(), workerContext, m_injectedScriptManage
r.get())); |
| 102 | 102 |
| 103 m_agents.append(InspectorProfilerAgent::create(m_instrumentingAgents.get(),
consoleAgent.get(), m_state.get(), m_injectedScriptManager.get())); | 103 m_agentFactories.append(InspectorProfilerFactory::create(m_instrumentingAgen
ts.get(), m_state.get(), consoleFactory.get(), m_injectedScriptManager.get())); |
| 104 m_agents.append(InspectorHeapProfilerAgent::create(m_instrumentingAgents.get
(), m_state.get(), m_injectedScriptManager.get())); | 104 m_agentFactories.append(InspectorHeapProfilerFactory::create(m_instrumenting
Agents.get(), m_state.get(), m_injectedScriptManager.get())); |
| 105 m_agents.append(InspectorTimelineAgent::create(m_instrumentingAgents.get(),
0, 0, 0, m_state.get(), InspectorTimelineAgent::WorkerInspector, 0)); | 105 m_agentFactories.append(InspectorTimelineFactory::create(m_instrumentingAgen
ts.get(), m_state.get(), 0, 0, 0, InspectorTimelineAgent::WorkerInspector, 0)); |
| 106 m_agents.append(consoleAgent.release()); | 106 m_agentFactories.append(consoleFactory.release()); |
| 107 | 107 |
| 108 m_injectedScriptManager->injectedScriptHost()->init(m_instrumentingAgents.ge
t(), m_debugServer.get()); | 108 m_injectedScriptManager->injectedScriptHost()->init(m_instrumentingAgents.ge
t(), m_debugServer.get()); |
| 109 } | 109 } |
| 110 | 110 |
| 111 WorkerInspectorController::~WorkerInspectorController() | 111 WorkerInspectorController::~WorkerInspectorController() |
| 112 { | 112 { |
| 113 m_instrumentingAgents->reset(); | 113 m_instrumentingAgents->reset(); |
| 114 disconnectFrontend(); | 114 disconnectFrontend(); |
| 115 } | 115 } |
| 116 | 116 |
| 117 void WorkerInspectorController::connectFrontend() | 117 void WorkerInspectorController::connectFrontend() |
| 118 { | 118 { |
| 119 ASSERT(!m_frontend); | 119 ASSERT(!m_frontend); |
| 120 m_state->unmute(); | 120 m_state->unmute(); |
| 121 m_frontendChannel = adoptPtr(new PageInspectorProxy(m_workerContext)); | 121 m_frontendChannel = adoptPtr(new PageInspectorProxy(m_workerContext)); |
| 122 m_frontend = adoptPtr(new InspectorFrontend(m_frontendChannel.get())); | 122 m_frontend = adoptPtr(new InspectorFrontend(m_frontendChannel.get())); |
| 123 m_backendDispatcher = InspectorBackendDispatcher::create(m_frontendChannel.g
et()); | 123 m_backendDispatcher = InspectorBackendDispatcher::create(m_frontendChannel.g
et()); |
| 124 m_agents.registerInDispatcher(m_backendDispatcher.get()); | 124 m_agentFactories.registerInDispatcher(m_backendDispatcher.get()); |
| 125 m_agents.setFrontend(m_frontend.get()); | 125 m_agentFactories.setFrontend(m_frontend.get()); |
| 126 } | 126 } |
| 127 | 127 |
| 128 void WorkerInspectorController::disconnectFrontend() | 128 void WorkerInspectorController::disconnectFrontend() |
| 129 { | 129 { |
| 130 if (!m_frontend) | 130 if (!m_frontend) |
| 131 return; | 131 return; |
| 132 m_backendDispatcher->clearFrontend(); | 132 m_backendDispatcher->clearFrontend(); |
| 133 m_backendDispatcher.clear(); | 133 m_backendDispatcher.clear(); |
| 134 // Destroying agents would change the state, but we don't want that. | 134 // Destroying agents would change the state, but we don't want that. |
| 135 // Pre-disconnect state will be used to restore inspector agents. | 135 // Pre-disconnect state will be used to restore inspector agents. |
| 136 m_state->mute(); | 136 m_state->mute(); |
| 137 m_agents.clearFrontend(); | 137 m_agentFactories.clearFrontend(); |
| 138 m_frontend.clear(); | 138 m_frontend.clear(); |
| 139 m_frontendChannel.clear(); | 139 m_frontendChannel.clear(); |
| 140 } | 140 } |
| 141 | 141 |
| 142 void WorkerInspectorController::restoreInspectorStateFromCookie(const String& in
spectorCookie) | 142 void WorkerInspectorController::restoreInspectorStateFromCookie(const String& in
spectorCookie) |
| 143 { | 143 { |
| 144 ASSERT(!m_frontend); | 144 ASSERT(!m_frontend); |
| 145 connectFrontend(); | 145 connectFrontend(); |
| 146 m_state->loadFromCookie(inspectorCookie); | 146 m_state->loadFromCookie(inspectorCookie); |
| 147 | 147 |
| 148 m_agents.restore(); | 148 m_agentFactories.restore(); |
| 149 } | 149 } |
| 150 | 150 |
| 151 void WorkerInspectorController::dispatchMessageFromFrontend(const String& messag
e) | 151 void WorkerInspectorController::dispatchMessageFromFrontend(const String& messag
e) |
| 152 { | 152 { |
| 153 if (m_backendDispatcher) | 153 if (m_backendDispatcher) |
| 154 m_backendDispatcher->dispatch(message); | 154 m_backendDispatcher->dispatch(message); |
| 155 } | 155 } |
| 156 | 156 |
| 157 void WorkerInspectorController::resume() | 157 void WorkerInspectorController::resume() |
| 158 { | 158 { |
| 159 if (WorkerRuntimeAgent* runtimeAgent = m_instrumentingAgents->workerRuntimeA
gent()) { | 159 if (WorkerRuntimeAgent* runtimeAgent = m_instrumentingAgents->workerRuntimeA
gent()) { |
| 160 ErrorString unused; | 160 ErrorString unused; |
| 161 runtimeAgent->run(&unused); | 161 runtimeAgent->run(&unused); |
| 162 } | 162 } |
| 163 } | 163 } |
| 164 | 164 |
| 165 } | 165 } |
| OLD | NEW |