Web Inspector: Extract InspectorFrontendDispatchers from InspectorFrontend
authorjoepeck@webkit.org <joepeck@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 13 Nov 2013 22:58:16 +0000 (22:58 +0000)
committerjoepeck@webkit.org <joepeck@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 13 Nov 2013 22:58:16 +0000 (22:58 +0000)
https://bugs.webkit.org/show_bug.cgi?id=124246

Reviewed by NOBODY (OOPS!).

No new tests, this is just refactoring without changing functionality.
Set of changes made:

  - Remove "class InspectorFrontend" that currently does nothing but hold
    sub-frontend dispatcher classes. Catches some stale code.
  - Generate individual "class InspectorFooFrontendDispatcher" classes for
    domains that have events. Catches some unnecessary classes.
  - Simplify the Base Agent interface from optional set/clearFrontend/register
    to required didCreateFrontendAndBackend/willDestroyFrontendAndBackend.
    New agents must implement this and this will be their cue to setup
    frontend and backend dispatchers.
  - Base Agent no longer needs to be templated or have an Interface class.
  - While we are changing subclass BaseAgent superclass calls, use ASCIILiteral
  - In agents with events, convert "InspectorFrontend::Foo* m_frontend" to
    "unique_ptr<InspectorFooFrontendDispatcher> m_frontendDispatcher" and
    update uses as appropriate within the classes.
  - In agents with events, create dispatchers in didCreateFrontendAndBackend
    and clear them in willDestroyFrontendAndBackend.

* inspector/CodeGeneratorInspector.py:
(Generator):
(Generator.go):
(Generator.process_event):
* inspector/CodeGeneratorInspectorStrings.py:
(InspectorFrontendChannel):
* inspector/ConsoleMessage.cpp:
(WebCore::ConsoleMessage::addToFrontend):
(WebCore::ConsoleMessage::updateRepeatCountInConsole):
* inspector/ConsoleMessage.h:
* inspector/InjectedScriptHost.h:
* inspector/InspectorAgent.cpp:
(WebCore::InspectorAgent::InspectorAgent):
(WebCore::InspectorAgent::didCreateFrontendAndBackend):
(WebCore::InspectorAgent::willDestroyFrontendAndBackend):
(WebCore::InspectorAgent::enable):
(WebCore::InspectorAgent::evaluateForTestInFrontend):
(WebCore::InspectorAgent::inspect):
* inspector/InspectorAgent.h:
(WebCore::InspectorAgent::hasFrontend):
* inspector/InspectorAgentRegistry.cpp:
(WebCore::InspectorAgentRegistry::append):
(WebCore::InspectorAgentRegistry::didCreateFrontendAndBackend):
(WebCore::InspectorAgentRegistry::willDestroyFrontendAndBackend):
* inspector/InspectorAgentRegistry.h:
* inspector/InspectorApplicationCacheAgent.cpp:
(WebCore::InspectorApplicationCacheAgent::InspectorApplicationCacheAgent):
(WebCore::InspectorApplicationCacheAgent::didCreateFrontendAndBackend):
(WebCore::InspectorApplicationCacheAgent::willDestroyFrontendAndBackend):
(WebCore::InspectorApplicationCacheAgent::updateApplicationCacheStatus):
(WebCore::InspectorApplicationCacheAgent::networkStateChanged):
* inspector/InspectorApplicationCacheAgent.h:
* inspector/InspectorBaseAgent.h:
(WebCore::InspectorBaseAgent::discardAgent):
(WebCore::InspectorBaseAgent::InspectorBaseAgent):
* inspector/InspectorCSSAgent.cpp:
(WebCore::InspectorCSSAgent::InspectorCSSAgent):
(WebCore::InspectorCSSAgent::didCreateFrontendAndBackend):
(WebCore::InspectorCSSAgent::willDestroyFrontendAndBackend):
(WebCore::InspectorCSSAgent::mediaQueryResultChanged):
(WebCore::InspectorCSSAgent::didCreateNamedFlow):
(WebCore::InspectorCSSAgent::willRemoveNamedFlow):
(WebCore::InspectorCSSAgent::regionLayoutUpdated):
(WebCore::InspectorCSSAgent::regionOversetChanged):
(WebCore::InspectorCSSAgent::didRegisterNamedFlowContentElement):
(WebCore::InspectorCSSAgent::didUnregisterNamedFlowContentElement):
(WebCore::InspectorCSSAgent::stopSelectorProfilerImpl):
(WebCore::InspectorCSSAgent::styleSheetChanged):
* inspector/InspectorCSSAgent.h:
* inspector/InspectorCanvasAgent.cpp:
(WebCore::InspectorCanvasAgent::InspectorCanvasAgent):
(WebCore::InspectorCanvasAgent::didCreateFrontendAndBackend):
(WebCore::InspectorCanvasAgent::willDestroyFrontendAndBackend):
(WebCore::InspectorCanvasAgent::notifyRenderingContextWasWrapped):
(WebCore::InspectorCanvasAgent::findFramesWithUninstrumentedCanvases):
(WebCore::InspectorCanvasAgent::frameNavigated):
* inspector/InspectorCanvasAgent.h:
* inspector/InspectorConsoleAgent.cpp:
(WebCore::InspectorConsoleAgent::InspectorConsoleAgent):
(WebCore::InspectorConsoleAgent::enable):
(WebCore::InspectorConsoleAgent::clearMessages):
(WebCore::InspectorConsoleAgent::didCreateFrontendAndBackend):
(WebCore::InspectorConsoleAgent::willDestroyFrontendAndBackend):
(WebCore::InspectorConsoleAgent::addMessageToConsole):
(WebCore::InspectorConsoleAgent::didFinishXHRLoading):
(WebCore::InspectorConsoleAgent::addConsoleMessage):
* inspector/InspectorConsoleAgent.h:
* inspector/InspectorController.cpp:
(WebCore::InspectorController::InspectorController):
(WebCore::InspectorController::connectFrontend):
(WebCore::InspectorController::disconnectFrontend):
(WebCore::InspectorController::show):
(WebCore::InspectorController::close):
* inspector/InspectorController.h:
(WebCore::InspectorController::hasFrontend):
* inspector/InspectorDOMAgent.cpp:
(WebCore::InspectorDOMAgent::InspectorDOMAgent):
(WebCore::InspectorDOMAgent::didCreateFrontendAndBackend):
(WebCore::InspectorDOMAgent::willDestroyFrontendAndBackend):
(WebCore::InspectorDOMAgent::setDocument):
(WebCore::InspectorDOMAgent::pushChildNodesToFrontend):
(WebCore::InspectorDOMAgent::pushNodePathToFrontend):
(WebCore::InspectorDOMAgent::focusNode):
(WebCore::InspectorDOMAgent::mainFrameDOMContentLoaded):
(WebCore::InspectorDOMAgent::didCommitLoad):
(WebCore::InspectorDOMAgent::didInsertDOMNode):
(WebCore::InspectorDOMAgent::didRemoveDOMNode):
(WebCore::InspectorDOMAgent::didModifyDOMAttr):
(WebCore::InspectorDOMAgent::didRemoveDOMAttr):
(WebCore::InspectorDOMAgent::styleAttributeInvalidated):
(WebCore::InspectorDOMAgent::characterDataModified):
(WebCore::InspectorDOMAgent::didPushShadowRoot):
(WebCore::InspectorDOMAgent::willPopShadowRoot):
* inspector/InspectorDOMAgent.h:
* inspector/InspectorDOMDebuggerAgent.cpp:
(WebCore::InspectorDOMDebuggerAgent::InspectorDOMDebuggerAgent):
(WebCore::InspectorDOMDebuggerAgent::didCreateFrontendAndBackend):
(WebCore::InspectorDOMDebuggerAgent::willDestroyFrontendAndBackend):
(WebCore::InspectorDOMDebuggerAgent::didInvalidateStyleAttr):
(WebCore::InspectorDOMDebuggerAgent::willInsertDOMNode):
(WebCore::InspectorDOMDebuggerAgent::willRemoveDOMNode):
(WebCore::InspectorDOMDebuggerAgent::willModifyDOMAttr):
(WebCore::InspectorDOMDebuggerAgent::pauseOnNativeEventIfNeeded):
(WebCore::InspectorDOMDebuggerAgent::willSendXMLHttpRequest):
* inspector/InspectorDOMDebuggerAgent.h:
* inspector/InspectorDOMStorageAgent.cpp:
(WebCore::InspectorDOMStorageAgent::InspectorDOMStorageAgent):
(WebCore::InspectorDOMStorageAgent::didCreateFrontendAndBackend):
(WebCore::InspectorDOMStorageAgent::willDestroyFrontendAndBackend):
(WebCore::InspectorDOMStorageAgent::didDispatchDOMStorageEvent):
* inspector/InspectorDOMStorageAgent.h:
* inspector/InspectorDatabaseAgent.cpp:
(WebCore::InspectorDatabaseAgent::didOpenDatabase):
(WebCore::InspectorDatabaseAgent::InspectorDatabaseAgent):
(WebCore::InspectorDatabaseAgent::didCreateFrontendAndBackend):
(WebCore::InspectorDatabaseAgent::willDestroyFrontendAndBackend):
(WebCore::InspectorDatabaseAgent::enable):
* inspector/InspectorDatabaseAgent.h:
* inspector/InspectorDatabaseResource.cpp:
(WebCore::InspectorDatabaseResource::bind):
* inspector/InspectorDatabaseResource.h:
* inspector/InspectorDebuggerAgent.cpp:
(WebCore::InspectorDebuggerAgent::InspectorDebuggerAgent):
(WebCore::InspectorDebuggerAgent::enable):
(WebCore::InspectorDebuggerAgent::didCreateFrontendAndBackend):
(WebCore::InspectorDebuggerAgent::willDestroyFrontendAndBackend):
(WebCore::InspectorDebuggerAgent::addMessageToConsole):
(WebCore::InspectorDebuggerAgent::schedulePauseOnNextStatement):
(WebCore::InspectorDebuggerAgent::scriptExecutionBlockedByCSP):
(WebCore::InspectorDebuggerAgent::didParseSource):
(WebCore::InspectorDebuggerAgent::failedToParseSource):
(WebCore::InspectorDebuggerAgent::didPause):
(WebCore::InspectorDebuggerAgent::didContinue):
(WebCore::InspectorDebuggerAgent::breakProgram):
(WebCore::InspectorDebuggerAgent::clearBreakDetails):
(WebCore::InspectorDebuggerAgent::reset):
* inspector/InspectorDebuggerAgent.h:
* inspector/InspectorHeapProfilerAgent.cpp:
(WebCore::InspectorHeapProfilerAgent::InspectorHeapProfilerAgent):
(WebCore::InspectorHeapProfilerAgent::resetFrontendProfiles):
(WebCore::InspectorHeapProfilerAgent::didCreateFrontendAndBackend):
(WebCore::InspectorHeapProfilerAgent::willDestroyFrontendAndBackend):
(WebCore::InspectorHeapProfilerAgent::getHeapSnapshot):
(WebCore::InspectorHeapProfilerAgent::takeHeapSnapshot):
* inspector/InspectorHeapProfilerAgent.h:
* inspector/InspectorIndexedDBAgent.cpp:
(WebCore::InspectorIndexedDBAgent::InspectorIndexedDBAgent):
(WebCore::InspectorIndexedDBAgent::didCreateFrontendAndBackend):
(WebCore::InspectorIndexedDBAgent::willDestroyFrontendAndBackend):
* inspector/InspectorIndexedDBAgent.h:
* inspector/InspectorInputAgent.cpp:
(WebCore::InspectorInputAgent::InspectorInputAgent):
(WebCore::InspectorInputAgent::didCreateFrontendAndBackend):
(WebCore::InspectorInputAgent::willDestroyFrontendAndBackend):
* inspector/InspectorInputAgent.h:
* inspector/InspectorLayerTreeAgent.cpp:
(WebCore::InspectorLayerTreeAgent::InspectorLayerTreeAgent):
(WebCore::InspectorLayerTreeAgent::didCreateFrontendAndBackend):
(WebCore::InspectorLayerTreeAgent::willDestroyFrontendAndBackend):
(WebCore::InspectorLayerTreeAgent::layerTreeDidChange):
* inspector/InspectorLayerTreeAgent.h:
* inspector/InspectorMemoryAgent.cpp:
(WebCore::InspectorMemoryAgent::didCreateFrontendAndBackend):
(WebCore::InspectorMemoryAgent::willDestroyFrontendAndBackend):
(WebCore::InspectorMemoryAgent::InspectorMemoryAgent):
* inspector/InspectorMemoryAgent.h:
* inspector/InspectorPageAgent.cpp:
(WebCore::InspectorPageAgent::InspectorPageAgent):
(WebCore::InspectorPageAgent::didCreateFrontendAndBackend):
(WebCore::InspectorPageAgent::willDestroyFrontendAndBackend):
(WebCore::InspectorPageAgent::didClearWindowObjectInWorld):
(WebCore::InspectorPageAgent::domContentEventFired):
(WebCore::InspectorPageAgent::loadEventFired):
(WebCore::InspectorPageAgent::frameNavigated):
(WebCore::InspectorPageAgent::frameDetached):
(WebCore::InspectorPageAgent::frameStartedLoading):
(WebCore::InspectorPageAgent::frameStoppedLoading):
(WebCore::InspectorPageAgent::frameScheduledNavigation):
(WebCore::InspectorPageAgent::frameClearedScheduledNavigation):
(WebCore::InspectorPageAgent::willRunJavaScriptDialog):
(WebCore::InspectorPageAgent::didRunJavaScriptDialog):
(WebCore::InspectorPageAgent::scriptsEnabled):
* inspector/InspectorPageAgent.h:
* inspector/InspectorProfilerAgent.cpp:
(WebCore::InspectorProfilerAgent::InspectorProfilerAgent):
(WebCore::InspectorProfilerAgent::addProfile):
(WebCore::InspectorProfilerAgent::addProfileFinishedMessageToConsole):
(WebCore::InspectorProfilerAgent::addStartProfilingMessageToConsole):
(WebCore::InspectorProfilerAgent::getHeapSnapshot):
(WebCore::InspectorProfilerAgent::resetFrontendProfiles):
(WebCore::InspectorProfilerAgent::didCreateFrontendAndBackend):
(WebCore::InspectorProfilerAgent::willDestroyFrontendAndBackend):
(WebCore::InspectorProfilerAgent::takeHeapSnapshot):
(WebCore::InspectorProfilerAgent::toggleRecordButton):
* inspector/InspectorProfilerAgent.h:
* inspector/InspectorResourceAgent.cpp:
(WebCore::InspectorResourceAgent::didCreateFrontendAndBackend):
(WebCore::InspectorResourceAgent::willDestroyFrontendAndBackend):
(WebCore::InspectorResourceAgent::willSendRequest):
(WebCore::InspectorResourceAgent::markResourceAsCached):
(WebCore::InspectorResourceAgent::didReceiveResponse):
(WebCore::InspectorResourceAgent::didReceiveData):
(WebCore::InspectorResourceAgent::didFinishLoading):
(WebCore::InspectorResourceAgent::didFailLoading):
(WebCore::InspectorResourceAgent::didLoadResourceFromMemoryCache):
(WebCore::InspectorResourceAgent::didCreateWebSocket):
(WebCore::InspectorResourceAgent::willSendWebSocketHandshakeRequest):
(WebCore::InspectorResourceAgent::didReceiveWebSocketHandshakeResponse):
(WebCore::InspectorResourceAgent::didCloseWebSocket):
(WebCore::InspectorResourceAgent::didReceiveWebSocketFrame):
(WebCore::InspectorResourceAgent::didSendWebSocketFrame):
(WebCore::InspectorResourceAgent::didReceiveWebSocketFrameError):
(WebCore::InspectorResourceAgent::enable):
(WebCore::InspectorResourceAgent::InspectorResourceAgent):
* inspector/InspectorResourceAgent.h:
* inspector/InspectorRuntimeAgent.cpp:
(WebCore::InspectorRuntimeAgent::InspectorRuntimeAgent):
* inspector/InspectorRuntimeAgent.h:
* inspector/InspectorTimelineAgent.cpp:
(WebCore::InspectorTimelineAgent::~InspectorTimelineAgent):
(WebCore::InspectorTimelineAgent::didCreateFrontendAndBackend):
(WebCore::InspectorTimelineAgent::willDestroyFrontendAndBackend):
(WebCore::InspectorTimelineAgent::start):
(WebCore::InspectorTimelineAgent::InspectorTimelineAgent):
(WebCore::InspectorTimelineAgent::sendEvent):
* inspector/InspectorTimelineAgent.h:
* inspector/InspectorWorkerAgent.cpp:
(WebCore::InspectorWorkerAgent::WorkerFrontendChannel::WorkerFrontendChannel):
(WebCore::InspectorWorkerAgent::WorkerFrontendChannel::dispatchMessageFromWorker):
(WebCore::InspectorWorkerAgent::InspectorWorkerAgent):
(WebCore::InspectorWorkerAgent::didCreateFrontendAndBackend):
(WebCore::InspectorWorkerAgent::willDestroyFrontendAndBackend):
(WebCore::InspectorWorkerAgent::enable):
(WebCore::InspectorWorkerAgent::disable):
(WebCore::InspectorWorkerAgent::didStartWorkerGlobalScope):
(WebCore::InspectorWorkerAgent::workerGlobalScopeTerminated):
(WebCore::InspectorWorkerAgent::createWorkerFrontendChannel):
* inspector/InspectorWorkerAgent.h:
* inspector/PageRuntimeAgent.cpp:
(WebCore::PageRuntimeAgent::PageRuntimeAgent):
(WebCore::PageRuntimeAgent::didCreateFrontendAndBackend):
(WebCore::PageRuntimeAgent::willDestroyFrontendAndBackend):
(WebCore::PageRuntimeAgent::didCreateMainWorldContext):
(WebCore::PageRuntimeAgent::didCreateIsolatedContext):
(WebCore::PageRuntimeAgent::notifyContextCreated):
* inspector/PageRuntimeAgent.h:
* inspector/TimelineRecordFactory.h:
* inspector/WorkerInspectorController.cpp:
(WebCore::WorkerInspectorController::connectFrontend):
(WebCore::WorkerInspectorController::disconnectFrontend):
* inspector/WorkerInspectorController.h:
(WebCore::WorkerInspectorController::hasFrontend):
* inspector/WorkerRuntimeAgent.cpp:
(WebCore::WorkerRuntimeAgent::didCreateFrontendAndBackend):
(WebCore::WorkerRuntimeAgent::willDestroyFrontendAndBackend):
* inspector/WorkerRuntimeAgent.h:
* inspector/protocol/Input.json:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@159243 268f45cc-cd09-0410-ab3c-d52691b4dbfc

63 files changed:
Source/WebCore/ChangeLog
Source/WebCore/inspector/CodeGeneratorInspector.py
Source/WebCore/inspector/CodeGeneratorInspectorStrings.py
Source/WebCore/inspector/ConsoleMessage.cpp
Source/WebCore/inspector/ConsoleMessage.h
Source/WebCore/inspector/InjectedScriptHost.h
Source/WebCore/inspector/InspectorAgent.cpp
Source/WebCore/inspector/InspectorAgent.h
Source/WebCore/inspector/InspectorAgentRegistry.cpp
Source/WebCore/inspector/InspectorAgentRegistry.h
Source/WebCore/inspector/InspectorApplicationCacheAgent.cpp
Source/WebCore/inspector/InspectorApplicationCacheAgent.h
Source/WebCore/inspector/InspectorBaseAgent.h
Source/WebCore/inspector/InspectorCSSAgent.cpp
Source/WebCore/inspector/InspectorCSSAgent.h
Source/WebCore/inspector/InspectorCanvasAgent.cpp
Source/WebCore/inspector/InspectorCanvasAgent.h
Source/WebCore/inspector/InspectorConsoleAgent.cpp
Source/WebCore/inspector/InspectorConsoleAgent.h
Source/WebCore/inspector/InspectorController.cpp
Source/WebCore/inspector/InspectorController.h
Source/WebCore/inspector/InspectorDOMAgent.cpp
Source/WebCore/inspector/InspectorDOMAgent.h
Source/WebCore/inspector/InspectorDOMDebuggerAgent.cpp
Source/WebCore/inspector/InspectorDOMDebuggerAgent.h
Source/WebCore/inspector/InspectorDOMStorageAgent.cpp
Source/WebCore/inspector/InspectorDOMStorageAgent.h
Source/WebCore/inspector/InspectorDatabaseAgent.cpp
Source/WebCore/inspector/InspectorDatabaseAgent.h
Source/WebCore/inspector/InspectorDatabaseResource.cpp
Source/WebCore/inspector/InspectorDatabaseResource.h
Source/WebCore/inspector/InspectorDebuggerAgent.cpp
Source/WebCore/inspector/InspectorDebuggerAgent.h
Source/WebCore/inspector/InspectorHeapProfilerAgent.cpp
Source/WebCore/inspector/InspectorHeapProfilerAgent.h
Source/WebCore/inspector/InspectorIndexedDBAgent.cpp
Source/WebCore/inspector/InspectorIndexedDBAgent.h
Source/WebCore/inspector/InspectorInputAgent.cpp
Source/WebCore/inspector/InspectorInputAgent.h
Source/WebCore/inspector/InspectorLayerTreeAgent.cpp
Source/WebCore/inspector/InspectorLayerTreeAgent.h
Source/WebCore/inspector/InspectorMemoryAgent.cpp
Source/WebCore/inspector/InspectorMemoryAgent.h
Source/WebCore/inspector/InspectorPageAgent.cpp
Source/WebCore/inspector/InspectorPageAgent.h
Source/WebCore/inspector/InspectorProfilerAgent.cpp
Source/WebCore/inspector/InspectorProfilerAgent.h
Source/WebCore/inspector/InspectorResourceAgent.cpp
Source/WebCore/inspector/InspectorResourceAgent.h
Source/WebCore/inspector/InspectorRuntimeAgent.cpp
Source/WebCore/inspector/InspectorRuntimeAgent.h
Source/WebCore/inspector/InspectorTimelineAgent.cpp
Source/WebCore/inspector/InspectorTimelineAgent.h
Source/WebCore/inspector/InspectorWorkerAgent.cpp
Source/WebCore/inspector/InspectorWorkerAgent.h
Source/WebCore/inspector/PageRuntimeAgent.cpp
Source/WebCore/inspector/PageRuntimeAgent.h
Source/WebCore/inspector/TimelineRecordFactory.h
Source/WebCore/inspector/WorkerInspectorController.cpp
Source/WebCore/inspector/WorkerInspectorController.h
Source/WebCore/inspector/WorkerRuntimeAgent.cpp
Source/WebCore/inspector/WorkerRuntimeAgent.h
Source/WebCore/inspector/protocol/Input.json

index 2980e59..0685094 100644 (file)
@@ -1,3 +1,287 @@
+2013-11-13  Joseph Pecoraro  <pecoraro@apple.com>
+
+        Web Inspector: Extract InspectorFrontendDispatchers from InspectorFrontend
+        https://bugs.webkit.org/show_bug.cgi?id=124246
+
+        Reviewed by Timothy Hatcher.
+
+        No new tests, this is just refactoring without changing functionality.
+        Set of changes made:
+
+          - Remove "class InspectorFrontend" that currently does nothing but hold
+            sub-frontend dispatcher classes. Catches some stale code.
+          - Generate individual "class InspectorFooFrontendDispatcher" classes for
+            domains that have events. Catches some unnecessary classes.
+          - Simplify the Base Agent interface from optional set/clearFrontend/register
+            to required didCreateFrontendAndBackend/willDestroyFrontendAndBackend.
+            New agents must implement this and this will be their cue to setup
+            frontend and backend dispatchers.
+          - Base Agent no longer needs to be templated or have an Interface class.
+          - While we are changing subclass BaseAgent superclass calls, use ASCIILiteral
+          - In agents with events, convert "InspectorFrontend::Foo* m_frontend" to
+            "unique_ptr<InspectorFooFrontendDispatcher> m_frontendDispatcher" and
+            update uses as appropriate within the classes.
+          - In agents with events, create dispatchers in didCreateFrontendAndBackend
+            and clear them in willDestroyFrontendAndBackend.
+
+        * inspector/CodeGeneratorInspector.py:
+        (Generator):
+        (Generator.go):
+        (Generator.process_event):
+        * inspector/CodeGeneratorInspectorStrings.py:
+        (InspectorFrontendChannel):
+        * inspector/ConsoleMessage.cpp:
+        (WebCore::ConsoleMessage::addToFrontend):
+        (WebCore::ConsoleMessage::updateRepeatCountInConsole):
+        * inspector/ConsoleMessage.h:
+        * inspector/InjectedScriptHost.h:
+        * inspector/InspectorAgent.cpp:
+        (WebCore::InspectorAgent::InspectorAgent):
+        (WebCore::InspectorAgent::didCreateFrontendAndBackend):
+        (WebCore::InspectorAgent::willDestroyFrontendAndBackend):
+        (WebCore::InspectorAgent::enable):
+        (WebCore::InspectorAgent::evaluateForTestInFrontend):
+        (WebCore::InspectorAgent::inspect):
+        * inspector/InspectorAgent.h:
+        (WebCore::InspectorAgent::hasFrontend):
+        * inspector/InspectorAgentRegistry.cpp:
+        (WebCore::InspectorAgentRegistry::append):
+        (WebCore::InspectorAgentRegistry::didCreateFrontendAndBackend):
+        (WebCore::InspectorAgentRegistry::willDestroyFrontendAndBackend):
+        * inspector/InspectorAgentRegistry.h:
+        * inspector/InspectorApplicationCacheAgent.cpp:
+        (WebCore::InspectorApplicationCacheAgent::InspectorApplicationCacheAgent):
+        (WebCore::InspectorApplicationCacheAgent::didCreateFrontendAndBackend):
+        (WebCore::InspectorApplicationCacheAgent::willDestroyFrontendAndBackend):
+        (WebCore::InspectorApplicationCacheAgent::updateApplicationCacheStatus):
+        (WebCore::InspectorApplicationCacheAgent::networkStateChanged):
+        * inspector/InspectorApplicationCacheAgent.h:
+        * inspector/InspectorBaseAgent.h:
+        (WebCore::InspectorBaseAgent::discardAgent):
+        (WebCore::InspectorBaseAgent::InspectorBaseAgent):
+        * inspector/InspectorCSSAgent.cpp:
+        (WebCore::InspectorCSSAgent::InspectorCSSAgent):
+        (WebCore::InspectorCSSAgent::didCreateFrontendAndBackend):
+        (WebCore::InspectorCSSAgent::willDestroyFrontendAndBackend):
+        (WebCore::InspectorCSSAgent::mediaQueryResultChanged):
+        (WebCore::InspectorCSSAgent::didCreateNamedFlow):
+        (WebCore::InspectorCSSAgent::willRemoveNamedFlow):
+        (WebCore::InspectorCSSAgent::regionLayoutUpdated):
+        (WebCore::InspectorCSSAgent::regionOversetChanged):
+        (WebCore::InspectorCSSAgent::didRegisterNamedFlowContentElement):
+        (WebCore::InspectorCSSAgent::didUnregisterNamedFlowContentElement):
+        (WebCore::InspectorCSSAgent::stopSelectorProfilerImpl):
+        (WebCore::InspectorCSSAgent::styleSheetChanged):
+        * inspector/InspectorCSSAgent.h:
+        * inspector/InspectorCanvasAgent.cpp:
+        (WebCore::InspectorCanvasAgent::InspectorCanvasAgent):
+        (WebCore::InspectorCanvasAgent::didCreateFrontendAndBackend):
+        (WebCore::InspectorCanvasAgent::willDestroyFrontendAndBackend):
+        (WebCore::InspectorCanvasAgent::notifyRenderingContextWasWrapped):
+        (WebCore::InspectorCanvasAgent::findFramesWithUninstrumentedCanvases):
+        (WebCore::InspectorCanvasAgent::frameNavigated):
+        * inspector/InspectorCanvasAgent.h:
+        * inspector/InspectorConsoleAgent.cpp:
+        (WebCore::InspectorConsoleAgent::InspectorConsoleAgent):
+        (WebCore::InspectorConsoleAgent::enable):
+        (WebCore::InspectorConsoleAgent::clearMessages):
+        (WebCore::InspectorConsoleAgent::didCreateFrontendAndBackend):
+        (WebCore::InspectorConsoleAgent::willDestroyFrontendAndBackend):
+        (WebCore::InspectorConsoleAgent::addMessageToConsole):
+        (WebCore::InspectorConsoleAgent::didFinishXHRLoading):
+        (WebCore::InspectorConsoleAgent::addConsoleMessage):
+        * inspector/InspectorConsoleAgent.h:
+        * inspector/InspectorController.cpp:
+        (WebCore::InspectorController::InspectorController):
+        (WebCore::InspectorController::connectFrontend):
+        (WebCore::InspectorController::disconnectFrontend):
+        (WebCore::InspectorController::show):
+        (WebCore::InspectorController::close):
+        * inspector/InspectorController.h:
+        (WebCore::InspectorController::hasFrontend):
+        * inspector/InspectorDOMAgent.cpp:
+        (WebCore::InspectorDOMAgent::InspectorDOMAgent):
+        (WebCore::InspectorDOMAgent::didCreateFrontendAndBackend):
+        (WebCore::InspectorDOMAgent::willDestroyFrontendAndBackend):
+        (WebCore::InspectorDOMAgent::setDocument):
+        (WebCore::InspectorDOMAgent::pushChildNodesToFrontend):
+        (WebCore::InspectorDOMAgent::pushNodePathToFrontend):
+        (WebCore::InspectorDOMAgent::focusNode):
+        (WebCore::InspectorDOMAgent::mainFrameDOMContentLoaded):
+        (WebCore::InspectorDOMAgent::didCommitLoad):
+        (WebCore::InspectorDOMAgent::didInsertDOMNode):
+        (WebCore::InspectorDOMAgent::didRemoveDOMNode):
+        (WebCore::InspectorDOMAgent::didModifyDOMAttr):
+        (WebCore::InspectorDOMAgent::didRemoveDOMAttr):
+        (WebCore::InspectorDOMAgent::styleAttributeInvalidated):
+        (WebCore::InspectorDOMAgent::characterDataModified):
+        (WebCore::InspectorDOMAgent::didPushShadowRoot):
+        (WebCore::InspectorDOMAgent::willPopShadowRoot):
+        * inspector/InspectorDOMAgent.h:
+        * inspector/InspectorDOMDebuggerAgent.cpp:
+        (WebCore::InspectorDOMDebuggerAgent::InspectorDOMDebuggerAgent):
+        (WebCore::InspectorDOMDebuggerAgent::didCreateFrontendAndBackend):
+        (WebCore::InspectorDOMDebuggerAgent::willDestroyFrontendAndBackend):
+        (WebCore::InspectorDOMDebuggerAgent::didInvalidateStyleAttr):
+        (WebCore::InspectorDOMDebuggerAgent::willInsertDOMNode):
+        (WebCore::InspectorDOMDebuggerAgent::willRemoveDOMNode):
+        (WebCore::InspectorDOMDebuggerAgent::willModifyDOMAttr):
+        (WebCore::InspectorDOMDebuggerAgent::pauseOnNativeEventIfNeeded):
+        (WebCore::InspectorDOMDebuggerAgent::willSendXMLHttpRequest):
+        * inspector/InspectorDOMDebuggerAgent.h:
+        * inspector/InspectorDOMStorageAgent.cpp:
+        (WebCore::InspectorDOMStorageAgent::InspectorDOMStorageAgent):
+        (WebCore::InspectorDOMStorageAgent::didCreateFrontendAndBackend):
+        (WebCore::InspectorDOMStorageAgent::willDestroyFrontendAndBackend):
+        (WebCore::InspectorDOMStorageAgent::didDispatchDOMStorageEvent):
+        * inspector/InspectorDOMStorageAgent.h:
+        * inspector/InspectorDatabaseAgent.cpp:
+        (WebCore::InspectorDatabaseAgent::didOpenDatabase):
+        (WebCore::InspectorDatabaseAgent::InspectorDatabaseAgent):
+        (WebCore::InspectorDatabaseAgent::didCreateFrontendAndBackend):
+        (WebCore::InspectorDatabaseAgent::willDestroyFrontendAndBackend):
+        (WebCore::InspectorDatabaseAgent::enable):
+        * inspector/InspectorDatabaseAgent.h:
+        * inspector/InspectorDatabaseResource.cpp:
+        (WebCore::InspectorDatabaseResource::bind):
+        * inspector/InspectorDatabaseResource.h:
+        * inspector/InspectorDebuggerAgent.cpp:
+        (WebCore::InspectorDebuggerAgent::InspectorDebuggerAgent):
+        (WebCore::InspectorDebuggerAgent::enable):
+        (WebCore::InspectorDebuggerAgent::didCreateFrontendAndBackend):
+        (WebCore::InspectorDebuggerAgent::willDestroyFrontendAndBackend):
+        (WebCore::InspectorDebuggerAgent::addMessageToConsole):
+        (WebCore::InspectorDebuggerAgent::schedulePauseOnNextStatement):
+        (WebCore::InspectorDebuggerAgent::scriptExecutionBlockedByCSP):
+        (WebCore::InspectorDebuggerAgent::didParseSource):
+        (WebCore::InspectorDebuggerAgent::failedToParseSource):
+        (WebCore::InspectorDebuggerAgent::didPause):
+        (WebCore::InspectorDebuggerAgent::didContinue):
+        (WebCore::InspectorDebuggerAgent::breakProgram):
+        (WebCore::InspectorDebuggerAgent::clearBreakDetails):
+        (WebCore::InspectorDebuggerAgent::reset):
+        * inspector/InspectorDebuggerAgent.h:
+        * inspector/InspectorHeapProfilerAgent.cpp:
+        (WebCore::InspectorHeapProfilerAgent::InspectorHeapProfilerAgent):
+        (WebCore::InspectorHeapProfilerAgent::resetFrontendProfiles):
+        (WebCore::InspectorHeapProfilerAgent::didCreateFrontendAndBackend):
+        (WebCore::InspectorHeapProfilerAgent::willDestroyFrontendAndBackend):
+        (WebCore::InspectorHeapProfilerAgent::getHeapSnapshot):
+        (WebCore::InspectorHeapProfilerAgent::takeHeapSnapshot):
+        * inspector/InspectorHeapProfilerAgent.h:
+        * inspector/InspectorIndexedDBAgent.cpp:
+        (WebCore::InspectorIndexedDBAgent::InspectorIndexedDBAgent):
+        (WebCore::InspectorIndexedDBAgent::didCreateFrontendAndBackend):
+        (WebCore::InspectorIndexedDBAgent::willDestroyFrontendAndBackend):
+        * inspector/InspectorIndexedDBAgent.h:
+        * inspector/InspectorInputAgent.cpp:
+        (WebCore::InspectorInputAgent::InspectorInputAgent):
+        (WebCore::InspectorInputAgent::didCreateFrontendAndBackend):
+        (WebCore::InspectorInputAgent::willDestroyFrontendAndBackend):
+        * inspector/InspectorInputAgent.h:
+        * inspector/InspectorLayerTreeAgent.cpp:
+        (WebCore::InspectorLayerTreeAgent::InspectorLayerTreeAgent):
+        (WebCore::InspectorLayerTreeAgent::didCreateFrontendAndBackend):
+        (WebCore::InspectorLayerTreeAgent::willDestroyFrontendAndBackend):
+        (WebCore::InspectorLayerTreeAgent::layerTreeDidChange):
+        * inspector/InspectorLayerTreeAgent.h:
+        * inspector/InspectorMemoryAgent.cpp:
+        (WebCore::InspectorMemoryAgent::didCreateFrontendAndBackend):
+        (WebCore::InspectorMemoryAgent::willDestroyFrontendAndBackend):
+        (WebCore::InspectorMemoryAgent::InspectorMemoryAgent):
+        * inspector/InspectorMemoryAgent.h:
+        * inspector/InspectorPageAgent.cpp:
+        (WebCore::InspectorPageAgent::InspectorPageAgent):
+        (WebCore::InspectorPageAgent::didCreateFrontendAndBackend):
+        (WebCore::InspectorPageAgent::willDestroyFrontendAndBackend):
+        (WebCore::InspectorPageAgent::didClearWindowObjectInWorld):
+        (WebCore::InspectorPageAgent::domContentEventFired):
+        (WebCore::InspectorPageAgent::loadEventFired):
+        (WebCore::InspectorPageAgent::frameNavigated):
+        (WebCore::InspectorPageAgent::frameDetached):
+        (WebCore::InspectorPageAgent::frameStartedLoading):
+        (WebCore::InspectorPageAgent::frameStoppedLoading):
+        (WebCore::InspectorPageAgent::frameScheduledNavigation):
+        (WebCore::InspectorPageAgent::frameClearedScheduledNavigation):
+        (WebCore::InspectorPageAgent::willRunJavaScriptDialog):
+        (WebCore::InspectorPageAgent::didRunJavaScriptDialog):
+        (WebCore::InspectorPageAgent::scriptsEnabled):
+        * inspector/InspectorPageAgent.h:
+        * inspector/InspectorProfilerAgent.cpp:
+        (WebCore::InspectorProfilerAgent::InspectorProfilerAgent):
+        (WebCore::InspectorProfilerAgent::addProfile):
+        (WebCore::InspectorProfilerAgent::addProfileFinishedMessageToConsole):
+        (WebCore::InspectorProfilerAgent::addStartProfilingMessageToConsole):
+        (WebCore::InspectorProfilerAgent::getHeapSnapshot):
+        (WebCore::InspectorProfilerAgent::resetFrontendProfiles):
+        (WebCore::InspectorProfilerAgent::didCreateFrontendAndBackend):
+        (WebCore::InspectorProfilerAgent::willDestroyFrontendAndBackend):
+        (WebCore::InspectorProfilerAgent::takeHeapSnapshot):
+        (WebCore::InspectorProfilerAgent::toggleRecordButton):
+        * inspector/InspectorProfilerAgent.h:
+        * inspector/InspectorResourceAgent.cpp:
+        (WebCore::InspectorResourceAgent::didCreateFrontendAndBackend):
+        (WebCore::InspectorResourceAgent::willDestroyFrontendAndBackend):
+        (WebCore::InspectorResourceAgent::willSendRequest):
+        (WebCore::InspectorResourceAgent::markResourceAsCached):
+        (WebCore::InspectorResourceAgent::didReceiveResponse):
+        (WebCore::InspectorResourceAgent::didReceiveData):
+        (WebCore::InspectorResourceAgent::didFinishLoading):
+        (WebCore::InspectorResourceAgent::didFailLoading):
+        (WebCore::InspectorResourceAgent::didLoadResourceFromMemoryCache):
+        (WebCore::InspectorResourceAgent::didCreateWebSocket):
+        (WebCore::InspectorResourceAgent::willSendWebSocketHandshakeRequest):
+        (WebCore::InspectorResourceAgent::didReceiveWebSocketHandshakeResponse):
+        (WebCore::InspectorResourceAgent::didCloseWebSocket):
+        (WebCore::InspectorResourceAgent::didReceiveWebSocketFrame):
+        (WebCore::InspectorResourceAgent::didSendWebSocketFrame):
+        (WebCore::InspectorResourceAgent::didReceiveWebSocketFrameError):
+        (WebCore::InspectorResourceAgent::enable):
+        (WebCore::InspectorResourceAgent::InspectorResourceAgent):
+        * inspector/InspectorResourceAgent.h:
+        * inspector/InspectorRuntimeAgent.cpp:
+        (WebCore::InspectorRuntimeAgent::InspectorRuntimeAgent):
+        * inspector/InspectorRuntimeAgent.h:
+        * inspector/InspectorTimelineAgent.cpp:
+        (WebCore::InspectorTimelineAgent::~InspectorTimelineAgent):
+        (WebCore::InspectorTimelineAgent::didCreateFrontendAndBackend):
+        (WebCore::InspectorTimelineAgent::willDestroyFrontendAndBackend):
+        (WebCore::InspectorTimelineAgent::start):
+        (WebCore::InspectorTimelineAgent::InspectorTimelineAgent):
+        (WebCore::InspectorTimelineAgent::sendEvent):
+        * inspector/InspectorTimelineAgent.h:
+        * inspector/InspectorWorkerAgent.cpp:
+        (WebCore::InspectorWorkerAgent::WorkerFrontendChannel::WorkerFrontendChannel):
+        (WebCore::InspectorWorkerAgent::WorkerFrontendChannel::dispatchMessageFromWorker):
+        (WebCore::InspectorWorkerAgent::InspectorWorkerAgent):
+        (WebCore::InspectorWorkerAgent::didCreateFrontendAndBackend):
+        (WebCore::InspectorWorkerAgent::willDestroyFrontendAndBackend):
+        (WebCore::InspectorWorkerAgent::enable):
+        (WebCore::InspectorWorkerAgent::disable):
+        (WebCore::InspectorWorkerAgent::didStartWorkerGlobalScope):
+        (WebCore::InspectorWorkerAgent::workerGlobalScopeTerminated):
+        (WebCore::InspectorWorkerAgent::createWorkerFrontendChannel):
+        * inspector/InspectorWorkerAgent.h:
+        * inspector/PageRuntimeAgent.cpp:
+        (WebCore::PageRuntimeAgent::PageRuntimeAgent):
+        (WebCore::PageRuntimeAgent::didCreateFrontendAndBackend):
+        (WebCore::PageRuntimeAgent::willDestroyFrontendAndBackend):
+        (WebCore::PageRuntimeAgent::didCreateMainWorldContext):
+        (WebCore::PageRuntimeAgent::didCreateIsolatedContext):
+        (WebCore::PageRuntimeAgent::notifyContextCreated):
+        * inspector/PageRuntimeAgent.h:
+        * inspector/TimelineRecordFactory.h:
+        * inspector/WorkerInspectorController.cpp:
+        (WebCore::WorkerInspectorController::connectFrontend):
+        (WebCore::WorkerInspectorController::disconnectFrontend):
+        * inspector/WorkerInspectorController.h:
+        (WebCore::WorkerInspectorController::hasFrontend):
+        * inspector/WorkerRuntimeAgent.cpp:
+        (WebCore::WorkerRuntimeAgent::didCreateFrontendAndBackend):
+        (WebCore::WorkerRuntimeAgent::willDestroyFrontendAndBackend):
+        * inspector/WorkerRuntimeAgent.h:
+        * inspector/protocol/Input.json:
+
 2013-11-13  Simon Fraser  <simon.fraser@apple.com>
 
         Rename FrameView's repaintFixedElementsAfterScrolling and updateFixedElementsAfterScrolling
index c2acb3d..b3b4c76 100755 (executable)
@@ -1723,7 +1723,8 @@ class Templates:
         return "/".join(components)
 
     file_header_ = ("// File is generated by %s\n\n" % get_this_script_path_(sys.argv[0]) +
-"""// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+"""// Copyright (c) 2013 Apple Inc. All Rights Reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 """)
@@ -1820,7 +1821,6 @@ def format_setter_value_expression(param_type_binding, value_ref):
         return value_ref
 
 class Generator:
-    frontend_class_field_lines = []
     frontend_domain_class_lines = []
 
     method_name_enum_list = []
@@ -1836,7 +1836,6 @@ class Generator:
     backend_setters_list = []
     backend_constructor_init_list = []
     backend_field_list = []
-    frontend_constructor_init_list = []
     type_builder_fragments = []
     type_builder_forwards = []
     validator_impl_list = []
@@ -1852,10 +1851,6 @@ class Generator:
             Generator.backend_method_implementation_list,
             Generator.backend_method_name_declaration_list,
             Generator.backend_agent_interface_list,
-            Generator.frontend_class_field_lines,
-            Generator.frontend_constructor_init_list,
-            Generator.frontend_domain_class_lines,
-            Generator.frontend_method_list,
             Generator.method_handler_list,
             Generator.method_name_enum_list,
             Generator.backend_constructor_init_list,
@@ -1897,17 +1892,20 @@ class Generator:
                                     Generator.process_enum(json_property, enum_name)
 
             if "events" in json_domain:
+                if domain_guard:
+                    domain_guard.generate_open(Generator.frontend_method_list)
+                    domain_guard.generate_open(Generator.frontend_domain_class_lines)
+
                 for json_event in json_domain["events"]:
                     Generator.process_event(json_event, domain_name, frontend_method_declaration_lines)
 
-            Generator.frontend_class_field_lines.append("    %s m_%s;\n" % (domain_name, domain_name_lower))
-            if Generator.frontend_constructor_init_list:
-                Generator.frontend_constructor_init_list.append("    , ")
-            Generator.frontend_constructor_init_list.append("m_%s(inspectorFrontendChannel)\n" % domain_name_lower)
-            Generator.frontend_domain_class_lines.append(Templates.frontend_domain_class.substitute(None,
-                domainClassName=domain_name,
-                domainFieldName=domain_name_lower,
-                frontendDomainMethodDeclarations="".join(flatten_list(frontend_method_declaration_lines))))
+                Generator.frontend_domain_class_lines.append(Templates.frontend_domain_class.substitute(None,
+                    domainClassName="Inspector%sFrontendDispatcher" % domain_name,
+                    frontendDomainMethodDeclarations="".join(flatten_list(frontend_method_declaration_lines))))
+
+                if domain_guard:
+                    domain_guard.generate_close(Generator.frontend_method_list)
+                    domain_guard.generate_close(Generator.frontend_domain_class_lines)
 
             agent_interface_name = Capitalizer.lower_camel_case_to_upper(domain_name) + "CommandHandler"
             Generator.backend_agent_interface_list.append("    class %s {\n" % agent_interface_name)
@@ -1961,7 +1959,7 @@ class Generator:
                 backend_js_event_param_list.append("\"%s\"" % parameter_name)
 
         frontend_method_declaration_lines.append(
-            "        void %s(%s);\n" % (event_name, ", ".join(decl_parameter_list)))
+            "    void %s(%s);\n" % (event_name, ", ".join(decl_parameter_list)))
 
         Generator.backend_js_domain_initializer_list.append("InspectorBackend.registerEvent(\"%s.%s\", [%s]);\n" % (
             domain_name, event_name, ", ".join(backend_js_event_param_list)))
@@ -2391,11 +2389,9 @@ backend_cpp_file.write(Templates.backend_cpp.substitute(None,
     messageHandlers="\n".join(Generator.method_handler_list)))
 
 frontend_h_file.write(Templates.frontend_h.substitute(None,
-    fieldDeclarations="".join(Generator.frontend_class_field_lines),
     domainClassList="".join(Generator.frontend_domain_class_lines)))
 
 frontend_cpp_file.write(Templates.frontend_cpp.substitute(None,
-    constructorInit="".join(Generator.frontend_constructor_init_list),
     methods="\n".join(Generator.frontend_method_list)))
 
 typebuilder_h_file.write(Templates.typebuilder_h.substitute(None,
index ed8eec4..9754e0f 100644 (file)
 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
-# THis file contains string resources for CodeGeneratorInspector.
+# This file contains string resources for CodeGeneratorInspector.
 # Its syntax is a Python syntax subset, suitable for manual parsing.
 
 frontend_domain_class = (
-"""    class $domainClassName {
-    public:
-        $domainClassName(InspectorFrontendChannel* inspectorFrontendChannel) : m_inspectorFrontendChannel(inspectorFrontendChannel) { }
-${frontendDomainMethodDeclarations}
-    protected:
-        InspectorFrontendChannel* m_inspectorFrontendChannel;
-    };
-
-    $domainClassName* $domainFieldName() { return &m_$domainFieldName; }
+"""class $domainClassName {
+public:
+    $domainClassName(InspectorFrontendChannel* inspectorFrontendChannel) : m_inspectorFrontendChannel(inspectorFrontendChannel) { }
+${frontendDomainMethodDeclarations}private:
+    InspectorFrontendChannel* m_inspectorFrontendChannel;
+};
 
 """)
 
@@ -62,7 +59,7 @@ ${responseCook}
 }
 """)
 
-frontend_method = ("""void InspectorFrontend::$domainName::$eventName($parameters)
+frontend_method = ("""void Inspector${domainName}FrontendDispatcher::$eventName($parameters)
 {
     RefPtr<InspectorObject> jsonMessage = InspectorObject::create();
     jsonMessage->setString("method", "$domainName.$eventName");
@@ -94,27 +91,14 @@ namespace WebCore {
 
 class InspectorFrontendChannel;
 
-// Both InspectorObject and InspectorArray may or may not be declared at this point as defined by ENABLED_INSPECTOR.
-// Double-check we have them at least as forward declaration.
-class InspectorArray;
-class InspectorObject;
-
-typedef String ErrorString;
-
 #if ENABLE(INSPECTOR)
 
-class InspectorFrontend {
-public:
-    InspectorFrontend(InspectorFrontendChannel*);
-
-
 $domainClassList
-private:
-${fieldDeclarations}};
 
 #endif // ENABLE(INSPECTOR)
 
 } // namespace WebCore
+
 #endif // !defined(InspectorFrontend_h)
 """)
 
@@ -205,12 +189,11 @@ backend_cpp = (
 #if ENABLE(INSPECTOR)
 
 #include "InspectorBackendDispatcher.h"
-#include <wtf/text/WTFString.h>
-#include <wtf/text/CString.h>
 
 #include "InspectorAgent.h"
 #include "InspectorValues.h"
 #include "InspectorFrontendChannel.h"
+#include <wtf/text/CString.h>
 #include <wtf/text/WTFString.h>
 
 namespace WebCore {
@@ -493,22 +476,17 @@ frontend_cpp = (
 """
 
 #include "config.h"
+
 #if ENABLE(INSPECTOR)
 
 #include "InspectorFrontend.h"
-#include <wtf/text/WTFString.h>
-#include <wtf/text/CString.h>
 
 #include "InspectorFrontendChannel.h"
-#include "InspectorValues.h"
+#include <wtf/text/CString.h>
 #include <wtf/text/WTFString.h>
 
 namespace WebCore {
 
-InspectorFrontend::InspectorFrontend(InspectorFrontendChannel* inspectorFrontendChannel)
-    : $constructorInit{
-}
-
 $methods
 
 } // namespace WebCore
index 9134b7f..0c970b8 100644 (file)
@@ -38,7 +38,6 @@
 #include "IdentifiersFactory.h"
 #include "InjectedScript.h"
 #include "InjectedScriptManager.h"
-#include "InspectorFrontend.h"
 #include "InspectorValues.h"
 #include "ScriptArguments.h"
 #include "ScriptCallFrame.h"
@@ -188,7 +187,7 @@ static TypeBuilder::Console::ConsoleMessage::Level::Enum messageLevelValue(Messa
     return TypeBuilder::Console::ConsoleMessage::Level::Log;
 }
 
-void ConsoleMessage::addToFrontend(InspectorFrontend::Console* frontend, InjectedScriptManager* injectedScriptManager, bool generatePreview)
+void ConsoleMessage::addToFrontend(InspectorConsoleFrontendDispatcher* consoleFrontendDispatcher, InjectedScriptManager* injectedScriptManager, bool generatePreview)
 {
     RefPtr<TypeBuilder::Console::ConsoleMessage> jsonObj = TypeBuilder::Console::ConsoleMessage::create()
         .setSource(messageSourceValue(m_source))
@@ -230,12 +229,12 @@ void ConsoleMessage::addToFrontend(InspectorFrontend::Console* frontend, Injecte
     }
     if (m_callStack)
         jsonObj->setStackTrace(m_callStack->buildInspectorArray());
-    frontend->messageAdded(jsonObj);
+    consoleFrontendDispatcher->messageAdded(jsonObj);
 }
 
-void ConsoleMessage::updateRepeatCountInConsole(InspectorFrontend::Console* frontend)
+void ConsoleMessage::updateRepeatCountInConsole(InspectorConsoleFrontendDispatcher* consoleFrontendDispatcher)
 {
-    frontend->messageRepeatCountUpdated(m_repeatCount);
+    consoleFrontendDispatcher->messageRepeatCountUpdated(m_repeatCount);
 }
 
 bool ConsoleMessage::isEqual(ConsoleMessage* msg) const
index cb26da0..07f88b6 100644 (file)
@@ -42,7 +42,6 @@ namespace WebCore {
 
 class DOMWindow;
 class InjectedScriptManager;
-class InspectorFrontend;
 class InspectorObject;
 class ScriptArguments;
 class ScriptCallFrame;
@@ -58,8 +57,8 @@ public:
     ConsoleMessage(bool canGenerateCallStack, MessageSource, MessageType, MessageLevel, const String& message, PassRefPtr<ScriptArguments>, JSC::ExecState*, unsigned long requestIdentifier = 0);
     ~ConsoleMessage();
 
-    void addToFrontend(InspectorFrontend::Console*, InjectedScriptManager*, bool generatePreview);
-    void updateRepeatCountInConsole(InspectorFrontend::Console*);
+    void addToFrontend(InspectorConsoleFrontendDispatcher*, InjectedScriptManager*, bool generatePreview);
+    void updateRepeatCountInConsole(InspectorConsoleFrontendDispatcher*);
     void incrementCount() { ++m_repeatCount; }
     bool isEqual(ConsoleMessage* msg) const;
 
index b911ed0..4a84182 100644 (file)
@@ -46,7 +46,6 @@ class InspectorDOMAgent;
 class InspectorDOMStorageAgent;
 class InspectorDatabaseAgent;
 class InspectorDebuggerAgent;
-class InspectorFrontend;
 class InspectorObject;
 class InspectorValue;
 class Node;
index a5c0102..4eadde4 100644 (file)
@@ -58,9 +58,8 @@
 namespace WebCore {
 
 InspectorAgent::InspectorAgent(Page* page, InjectedScriptManager* injectedScriptManager, InstrumentingAgents* instrumentingAgents)
-    : InspectorBaseAgent<InspectorAgent>("Inspector", instrumentingAgents)
+    : InspectorBaseAgent(ASCIILiteral("Inspector"), instrumentingAgents)
     , m_inspectedPage(page)
-    , m_frontend(0)
     , m_injectedScriptManager(injectedScriptManager)
     , m_enabled(false)
 {
@@ -94,15 +93,17 @@ void InspectorAgent::didClearWindowObjectInWorld(Frame* frame, DOMWrapperWorld&
     frame->script().executeScript(scriptSource.toString());
 }
 
-void InspectorAgent::setFrontend(InspectorFrontend* inspectorFrontend)
+void InspectorAgent::didCreateFrontendAndBackend(InspectorFrontendChannel* frontendChannel, InspectorBackendDispatcher* backendDispatcher)
 {
-    m_frontend = inspectorFrontend;
+    m_frontendDispatcher = std::make_unique<InspectorInspectorFrontendDispatcher>(frontendChannel);
+    backendDispatcher->registerAgent(this);
 }
 
-void InspectorAgent::clearFrontend()
+void InspectorAgent::willDestroyFrontendAndBackend()
 {
+    m_frontendDispatcher = nullptr;
+
     m_pendingEvaluateTestCommands.clear();
-    m_frontend = 0;
     m_injectedScriptManager->discardInjectedScripts();
     ErrorString error;
     disable(&error);
@@ -120,8 +121,8 @@ void InspectorAgent::enable(ErrorString*)
     if (m_pendingInspectData.first)
         inspect(m_pendingInspectData.first, m_pendingInspectData.second);
 
-    for (Vector<pair<long, String>>::iterator it = m_pendingEvaluateTestCommands.begin(); m_frontend && it != m_pendingEvaluateTestCommands.end(); ++it)
-        m_frontend->inspector()->evaluateForTestInFrontend(static_cast<int>((*it).first), (*it).second);
+    for (Vector<pair<long, String>>::iterator it = m_pendingEvaluateTestCommands.begin(); m_frontendDispatcher && it != m_pendingEvaluateTestCommands.end(); ++it)
+        m_frontendDispatcher->evaluateForTestInFrontend(static_cast<int>((*it).first), (*it).second);
     m_pendingEvaluateTestCommands.clear();
 }
 
@@ -137,8 +138,8 @@ void InspectorAgent::domContentLoadedEventFired()
 
 void InspectorAgent::evaluateForTestInFrontend(long callId, const String& script)
 {
-    if (m_enabled && m_frontend)
-        m_frontend->inspector()->evaluateForTestInFrontend(static_cast<int>(callId), script);
+    if (m_enabled && m_frontendDispatcher)
+        m_frontendDispatcher->evaluateForTestInFrontend(static_cast<int>(callId), script);
     else
         m_pendingEvaluateTestCommands.append(pair<long, String>(callId, script));
 }
@@ -150,8 +151,8 @@ void InspectorAgent::setInjectedScriptForOrigin(const String& origin, const Stri
 
 void InspectorAgent::inspect(PassRefPtr<TypeBuilder::Runtime::RemoteObject> objectToInspect, PassRefPtr<InspectorObject> hints)
 {
-    if (m_enabled && m_frontend) {
-        m_frontend->inspector()->inspect(objectToInspect, hints);
+    if (m_enabled && m_frontendDispatcher) {
+        m_frontendDispatcher->inspect(objectToInspect, hints);
         m_pendingInspectData.first = 0;
         m_pendingInspectData.second = 0;
         return;
index 28e3e8d..f8f3b06 100644 (file)
@@ -43,7 +43,7 @@ class DOMWrapperWorld;
 class DocumentLoader;
 class Frame;
 class InjectedScriptManager;
-class InspectorFrontend;
+class InspectorInspectorFrontendDispatcher;
 class InspectorObject;
 class InstrumentingAgents;
 class URL;
@@ -51,7 +51,7 @@ class Page;
 
 typedef String ErrorString;
 
-class InspectorAgent : public InspectorBaseAgent<InspectorAgent>, public InspectorBackendDispatcher::InspectorCommandHandler {
+class InspectorAgent : public InspectorBaseAgent, public InspectorBackendDispatcher::InspectorCommandHandler {
     WTF_MAKE_NONCOPYABLE(InspectorAgent);
 public:
     static PassOwnPtr<InspectorAgent> create(Page* page, InjectedScriptManager* injectedScriptManager, InstrumentingAgents* instrumentingAgents)
@@ -70,17 +70,15 @@ public:
     URL inspectedURL() const;
     URL inspectedURLWithoutFragment() const;
 
-    InspectorFrontend* frontend() const { return m_frontend; }
-
-    virtual void setFrontend(InspectorFrontend*);
-    virtual void clearFrontend();
+    virtual void didCreateFrontendAndBackend(InspectorFrontendChannel*, InspectorBackendDispatcher*) OVERRIDE;
+    virtual void willDestroyFrontendAndBackend() OVERRIDE;
 
     void didClearWindowObjectInWorld(Frame*, DOMWrapperWorld&);
 
     void didCommitLoad();
     void domContentLoadedEventFired();
 
-    bool hasFrontend() const { return m_frontend; }
+    bool hasFrontend() const { return !!m_frontendDispatcher; }
 
     // Generic code called from custom implementations.
     void evaluateForTestInFrontend(long testCallId, const String& script);
@@ -93,7 +91,7 @@ private:
     InspectorAgent(Page*, InjectedScriptManager*, InstrumentingAgents*);
 
     Page* m_inspectedPage;
-    InspectorFrontend* m_frontend;
+    std::unique_ptr<InspectorInspectorFrontendDispatcher> m_frontendDispatcher;
     InjectedScriptManager* m_injectedScriptManager;
 
     Vector<pair<long, String>> m_pendingEvaluateTestCommands;
index 60ed463..099d1a3 100644 (file)
 
 namespace WebCore {
 
-void InspectorAgentRegistry::append(PassOwnPtr<InspectorBaseAgentInterface> agent)
+void InspectorAgentRegistry::append(PassOwnPtr<InspectorBaseAgent> agent)
 {
     m_agents.append(agent);
 }
 
-void InspectorAgentRegistry::setFrontend(InspectorFrontend* frontend)
+void InspectorAgentRegistry::didCreateFrontendAndBackend(InspectorFrontendChannel* frontendChannel, InspectorBackendDispatcher* backendDispatcher)
 {
     for (size_t i = 0; i < m_agents.size(); i++)
-        m_agents[i]->setFrontend(frontend);
+        m_agents[i]->didCreateFrontendAndBackend(frontendChannel, backendDispatcher);
 }
 
-void InspectorAgentRegistry::clearFrontend()
+void InspectorAgentRegistry::willDestroyFrontendAndBackend()
 {
     for (size_t i = 0; i < m_agents.size(); i++)
-        m_agents[i]->clearFrontend();
-}
-
-void InspectorAgentRegistry::registerInDispatcher(InspectorBackendDispatcher* dispatcher)
-{
-    for (size_t i = 0; i < m_agents.size(); i++)
-        m_agents[i]->registerInDispatcher(dispatcher);
+        m_agents[i]->willDestroyFrontendAndBackend();
 }
 
 void InspectorAgentRegistry::discardAgents()
index 6092e18..4fd0353 100644 (file)
 namespace WebCore {
 
 class InspectorBackendDispatcher;
-class InspectorFrontend;
 
 class InspectorAgentRegistry {
 public:
-    void append(PassOwnPtr<InspectorBaseAgentInterface>);
+    void append(PassOwnPtr<InspectorBaseAgent>);
 
-    void setFrontend(InspectorFrontend*);
-    void clearFrontend();
-    void registerInDispatcher(InspectorBackendDispatcher*);
+    void didCreateFrontendAndBackend(InspectorFrontendChannel*, InspectorBackendDispatcher*);
+    void willDestroyFrontendAndBackend();
     void discardAgents();
 
 private:
-    Vector<OwnPtr<InspectorBaseAgentInterface>> m_agents;
+    Vector<OwnPtr<InspectorBaseAgent>> m_agents;
 };
 
 } // namespace WebCore
index 23478fc..75f25ae 100644 (file)
 namespace WebCore {
 
 InspectorApplicationCacheAgent::InspectorApplicationCacheAgent(InstrumentingAgents* instrumentingAgents, InspectorPageAgent* pageAgent)
-    : InspectorBaseAgent<InspectorApplicationCacheAgent>(ASCIILiteral("ApplicationCache"), instrumentingAgents)
+    : InspectorBaseAgent(ASCIILiteral("ApplicationCache"), instrumentingAgents)
     , m_pageAgent(pageAgent)
-    , m_frontend(0)
 {
 }
 
-void InspectorApplicationCacheAgent::setFrontend(InspectorFrontend* frontend)
+void InspectorApplicationCacheAgent::didCreateFrontendAndBackend(InspectorFrontendChannel* frontendChannel, InspectorBackendDispatcher* backendDispatcher)
 {
-    m_frontend = frontend->applicationcache();
+    m_frontendDispatcher = std::make_unique<InspectorApplicationCacheFrontendDispatcher>(frontendChannel);
+    backendDispatcher->registerAgent(this);
 }
 
-void InspectorApplicationCacheAgent::clearFrontend()
+void InspectorApplicationCacheAgent::willDestroyFrontendAndBackend()
 {
+    m_frontendDispatcher = nullptr;
+
     m_instrumentingAgents->setInspectorApplicationCacheAgent(0);
-    m_frontend = 0;
 }
 
 void InspectorApplicationCacheAgent::enable(ErrorString*)
@@ -81,13 +82,13 @@ void InspectorApplicationCacheAgent::updateApplicationCacheStatus(Frame* frame)
     ApplicationCacheHost::CacheInfo info = host->applicationCacheInfo();
 
     String manifestURL = info.m_manifest.string();
-    m_frontend->applicationCacheStatusUpdated(m_pageAgent->frameId(frame), manifestURL, static_cast<int>(status));
+    m_frontendDispatcher->applicationCacheStatusUpdated(m_pageAgent->frameId(frame), manifestURL, static_cast<int>(status));
 }
 
 void InspectorApplicationCacheAgent::networkStateChanged()
 {
     bool isNowOnline = networkStateNotifier().onLine();
-    m_frontend->networkStateUpdated(isNowOnline);
+    m_frontendDispatcher->networkStateUpdated(isNowOnline);
 }
 
 void InspectorApplicationCacheAgent::getFramesWithManifests(ErrorString*, RefPtr<TypeBuilder::Array<TypeBuilder::ApplicationCache::FrameWithManifest>>& result)
index 6ee3e14..e4faa11 100644 (file)
@@ -38,7 +38,7 @@ namespace WebCore {
 class Frame;
 class InspectorArray;
 class InspectorAgent;
-class InspectorFrontend;
+class InspectorApplicationCacheFrontendDispatcher;
 class InspectorObject;
 class InspectorPageAgent;
 class InspectorValue;
@@ -48,7 +48,7 @@ class ResourceResponse;
 
 typedef String ErrorString;
 
-class InspectorApplicationCacheAgent : public InspectorBaseAgent<InspectorApplicationCacheAgent>, public InspectorBackendDispatcher::ApplicationCacheCommandHandler {
+class InspectorApplicationCacheAgent : public InspectorBaseAgent, public InspectorBackendDispatcher::ApplicationCacheCommandHandler {
     WTF_MAKE_NONCOPYABLE(InspectorApplicationCacheAgent); WTF_MAKE_FAST_ALLOCATED;
 public:
     static PassOwnPtr<InspectorApplicationCacheAgent> create(InstrumentingAgents* instrumentingAgents, InspectorPageAgent* pageAgent)
@@ -58,8 +58,8 @@ public:
     ~InspectorApplicationCacheAgent() { }
 
     // InspectorBaseAgent
-    virtual void setFrontend(InspectorFrontend*);
-    virtual void clearFrontend();
+    virtual void didCreateFrontendAndBackend(InspectorFrontendChannel*, InspectorBackendDispatcher*) OVERRIDE;
+    virtual void willDestroyFrontendAndBackend() OVERRIDE;
 
     // InspectorInstrumentation API
     void updateApplicationCacheStatus(Frame*);
@@ -80,7 +80,7 @@ private:
     DocumentLoader* assertFrameWithDocumentLoader(ErrorString*, String frameId);
 
     InspectorPageAgent* m_pageAgent;
-    InspectorFrontend::ApplicationCache* m_frontend;
+    std::unique_ptr<InspectorApplicationCacheFrontendDispatcher> m_frontendDispatcher;
 };
 
 } // namespace WebCore
index 280b984..fe500e3 100644 (file)
 #define InspectorBaseAgent_h
 
 #include "InspectorBackendDispatcher.h"
-#include <wtf/Forward.h>
 #include <wtf/text/WTFString.h>
 
 namespace WebCore {
 
-class InspectorFrontend;
+class InspectorFrontendChannel;
 class InstrumentingAgents;
 
-class InspectorBaseAgentInterface {
-public:
-    InspectorBaseAgentInterface(const String& name, InstrumentingAgents* instrumentingAgents)
-        : m_instrumentingAgents(instrumentingAgents)
-        , m_name(name)
-    {
-    }
-
-    virtual ~InspectorBaseAgentInterface() { }
-
-    virtual void setFrontend(InspectorFrontend*) { }
-    virtual void clearFrontend() { }
-    virtual void registerInDispatcher(InspectorBackendDispatcher*) = 0;
-    virtual void discardAgent() { }
-
-    String name() const { return m_name; }
-
-protected:
-    InstrumentingAgents* m_instrumentingAgents;
-
-private:
-    String m_name;
-};
-
-template<typename T>
-class InspectorBaseAgent : public InspectorBaseAgentInterface {
+class InspectorBaseAgent {
 public:
     virtual ~InspectorBaseAgent() { }
 
-    virtual void registerInDispatcher(InspectorBackendDispatcher* dispatcher)
-    {
-        dispatcher->registerAgent(static_cast<T*>(this));
-    }
+    virtual void didCreateFrontendAndBackend(InspectorFrontendChannel*, InspectorBackendDispatcher*) = 0;
+    virtual void willDestroyFrontendAndBackend() = 0;
+    virtual void discardAgent() { }
 
 protected:
     InspectorBaseAgent(const String& name, InstrumentingAgents* instrumentingAgents)
-        : InspectorBaseAgentInterface(name, instrumentingAgents)
+        : m_instrumentingAgents(instrumentingAgents)
+        , m_name(name)
     {
     }
+
+    InstrumentingAgents* m_instrumentingAgents;
+    String m_name;
 };
 
 } // namespace WebCore
index ebedc72..6077ca1 100644 (file)
@@ -616,8 +616,7 @@ CSSStyleRule* InspectorCSSAgent::asCSSStyleRule(CSSRule* rule)
 }
 
 InspectorCSSAgent::InspectorCSSAgent(InstrumentingAgents* instrumentingAgents, InspectorDOMAgent* domAgent)
-    : InspectorBaseAgent<InspectorCSSAgent>("CSS", instrumentingAgents)
-    , m_frontend(0)
+    : InspectorBaseAgent(ASCIILiteral("CSS"), instrumentingAgents)
     , m_domAgent(domAgent)
     , m_lastStyleSheetId(1)
 {
@@ -630,16 +629,16 @@ InspectorCSSAgent::~InspectorCSSAgent()
     reset();
 }
 
-void InspectorCSSAgent::setFrontend(InspectorFrontend* frontend)
+void InspectorCSSAgent::didCreateFrontendAndBackend(InspectorFrontendChannel* frontendChannel, InspectorBackendDispatcher* backendDispatcher)
 {
-    ASSERT(!m_frontend);
-    m_frontend = frontend->css();
+    m_frontendDispatcher = std::make_unique<InspectorCSSFrontendDispatcher>(frontendChannel);
+    backendDispatcher->registerAgent(this);
 }
 
-void InspectorCSSAgent::clearFrontend()
+void InspectorCSSAgent::willDestroyFrontendAndBackend()
 {
-    ASSERT(m_frontend);
-    m_frontend = 0;
+    m_frontendDispatcher = nullptr;
+
     resetNonPersistentData();
     String errorString;
     stopSelectorProfilerImpl(&errorString, false);
@@ -682,8 +681,8 @@ void InspectorCSSAgent::disable(ErrorString*)
 
 void InspectorCSSAgent::mediaQueryResultChanged()
 {
-    if (m_frontend)
-        m_frontend->mediaQueryResultChanged();
+    if (m_frontendDispatcher)
+        m_frontendDispatcher->mediaQueryResultChanged();
 }
 
 void InspectorCSSAgent::didCreateNamedFlow(Document* document, WebKitNamedFlow* namedFlow)
@@ -693,7 +692,7 @@ void InspectorCSSAgent::didCreateNamedFlow(Document* document, WebKitNamedFlow*
         return;
 
     ErrorString errorString;
-    m_frontend->namedFlowCreated(buildObjectForNamedFlow(&errorString, namedFlow, documentNodeId));
+    m_frontendDispatcher->namedFlowCreated(buildObjectForNamedFlow(&errorString, namedFlow, documentNodeId));
 }
 
 void InspectorCSSAgent::willRemoveNamedFlow(Document* document, WebKitNamedFlow* namedFlow)
@@ -708,7 +707,7 @@ void InspectorCSSAgent::willRemoveNamedFlow(Document* document, WebKitNamedFlow*
     if (m_changeRegionOversetTask)
         m_changeRegionOversetTask->unschedule(namedFlow);
 
-    m_frontend->namedFlowRemoved(documentNodeId, namedFlow->name().string());
+    m_frontendDispatcher->namedFlowRemoved(documentNodeId, namedFlow->name().string());
 }
 
 void InspectorCSSAgent::didUpdateRegionLayout(Document* document, WebKitNamedFlow* namedFlow)
@@ -730,7 +729,7 @@ void InspectorCSSAgent::regionLayoutUpdated(WebKitNamedFlow* namedFlow, int docu
     ErrorString errorString;
     Ref<WebKitNamedFlow> protect(*namedFlow);
 
-    m_frontend->regionLayoutUpdated(buildObjectForNamedFlow(&errorString, namedFlow, documentNodeId));
+    m_frontendDispatcher->regionLayoutUpdated(buildObjectForNamedFlow(&errorString, namedFlow, documentNodeId));
 }
 
 void InspectorCSSAgent::didChangeRegionOverset(Document* document, WebKitNamedFlow* namedFlow)
@@ -752,7 +751,7 @@ void InspectorCSSAgent::regionOversetChanged(WebKitNamedFlow* namedFlow, int doc
     ErrorString errorString;
     Ref<WebKitNamedFlow> protect(*namedFlow);
     
-    m_frontend->regionOversetChanged(buildObjectForNamedFlow(&errorString, namedFlow, documentNodeId));
+    m_frontendDispatcher->regionOversetChanged(buildObjectForNamedFlow(&errorString, namedFlow, documentNodeId));
 }
 
 void InspectorCSSAgent::didRegisterNamedFlowContentElement(Document* document, WebKitNamedFlow* namedFlow, Node* contentElement, Node* nextContentElement)
@@ -764,7 +763,7 @@ void InspectorCSSAgent::didRegisterNamedFlowContentElement(Document* document, W
     ErrorString errorString;
     int contentElementNodeId = m_domAgent->pushNodeToFrontend(&errorString, documentNodeId, contentElement);
     int nextContentElementNodeId = nextContentElement ? m_domAgent->pushNodeToFrontend(&errorString, documentNodeId, nextContentElement) : 0;
-    m_frontend->registeredNamedFlowContentElement(documentNodeId, namedFlow->name().string(), contentElementNodeId, nextContentElementNodeId);
+    m_frontendDispatcher->registeredNamedFlowContentElement(documentNodeId, namedFlow->name().string(), contentElementNodeId, nextContentElementNodeId);
 }
 
 void InspectorCSSAgent::didUnregisterNamedFlowContentElement(Document* document, WebKitNamedFlow* namedFlow, Node* contentElement)
@@ -779,7 +778,7 @@ void InspectorCSSAgent::didUnregisterNamedFlowContentElement(Document* document,
         // We've already notified that the DOM node was removed from the DOM, so there's no need to send another event.
         return;
     }
-    m_frontend->unregisteredNamedFlowContentElement(documentNodeId, namedFlow->name().string(), contentElementNodeId);
+    m_frontendDispatcher->unregisteredNamedFlowContentElement(documentNodeId, namedFlow->name().string(), contentElementNodeId);
 }
 
 bool InspectorCSSAgent::forcePseudoState(Element* element, CSSSelector::PseudoType pseudoType)
@@ -1096,7 +1095,7 @@ PassRefPtr<TypeBuilder::CSS::SelectorProfile> InspectorCSSAgent::stopSelectorPro
     if (!m_currentSelectorProfile)
         return 0;
     RefPtr<TypeBuilder::CSS::SelectorProfile> result;
-    if (m_frontend && needProfile)
+    if (m_frontendDispatcher && needProfile)
         result = m_currentSelectorProfile->toInspectorObject();
     m_currentSelectorProfile.clear();
     return result.release();
@@ -1451,8 +1450,8 @@ void InspectorCSSAgent::didModifyDOMAttr(Element* element)
 
 void InspectorCSSAgent::styleSheetChanged(InspectorStyleSheet* styleSheet)
 {
-    if (m_frontend)
-        m_frontend->styleSheetChanged(styleSheet->id());
+    if (m_frontendDispatcher)
+        m_frontendDispatcher->styleSheetChanged(styleSheet->id());
 }
 
 void InspectorCSSAgent::resetPseudoStates()
index 529ad19..cbe6c36 100644 (file)
@@ -50,7 +50,7 @@ class Document;
 class DocumentStyleSheetCollection;
 class Element;
 class InspectorCSSOMWrappers;
-class InspectorFrontend;
+class InspectorCSSFrontendDispatcher;
 class InstrumentingAgents;
 class NameNodeMap;
 class Node;
@@ -64,7 +64,7 @@ class ChangeRegionOversetTask;
 #if ENABLE(INSPECTOR)
 
 class InspectorCSSAgent
-    : public InspectorBaseAgent<InspectorCSSAgent>
+    : public InspectorBaseAgent
     , public InspectorDOMAgent::DOMListener
     , public InspectorBackendDispatcher::CSSCommandHandler
     , public InspectorStyleSheet::Listener {
@@ -96,8 +96,8 @@ public:
     ~InspectorCSSAgent();
 
     bool forcePseudoState(Element*, CSSSelector::PseudoType);
-    virtual void setFrontend(InspectorFrontend*);
-    virtual void clearFrontend();
+    virtual void didCreateFrontendAndBackend(InspectorFrontendChannel*, InspectorBackendDispatcher*) OVERRIDE;
+    virtual void willDestroyFrontendAndBackend() OVERRIDE;
     virtual void discardAgent();
     virtual void enable(ErrorString*);
     virtual void disable(ErrorString*);
@@ -183,7 +183,7 @@ private:
 
     void resetPseudoStates();
 
-    InspectorFrontend::CSS* m_frontend;
+    std::unique_ptr<InspectorCSSFrontendDispatcher> m_frontendDispatcher;
     InspectorDOMAgent* m_domAgent;
 
     IdToInspectorStyleSheet m_idToInspectorStyleSheet;
index 5881c31..3de8d67 100644 (file)
@@ -62,10 +62,9 @@ using WebCore::TypeBuilder::Network::FrameId;
 namespace WebCore {
 
 InspectorCanvasAgent::InspectorCanvasAgent(InstrumentingAgents* instrumentingAgents, InspectorPageAgent* pageAgent, InjectedScriptManager* injectedScriptManager)
-    : InspectorBaseAgent<InspectorCanvasAgent>("Canvas", instrumentingAgents)
+    : InspectorBaseAgent(ASCIILiteral("Canvas"), instrumentingAgents)
     , m_pageAgent(pageAgent)
     , m_injectedScriptManager(injectedScriptManager)
-    , m_frontend(0)
     , m_enabled(false)
 {
 }
@@ -74,16 +73,17 @@ InspectorCanvasAgent::~InspectorCanvasAgent()
 {
 }
 
-void InspectorCanvasAgent::setFrontend(InspectorFrontend* frontend)
+void InspectorCanvasAgent::didCreateFrontendAndBackend(InspectorFrontendChannel* frontendChannel, InspectorBackendDispatcher* backendDispatcher)
 {
-    ASSERT(frontend);
-    m_frontend = frontend->canvas();
+    m_frontendDispatcher = std::make_unique<InspectorCanvasFrontendDispatcher>(frontendChannel);
+    backendDispatcher->registerAgent(this);
 }
 
-void InspectorCanvasAgent::clearFrontend()
+void InspectorCanvasAgent::willDestroyFrontendAndBackend()
 {
-    m_frontend = 0;
-    disable(0);
+    m_frontendDispatcher = nullptr;
+
+    disable(nullptr);
 }
 
 void InspectorCanvasAgent::enable(ErrorString*)
@@ -199,7 +199,7 @@ ScriptObject InspectorCanvasAgent::wrapWebGLRenderingContextForInstrumentation(c
 
 ScriptObject InspectorCanvasAgent::notifyRenderingContextWasWrapped(const ScriptObject& wrappedContext)
 {
-    ASSERT(m_frontend);
+    ASSERT(m_frontendDispatcher);
     JSC::ExecState* scriptState = wrappedContext.scriptState();
     DOMWindow* domWindow = scriptState ? domWindowFromExecState(scriptState) : 0;
     Frame* frame = domWindow ? domWindow->frame() : 0;
@@ -207,7 +207,7 @@ ScriptObject InspectorCanvasAgent::notifyRenderingContextWasWrapped(const Script
         m_framesWithUninstrumentedCanvases.set(frame, false);
     String frameId = m_pageAgent->frameId(frame);
     if (!frameId.isEmpty())
-        m_frontend->contextCreated(frameId);
+        m_frontendDispatcher->contextCreated(frameId);
     return wrappedContext;
 }
 
@@ -270,7 +270,7 @@ void InspectorCanvasAgent::findFramesWithUninstrumentedCanvases()
     for (FramesWithUninstrumentedCanvases::iterator it = m_framesWithUninstrumentedCanvases.begin(); it != m_framesWithUninstrumentedCanvases.end(); ++it) {
         String frameId = m_pageAgent->frameId(it->key);
         if (!frameId.isEmpty())
-            m_frontend->contextCreated(frameId);
+            m_frontendDispatcher->contextCreated(frameId);
     }
 }
 
@@ -289,14 +289,14 @@ void InspectorCanvasAgent::frameNavigated(Frame* frame)
     if (frame == m_pageAgent->mainFrame()) {
         for (FramesWithUninstrumentedCanvases::iterator it = m_framesWithUninstrumentedCanvases.begin(); it != m_framesWithUninstrumentedCanvases.end(); ++it)
             m_framesWithUninstrumentedCanvases.set(it->key, false);
-        m_frontend->traceLogsRemoved(0, 0);
+        m_frontendDispatcher->traceLogsRemoved(0, 0);
     } else {
         while (frame) {
             if (m_framesWithUninstrumentedCanvases.contains(frame))
                 m_framesWithUninstrumentedCanvases.set(frame, false);
             if (m_pageAgent->hasIdForFrame(frame)) {
                 String frameId = m_pageAgent->frameId(frame);
-                m_frontend->traceLogsRemoved(&frameId, 0);
+                m_frontendDispatcher->traceLogsRemoved(&frameId, 0);
             }
             frame = frame->tree().traverseNext();
         }
index 7e94553..2ebc71b 100644 (file)
@@ -53,7 +53,7 @@ class ScriptObject;
 
 typedef String ErrorString;
 
-class InspectorCanvasAgent : public InspectorBaseAgent<InspectorCanvasAgent>, public InspectorBackendDispatcher::CanvasCommandHandler {
+class InspectorCanvasAgent : public InspectorBaseAgent, public InspectorBackendDispatcher::CanvasCommandHandler {
 public:
     static PassOwnPtr<InspectorCanvasAgent> create(InstrumentingAgents* instrumentingAgents, InspectorPageAgent* pageAgent, InjectedScriptManager* injectedScriptManager)
     {
@@ -61,8 +61,8 @@ public:
     }
     ~InspectorCanvasAgent();
 
-    virtual void setFrontend(InspectorFrontend*);
-    virtual void clearFrontend();
+    virtual void didCreateFrontendAndBackend(InspectorFrontendChannel*, InspectorBackendDispatcher*) OVERRIDE;
+    virtual void willDestroyFrontendAndBackend() OVERRIDE;
 
     void frameNavigated(Frame*);
     void frameDetached(Frame*);
@@ -100,7 +100,7 @@ private:
 
     InspectorPageAgent* m_pageAgent;
     InjectedScriptManager* m_injectedScriptManager;
-    InspectorFrontend::Canvas* m_frontend;
+    std::unique_ptr<InspectorCanvasFrontendDispatcher> m_frontendDispatcher;
     bool m_enabled;
     // Contains all frames with canvases, value is true only for frames that have an uninstrumented canvas.
     typedef HashMap<Frame*, bool> FramesWithUninstrumentedCanvases;
index 2400a0a..62b9e32 100644 (file)
@@ -59,9 +59,8 @@ static const int expireConsoleMessagesStep = 100;
 int InspectorConsoleAgent::s_enabledAgentCount = 0;
 
 InspectorConsoleAgent::InspectorConsoleAgent(InstrumentingAgents* instrumentingAgents, InjectedScriptManager* injectedScriptManager)
-    : InspectorBaseAgent<InspectorConsoleAgent>("Console", instrumentingAgents)
+    : InspectorBaseAgent(ASCIILiteral("Console"), instrumentingAgents)
     , m_injectedScriptManager(injectedScriptManager)
-    , m_frontend(0)
     , m_previousMessage(0)
     , m_expiredConsoleMessageCount(0)
     , m_enabled(false)
@@ -88,12 +87,12 @@ void InspectorConsoleAgent::enable(ErrorString*)
 
     if (m_expiredConsoleMessageCount) {
         ConsoleMessage expiredMessage(!isWorkerAgent(), OtherMessageSource, LogMessageType, WarningMessageLevel, String::format("%d console messages are not shown.", m_expiredConsoleMessageCount));
-        expiredMessage.addToFrontend(m_frontend, m_injectedScriptManager, false);
+        expiredMessage.addToFrontend(m_frontendDispatcher.get(), m_injectedScriptManager, false);
     }
 
     size_t messageCount = m_consoleMessages.size();
     for (size_t i = 0; i < messageCount; ++i)
-        m_consoleMessages[i]->addToFrontend(m_frontend, m_injectedScriptManager, false);
+        m_consoleMessages[i]->addToFrontend(m_frontendDispatcher.get(), m_injectedScriptManager, false);
 }
 
 void InspectorConsoleAgent::disable(ErrorString*)
@@ -111,8 +110,8 @@ void InspectorConsoleAgent::clearMessages(ErrorString*)
     m_expiredConsoleMessageCount = 0;
     m_previousMessage = 0;
     m_injectedScriptManager->releaseObjectGroup("console");
-    if (m_frontend && m_enabled)
-        m_frontend->messagesCleared();
+    if (m_frontendDispatcher && m_enabled)
+        m_frontendDispatcher->messagesCleared();
 }
 
 void InspectorConsoleAgent::reset()
@@ -123,14 +122,16 @@ void InspectorConsoleAgent::reset()
     m_counts.clear();
 }
 
-void InspectorConsoleAgent::setFrontend(InspectorFrontend* frontend)
+void InspectorConsoleAgent::didCreateFrontendAndBackend(InspectorFrontendChannel* frontendChannel, InspectorBackendDispatcher* backendDispatcher)
 {
-    m_frontend = frontend->console();
+    m_frontendDispatcher = std::make_unique<InspectorConsoleFrontendDispatcher>(frontendChannel);
+    backendDispatcher->registerAgent(this);
 }
 
-void InspectorConsoleAgent::clearFrontend()
+void InspectorConsoleAgent::willDestroyFrontendAndBackend()
 {
-    m_frontend = 0;
+    m_frontendDispatcher = nullptr;
+
     String errorString;
     disable(&errorString);
 }
@@ -171,7 +172,7 @@ void InspectorConsoleAgent::addMessageToConsole(MessageSource source, MessageTyp
         clearMessages(&error);
     }
 
-    bool canGenerateCallStack = !isWorkerAgent() && m_frontend;
+    bool canGenerateCallStack = !isWorkerAgent() && m_frontendDispatcher;
     addConsoleMessage(adoptPtr(new ConsoleMessage(canGenerateCallStack, source, type, level, message, scriptID, lineNumber, columnNumber, state, requestIdentifier)));
 }
 
@@ -249,7 +250,7 @@ void InspectorConsoleAgent::didFinishXHRLoading(unsigned long requestIdentifier,
 {
     if (!developerExtrasEnabled())
         return;
-    if (m_frontend && m_monitoringXHREnabled) {
+    if (m_frontendDispatcher && m_monitoringXHREnabled) {
         String message = "XHR finished loading: \"" + url + "\".";
         addMessageToConsole(NetworkMessageSource, LogMessageType, DebugMessageLevel, message, sendURL, sendLineNumber, sendColumnNumber, 0, requestIdentifier);
     }
@@ -300,16 +301,16 @@ void InspectorConsoleAgent::addConsoleMessage(PassOwnPtr<ConsoleMessage> console
 
     if (m_previousMessage && !isGroupMessage(m_previousMessage->type()) && m_previousMessage->isEqual(consoleMessage.get())) {
         m_previousMessage->incrementCount();
-        if (m_frontend && m_enabled)
-            m_previousMessage->updateRepeatCountInConsole(m_frontend);
+        if (m_frontendDispatcher && m_enabled)
+            m_previousMessage->updateRepeatCountInConsole(m_frontendDispatcher.get());
     } else {
         m_previousMessage = consoleMessage.get();
         m_consoleMessages.append(consoleMessage);
-        if (m_frontend && m_enabled)
-            m_previousMessage->addToFrontend(m_frontend, m_injectedScriptManager, true);
+        if (m_frontendDispatcher && m_enabled)
+            m_previousMessage->addToFrontend(m_frontendDispatcher.get(), m_injectedScriptManager, true);
     }
 
-    if (!m_frontend && m_consoleMessages.size() >= maximumConsoleMessages) {
+    if (!m_frontendDispatcher && m_consoleMessages.size() >= maximumConsoleMessages) {
         m_expiredConsoleMessageCount += expireConsoleMessagesStep;
         m_consoleMessages.remove(0, expireConsoleMessagesStep);
     }
index c7f1c8a..4504abd 100644 (file)
@@ -42,7 +42,6 @@ namespace WebCore {
 
 class ConsoleMessage;
 class DOMWindow;
-class InspectorFrontend;
 class InjectedScriptManager;
 class InstrumentingAgents;
 class ResourceError;
@@ -53,7 +52,7 @@ class ScriptProfile;
 
 typedef String ErrorString;
 
-class InspectorConsoleAgent : public InspectorBaseAgent<InspectorConsoleAgent>, public InspectorBackendDispatcher::ConsoleCommandHandler {
+class InspectorConsoleAgent : public InspectorBaseAgent, public InspectorBackendDispatcher::ConsoleCommandHandler {
     WTF_MAKE_NONCOPYABLE(InspectorConsoleAgent);
 public:
     InspectorConsoleAgent(InstrumentingAgents*, InjectedScriptManager*);
@@ -65,8 +64,8 @@ public:
     bool enabled() const { return m_enabled; }
     void reset();
 
-    virtual void setFrontend(InspectorFrontend*);
-    virtual void clearFrontend();
+    virtual void didCreateFrontendAndBackend(InspectorFrontendChannel*, InspectorBackendDispatcher*) OVERRIDE;
+    virtual void willDestroyFrontendAndBackend() OVERRIDE;
 
     void addMessageToConsole(MessageSource, MessageType, MessageLevel, const String& message, JSC::ExecState*, PassRefPtr<ScriptArguments>, unsigned long requestIdentifier = 0);
     void addMessageToConsole(MessageSource, MessageType, MessageLevel, const String& message, const String& scriptID, unsigned lineNumber, unsigned columnNumber, JSC::ExecState* = 0, unsigned long requestIdentifier = 0);
@@ -101,7 +100,7 @@ protected:
     virtual bool developerExtrasEnabled() = 0;
 
     InjectedScriptManager* m_injectedScriptManager;
-    InspectorFrontend::Console* m_frontend;
+    std::unique_ptr<InspectorConsoleFrontendDispatcher> m_frontendDispatcher;
     ConsoleMessage* m_previousMessage;
     Vector<OwnPtr<ConsoleMessage>> m_consoleMessages;
     int m_expiredConsoleMessageCount;
index 3c9e6f5..cbfc213 100644 (file)
@@ -80,6 +80,7 @@ InspectorController::InspectorController(Page* page, InspectorClient* inspectorC
     : m_instrumentingAgents(InstrumentingAgents::create())
     , m_injectedScriptManager(InjectedScriptManager::createForPage())
     , m_overlay(InspectorOverlay::create(page, inspectorClient))
+    , m_inspectorFrontendChannel(nullptr)
     , m_page(page)
     , m_inspectorClient(inspectorClient)
     , m_isUnderTest(false)
@@ -223,30 +224,29 @@ void InspectorController::didClearWindowObjectInWorld(Frame* frame, DOMWrapperWo
 void InspectorController::connectFrontend(InspectorFrontendChannel* frontendChannel)
 {
     ASSERT(frontendChannel);
+    ASSERT(m_inspectorClient);
+    ASSERT(!m_inspectorFrontendChannel);
+    ASSERT(!m_inspectorBackendDispatcher);
 
-    m_inspectorFrontend = adoptPtr(new InspectorFrontend(frontendChannel));
+    m_inspectorFrontendChannel = frontendChannel;
+    m_inspectorBackendDispatcher = InspectorBackendDispatcher::create(frontendChannel);
 
-    m_agents.setFrontend(m_inspectorFrontend.get());
+    m_agents.didCreateFrontendAndBackend(frontendChannel, m_inspectorBackendDispatcher.get());
 
     InspectorInstrumentation::registerInstrumentingAgents(m_instrumentingAgents.get());
     InspectorInstrumentation::frontendCreated();
-
-    ASSERT(m_inspectorClient);
-    m_inspectorBackendDispatcher = InspectorBackendDispatcher::create(frontendChannel);
-
-    m_agents.registerInDispatcher(m_inspectorBackendDispatcher.get());
 }
 
 void InspectorController::disconnectFrontend()
 {
-    if (!m_inspectorFrontend)
+    if (!m_inspectorFrontendChannel)
         return;
-    m_inspectorBackendDispatcher->clearFrontend();
-    m_inspectorBackendDispatcher.clear();
 
-    m_agents.clearFrontend();
+    m_agents.willDestroyFrontendAndBackend();
 
-    m_inspectorFrontend.clear();
+    m_inspectorBackendDispatcher->clearFrontend();
+    m_inspectorBackendDispatcher.clear();
+    m_inspectorFrontendChannel = nullptr;
 
     // relese overlay page resources
     m_overlay->freePage();
@@ -259,7 +259,7 @@ void InspectorController::show()
     if (!enabled())
         return;
 
-    if (m_inspectorFrontend)
+    if (m_inspectorFrontendChannel)
         m_inspectorClient->bringFrontendToFront();
     else {
         InspectorFrontendChannel* frontendChannel = m_inspectorClient->openInspectorFrontend(this);
@@ -270,7 +270,7 @@ void InspectorController::show()
 
 void InspectorController::close()
 {
-    if (!m_inspectorFrontend)
+    if (!m_inspectorFrontendChannel)
         return;
     disconnectFrontend();
     m_inspectorClient->closeInspectorFrontend();
index 5f273ac..95ec7e3 100644 (file)
@@ -53,7 +53,6 @@ class InspectorClient;
 class InspectorDOMAgent;
 class InspectorDOMDebuggerAgent;
 class InspectorDebuggerAgent;
-class InspectorFrontend;
 class InspectorFrontendChannel;
 class InspectorFrontendClient;
 class InspectorMemoryAgent;
@@ -92,7 +91,7 @@ public:
 
     void dispatchMessageFromFrontend(const String& message);
 
-    bool hasFrontend() const { return m_inspectorFrontend; }
+    bool hasFrontend() const { return !!m_inspectorFrontendChannel; }
     void connectFrontend(InspectorFrontendChannel*);
     void disconnectFrontend();
     void setProcessId(long);
@@ -149,7 +148,7 @@ private:
 
     RefPtr<InspectorBackendDispatcher> m_inspectorBackendDispatcher;
     OwnPtr<InspectorFrontendClient> m_inspectorFrontendClient;
-    OwnPtr<InspectorFrontend> m_inspectorFrontend;
+    InspectorFrontendChannel* m_inspectorFrontendChannel;
     Page* m_page;
     InspectorClient* m_inspectorClient;
     InspectorAgentRegistry m_agents;
index 85d793a..e6bcb4c 100644 (file)
@@ -211,12 +211,11 @@ String InspectorDOMAgent::toErrorString(const ExceptionCode& ec)
 }
 
 InspectorDOMAgent::InspectorDOMAgent(InstrumentingAgents* instrumentingAgents, InspectorPageAgent* pageAgent, InjectedScriptManager* injectedScriptManager, InspectorOverlay* overlay, InspectorClient* client)
-    : InspectorBaseAgent<InspectorDOMAgent>("DOM", instrumentingAgents)
+    : InspectorBaseAgent(ASCIILiteral("DOM"), instrumentingAgents)
     , m_pageAgent(pageAgent)
     , m_injectedScriptManager(injectedScriptManager)
     , m_overlay(overlay)
     , m_client(client)
-    , m_frontend(0)
     , m_domListener(0)
     , m_lastNodeId(1)
     , m_lastBackendNodeId(-1)
@@ -232,13 +231,14 @@ InspectorDOMAgent::~InspectorDOMAgent()
     ASSERT(!m_searchingForNode);
 }
 
-void InspectorDOMAgent::setFrontend(InspectorFrontend* frontend)
+void InspectorDOMAgent::didCreateFrontendAndBackend(InspectorFrontendChannel* frontendChannel, InspectorBackendDispatcher* backendDispatcher)
 {
-    ASSERT(!m_frontend);
+    m_frontendDispatcher = std::make_unique<InspectorDOMFrontendDispatcher>(frontendChannel);
+    backendDispatcher->registerAgent(this);
+
     m_history = adoptPtr(new InspectorHistory());
     m_domEditor = adoptPtr(new DOMEditor(m_history.get()));
 
-    m_frontend = frontend->dom();
     m_instrumentingAgents->setInspectorDOMAgent(this);
     m_document = m_pageAgent->mainFrame()->document();
 
@@ -246,9 +246,9 @@ void InspectorDOMAgent::setFrontend(InspectorFrontend* frontend)
         focusNode();
 }
 
-void InspectorDOMAgent::clearFrontend()
+void InspectorDOMAgent::willDestroyFrontendAndBackend()
 {
-    ASSERT(m_frontend);
+    m_frontendDispatcher = nullptr;
 
     m_history.clear();
     m_domEditor.clear();
@@ -257,7 +257,6 @@ void InspectorDOMAgent::clearFrontend()
     setSearchingForNode(&error, false, 0);
     hideHighlight(&error);
 
-    m_frontend = 0;
     m_instrumentingAgents->setInspectorDOMAgent(0);
     m_documentRequested = false;
     reset();
@@ -305,7 +304,7 @@ void InspectorDOMAgent::setDocument(Document* doc)
 
     // Immediately communicate 0 document or document that has finished loading.
     if (!doc || !doc->parsing())
-        m_frontend->documentUpdated();
+        m_frontendDispatcher->documentUpdated();
 }
 
 void InspectorDOMAgent::releaseDanglingNodes()
@@ -462,7 +461,7 @@ void InspectorDOMAgent::pushChildNodesToFrontend(int nodeId, int depth)
     }
 
     RefPtr<TypeBuilder::Array<TypeBuilder::DOM::Node>> children = buildArrayForContainerChildren(node, depth, nodeMap);
-    m_frontend->setChildNodes(nodeId, children.release());
+    m_frontendDispatcher->setChildNodes(nodeId, children.release());
 }
 
 void InspectorDOMAgent::discardBindings()
@@ -589,7 +588,7 @@ int InspectorDOMAgent::pushNodePathToFrontend(Node* nodeToPush)
             m_danglingNodeToIdMaps.append(newMap.release());
             RefPtr<TypeBuilder::Array<TypeBuilder::DOM::Node>> children = TypeBuilder::Array<TypeBuilder::DOM::Node>::create();
             children->addItem(buildObjectForNode(node, 0, danglingMap));
-            m_frontend->setChildNodes(0, children);
+            m_frontendDispatcher->setChildNodes(0, children);
             break;
         } else {
             path.append(parent);
@@ -1068,7 +1067,7 @@ void InspectorDOMAgent::inspect(Node* inspectedNode)
 
 void InspectorDOMAgent::focusNode()
 {
-    if (!m_frontend)
+    if (!m_frontendDispatcher)
         return;
 
     ASSERT(m_nodeToFocus);
@@ -1575,7 +1574,7 @@ void InspectorDOMAgent::mainFrameDOMContentLoaded()
     // Re-push document once it is loaded.
     discardBindings();
     if (m_documentRequested)
-        m_frontend->documentUpdated();
+        m_frontendDispatcher->documentUpdated();
 }
 
 void InspectorDOMAgent::didCommitLoad(Document* document)
@@ -1590,13 +1589,13 @@ void InspectorDOMAgent::didCommitLoad(Document* document)
 
     // Re-add frame owner element together with its new children.
     int parentId = m_documentNodeToIdMap.get(innerParentNode(frameOwner));
-    m_frontend->childNodeRemoved(parentId, frameOwnerId);
+    m_frontendDispatcher->childNodeRemoved(parentId, frameOwnerId);
     unbind(frameOwner, &m_documentNodeToIdMap);
 
     RefPtr<TypeBuilder::DOM::Node> value = buildObjectForNode(frameOwner, 0, &m_documentNodeToIdMap);
     Node* previousSibling = innerPreviousSibling(frameOwner);
     int prevId = previousSibling ? m_documentNodeToIdMap.get(previousSibling) : 0;
-    m_frontend->childNodeInserted(parentId, prevId, value.release());
+    m_frontendDispatcher->childNodeInserted(parentId, prevId, value.release());
 }
 
 void InspectorDOMAgent::didInsertDOMNode(Node* node)
@@ -1618,13 +1617,13 @@ void InspectorDOMAgent::didInsertDOMNode(Node* node)
 
     if (!m_childrenRequested.contains(parentId)) {
         // No children are mapped yet -> only notify on changes of hasChildren.
-        m_frontend->childNodeCountUpdated(parentId, innerChildNodeCount(parent));
+        m_frontendDispatcher->childNodeCountUpdated(parentId, innerChildNodeCount(parent));
     } else {
         // Children have been requested -> return value of a new child.
         Node* prevSibling = innerPreviousSibling(node);
         int prevId = prevSibling ? m_documentNodeToIdMap.get(prevSibling) : 0;
         RefPtr<TypeBuilder::DOM::Node> value = buildObjectForNode(node, 0, &m_documentNodeToIdMap);
-        m_frontend->childNodeInserted(parentId, prevId, value.release());
+        m_frontendDispatcher->childNodeInserted(parentId, prevId, value.release());
     }
 }
 
@@ -1644,9 +1643,9 @@ void InspectorDOMAgent::didRemoveDOMNode(Node* node)
     if (!m_childrenRequested.contains(parentId)) {
         // No children are mapped yet -> only notify on changes of hasChildren.
         if (innerChildNodeCount(parent) == 1)
-            m_frontend->childNodeCountUpdated(parentId, 0);
+            m_frontendDispatcher->childNodeCountUpdated(parentId, 0);
     } else
-        m_frontend->childNodeRemoved(parentId, m_documentNodeToIdMap.get(node));
+        m_frontendDispatcher->childNodeRemoved(parentId, m_documentNodeToIdMap.get(node));
     unbind(node, &m_documentNodeToIdMap);
 }
 
@@ -1670,7 +1669,7 @@ void InspectorDOMAgent::didModifyDOMAttr(Element* element, const AtomicString& n
     if (m_domListener)
         m_domListener->didModifyDOMAttr(element);
 
-    m_frontend->attributeModified(id, name, value);
+    m_frontendDispatcher->attributeModified(id, name, value);
 }
 
 void InspectorDOMAgent::didRemoveDOMAttr(Element* element, const AtomicString& name)
@@ -1683,7 +1682,7 @@ void InspectorDOMAgent::didRemoveDOMAttr(Element* element, const AtomicString& n
     if (m_domListener)
         m_domListener->didModifyDOMAttr(element);
 
-    m_frontend->attributeRemoved(id, name);
+    m_frontendDispatcher->attributeRemoved(id, name);
 }
 
 void InspectorDOMAgent::styleAttributeInvalidated(const Vector<Element*>& elements)
@@ -1700,7 +1699,7 @@ void InspectorDOMAgent::styleAttributeInvalidated(const Vector<Element*>& elemen
             m_domListener->didModifyDOMAttr(element);
         nodeIds->addItem(id);
     }
-    m_frontend->inlineStyleInvalidated(nodeIds.release());
+    m_frontendDispatcher->inlineStyleInvalidated(nodeIds.release());
 }
 
 void InspectorDOMAgent::characterDataModified(CharacterData* characterData)
@@ -1711,7 +1710,7 @@ void InspectorDOMAgent::characterDataModified(CharacterData* characterData)
         didInsertDOMNode(characterData);
         return;
     }
-    m_frontend->characterDataModified(id, characterData->data());
+    m_frontendDispatcher->characterDataModified(id, characterData->data());
 }
 
 void InspectorDOMAgent::didInvalidateStyleAttr(Node* node)
@@ -1730,7 +1729,7 @@ void InspectorDOMAgent::didPushShadowRoot(Element* host, ShadowRoot* root)
 {
     int hostId = m_documentNodeToIdMap.get(host);
     if (hostId)
-        m_frontend->shadowRootPushed(hostId, buildObjectForNode(root, 0, &m_documentNodeToIdMap));
+        m_frontendDispatcher->shadowRootPushed(hostId, buildObjectForNode(root, 0, &m_documentNodeToIdMap));
 }
 
 void InspectorDOMAgent::willPopShadowRoot(Element* host, ShadowRoot* root)
@@ -1738,7 +1737,7 @@ void InspectorDOMAgent::willPopShadowRoot(Element* host, ShadowRoot* root)
     int hostId = m_documentNodeToIdMap.get(host);
     int rootId = m_documentNodeToIdMap.get(root);
     if (hostId && rootId)
-        m_frontend->shadowRootPopped(hostId, rootId);
+        m_frontendDispatcher->shadowRootPopped(hostId, rootId);
 }
 
 void InspectorDOMAgent::frameDocumentUpdated(Frame* frame)
index 3f833ac..31ed69d 100644 (file)
@@ -58,7 +58,6 @@ class Document;
 class Element;
 class Event;
 class InspectorClient;
-class InspectorFrontend;
 class InspectorHistory;
 class InspectorOverlay;
 class InspectorPageAgent;
@@ -91,7 +90,7 @@ struct EventListenerInfo {
     const EventListenerVector eventListenerVector;
 };
 
-class InspectorDOMAgent : public InspectorBaseAgent<InspectorDOMAgent>, public InspectorBackendDispatcher::DOMCommandHandler {
+class InspectorDOMAgent : public InspectorBaseAgent, public InspectorBackendDispatcher::DOMCommandHandler {
     WTF_MAKE_NONCOPYABLE(InspectorDOMAgent);
 public:
     struct DOMListener {
@@ -112,8 +111,8 @@ public:
 
     ~InspectorDOMAgent();
 
-    virtual void setFrontend(InspectorFrontend*);
-    virtual void clearFrontend();
+    virtual void didCreateFrontendAndBackend(InspectorFrontendChannel*, InspectorBackendDispatcher*) OVERRIDE;
+    virtual void willDestroyFrontendAndBackend() OVERRIDE;
 
     Vector<Document*> documents();
     void reset();
@@ -245,7 +244,7 @@ private:
     InjectedScriptManager* m_injectedScriptManager;
     InspectorOverlay* m_overlay;
     InspectorClient* m_client;
-    InspectorFrontend::DOM* m_frontend;
+    std::unique_ptr<InspectorDOMFrontendDispatcher> m_frontendDispatcher;
     DOMListener* m_domListener;
     NodeToIdMap m_documentNodeToIdMap;
     typedef HashMap<RefPtr<Node>, BackendNodeId> NodeToBackendIdMap;
index 00e0e50..cfe5eef 100644 (file)
@@ -69,7 +69,7 @@ PassOwnPtr<InspectorDOMDebuggerAgent> InspectorDOMDebuggerAgent::create(Instrume
 }
 
 InspectorDOMDebuggerAgent::InspectorDOMDebuggerAgent(InstrumentingAgents* instrumentingAgents, InspectorDOMAgent* domAgent, InspectorDebuggerAgent* debuggerAgent, InspectorAgent*)
-    : InspectorBaseAgent<InspectorDOMDebuggerAgent>("DOMDebugger", instrumentingAgents)
+    : InspectorBaseAgent(ASCIILiteral("DOMDebugger"), instrumentingAgents)
     , m_domAgent(domAgent)
     , m_debuggerAgent(debuggerAgent)
     , m_pauseInNextEventListener(false)
@@ -111,7 +111,12 @@ void InspectorDOMDebuggerAgent::disable()
     clear();
 }
 
-void InspectorDOMDebuggerAgent::clearFrontend()
+void InspectorDOMDebuggerAgent::didCreateFrontendAndBackend(InspectorFrontendChannel*, InspectorBackendDispatcher* backendDispatcher)
+{
+    backendDispatcher->registerAgent(this);
+}
+
+void InspectorDOMDebuggerAgent::willDestroyFrontendAndBackend()
 {
     disable();
 }
@@ -172,7 +177,7 @@ void InspectorDOMDebuggerAgent::didInvalidateStyleAttr(Node* node)
     if (hasBreakpoint(node, AttributeModified)) {
         RefPtr<InspectorObject> eventData = InspectorObject::create();
         descriptionForDOMEvent(node, AttributeModified, false, eventData.get());
-        m_debuggerAgent->breakProgram(InspectorFrontend::Debugger::Reason::DOM, eventData.release());
+        m_debuggerAgent->breakProgram(InspectorDebuggerFrontendDispatcher::Reason::DOM, eventData.release());
     }
 }
 
@@ -272,7 +277,7 @@ void InspectorDOMDebuggerAgent::willInsertDOMNode(Node* parent)
     if (hasBreakpoint(parent, SubtreeModified)) {
         RefPtr<InspectorObject> eventData = InspectorObject::create();
         descriptionForDOMEvent(parent, SubtreeModified, true, eventData.get());
-        m_debuggerAgent->breakProgram(InspectorFrontend::Debugger::Reason::DOM, eventData.release());
+        m_debuggerAgent->breakProgram(InspectorDebuggerFrontendDispatcher::Reason::DOM, eventData.release());
     }
 }
 
@@ -282,11 +287,11 @@ void InspectorDOMDebuggerAgent::willRemoveDOMNode(Node* node)
     if (hasBreakpoint(node, NodeRemoved)) {
         RefPtr<InspectorObject> eventData = InspectorObject::create();
         descriptionForDOMEvent(node, NodeRemoved, false, eventData.get());
-        m_debuggerAgent->breakProgram(InspectorFrontend::Debugger::Reason::DOM, eventData.release());
+        m_debuggerAgent->breakProgram(InspectorDebuggerFrontendDispatcher::Reason::DOM, eventData.release());
     } else if (parentNode && hasBreakpoint(parentNode, SubtreeModified)) {
         RefPtr<InspectorObject> eventData = InspectorObject::create();
         descriptionForDOMEvent(node, SubtreeModified, false, eventData.get());
-        m_debuggerAgent->breakProgram(InspectorFrontend::Debugger::Reason::DOM, eventData.release());
+        m_debuggerAgent->breakProgram(InspectorDebuggerFrontendDispatcher::Reason::DOM, eventData.release());
     }
 }
 
@@ -295,7 +300,7 @@ void InspectorDOMDebuggerAgent::willModifyDOMAttr(Element* element)
     if (hasBreakpoint(element, AttributeModified)) {
         RefPtr<InspectorObject> eventData = InspectorObject::create();
         descriptionForDOMEvent(element, AttributeModified, false, eventData.get());
-        m_debuggerAgent->breakProgram(InspectorFrontend::Debugger::Reason::DOM, eventData.release());
+        m_debuggerAgent->breakProgram(InspectorDebuggerFrontendDispatcher::Reason::DOM, eventData.release());
     }
 }
 
@@ -369,9 +374,9 @@ void InspectorDOMDebuggerAgent::pauseOnNativeEventIfNeeded(bool isDOMEvent, cons
     RefPtr<InspectorObject> eventData = InspectorObject::create();
     eventData->setString("eventName", fullEventName);
     if (synchronous)
-        m_debuggerAgent->breakProgram(InspectorFrontend::Debugger::Reason::EventListener, eventData.release());
+        m_debuggerAgent->breakProgram(InspectorDebuggerFrontendDispatcher::Reason::EventListener, eventData.release());
     else
-        m_debuggerAgent->schedulePauseOnNextStatement(InspectorFrontend::Debugger::Reason::EventListener, eventData.release());
+        m_debuggerAgent->schedulePauseOnNextStatement(InspectorDebuggerFrontendDispatcher::Reason::EventListener, eventData.release());
 }
 
 void InspectorDOMDebuggerAgent::setXHRBreakpoint(ErrorString*, const String& url)
@@ -414,7 +419,7 @@ void InspectorDOMDebuggerAgent::willSendXMLHttpRequest(const String& url)
     RefPtr<InspectorObject> eventData = InspectorObject::create();
     eventData->setString("breakpointURL", breakpointURL);
     eventData->setString("url", url);
-    m_debuggerAgent->breakProgram(InspectorFrontend::Debugger::Reason::XHR, eventData.release());
+    m_debuggerAgent->breakProgram(InspectorDebuggerFrontendDispatcher::Reason::XHR, eventData.release());
 }
 
 void InspectorDOMDebuggerAgent::clear()
index 381e214..ae25a03 100644 (file)
@@ -46,21 +46,20 @@ class Element;
 class InspectorAgent;
 class InspectorDOMAgent;
 class InspectorDebuggerAgent;
-class InspectorFrontend;
 class InspectorObject;
 class InstrumentingAgents;
 class Node;
 
 typedef String ErrorString;
 
-class InspectorDOMDebuggerAgent : public InspectorBaseAgent<InspectorDOMDebuggerAgent>, public InspectorDebuggerAgent::Listener, public InspectorBackendDispatcher::DOMDebuggerCommandHandler {
+class InspectorDOMDebuggerAgent : public InspectorBaseAgent, public InspectorDebuggerAgent::Listener, public InspectorBackendDispatcher::DOMDebuggerCommandHandler {
     WTF_MAKE_NONCOPYABLE(InspectorDOMDebuggerAgent);
 public:
     static PassOwnPtr<InspectorDOMDebuggerAgent> create(InstrumentingAgents*, InspectorDOMAgent*, InspectorDebuggerAgent*, InspectorAgent*);
 
     virtual ~InspectorDOMDebuggerAgent();
 
-    // DOMDebugger API for InspectorFrontend
+    // DOMDebugger API
     virtual void setXHRBreakpoint(ErrorString*, const String& url);
     virtual void removeXHRBreakpoint(ErrorString*, const String& url);
     virtual void setEventListenerBreakpoint(ErrorString*, const String& eventName);
@@ -80,7 +79,8 @@ public:
     void willSendXMLHttpRequest(const String& url);
     void pauseOnNativeEventIfNeeded(bool isDOMEvent, const String& eventName, bool synchronous);
 
-    virtual void clearFrontend();
+    virtual void didCreateFrontendAndBackend(InspectorFrontendChannel*, InspectorBackendDispatcher*) OVERRIDE;
+    virtual void willDestroyFrontendAndBackend() OVERRIDE;
     virtual void discardAgent();
 
 private:
index 59a9810..419af92 100644 (file)
@@ -56,9 +56,8 @@
 namespace WebCore {
 
 InspectorDOMStorageAgent::InspectorDOMStorageAgent(InstrumentingAgents* instrumentingAgents, InspectorPageAgent* pageAgent)
-    : InspectorBaseAgent<InspectorDOMStorageAgent>("DOMStorage", instrumentingAgents)
+    : InspectorBaseAgent(ASCIILiteral("DOMStorage"), instrumentingAgents)
     , m_pageAgent(pageAgent)
-    , m_frontend(0)
     , m_enabled(false)
 {
     m_instrumentingAgents->setInspectorDOMStorageAgent(this);
@@ -70,15 +69,17 @@ InspectorDOMStorageAgent::~InspectorDOMStorageAgent()
     m_instrumentingAgents = 0;
 }
 
-void InspectorDOMStorageAgent::setFrontend(InspectorFrontend* frontend)
+void InspectorDOMStorageAgent::didCreateFrontendAndBackend(InspectorFrontendChannel* frontendChannel, InspectorBackendDispatcher* backendDispatcher)
 {
-    m_frontend = frontend;
+    m_frontendDispatcher = std::make_unique<InspectorDOMStorageFrontendDispatcher>(frontendChannel);
+    backendDispatcher->registerAgent(this);
 }
 
-void InspectorDOMStorageAgent::clearFrontend()
+void InspectorDOMStorageAgent::willDestroyFrontendAndBackend()
 {
-    m_frontend = 0;
-    disable(0);
+    m_frontendDispatcher = nullptr;
+
+    disable(nullptr);
 }
 
 void InspectorDOMStorageAgent::enable(ErrorString*)
@@ -164,19 +165,19 @@ PassRefPtr<TypeBuilder::DOMStorage::StorageId> InspectorDOMStorageAgent::storage
 
 void InspectorDOMStorageAgent::didDispatchDOMStorageEvent(const String& key, const String& oldValue, const String& newValue, StorageType storageType, SecurityOrigin* securityOrigin, Page*)
 {
-    if (!m_frontend || !m_enabled)
+    if (!m_frontendDispatcher || !m_enabled)
         return;
 
     RefPtr<TypeBuilder::DOMStorage::StorageId> id = storageId(securityOrigin, storageType == LocalStorage);
 
     if (key.isNull())
-        m_frontend->domstorage()->domStorageItemsCleared(id);
+        m_frontendDispatcher->domStorageItemsCleared(id);
     else if (newValue.isNull())
-        m_frontend->domstorage()->domStorageItemRemoved(id, key);
+        m_frontendDispatcher->domStorageItemRemoved(id, key);
     else if (oldValue.isNull())
-        m_frontend->domstorage()->domStorageItemAdded(id, key, newValue);
+        m_frontendDispatcher->domStorageItemAdded(id, key, newValue);
     else
-        m_frontend->domstorage()->domStorageItemUpdated(id, key, oldValue, newValue);
+        m_frontendDispatcher->domStorageItemUpdated(id, key, oldValue, newValue);
 }
 
 PassRefPtr<StorageArea> InspectorDOMStorageAgent::findStorageArea(ErrorString* errorString, const RefPtr<InspectorObject>& storageId, Frame*& targetFrame)
index a9a08cd..84ab932 100644 (file)
@@ -39,7 +39,7 @@ namespace WebCore {
 
 class Frame;
 class InspectorArray;
-class InspectorFrontend;
+class InspectorDOMStorageFrontendDispatcher;
 class InspectorPageAgent;
 class InstrumentingAgents;
 class Page;
@@ -49,7 +49,7 @@ class StorageArea;
 
 typedef String ErrorString;
 
-class InspectorDOMStorageAgent : public InspectorBaseAgent<InspectorDOMStorageAgent>, public InspectorBackendDispatcher::DOMStorageCommandHandler {
+class InspectorDOMStorageAgent : public InspectorBaseAgent, public InspectorBackendDispatcher::DOMStorageCommandHandler {
 public:
     static PassOwnPtr<InspectorDOMStorageAgent> create(InstrumentingAgents* instrumentingAgents, InspectorPageAgent* pageAgent)
     {
@@ -57,8 +57,8 @@ public:
     }
     ~InspectorDOMStorageAgent();
 
-    virtual void setFrontend(InspectorFrontend*);
-    virtual void clearFrontend();
+    virtual void didCreateFrontendAndBackend(InspectorFrontendChannel*, InspectorBackendDispatcher*) OVERRIDE;
+    virtual void willDestroyFrontendAndBackend() OVERRIDE;
 
     // Called from the front-end.
     virtual void enable(ErrorString*);
@@ -81,7 +81,7 @@ private:
     PassRefPtr<StorageArea> findStorageArea(ErrorString*, const RefPtr<InspectorObject>&, Frame*&);
 
     InspectorPageAgent* m_pageAgent;
-    InspectorFrontend* m_frontend;
+    std::unique_ptr<InspectorDOMStorageFrontendDispatcher> m_frontendDispatcher;
     bool m_enabled;
 };
 
index f4288a7..7a77415 100644 (file)
@@ -201,8 +201,8 @@ void InspectorDatabaseAgent::didOpenDatabase(PassRefPtr<Database> database, cons
     RefPtr<InspectorDatabaseResource> resource = InspectorDatabaseResource::create(database, domain, name, version);
     m_resources.set(resource->id(), resource);
     // Resources are only bound while visible.
-    if (m_frontend && m_enabled)
-        resource->bind(m_frontend);
+    if (m_frontendDispatcher && m_enabled)
+        resource->bind(m_frontendDispatcher.get());
 }
 
 void InspectorDatabaseAgent::clearResources()
@@ -211,7 +211,7 @@ void InspectorDatabaseAgent::clearResources()
 }
 
 InspectorDatabaseAgent::InspectorDatabaseAgent(InstrumentingAgents* instrumentingAgents)
-    : InspectorBaseAgent<InspectorDatabaseAgent>("Database", instrumentingAgents)
+    : InspectorBaseAgent(ASCIILiteral("Database"), instrumentingAgents)
     , m_enabled(false)
 {
     m_instrumentingAgents->setInspectorDatabaseAgent(this);
@@ -222,15 +222,17 @@ InspectorDatabaseAgent::~InspectorDatabaseAgent()
     m_instrumentingAgents->setInspectorDatabaseAgent(0);
 }
 
-void InspectorDatabaseAgent::setFrontend(InspectorFrontend* frontend)
+void InspectorDatabaseAgent::didCreateFrontendAndBackend(InspectorFrontendChannel* frontendChannel, InspectorBackendDispatcher* backendDispatcher)
 {
-    m_frontend = frontend->database();
+    m_frontendDispatcher = std::make_unique<InspectorDatabaseFrontendDispatcher>(frontendChannel);
+    backendDispatcher->registerAgent(this);
 }
 
-void InspectorDatabaseAgent::clearFrontend()
+void InspectorDatabaseAgent::willDestroyFrontendAndBackend()
 {
-    m_frontend = 0;
-    disable(0);
+    m_frontendDispatcher = nullptr;
+
+    disable(nullptr);
 }
 
 void InspectorDatabaseAgent::enable(ErrorString*)
@@ -241,7 +243,7 @@ void InspectorDatabaseAgent::enable(ErrorString*)
 
     DatabaseResourcesMap::iterator databasesEnd = m_resources.end();
     for (DatabaseResourcesMap::iterator it = m_resources.begin(); it != databasesEnd; ++it)
-        it->value->bind(m_frontend);
+        it->value->bind(m_frontendDispatcher.get());
 }
 
 void InspectorDatabaseAgent::disable(ErrorString*)
index 58a1d65..a21bca8 100644 (file)
@@ -42,12 +42,11 @@ namespace WebCore {
 class Database;
 class InspectorArray;
 class InspectorDatabaseResource;
-class InspectorFrontend;
 class InstrumentingAgents;
 
 typedef String ErrorString;
 
-class InspectorDatabaseAgent : public InspectorBaseAgent<InspectorDatabaseAgent>, public InspectorBackendDispatcher::DatabaseCommandHandler {
+class InspectorDatabaseAgent : public InspectorBaseAgent, public InspectorBackendDispatcher::DatabaseCommandHandler {
 public:
     static PassOwnPtr<InspectorDatabaseAgent> create(InstrumentingAgents* instrumentingAgents)
     {
@@ -55,8 +54,8 @@ public:
     }
     ~InspectorDatabaseAgent();
 
-    virtual void setFrontend(InspectorFrontend*);
-    virtual void clearFrontend();
+    virtual void didCreateFrontendAndBackend(InspectorFrontendChannel*, InspectorBackendDispatcher*) OVERRIDE;
+    virtual void willDestroyFrontendAndBackend() OVERRIDE;
 
     void clearResources();
 
@@ -76,7 +75,7 @@ private:
     Database* databaseForId(const String& databaseId);
     InspectorDatabaseResource* findByFileName(const String& fileName);
 
-    InspectorFrontend::Database* m_frontend;
+    std::unique_ptr<InspectorDatabaseFrontendDispatcher> m_frontendDispatcher;
     typedef HashMap<String, RefPtr<InspectorDatabaseResource>> DatabaseResourcesMap;
     DatabaseResourcesMap m_resources;
     bool m_enabled;
index 0f46538..9d4b73f 100644 (file)
@@ -56,14 +56,14 @@ InspectorDatabaseResource::InspectorDatabaseResource(PassRefPtr<Database> databa
 {
 }
 
-void InspectorDatabaseResource::bind(InspectorFrontend::Database* frontend)
+void InspectorDatabaseResource::bind(InspectorDatabaseFrontendDispatcher* databaseFrontendDispatcher)
 {
     RefPtr<TypeBuilder::Database::Database> jsonObject = TypeBuilder::Database::Database::create()
         .setId(m_id)
         .setDomain(m_domain)
         .setName(m_name)
         .setVersion(m_version);
-    frontend->addDatabase(jsonObject);
+    databaseFrontendDispatcher->addDatabase(jsonObject);
 }
 
 } // namespace WebCore
index a6bb0c0..80c2ae4 100644 (file)
 #include <wtf/text/WTFString.h>
 
 namespace WebCore {
+
 class Database;
-class InspectorFrontend;
 
 class InspectorDatabaseResource : public RefCounted<InspectorDatabaseResource> {
 public:
     static PassRefPtr<InspectorDatabaseResource> create(PassRefPtr<Database> database, const String& domain, const String& name, const String& version);
 
-    void bind(InspectorFrontend::Database*);
+    void bind(InspectorDatabaseFrontendDispatcher*);
     Database* database() { return m_database.get(); }
     void setDatabase(PassRefPtr<Database> database) { m_database = database; }
     String id() const { return m_id; }
index 6faee89..2df58c3 100644 (file)
@@ -55,9 +55,8 @@ namespace WebCore {
 const char* InspectorDebuggerAgent::backtraceObjectGroup = "backtrace";
 
 InspectorDebuggerAgent::InspectorDebuggerAgent(InstrumentingAgents* instrumentingAgents, InjectedScriptManager* injectedScriptManager)
-    : InspectorBaseAgent<InspectorDebuggerAgent>("Debugger", instrumentingAgents)
+    : InspectorBaseAgent(ASCIILiteral("Debugger"), instrumentingAgents)
     , m_injectedScriptManager(injectedScriptManager)
-    , m_frontend(0)
     , m_pausedScriptState(0)
     , m_continueToLocationBreakpointID(noBreakpointID)
     , m_enabled(false)
@@ -126,7 +125,7 @@ void InspectorDebuggerAgent::enable(ErrorString*)
 
     enable();
 
-    ASSERT(m_frontend);
+    ASSERT(m_frontendDispatcher);
 }
 
 void InspectorDebuggerAgent::disable(ErrorString*)
@@ -137,17 +136,15 @@ void InspectorDebuggerAgent::disable(ErrorString*)
     disable();
 }
 
-void InspectorDebuggerAgent::setFrontend(InspectorFrontend* frontend)
+void InspectorDebuggerAgent::didCreateFrontendAndBackend(InspectorFrontendChannel* frontendChannel, InspectorBackendDispatcher* backendDispatcher)
 {
-    m_frontend = frontend->debugger();
+    m_frontendDispatcher = std::make_unique<InspectorDebuggerFrontendDispatcher>(frontendChannel);
+    backendDispatcher->registerAgent(this);
 }
 
-void InspectorDebuggerAgent::clearFrontend()
+void InspectorDebuggerAgent::willDestroyFrontendAndBackend()
 {
-    m_frontend = 0;
-
-    if (!enabled())
-        return;
+    m_frontendDispatcher = nullptr;
 
     disable();
 }
@@ -173,7 +170,7 @@ bool InspectorDebuggerAgent::runningNestedMessageLoop()
 void InspectorDebuggerAgent::addMessageToConsole(MessageSource source, MessageType type)
 {
     if (scriptDebugServer().pauseOnExceptionsState() != ScriptDebugServer::DontPauseOnExceptions && source == ConsoleAPIMessageSource && type == AssertMessageType)
-        breakProgram(InspectorFrontend::Debugger::Reason::Assert, 0);
+        breakProgram(InspectorDebuggerFrontendDispatcher::Reason::Assert, 0);
 }
 
 static PassRefPtr<InspectorObject> buildObjectForBreakpointCookie(const String& url, int lineNumber, int columnNumber, const String& condition, RefPtr<InspectorArray>& actions, bool isRegex, bool autoContinue)
@@ -467,7 +464,7 @@ void InspectorDebuggerAgent::getFunctionDetails(ErrorString* errorString, const
     injectedScript.getFunctionDetails(errorString, functionId, &details);
 }
 
-void InspectorDebuggerAgent::schedulePauseOnNextStatement(InspectorFrontend::Debugger::Reason::Enum breakReason, PassRefPtr<InspectorObject> data)
+void InspectorDebuggerAgent::schedulePauseOnNextStatement(InspectorDebuggerFrontendDispatcher::Reason::Enum breakReason, PassRefPtr<InspectorObject> data)
 {
     if (m_javaScriptPauseScheduled)
         return;
@@ -636,7 +633,7 @@ void InspectorDebuggerAgent::scriptExecutionBlockedByCSP(const String& directive
     if (scriptDebugServer().pauseOnExceptionsState() != ScriptDebugServer::DontPauseOnExceptions) {
         RefPtr<InspectorObject> directive = InspectorObject::create();
         directive->setString("directiveText", directiveText);
-        breakProgram(InspectorFrontend::Debugger::Reason::CSPViolation, directive.release());
+        breakProgram(InspectorDebuggerFrontendDispatcher::Reason::CSPViolation, directive.release());
     }
 }
 
@@ -690,7 +687,7 @@ void InspectorDebuggerAgent::didParseSource(SourceID sourceID, const Script& inS
     String* sourceMapURLParam = script.sourceMappingURL.isNull() ? 0 : &script.sourceMappingURL;
     const bool* isContentScript = script.isContentScript ? &script.isContentScript : 0;
     String scriptIDStr = String::number(sourceID);
-    m_frontend->scriptParsed(scriptIDStr, scriptURL, script.startLine, script.startColumn, script.endLine, script.endColumn, isContentScript, sourceMapURLParam, hasSourceURLParam);
+    m_frontendDispatcher->scriptParsed(scriptIDStr, scriptURL, script.startLine, script.startColumn, script.endLine, script.endColumn, isContentScript, sourceMapURLParam, hasSourceURLParam);
 
     m_scripts.set(sourceID, script);
 
@@ -719,13 +716,13 @@ void InspectorDebuggerAgent::didParseSource(SourceID sourceID, const Script& inS
 
         RefPtr<TypeBuilder::Debugger::Location> location = resolveBreakpoint(it->key, sourceID, breakpoint);
         if (location)
-            m_frontend->breakpointResolved(it->key, location);
+            m_frontendDispatcher->breakpointResolved(it->key, location);
     }
 }
 
 void InspectorDebuggerAgent::failedToParseSource(const String& url, const String& data, int firstLine, int errorLine, const String& errorMessage)
 {
-    m_frontend->scriptFailedToParse(url, data, firstLine, errorLine, errorMessage);
+    m_frontendDispatcher->scriptFailedToParse(url, data, firstLine, errorLine, errorMessage);
 }
 
 void InspectorDebuggerAgent::didPause(JSC::ExecState* scriptState, const ScriptValue& callFrames, const ScriptValue& exception)
@@ -737,13 +734,13 @@ void InspectorDebuggerAgent::didPause(JSC::ExecState* scriptState, const ScriptV
     if (!exception.hasNoValue()) {
         InjectedScript injectedScript = m_injectedScriptManager->injectedScriptFor(scriptState);
         if (!injectedScript.hasNoValue()) {
-            m_breakReason = InspectorFrontend::Debugger::Reason::Exception;
+            m_breakReason = InspectorDebuggerFrontendDispatcher::Reason::Exception;
             m_breakAuxData = injectedScript.wrapObject(exception, "backtrace")->openAccessors();
             // m_breakAuxData might be null after this.
         }
     }
 
-    m_frontend->paused(currentCallFrames(), m_breakReason, m_breakAuxData);
+    m_frontendDispatcher->paused(currentCallFrames(), m_breakReason, m_breakAuxData);
     m_javaScriptPauseScheduled = false;
 
     if (m_continueToLocationBreakpointID != noBreakpointID) {
@@ -759,10 +756,10 @@ void InspectorDebuggerAgent::didContinue()
     m_pausedScriptState = 0;
     m_currentCallStack = ScriptValue();
     clearBreakDetails();
-    m_frontend->resumed();
+    m_frontendDispatcher->resumed();
 }
 
-void InspectorDebuggerAgent::breakProgram(InspectorFrontend::Debugger::Reason::Enum breakReason, PassRefPtr<InspectorObject> data)
+void InspectorDebuggerAgent::breakProgram(InspectorDebuggerFrontendDispatcher::Reason::Enum breakReason, PassRefPtr<InspectorObject> data)
 {
     m_breakReason = breakReason;
     m_breakAuxData = data;
@@ -793,7 +790,7 @@ bool InspectorDebuggerAgent::assertPaused(ErrorString* errorString)
 
 void InspectorDebuggerAgent::clearBreakDetails()
 {
-    m_breakReason = InspectorFrontend::Debugger::Reason::Other;
+    m_breakReason = InspectorDebuggerFrontendDispatcher::Reason::Other;
     m_breakAuxData = 0;
 }
 
@@ -802,8 +799,8 @@ void InspectorDebuggerAgent::reset()
     scriptDebugServer().clearBreakpoints();
     m_scripts.clear();
     m_breakpointIdentifierToDebugServerBreakpointIDs.clear();
-    if (m_frontend)
-        m_frontend->globalObjectCleared();
+    if (m_frontendDispatcher)
+        m_frontendDispatcher->globalObjectCleared();
 }
 
 } // namespace WebCore
index 95e19f4..42951dd 100644 (file)
@@ -51,7 +51,6 @@
 namespace WebCore {
 
 class InjectedScriptManager;
-class InspectorFrontend;
 class InspectorArray;
 class InspectorObject;
 class InspectorValue;
@@ -61,7 +60,7 @@ class ScriptValue;
 
 typedef String ErrorString;
 
-class InspectorDebuggerAgent : public InspectorBaseAgent<InspectorDebuggerAgent>, public ScriptDebugListener, public InspectorBackendDispatcher::DebuggerCommandHandler {
+class InspectorDebuggerAgent : public InspectorBaseAgent, public ScriptDebugListener, public InspectorBackendDispatcher::DebuggerCommandHandler {
     WTF_MAKE_NONCOPYABLE(InspectorDebuggerAgent); WTF_MAKE_FAST_ALLOCATED;
 public:
     static const char* backtraceObjectGroup;
@@ -72,8 +71,8 @@ public:
     virtual void canSetScriptSource(ErrorString*, bool*);
     virtual void supportsSeparateScriptCompilationAndExecution(ErrorString*, bool*);
 
-    virtual void setFrontend(InspectorFrontend*);
-    virtual void clearFrontend();
+    virtual void didCreateFrontendAndBackend(InspectorFrontendChannel*, InspectorBackendDispatcher*) OVERRIDE;
+    virtual void willDestroyFrontendAndBackend() OVERRIDE;
 
     bool isPaused();
     bool runningNestedMessageLoop();
@@ -113,9 +112,9 @@ public:
     void runScript(ErrorString*, const TypeBuilder::Debugger::ScriptId&, const int* executionContextId, const String* objectGroup, const bool* doNotPauseOnExceptionsAndMuteConsole, RefPtr<TypeBuilder::Runtime::RemoteObject>& result, TypeBuilder::OptOutput<bool>* wasThrown);
     virtual void setOverlayMessage(ErrorString*, const String*);
 
-    void schedulePauseOnNextStatement(InspectorFrontend::Debugger::Reason::Enum breakReason, PassRefPtr<InspectorObject> data);
+    void schedulePauseOnNextStatement(InspectorDebuggerFrontendDispatcher::Reason::Enum breakReason, PassRefPtr<InspectorObject> data);
     void cancelPauseOnNextStatement();
-    void breakProgram(InspectorFrontend::Debugger::Reason::Enum breakReason, PassRefPtr<InspectorObject> data);
+    void breakProgram(InspectorDebuggerFrontendDispatcher::Reason::Enum breakReason, PassRefPtr<InspectorObject> data);
     virtual void scriptExecutionBlockedByCSP(const String& directiveText);
 
     class Listener {
@@ -168,14 +167,14 @@ private:
     typedef HashMap<String, RefPtr<InspectorObject>> BreakpointIdentifierToBreakpointMap;
 
     InjectedScriptManager* m_injectedScriptManager;
-    InspectorFrontend::Debugger* m_frontend;
+    std::unique_ptr<InspectorDebuggerFrontendDispatcher> m_frontendDispatcher;
     JSC::ExecState* m_pausedScriptState;
     ScriptValue m_currentCallStack;
     ScriptsMap m_scripts;
     BreakpointIdentifierToDebugServerBreakpointIDsMap m_breakpointIdentifierToDebugServerBreakpointIDs;
     BreakpointIdentifierToBreakpointMap m_javaScriptBreakpoints;
     BreakpointID m_continueToLocationBreakpointID;
-    InspectorFrontend::Debugger::Reason::Enum m_breakReason;
+    InspectorDebuggerFrontendDispatcher::Reason::Enum m_breakReason;
     RefPtr<InspectorObject> m_breakAuxData;
     bool m_enabled;
     bool m_javaScriptPauseScheduled;
index 4b2c1b6..8ccbf15 100644 (file)
@@ -49,9 +49,8 @@ PassOwnPtr<InspectorHeapProfilerAgent> InspectorHeapProfilerAgent::create(Instru
 }
 
 InspectorHeapProfilerAgent::InspectorHeapProfilerAgent(InstrumentingAgents* instrumentingAgents, InjectedScriptManager* injectedScriptManager)
-    : InspectorBaseAgent<InspectorHeapProfilerAgent>("HeapProfiler", instrumentingAgents)
+    : InspectorBaseAgent(ASCIILiteral("HeapProfiler"), instrumentingAgents)
     , m_injectedScriptManager(injectedScriptManager)
-    , m_frontend(0)
     , m_nextUserInitiatedHeapSnapshotNumber(1)
     , m_profileHeadersRequested(false)
 {
@@ -73,23 +72,25 @@ void InspectorHeapProfilerAgent::resetState()
 
 void InspectorHeapProfilerAgent::resetFrontendProfiles()
 {
-    if (!m_frontend)
+    if (!m_frontendDispatcher)
         return;
     if (!m_profileHeadersRequested)
         return;
     if (m_snapshots.isEmpty())
-        m_frontend->resetProfiles();
+        m_frontendDispatcher->resetProfiles();
 }
 
-void InspectorHeapProfilerAgent::setFrontend(InspectorFrontend* frontend)
+void InspectorHeapProfilerAgent::didCreateFrontendAndBackend(InspectorFrontendChannel* frontendChannel, InspectorBackendDispatcher* backendDispatcher)
 {
-    m_frontend = frontend->heapprofiler();
+    m_frontendDispatcher = std::make_unique<InspectorHeapProfilerFrontendDispatcher>(frontendChannel);
+    backendDispatcher->registerAgent(this);
 }
 
-void InspectorHeapProfilerAgent::clearFrontend()
+void InspectorHeapProfilerAgent::willDestroyFrontendAndBackend()
 {
+    m_frontendDispatcher = nullptr;
+
     m_profileHeadersRequested = false;
-    m_frontend = 0;
 }
 
 void InspectorHeapProfilerAgent::collectGarbage(WebCore::ErrorString*)
@@ -125,12 +126,12 @@ void InspectorHeapProfilerAgent::getHeapSnapshot(ErrorString* errorString, int r
 {
     class OutputStream : public ScriptHeapSnapshot::OutputStream {
     public:
-        OutputStream(InspectorFrontend::HeapProfiler* frontend, unsigned uid)
-            : m_frontend(frontend), m_uid(uid) { }
-        void Write(const String& chunk) { m_frontend->addHeapSnapshotChunk(m_uid, chunk); }
-        void Close() { m_frontend->finishHeapSnapshot(m_uid); }
+        OutputStream(InspectorHeapProfilerFrontendDispatcher* frontend, unsigned uid)
+            : m_frontendDispatcher(frontend), m_uid(uid) { }
+        void Write(const String& chunk) { m_frontendDispatcher->addHeapSnapshotChunk(m_uid, chunk); }
+        void Close() { m_frontendDispatcher->finishHeapSnapshot(m_uid); }
     private:
-        InspectorFrontend::HeapProfiler* m_frontend;
+        InspectorHeapProfilerFrontendDispatcher* m_frontendDispatcher;
         int m_uid;
     };
 
@@ -141,8 +142,8 @@ void InspectorHeapProfilerAgent::getHeapSnapshot(ErrorString* errorString, int r
         return;
     }
     RefPtr<ScriptHeapSnapshot> snapshot = it->value;
-    if (m_frontend) {
-        OutputStream stream(m_frontend, uid);
+    if (m_frontendDispatcher) {
+        OutputStream stream(m_frontendDispatcher.get(), uid);
         snapshot->writeJSON(&stream);
     }
 }
@@ -158,33 +159,33 @@ void InspectorHeapProfilerAgent::takeHeapSnapshot(ErrorString*, const bool* repo
 {
     class HeapSnapshotProgress: public ScriptProfiler::HeapSnapshotProgress {
     public:
-        explicit HeapSnapshotProgress(InspectorFrontend::HeapProfiler* frontend)
-            : m_frontend(frontend) { }
+        explicit HeapSnapshotProgress(InspectorHeapProfilerFrontendDispatcher* frontend)
+            : m_frontendDispatcher(frontend) { }
         void Start(int totalWork)
         {
             m_totalWork = totalWork;
         }
         void Worked(int workDone)
         {
-            if (m_frontend)
-                m_frontend->reportHeapSnapshotProgress(workDone, m_totalWork);
+            if (m_frontendDispatcher)
+                m_frontendDispatcher->reportHeapSnapshotProgress(workDone, m_totalWork);
         }
         void Done() { }
         bool isCanceled() { return false; }
     private:
-        InspectorFrontend::HeapProfiler* m_frontend;
+        InspectorHeapProfilerFrontendDispatcher* m_frontendDispatcher;
         int m_totalWork;
     };
 
     String title = makeString(UserInitiatedProfileNameHeap, '.', String::number(m_nextUserInitiatedHeapSnapshotNumber));
     ++m_nextUserInitiatedHeapSnapshotNumber;
 
-    HeapSnapshotProgress progress(reportProgress && *reportProgress ? m_frontend : 0);
+    HeapSnapshotProgress progress(reportProgress && *reportProgress ? m_frontendDispatcher.get() : nullptr);
     RefPtr<ScriptHeapSnapshot> snapshot = ScriptProfiler::takeHeapSnapshot(title, &progress);
     if (snapshot) {
         m_snapshots.add(snapshot->uid(), snapshot);
-        if (m_frontend)
-            m_frontend->addProfileHeader(createSnapshotHeader(*snapshot));
+        if (m_frontendDispatcher)
+            m_frontendDispatcher->addProfileHeader(createSnapshotHeader(*snapshot));
     }
 }
 
index 935e89a..26c2d19 100644 (file)
@@ -49,7 +49,7 @@ class ScriptProfile;
 
 typedef String ErrorString;
 
-class InspectorHeapProfilerAgent : public InspectorBaseAgent<InspectorHeapProfilerAgent>, public InspectorBackendDispatcher::HeapProfilerCommandHandler {
+class InspectorHeapProfilerAgent : public InspectorBaseAgent, public InspectorBackendDispatcher::HeapProfilerCommandHandler {
     WTF_MAKE_NONCOPYABLE(InspectorHeapProfilerAgent); WTF_MAKE_FAST_ALLOCATED;
 public:
     static PassOwnPtr<InspectorHeapProfilerAgent> create(InstrumentingAgents*, InjectedScriptManager*);
@@ -65,8 +65,8 @@ public:
     virtual void getHeapSnapshot(ErrorString*, int uid);
     virtual void removeProfile(ErrorString*, int uid);
 
-    virtual void setFrontend(InspectorFrontend*);
-    virtual void clearFrontend();
+    virtual void didCreateFrontendAndBackend(InspectorFrontendChannel*, InspectorBackendDispatcher*) OVERRIDE;
+    virtual void willDestroyFrontendAndBackend() OVERRIDE;
 
     virtual void takeHeapSnapshot(ErrorString*, const bool* reportProgress);
 
@@ -83,7 +83,7 @@ private:
     PassRefPtr<TypeBuilder::HeapProfiler::ProfileHeader> createSnapshotHeader(const ScriptHeapSnapshot&);
 
     InjectedScriptManager* m_injectedScriptManager;
-    InspectorFrontend::HeapProfiler* m_frontend;
+    std::unique_ptr<InspectorHeapProfilerFrontendDispatcher> m_frontendDispatcher;
     unsigned m_nextUserInitiatedHeapSnapshotNumber;
     IdToHeapSnapshotMap m_snapshots;
     bool m_profileHeadersRequested;
index 4f87912..1e27207 100644 (file)
@@ -557,7 +557,7 @@ public:
 } // namespace
 
 InspectorIndexedDBAgent::InspectorIndexedDBAgent(InstrumentingAgents* instrumentingAgents, InjectedScriptManager* injectedScriptManager, InspectorPageAgent* pageAgent)
-    : InspectorBaseAgent<InspectorIndexedDBAgent>("IndexedDB", instrumentingAgents)
+    : InspectorBaseAgent(ASCIILiteral("IndexedDB"), instrumentingAgents)
     , m_injectedScriptManager(injectedScriptManager)
     , m_pageAgent(pageAgent)
 {
@@ -567,9 +567,14 @@ InspectorIndexedDBAgent::~InspectorIndexedDBAgent()
 {
 }
 
-void InspectorIndexedDBAgent::clearFrontend()
+void InspectorIndexedDBAgent::didCreateFrontendAndBackend(InspectorFrontendChannel*, InspectorBackendDispatcher* backendDispatcher)
 {
-    disable(0);
+    backendDispatcher->registerAgent(this);
+}
+
+void InspectorIndexedDBAgent::willDestroyFrontendAndBackend()
+{
+    disable(nullptr);
 }
 
 void InspectorIndexedDBAgent::enable(ErrorString*)
index 8f9a8c7..ef40dbc 100644 (file)
@@ -44,7 +44,7 @@ class InspectorPageAgent;
 
 typedef String ErrorString;
 
-class InspectorIndexedDBAgent : public InspectorBaseAgent<InspectorIndexedDBAgent>, public InspectorBackendDispatcher::IndexedDBCommandHandler {
+class InspectorIndexedDBAgent : public InspectorBaseAgent, public InspectorBackendDispatcher::IndexedDBCommandHandler {
 public:
     static PassOwnPtr<InspectorIndexedDBAgent> create(InstrumentingAgents* instrumentingAgents, InjectedScriptManager* injectedScriptManager, InspectorPageAgent* pageAgent)
     {
@@ -52,7 +52,8 @@ public:
     }
     ~InspectorIndexedDBAgent();
 
-    virtual void clearFrontend();
+    virtual void didCreateFrontendAndBackend(InspectorFrontendChannel*, InspectorBackendDispatcher*) OVERRIDE;
+    virtual void willDestroyFrontendAndBackend() OVERRIDE;
 
     // Called from the front-end.
     virtual void enable(ErrorString*);
index 3142eda..f26d71d 100644 (file)
@@ -52,7 +52,7 @@
 namespace WebCore {
 
 InspectorInputAgent::InspectorInputAgent(InstrumentingAgents* instrumentingAgents, Page* page)
-    : InspectorBaseAgent<InspectorInputAgent>("Input", instrumentingAgents)
+    : InspectorBaseAgent(ASCIILiteral("Input"), instrumentingAgents)
     , m_page(page)
 {
 }
@@ -61,6 +61,15 @@ InspectorInputAgent::~InspectorInputAgent()
 {
 }
 
+void InspectorInputAgent::didCreateFrontendAndBackend(InspectorFrontendChannel*, InspectorBackendDispatcher* backendDispatcher)
+{
+    backendDispatcher->registerAgent(this);
+}
+
+void InspectorInputAgent::willDestroyFrontendAndBackend()
+{
+}
+
 void InspectorInputAgent::dispatchKeyEvent(ErrorString* error, const String& type, const int* modifiers, const double* timestamp, const String* text, const String* unmodifiedText, const String* keyIdentifier, const int* windowsVirtualKeyCode, const int* nativeVirtualKeyCode, const int* macCharCode, const bool* autoRepeat, const bool* isKeypad, const bool* isSystemKey)
 {
     PlatformEvent::Type convertedType;
index a85ad3a..3f71e74 100644 (file)
@@ -44,7 +44,7 @@ class Page;
 
 typedef String ErrorString;
 
-class InspectorInputAgent : public InspectorBaseAgent<InspectorInputAgent>, public InspectorBackendDispatcher::InputCommandHandler {
+class InspectorInputAgent : public InspectorBaseAgent, public InspectorBackendDispatcher::InputCommandHandler {
     WTF_MAKE_NONCOPYABLE(InspectorInputAgent);
 public:
     static PassOwnPtr<InspectorInputAgent> create(InstrumentingAgents* instrumentingAgents, Page* page)
@@ -54,6 +54,9 @@ public:
 
     ~InspectorInputAgent();
 
+    virtual void didCreateFrontendAndBackend(InspectorFrontendChannel*, InspectorBackendDispatcher*) OVERRIDE;
+    virtual void willDestroyFrontendAndBackend() OVERRIDE;
+
     // Methods called from the frontend for simulating input.
     virtual void dispatchKeyEvent(ErrorString*, const String& type, const int* modifiers, const double* timestamp, const String* text, const String* unmodifiedText, const String* keyIdentifier, const int* windowsVirtualKeyCode, const int* nativeVirtualKeyCode, const int* macCharCode, const bool* autoRepeat, const bool* isKeypad, const bool* isSystemKey);
     virtual void dispatchMouseEvent(ErrorString*, const String& type, int x, int y, const int* modifiers, const double* timestamp, const String* button, const int* clickCount);
index 9f52c6e..35a511e 100644 (file)
@@ -49,8 +49,7 @@
 namespace WebCore {
 
 InspectorLayerTreeAgent::InspectorLayerTreeAgent(InstrumentingAgents* instrumentingAgents)
-    : InspectorBaseAgent<InspectorLayerTreeAgent>("LayerTree", instrumentingAgents)
-    , m_frontend(0)
+    : InspectorBaseAgent(ASCIILiteral("LayerTree"), instrumentingAgents)
 {
 }
 
@@ -59,15 +58,17 @@ InspectorLayerTreeAgent::~InspectorLayerTreeAgent()
     reset();
 }
 
-void InspectorLayerTreeAgent::setFrontend(InspectorFrontend* frontend)
+void InspectorLayerTreeAgent::didCreateFrontendAndBackend(InspectorFrontendChannel* frontendChannel, InspectorBackendDispatcher* backendDispatcher)
 {
-    m_frontend = frontend->layertree();
+    m_frontendDispatcher = std::make_unique<InspectorLayerTreeFrontendDispatcher>(frontendChannel);
+    backendDispatcher->registerAgent(this);
 }
 
-void InspectorLayerTreeAgent::clearFrontend()
+void InspectorLayerTreeAgent::willDestroyFrontendAndBackend()
 {
-    m_frontend = 0;
-    disable(0);
+    m_frontendDispatcher = nullptr;
+
+    disable(nullptr);
 }
 
 void InspectorLayerTreeAgent::reset()
@@ -90,7 +91,7 @@ void InspectorLayerTreeAgent::disable(ErrorString*)
 
 void InspectorLayerTreeAgent::layerTreeDidChange()
 {
-    m_frontend->layerTreeDidChange();
+    m_frontendDispatcher->layerTreeDidChange();
 }
 
 void InspectorLayerTreeAgent::renderLayerDestroyed(const RenderLayer* renderLayer)
index 53ba631..27d55d7 100644 (file)
@@ -46,7 +46,7 @@ class InstrumentingAgents;
 
 typedef String ErrorString;
 
-class InspectorLayerTreeAgent : public InspectorBaseAgent<InspectorLayerTreeAgent>, public InspectorBackendDispatcher::LayerTreeCommandHandler {
+class InspectorLayerTreeAgent : public InspectorBaseAgent, public InspectorBackendDispatcher::LayerTreeCommandHandler {
 public:
     static PassOwnPtr<InspectorLayerTreeAgent> create(InstrumentingAgents* instrumentingAgents)
     {
@@ -54,8 +54,8 @@ public:
     }
     ~InspectorLayerTreeAgent();
 
-    virtual void setFrontend(InspectorFrontend*);
-    virtual void clearFrontend();
+    virtual void didCreateFrontendAndBackend(InspectorFrontendChannel*, InspectorBackendDispatcher*) OVERRIDE;
+    virtual void willDestroyFrontendAndBackend() OVERRIDE;
     void reset();
 
     void layerTreeDidChange();
@@ -86,7 +86,7 @@ private:
     String bindPseudoElement(PseudoElement*);
     void unbindPseudoElement(PseudoElement*);
 
-    InspectorFrontend::LayerTree* m_frontend;
+    std::unique_ptr<InspectorLayerTreeFrontendDispatcher> m_frontendDispatcher;
 
     HashMap<const RenderLayer*, String> m_documentLayerToIdMap;
     HashMap<String, const RenderLayer*> m_idToLayer;
index 2632bd4..3c269fc 100644 (file)
@@ -67,6 +67,15 @@ InspectorMemoryAgent::~InspectorMemoryAgent()
 {
 }
 
+void InspectorMemoryAgent::didCreateFrontendAndBackend(InspectorFrontendChannel*, InspectorBackendDispatcher* backendDispatcher)
+{
+    backendDispatcher->registerAgent(this);
+}
+
+void InspectorMemoryAgent::willDestroyFrontendAndBackend()
+{
+}
+
 void InspectorMemoryAgent::getDOMCounters(ErrorString*, int* documents, int* nodes, int* jsEventListeners)
 {
     *documents = InspectorCounters::counterValue(InspectorCounters::DocumentCounter);
@@ -75,8 +84,7 @@ void InspectorMemoryAgent::getDOMCounters(ErrorString*, int* documents, int* nod
 }
 
 InspectorMemoryAgent::InspectorMemoryAgent(InstrumentingAgents* instrumentingAgents)
-    : InspectorBaseAgent<InspectorMemoryAgent>("Memory", instrumentingAgents)
-    , m_frontend(0)
+    : InspectorBaseAgent(ASCIILiteral("Memory"), instrumentingAgents)
 {
 }
 
@@ -85,18 +93,6 @@ PassOwnPtr<InspectorMemoryAgent> InspectorMemoryAgent::create(InstrumentingAgent
     return adoptPtr(new InspectorMemoryAgent(instrumentingAgents));
 }
 
-
-void InspectorMemoryAgent::setFrontend(InspectorFrontend* frontend)
-{
-    ASSERT(!m_frontend);
-    m_frontend = frontend->memory();
-}
-
-void InspectorMemoryAgent::clearFrontend()
-{
-    m_frontend = 0;
-}
-
 } // namespace WebCore
 
 #endif // ENABLE(INSPECTOR)
index 71d470d..f14dba9 100644 (file)
@@ -45,21 +45,19 @@ class InstrumentingAgents;
 
 typedef String ErrorString;
 
-class InspectorMemoryAgent : public InspectorBaseAgent<InspectorMemoryAgent>, public InspectorBackendDispatcher::MemoryCommandHandler {
+class InspectorMemoryAgent : public InspectorBaseAgent, public InspectorBackendDispatcher::MemoryCommandHandler {
     WTF_MAKE_NONCOPYABLE(InspectorMemoryAgent);
 public:
     static PassOwnPtr<InspectorMemoryAgent> create(InstrumentingAgents* instrumentingAgents);
     virtual ~InspectorMemoryAgent();
 
-    virtual void getDOMCounters(ErrorString*, int* documents, int* nodes, int* jsEventListeners);
+    virtual void didCreateFrontendAndBackend(InspectorFrontendChannel*, InspectorBackendDispatcher*) OVERRIDE;
+    virtual void willDestroyFrontendAndBackend() OVERRIDE;
 
-    virtual void setFrontend(InspectorFrontend*);
-    virtual void clearFrontend();
+    virtual void getDOMCounters(ErrorString*, int* documents, int* nodes, int* jsEventListeners);
 
 private:
     InspectorMemoryAgent(InstrumentingAgents*);
-
-    InspectorFrontend::Memory* m_frontend;
 };
 
 } // namespace WebCore
index 365919e..e136d11 100644 (file)
@@ -348,12 +348,11 @@ TypeBuilder::Page::ResourceType::Enum InspectorPageAgent::cachedResourceTypeJson
 }
 
 InspectorPageAgent::InspectorPageAgent(InstrumentingAgents* instrumentingAgents, Page* page, InspectorAgent* inspectorAgent, InjectedScriptManager* injectedScriptManager, InspectorClient* client, InspectorOverlay* overlay)
-    : InspectorBaseAgent<InspectorPageAgent>("Page", instrumentingAgents)
+    : InspectorBaseAgent(ASCIILiteral("Page"), instrumentingAgents)
     , m_page(page)
     , m_inspectorAgent(inspectorAgent)
     , m_injectedScriptManager(injectedScriptManager)
     , m_client(client)
-    , m_frontend(0)
     , m_overlay(overlay)
     , m_lastScriptIdentifier(0)
     , m_screenWidthOverride(0)
@@ -369,19 +368,21 @@ InspectorPageAgent::InspectorPageAgent(InstrumentingAgents* instrumentingAgents,
 {
 }
 
-void InspectorPageAgent::setFrontend(InspectorFrontend* frontend)
+void InspectorPageAgent::didCreateFrontendAndBackend(InspectorFrontendChannel* frontendChannel, InspectorBackendDispatcher* backendDispatcher)
 {
-    m_frontend = frontend->page();
+    m_frontendDispatcher = std::make_unique<InspectorPageFrontendDispatcher>(frontendChannel);
+    backendDispatcher->registerAgent(this);
 }
 
-void InspectorPageAgent::clearFrontend()
+void InspectorPageAgent::willDestroyFrontendAndBackend()
 {
+    m_frontendDispatcher = nullptr;
+
     ErrorString error;
     disable(&error);
 #if ENABLE(TOUCH_EVENTS)
     updateTouchEventEmulationInPage(false);
 #endif
-    m_frontend = 0;
 }
 
 void InspectorPageAgent::webViewResized(const IntSize& size)
@@ -819,7 +820,7 @@ void InspectorPageAgent::didClearWindowObjectInWorld(Frame* frame, DOMWrapperWor
     if (frame->isMainFrame())
         m_injectedScriptManager->discardInjectedScripts();
 
-    if (!m_frontend)
+    if (!m_frontendDispatcher)
         return;
 
     if (m_scriptsToEvaluateOnLoad) {
@@ -838,12 +839,12 @@ void InspectorPageAgent::didClearWindowObjectInWorld(Frame* frame, DOMWrapperWor
 void InspectorPageAgent::domContentEventFired()
 {
     m_isFirstLayoutAfterOnLoad = true;
-    m_frontend->domContentEventFired(currentTime());
+    m_frontendDispatcher->domContentEventFired(currentTime());
 }
 
 void InspectorPageAgent::loadEventFired()
 {
-    m_frontend->loadEventFired(currentTime());
+    m_frontendDispatcher->loadEventFired(currentTime());
 }
 
 void InspectorPageAgent::frameNavigated(DocumentLoader* loader)
@@ -854,14 +855,14 @@ void InspectorPageAgent::frameNavigated(DocumentLoader* loader)
         m_pendingScriptToEvaluateOnLoadOnce = String();
         m_pendingScriptPreprocessor = String();
     }
-    m_frontend->frameNavigated(buildObjectForFrame(loader->frame()));
+    m_frontendDispatcher->frameNavigated(buildObjectForFrame(loader->frame()));
 }
 
 void InspectorPageAgent::frameDetached(Frame* frame)
 {
     HashMap<Frame*, String>::iterator iterator = m_frameToIdentifier.find(frame);
     if (iterator != m_frameToIdentifier.end()) {
-        m_frontend->frameDetached(iterator->value);
+        m_frontendDispatcher->frameDetached(iterator->value);
         m_identifierToFrame.remove(iterator->value);
         m_frameToIdentifier.remove(iterator);
     }
@@ -945,32 +946,32 @@ void InspectorPageAgent::loaderDetachedFromFrame(DocumentLoader* loader)
 
 void InspectorPageAgent::frameStartedLoading(Frame* frame)
 {
-    m_frontend->frameStartedLoading(frameId(frame));
+    m_frontendDispatcher->frameStartedLoading(frameId(frame));
 }
 
 void InspectorPageAgent::frameStoppedLoading(Frame* frame)
 {
-    m_frontend->frameStoppedLoading(frameId(frame));
+    m_frontendDispatcher->frameStoppedLoading(frameId(frame));
 }
 
 void InspectorPageAgent::frameScheduledNavigation(Frame* frame, double delay)
 {
-    m_frontend->frameScheduledNavigation(frameId(frame), delay);
+    m_frontendDispatcher->frameScheduledNavigation(frameId(frame), delay);
 }
 
 void InspectorPageAgent::frameClearedScheduledNavigation(Frame* frame)
 {
-    m_frontend->frameClearedScheduledNavigation(frameId(frame));
+    m_frontendDispatcher->frameClearedScheduledNavigation(frameId(frame));
 }
 
 void InspectorPageAgent::willRunJavaScriptDialog(const String& message)
 {
-    m_frontend->javascriptDialogOpening(message);
+    m_frontendDispatcher->javascriptDialogOpening(message);
 }
 
 void InspectorPageAgent::didRunJavaScriptDialog()
 {
-    m_frontend->javascriptDialogClosed();
+    m_frontendDispatcher->javascriptDialogClosed();
 }
 
 void InspectorPageAgent::applyScreenWidthOverride(long* width)
@@ -1035,7 +1036,7 @@ void InspectorPageAgent::scriptsEnabled(bool isEnabled)
     if (m_ignoreScriptsEnabledNotification)
         return;
 
-    m_frontend->scriptsEnabled(isEnabled);
+    m_frontendDispatcher->scriptsEnabled(isEnabled);
 }
 
 PassRefPtr<TypeBuilder::Page::Frame> InspectorPageAgent::buildObjectForFrame(Frame* frame)
index 4e6ab7b..7645f44 100644 (file)
@@ -67,7 +67,7 @@ class TextResourceDecoder;
 
 typedef String ErrorString;
 
-class InspectorPageAgent : public InspectorBaseAgent<InspectorPageAgent>, public InspectorBackendDispatcher::PageCommandHandler {
+class InspectorPageAgent : public InspectorBaseAgent, public InspectorBackendDispatcher::PageCommandHandler {
     WTF_MAKE_NONCOPYABLE(InspectorPageAgent);
 public:
     enum ResourceType {
@@ -162,8 +162,8 @@ public:
     void scriptsEnabled(bool isEnabled);
 
     // Inspector Controller API
-    virtual void setFrontend(InspectorFrontend*);
-    virtual void clearFrontend();
+    virtual void didCreateFrontendAndBackend(InspectorFrontendChannel*, InspectorBackendDispatcher*) OVERRIDE;
+    virtual void willDestroyFrontendAndBackend() OVERRIDE;
 
     void webViewResized(const IntSize&);
 
@@ -197,7 +197,7 @@ private:
     InspectorAgent* m_inspectorAgent;
     InjectedScriptManager* m_injectedScriptManager;
     InspectorClient* m_client;
-    InspectorFrontend::Page* m_frontend;
+    std::unique_ptr<InspectorPageFrontendDispatcher> m_frontendDispatcher;
     InspectorOverlay* m_overlay;
     long m_lastScriptIdentifier;
     String m_pendingScriptToEvaluateOnLoadOnce;
index d5c1846..d6465a2 100644 (file)
@@ -121,10 +121,9 @@ PassOwnPtr<InspectorProfilerAgent> InspectorProfilerAgent::create(InstrumentingA
 #endif
 
 InspectorProfilerAgent::InspectorProfilerAgent(InstrumentingAgents* instrumentingAgents, InspectorConsoleAgent* consoleAgent, InjectedScriptManager* injectedScriptManager)
-    : InspectorBaseAgent<InspectorProfilerAgent>("Profiler", instrumentingAgents)
+    : InspectorBaseAgent(ASCIILiteral("Profiler"), instrumentingAgents)
     , m_consoleAgent(consoleAgent)
     , m_injectedScriptManager(injectedScriptManager)
-    , m_frontend(0)
     , m_enabled(false)
     , m_profileHeadersRequested(false)
     , m_recordingCPUProfile(false)
@@ -145,14 +144,14 @@ void InspectorProfilerAgent::addProfile(PassRefPtr<ScriptProfile> prpProfile, un
 {
     RefPtr<ScriptProfile> profile = prpProfile;
     m_profiles.add(profile->uid(), profile);
-    if (m_frontend && m_profileHeadersRequested)
-        m_frontend->addProfileHeader(createProfileHeader(*profile));
+    if (m_frontendDispatcher && m_profileHeadersRequested)
+        m_frontendDispatcher->addProfileHeader(createProfileHeader(*profile));
     addProfileFinishedMessageToConsole(profile, lineNumber, columnNumber, sourceURL);
 }
 
 void InspectorProfilerAgent::addProfileFinishedMessageToConsole(PassRefPtr<ScriptProfile> prpProfile, unsigned lineNumber, unsigned columnNumber, const String& sourceURL)
 {
-    if (!m_frontend)
+    if (!m_frontendDispatcher)
         return;
     RefPtr<ScriptProfile> profile = prpProfile;
     String message = makeString(profile->title(), '#', String::number(profile->uid()));
@@ -161,7 +160,7 @@ void InspectorProfilerAgent::addProfileFinishedMessageToConsole(PassRefPtr<Scrip
 
 void InspectorProfilerAgent::addStartProfilingMessageToConsole(const String& title, unsigned lineNumber, unsigned columnNumber, const String& sourceURL)
 {
-    if (!m_frontend)
+    if (!m_frontendDispatcher)
         return;
     m_consoleAgent->addMessageToConsole(ConsoleAPIMessageSource, ProfileMessageType, DebugMessageLevel, title, sourceURL, lineNumber, columnNumber);
 }
@@ -260,12 +259,12 @@ namespace {
 
 class OutputStream : public ScriptHeapSnapshot::OutputStream {
 public:
-    OutputStream(InspectorFrontend::Profiler* frontend, unsigned uid)
-        : m_frontend(frontend), m_uid(uid) { }
-    void Write(const String& chunk) { m_frontend->addHeapSnapshotChunk(m_uid, chunk); }
-    void Close() { m_frontend->finishHeapSnapshot(m_uid); }
+    OutputStream(InspectorProfilerFrontendDispatcher* frontend, unsigned uid)
+        : m_frontendDispatcher(frontend), m_uid(uid) { }
+    void Write(const String& chunk) { m_frontendDispatcher->addHeapSnapshotChunk(m_uid, chunk); }
+    void Close() { m_frontendDispatcher->finishHeapSnapshot(m_uid); }
 private:
-    InspectorFrontend::Profiler* m_frontend;
+    InspectorProfilerFrontendDispatcher* m_frontendDispatcher;
     int m_uid;
 };
 
@@ -293,8 +292,8 @@ void InspectorProfilerAgent::getHeapSnapshot(ErrorString* errorString, int rawUi
         return;
     }
     RefPtr<ScriptHeapSnapshot> snapshot = it->value;
-    if (m_frontend) {
-        OutputStream stream(m_frontend, uid);
+    if (m_frontendDispatcher) {
+        OutputStream stream(m_frontendDispatcher.get(), uid);
         snapshot->writeJSON(&stream);
     }
 }
@@ -322,22 +321,24 @@ void InspectorProfilerAgent::resetState()
 
 void InspectorProfilerAgent::resetFrontendProfiles()
 {
-    if (!m_frontend)
+    if (!m_frontendDispatcher)
         return;
     if (!m_profileHeadersRequested)
         return;
     if (m_profiles.isEmpty() && m_snapshots.isEmpty())
-        m_frontend->resetProfiles();
+        m_frontendDispatcher->resetProfiles();
 }
 
-void InspectorProfilerAgent::setFrontend(InspectorFrontend* frontend)
+void InspectorProfilerAgent::didCreateFrontendAndBackend(InspectorFrontendChannel* frontendChannel, InspectorBackendDispatcher* backendDispatcher)
 {
-    m_frontend = frontend->profiler();
+    m_frontendDispatcher = std::make_unique<InspectorProfilerFrontendDispatcher>(frontendChannel);
+    backendDispatcher->registerAgent(this);
 }
 
-void InspectorProfilerAgent::clearFrontend()
+void InspectorProfilerAgent::willDestroyFrontendAndBackend()
 {
-    m_frontend = 0;
+    m_frontendDispatcher = nullptr;
+
     stop();
     ErrorString error;
     disable(&error);
@@ -374,21 +375,21 @@ namespace {
 
 class HeapSnapshotProgress: public ScriptProfiler::HeapSnapshotProgress {
 public:
-    explicit HeapSnapshotProgress(InspectorFrontend::Profiler* frontend)
-        : m_frontend(frontend) { }
+    explicit HeapSnapshotProgress(InspectorProfilerFrontendDispatcher* frontend)
+        : m_frontendDispatcher(frontend) { }
     void Start(int totalWork)
     {
         m_totalWork = totalWork;
     }
     void Worked(int workDone)
     {
-        if (m_frontend)
-            m_frontend->reportHeapSnapshotProgress(workDone, m_totalWork);
+        if (m_frontendDispatcher)
+            m_frontendDispatcher->reportHeapSnapshotProgress(workDone, m_totalWork);
     }
     void Done() { }
     bool isCanceled() { return false; }
 private:
-    InspectorFrontend::Profiler* m_frontend;
+    InspectorProfilerFrontendDispatcher* m_frontendDispatcher;
     int m_totalWork;
 };
 
@@ -399,19 +400,19 @@ void InspectorProfilerAgent::takeHeapSnapshot(ErrorString*, const bool* reportPr
     String title = makeString(UserInitiatedProfileName, '.', String::number(m_nextUserInitiatedHeapSnapshotNumber));
     ++m_nextUserInitiatedHeapSnapshotNumber;
 
-    HeapSnapshotProgress progress(reportProgress && *reportProgress ? m_frontend : 0);
+    HeapSnapshotProgress progress(reportProgress && *reportProgress ? m_frontendDispatcher.get() : nullptr);
     RefPtr<ScriptHeapSnapshot> snapshot = ScriptProfiler::takeHeapSnapshot(title, &progress);
     if (snapshot) {
         m_snapshots.add(snapshot->uid(), snapshot);
-        if (m_frontend)
-            m_frontend->addProfileHeader(createSnapshotHeader(*snapshot));
+        if (m_frontendDispatcher)
+            m_frontendDispatcher->addProfileHeader(createSnapshotHeader(*snapshot));
     }
 }
 
 void InspectorProfilerAgent::toggleRecordButton(bool isProfiling)
 {
-    if (m_frontend)
-        m_frontend->setRecordingProfile(isProfiling);
+    if (m_frontendDispatcher)
+        m_frontendDispatcher->setRecordingProfile(isProfiling);
 }
 
 void InspectorProfilerAgent::getObjectByHeapObjectId(ErrorString* error, const String& heapSnapshotObjectId, const String* objectGroup, RefPtr<TypeBuilder::Runtime::RemoteObject>& result)
index 4223f24..6ec77ea 100644 (file)
@@ -45,7 +45,6 @@ namespace WebCore {
 class InjectedScriptManager;
 class InspectorArray;
 class InspectorConsoleAgent;
-class InspectorFrontend;
 class InspectorObject;
 class InstrumentingAgents;
 class Page;
@@ -55,7 +54,7 @@ class WorkerGlobalScope;
 
 typedef String ErrorString;
 
-class InspectorProfilerAgent : public InspectorBaseAgent<InspectorProfilerAgent>, public InspectorBackendDispatcher::ProfilerCommandHandler {
+class InspectorProfilerAgent : public InspectorBaseAgent, public InspectorBackendDispatcher::ProfilerCommandHandler {
     WTF_MAKE_NONCOPYABLE(InspectorProfilerAgent); WTF_MAKE_FAST_ALLOCATED;
 public:
     static PassOwnPtr<InspectorProfilerAgent> create(InstrumentingAgents*, InspectorConsoleAgent*, Page*, InjectedScriptManager*);
@@ -90,8 +89,8 @@ public:
     virtual void getHeapSnapshot(ErrorString*, int uid);
     virtual void removeProfile(ErrorString*, const String& type, int uid);
 
-    virtual void setFrontend(InspectorFrontend*);
-    virtual void clearFrontend();
+    virtual void didCreateFrontendAndBackend(InspectorFrontendChannel*, InspectorBackendDispatcher*) OVERRIDE;
+    virtual void willDestroyFrontendAndBackend() OVERRIDE;
 
     virtual void takeHeapSnapshot(ErrorString*, const bool* reportProgress);
     void toggleRecordButton(bool isProfiling);
@@ -116,7 +115,7 @@ private:
 
     InspectorConsoleAgent* m_consoleAgent;
     InjectedScriptManager* m_injectedScriptManager;
-    InspectorFrontend::Profiler* m_frontend;
+    std::unique_ptr<InspectorProfilerFrontendDispatcher> m_frontendDispatcher;
     bool m_enabled;
     bool m_profileHeadersRequested;
     bool m_recordingCPUProfile;
index a50d4e9..208802d 100644 (file)
 
 namespace WebCore {
 
-void InspectorResourceAgent::setFrontend(InspectorFrontend* frontend)
+void InspectorResourceAgent::didCreateFrontendAndBackend(InspectorFrontendChannel* frontendChannel, InspectorBackendDispatcher* backendDispatcher)
 {
-    m_frontend = frontend->network();
+    m_frontendDispatcher = std::make_unique<InspectorNetworkFrontendDispatcher>(frontendChannel);
+    backendDispatcher->registerAgent(this);
 }
 
-void InspectorResourceAgent::clearFrontend()
+void InspectorResourceAgent::willDestroyFrontendAndBackend()
 {
-    m_frontend = 0;
+    m_frontendDispatcher = nullptr;
+
     ErrorString error;
     disable(&error);
 }
@@ -216,12 +218,12 @@ void InspectorResourceAgent::willSendRequest(unsigned long identifier, DocumentL
     TypeBuilder::Page::ResourceType::Enum resourceType = InspectorPageAgent::resourceTypeJson(type);
 
     RefPtr<TypeBuilder::Network::Initiator> initiatorObject = buildInitiatorObject(loader->frame() ? loader->frame()->document() : 0);
-    m_frontend->requestWillBeSent(requestId, m_pageAgent->frameId(loader->frame()), m_pageAgent->loaderId(loader), loader->url().string(), buildObjectForResourceRequest(request), currentTime(), initiatorObject, buildObjectForResourceResponse(redirectResponse, loader), type != InspectorPageAgent::OtherResource ? &resourceType : 0);
+    m_frontendDispatcher->requestWillBeSent(requestId, m_pageAgent->frameId(loader->frame()), m_pageAgent->loaderId(loader), loader->url().string(), buildObjectForResourceRequest(request), currentTime(), initiatorObject, buildObjectForResourceResponse(redirectResponse, loader), type != InspectorPageAgent::OtherResource ? &resourceType : 0);
 }
 
 void InspectorResourceAgent::markResourceAsCached(unsigned long identifier)
 {
-    m_frontend->requestServedFromCache(IdentifiersFactory::requestId(identifier));
+    m_frontendDispatcher->requestServedFromCache(IdentifiersFactory::requestId(identifier));
 }
 
 void InspectorResourceAgent::didReceiveResponse(unsigned long identifier, DocumentLoader* loader, const ResourceResponse& response, ResourceLoader* resourceLoader)
@@ -255,7 +257,7 @@ void InspectorResourceAgent::didReceiveResponse(unsigned long identifier, Docume
     m_resourcesData->responseReceived(requestId, m_pageAgent->frameId(loader->frame()), response);
     m_resourcesData->setResourceType(requestId, type);
 
-    m_frontend->responseReceived(requestId, m_pageAgent->frameId(loader->frame()), m_pageAgent->loaderId(loader), currentTime(), InspectorPageAgent::resourceTypeJson(type), resourceResponse);
+    m_frontendDispatcher->responseReceived(requestId, m_pageAgent->frameId(loader->frame()), m_pageAgent->loaderId(loader), currentTime(), InspectorPageAgent::resourceTypeJson(type), resourceResponse);
 
     // If we revalidated the resource and got Not modified, send content length following didReceiveResponse
     // as there will be no calls to didReceiveData from the network stack.
@@ -278,7 +280,7 @@ void InspectorResourceAgent::didReceiveData(unsigned long identifier, const char
             m_resourcesData->maybeAddResourceData(requestId, data, dataLength);
     }
 
-    m_frontend->dataReceived(requestId, currentTime(), dataLength, encodedDataLength);
+    m_frontendDispatcher->dataReceived(requestId, currentTime(), dataLength, encodedDataLength);
 }
 
 void InspectorResourceAgent::didFinishLoading(unsigned long identifier, DocumentLoader* loader, double finishTime)
@@ -299,7 +301,7 @@ void InspectorResourceAgent::didFinishLoading(unsigned long identifier, Document
     if (resourceData && resourceData->cachedResource())
         sourceMappingURL = InspectorPageAgent::sourceMapURLForResource(resourceData->cachedResource());
 
-    m_frontend->loadingFinished(requestId, finishTime, !sourceMappingURL.isEmpty() ? &sourceMappingURL : 0);
+    m_frontendDispatcher->loadingFinished(requestId, finishTime, !sourceMappingURL.isEmpty() ? &sourceMappingURL : 0);
 }
 
 void InspectorResourceAgent::didFailLoading(unsigned long identifier, DocumentLoader* loader, const ResourceError& error)
@@ -315,7 +317,7 @@ void InspectorResourceAgent::didFailLoading(unsigned long identifier, DocumentLo
     }
 
     bool canceled = error.isCancellation();
-    m_frontend->loadingFailed(requestId, currentTime(), error.localizedDescription(), canceled ? &canceled : 0);
+    m_frontendDispatcher->loadingFailed(requestId, currentTime(), error.localizedDescription(), canceled ? &canceled : 0);
 }
 
 void InspectorResourceAgent::didLoadResourceFromMemoryCache(DocumentLoader* loader, CachedResource* resource)
@@ -334,7 +336,7 @@ void InspectorResourceAgent::didLoadResourceFromMemoryCache(DocumentLoader* load
 
     RefPtr<TypeBuilder::Network::Initiator> initiatorObject = buildInitiatorObject(loader->frame() ? loader->frame()->document() : 0);
 
-    m_frontend->requestServedFromMemoryCache(requestId, frameId, loaderId, loader->url().string(), currentTime(), initiatorObject, buildObjectForCachedResource(resource, loader));
+    m_frontendDispatcher->requestServedFromMemoryCache(requestId, frameId, loaderId, loader->url().string(), currentTime(), initiatorObject, buildObjectForCachedResource(resource, loader));
 }
 
 void InspectorResourceAgent::setInitialScriptContent(unsigned long identifier, const String& sourceString)
@@ -467,14 +469,14 @@ PassRefPtr<TypeBuilder::Network::Initiator> InspectorResourceAgent::buildInitiat
 
 void InspectorResourceAgent::didCreateWebSocket(unsigned long identifier, const URL& requestURL)
 {
-    m_frontend->webSocketCreated(IdentifiersFactory::requestId(identifier), requestURL.string());
+    m_frontendDispatcher->webSocketCreated(IdentifiersFactory::requestId(identifier), requestURL.string());
 }
 
 void InspectorResourceAgent::willSendWebSocketHandshakeRequest(unsigned long identifier, const ResourceRequest& request)
 {
     RefPtr<TypeBuilder::Network::WebSocketRequest> requestObject = TypeBuilder::Network::WebSocketRequest::create()
         .setHeaders(buildObjectForHeaders(request.httpHeaderFields()));
-    m_frontend->webSocketWillSendHandshakeRequest(IdentifiersFactory::requestId(identifier), currentTime(), requestObject);
+    m_frontendDispatcher->webSocketWillSendHandshakeRequest(IdentifiersFactory::requestId(identifier), currentTime(), requestObject);
 }
 
 void InspectorResourceAgent::didReceiveWebSocketHandshakeResponse(unsigned long identifier, const ResourceResponse& response)
@@ -483,12 +485,12 @@ void InspectorResourceAgent::didReceiveWebSocketHandshakeResponse(unsigned long
         .setStatus(response.httpStatusCode())
         .setStatusText(response.httpStatusText())
         .setHeaders(buildObjectForHeaders(response.httpHeaderFields()));
-    m_frontend->webSocketHandshakeResponseReceived(IdentifiersFactory::requestId(identifier), currentTime(), responseObject);
+    m_frontendDispatcher->webSocketHandshakeResponseReceived(IdentifiersFactory::requestId(identifier), currentTime(), responseObject);
 }
 
 void InspectorResourceAgent::didCloseWebSocket(unsigned long identifier)
 {
-    m_frontend->webSocketClosed(IdentifiersFactory::requestId(identifier), currentTime());
+    m_frontendDispatcher->webSocketClosed(IdentifiersFactory::requestId(identifier), currentTime());
 }
 
 void InspectorResourceAgent::didReceiveWebSocketFrame(unsigned long identifier, const WebSocketFrame& frame)
@@ -497,7 +499,7 @@ void InspectorResourceAgent::didReceiveWebSocketFrame(unsigned long identifier,
         .setOpcode(frame.opCode)
         .setMask(frame.masked)
         .setPayloadData(String(frame.payload, frame.payloadLength));
-    m_frontend->webSocketFrameReceived(IdentifiersFactory::requestId(identifier), currentTime(), frameObject);
+    m_frontendDispatcher->webSocketFrameReceived(IdentifiersFactory::requestId(identifier), currentTime(), frameObject);
 }
 
 void InspectorResourceAgent::didSendWebSocketFrame(unsigned long identifier, const WebSocketFrame& frame)
@@ -506,12 +508,12 @@ void InspectorResourceAgent::didSendWebSocketFrame(unsigned long identifier, con
         .setOpcode(frame.opCode)
         .setMask(frame.masked)
         .setPayloadData(String(frame.payload, frame.payloadLength));
-    m_frontend->webSocketFrameSent(IdentifiersFactory::requestId(identifier), currentTime(), frameObject);
+    m_frontendDispatcher->webSocketFrameSent(IdentifiersFactory::requestId(identifier), currentTime(), frameObject);
 }
 
 void InspectorResourceAgent::didReceiveWebSocketFrameError(unsigned long identifier, const String& errorMessage)
 {
-    m_frontend->webSocketFrameError(IdentifiersFactory::requestId(identifier), currentTime(), errorMessage);
+    m_frontendDispatcher->webSocketFrameError(IdentifiersFactory::requestId(identifier), currentTime(), errorMessage);
 }
 
 #endif // ENABLE(WEB_SOCKETS)
@@ -529,7 +531,7 @@ void InspectorResourceAgent::enable(ErrorString*)
 
 void InspectorResourceAgent::enable()
 {
-    if (!m_frontend)
+    if (!m_frontendDispatcher)
         return;
     m_enabled = true;
     m_instrumentingAgents->setInspectorResourceAgent(this);
@@ -647,10 +649,9 @@ void InspectorResourceAgent::mainFrameNavigated(DocumentLoader* loader)
 }
 
 InspectorResourceAgent::InspectorResourceAgent(InstrumentingAgents* instrumentingAgents, InspectorPageAgent* pageAgent, InspectorClient* client)
-    : InspectorBaseAgent<InspectorResourceAgent>("Network", instrumentingAgents)
+    : InspectorBaseAgent(ASCIILiteral("Network"), instrumentingAgents)
     , m_pageAgent(pageAgent)
     , m_client(client)
-    , m_frontend(0)
     , m_resourcesData(adoptPtr(new NetworkResourcesData()))
     , m_enabled(false)
     , m_cacheDisabled(false)
index 3b921be..afea1ee 100644 (file)
@@ -55,7 +55,6 @@ class Frame;
 class HTTPHeaderMap;
 class InspectorArray;
 class InspectorClient;
-class InspectorFrontend;
 class InspectorObject;
 class InspectorPageAgent;
 class InstrumentingAgents;
@@ -77,20 +76,18 @@ struct WebSocketFrame;
 
 typedef String ErrorString;
 
-class InspectorResourceAgent : public InspectorBaseAgent<InspectorResourceAgent>, public InspectorBackendDispatcher::NetworkCommandHandler {
+class InspectorResourceAgent : public InspectorBaseAgent, public InspectorBackendDispatcher::NetworkCommandHandler {
 public:
     static PassOwnPtr<InspectorResourceAgent> create(InstrumentingAgents* instrumentingAgents, InspectorPageAgent* pageAgent, InspectorClient* client)
     {
         return adoptPtr(new InspectorResourceAgent(instrumentingAgents, pageAgent, client));
     }
 
-    virtual void setFrontend(InspectorFrontend*);
-    virtual void clearFrontend();
-
-    static PassRefPtr<InspectorResourceAgent> restore(Page*, InspectorFrontend*);
-
     ~InspectorResourceAgent();
 
+    virtual void didCreateFrontendAndBackend(InspectorFrontendChannel*, InspectorBackendDispatcher*) OVERRIDE;
+    virtual void willDestroyFrontendAndBackend() OVERRIDE;
+
     void willSendRequest(unsigned long identifier, DocumentLoader*, ResourceRequest&, const ResourceResponse& redirectResponse);
     void markResourceAsCached(unsigned long identifier);
     void didReceiveResponse(unsigned long identifier, DocumentLoader* laoder, const ResourceResponse&, ResourceLoader*);
@@ -156,7 +153,7 @@ private:
 
     InspectorPageAgent* m_pageAgent;
     InspectorClient* m_client;
-    InspectorFrontend::Network* m_frontend;
+    std::unique_ptr<InspectorNetworkFrontendDispatcher> m_frontendDispatcher;
     String m_userAgentOverride;
     OwnPtr<NetworkResourcesData> m_resourcesData;
     bool m_enabled;
index 981be3b..8b34690 100644 (file)
@@ -58,7 +58,7 @@ static bool asBool(const bool* const b)
 }
 
 InspectorRuntimeAgent::InspectorRuntimeAgent(InstrumentingAgents* instrumentingAgents, InjectedScriptManager* injectedScriptManager)
-    : InspectorBaseAgent<InspectorRuntimeAgent>("Runtime", instrumentingAgents)
+    : InspectorBaseAgent(ASCIILiteral("Runtime"), instrumentingAgents)
     , m_enabled(false)
     , m_injectedScriptManager(injectedScriptManager)
 #if ENABLE(JAVASCRIPT_DEBUGGER)
index d35b361..3e35219 100644 (file)
@@ -43,7 +43,6 @@ namespace WebCore {
 class InjectedScript;
 class InjectedScriptManager;
 class InspectorArray;
-class InspectorFrontend;
 class InspectorObject;
 class InspectorValue;
 class InstrumentingAgents;
@@ -52,7 +51,7 @@ class WorkerGlobalScope;
 
 typedef String ErrorString;
 
-class InspectorRuntimeAgent : public InspectorBaseAgent<InspectorRuntimeAgent>, public InspectorBackendDispatcher::RuntimeCommandHandler {
+class InspectorRuntimeAgent : public InspectorBaseAgent, public InspectorBackendDispatcher::RuntimeCommandHandler {
     WTF_MAKE_NONCOPYABLE(InspectorRuntimeAgent);
 public:
     virtual ~InspectorRuntimeAgent();
index 89a5d60..f04dc23 100644 (file)
@@ -63,24 +63,25 @@ void TimelineTimeConverter::reset()
 
 InspectorTimelineAgent::~InspectorTimelineAgent()
 {
-    clearFrontend();
 }
 
-void InspectorTimelineAgent::setFrontend(InspectorFrontend* frontend)
+void InspectorTimelineAgent::didCreateFrontendAndBackend(InspectorFrontendChannel* frontendChannel, InspectorBackendDispatcher* backendDispatcher)
 {
-    m_frontend = frontend->timeline();
+    m_frontendDispatcher = std::make_unique<InspectorTimelineFrontendDispatcher>(frontendChannel);
+    backendDispatcher->registerAgent(this);
 }
 
-void InspectorTimelineAgent::clearFrontend()
+void InspectorTimelineAgent::willDestroyFrontendAndBackend()
 {
+    m_frontendDispatcher = nullptr;
+
     ErrorString error;
     stop(&error);
-    m_frontend = 0;
 }
 
 void InspectorTimelineAgent::start(ErrorString*, const int* maxCallStackDepth, const bool* includeDomCounters)
 {
-    if (!m_frontend)
+    if (!m_frontendDispatcher)
         return;
 
     if (maxCallStackDepth && *maxCallStackDepth > 0)
@@ -578,10 +579,9 @@ void InspectorTimelineAgent::didCompleteCurrentRecord(TimelineRecordType type)
 }
 
 InspectorTimelineAgent::InspectorTimelineAgent(InstrumentingAgents* instrumentingAgents, InspectorPageAgent* pageAgent, InspectorMemoryAgent* memoryAgent, InspectorType type, InspectorClient* client)
-    : InspectorBaseAgent<InspectorTimelineAgent>("Timeline", instrumentingAgents)
+    : InspectorBaseAgent(ASCIILiteral("Timeline"), instrumentingAgents)
     , m_pageAgent(pageAgent)
     , m_memoryAgent(memoryAgent)
-    , m_frontend(0)
     , m_id(1)
     , m_maxCallStackDepth(5)
     , m_inspectorType(type)
@@ -604,7 +604,7 @@ void InspectorTimelineAgent::sendEvent(PassRefPtr<InspectorObject> event)
 {
     // FIXME: runtimeCast is a hack. We do it because we can't build TimelineEvent directly now.
     RefPtr<TypeBuilder::Timeline::TimelineEvent> recordChecked = TypeBuilder::Timeline::TimelineEvent::runtimeCast(event);
-    m_frontend->eventRecorded(recordChecked.release());
+    m_frontendDispatcher->eventRecorded(recordChecked.release());
 }
 
 void InspectorTimelineAgent::pushCurrentRecord(PassRefPtr<InspectorObject> data, TimelineRecordType type, bool captureCallStack, Frame* frame)
index 2ff74b1..707e227 100644 (file)
@@ -47,7 +47,6 @@ class Event;
 class FloatQuad;
 class Frame;
 class InspectorClient;
-class InspectorFrontend;
 class InspectorMemoryAgent;
 class InspectorPageAgent;
 class InstrumentingAgents;
@@ -122,7 +121,7 @@ private:
 };
 
 class InspectorTimelineAgent
-    : public InspectorBaseAgent<InspectorTimelineAgent>
+    : public InspectorBaseAgent
     , public InspectorBackendDispatcher::TimelineCommandHandler {
     WTF_MAKE_NONCOPYABLE(InspectorTimelineAgent);
 public:
@@ -135,8 +134,8 @@ public:
 
     ~InspectorTimelineAgent();
 
-    virtual void setFrontend(InspectorFrontend*);
-    virtual void clearFrontend();
+    virtual void didCreateFrontendAndBackend(InspectorFrontendChannel*, InspectorBackendDispatcher*) OVERRIDE;
+    virtual void willDestroyFrontendAndBackend() OVERRIDE;
 
     virtual void start(ErrorString*, const int* maxCallStackDepth, const bool* includeDomCounters);
     virtual void stop(ErrorString*);
@@ -259,7 +258,7 @@ private:
     InspectorMemoryAgent* m_memoryAgent;
     TimelineTimeConverter m_timeConverter;
 
-    InspectorFrontend::Timeline* m_frontend;
+    std::unique_ptr<InspectorTimelineFrontendDispatcher> m_frontendDispatcher;
     double m_timestampOffset;
 
     Vector<TimelineRecordEntry> m_recordStack;
index 249ff55..25d2293 100644 (file)
@@ -48,8 +48,8 @@ namespace WebCore {
 class InspectorWorkerAgent::WorkerFrontendChannel : public WorkerGlobalScopeProxy::PageInspector {
     WTF_MAKE_FAST_ALLOCATED;
 public:
-    explicit WorkerFrontendChannel(InspectorFrontend* frontend, WorkerGlobalScopeProxy* proxy)
-        : m_frontend(frontend)
+    explicit WorkerFrontendChannel(InspectorWorkerFrontendDispatcher* frontendDispatcher, WorkerGlobalScopeProxy* proxy)
+        : m_frontendDispatcher(frontendDispatcher)
         , m_proxy(proxy)
         , m_id(s_nextId++)
         , m_connected(false)
@@ -89,10 +89,10 @@ private:
         RefPtr<InspectorObject> messageObject = value->asObject();
         if (!messageObject)
             return;
-        m_frontend->worker()->dispatchMessageFromWorker(m_id, messageObject);
+        m_frontendDispatcher->dispatchMessageFromWorker(m_id, messageObject);
     }
 
-    InspectorFrontend* m_frontend;
+    InspectorWorkerFrontendDispatcher* m_frontendDispatcher;
     WorkerGlobalScopeProxy* m_proxy;
     int m_id;
     bool m_connected;
@@ -107,8 +107,7 @@ PassOwnPtr<InspectorWorkerAgent> InspectorWorkerAgent::create(InstrumentingAgent
 }
 
 InspectorWorkerAgent::InspectorWorkerAgent(InstrumentingAgents* instrumentingAgents)
-    : InspectorBaseAgent<InspectorWorkerAgent>("Worker", instrumentingAgents)
-    , m_inspectorFrontend(0)
+    : InspectorBaseAgent(ASCIILiteral("Worker"), instrumentingAgents)
     , m_enabled(false)
     , m_shouldPauseDedicatedWorkerOnStart(false)
 {
@@ -120,31 +119,35 @@ InspectorWorkerAgent::~InspectorWorkerAgent()
     m_instrumentingAgents->setInspectorWorkerAgent(0);
 }
 
-void InspectorWorkerAgent::setFrontend(InspectorFrontend* frontend)
+void InspectorWorkerAgent::didCreateFrontendAndBackend(InspectorFrontendChannel* frontendChannel, InspectorBackendDispatcher* backendDispatcher)
 {
-    m_inspectorFrontend = frontend;
+    m_frontendDispatcher = std::make_unique<InspectorWorkerFrontendDispatcher>(frontendChannel);
+    backendDispatcher->registerAgent(this);
 }
 
-void InspectorWorkerAgent::clearFrontend()
+void InspectorWorkerAgent::willDestroyFrontendAndBackend()
 {
     m_shouldPauseDedicatedWorkerOnStart = false;
-    disable(0);
-    m_inspectorFrontend = 0;
+    disable(nullptr);
+
+    m_frontendDispatcher = nullptr;
 }
 
 void InspectorWorkerAgent::enable(ErrorString*)
 {
     m_enabled = true;
-    if (!m_inspectorFrontend)
+    if (!m_frontendDispatcher)
         return;
+
     createWorkerFrontendChannelsForExistingWorkers();
 }
 
 void InspectorWorkerAgent::disable(ErrorString*)
 {
     m_enabled = false;
-    if (!m_inspectorFrontend)
+    if (!m_frontendDispatcher)
         return;
+
     destroyWorkerFrontendChannels();
 }
 
@@ -197,7 +200,7 @@ bool InspectorWorkerAgent::shouldPauseDedicatedWorkerOnStart() const
 void InspectorWorkerAgent::didStartWorkerGlobalScope(WorkerGlobalScopeProxy* workerGlobalScopeProxy, const URL& url)
 {
     m_dedicatedWorkers.set(workerGlobalScopeProxy, url.string());
-    if (m_inspectorFrontend && m_enabled)
+    if (m_frontendDispatcher && m_enabled)
         createWorkerFrontendChannel(workerGlobalScopeProxy, url.string());
 }
 
@@ -206,7 +209,7 @@ void InspectorWorkerAgent::workerGlobalScopeTerminated(WorkerGlobalScopeProxy* p
     m_dedicatedWorkers.remove(proxy);
     for (WorkerChannels::iterator it = m_idToChannel.begin(); it != m_idToChannel.end(); ++it) {
         if (proxy == it->value->proxy()) {
-            m_inspectorFrontend->worker()->workerTerminated(it->key);
+            m_frontendDispatcher->workerTerminated(it->key);
             delete it->value;
             m_idToChannel.remove(it);
             return;
@@ -231,13 +234,13 @@ void InspectorWorkerAgent::destroyWorkerFrontendChannels()
 
 void InspectorWorkerAgent::createWorkerFrontendChannel(WorkerGlobalScopeProxy* workerGlobalScopeProxy, const String& url)
 {
-    WorkerFrontendChannel* channel = new WorkerFrontendChannel(m_inspectorFrontend, workerGlobalScopeProxy);
+    WorkerFrontendChannel* channel = new WorkerFrontendChannel(m_frontendDispatcher.get(), workerGlobalScopeProxy);
     m_idToChannel.set(channel->id(), channel);
 
-    ASSERT(m_inspectorFrontend);
+    ASSERT(m_frontendDispatcher);
     if (m_shouldPauseDedicatedWorkerOnStart)
         channel->connectToWorkerGlobalScope();
-    m_inspectorFrontend->worker()->workerCreated(channel->id(), url, m_shouldPauseDedicatedWorkerOnStart);
+    m_frontendDispatcher->workerCreated(channel->id(), url, m_shouldPauseDedicatedWorkerOnStart);
 }
 
 } // namespace WebCore
index fbd9084..c81cf0f 100644 (file)
 #include <wtf/HashMap.h>
 
 namespace WebCore {
-class InspectorFrontend;
 class InspectorObject;
+class InspectorWorkerFrontendDispatcher;
 class InstrumentingAgents;
 class URL;
 class WorkerGlobalScopeProxy;
 
 typedef String ErrorString;
 
-class InspectorWorkerAgent : public InspectorBaseAgent<InspectorWorkerAgent>, public InspectorBackendDispatcher::WorkerCommandHandler {
+class InspectorWorkerAgent : public InspectorBaseAgent, public InspectorBackendDispatcher::WorkerCommandHandler {
 public:
     static PassOwnPtr<InspectorWorkerAgent> create(InstrumentingAgents*);
     ~InspectorWorkerAgent();
 
-    virtual void setFrontend(InspectorFrontend*);
-    virtual void clearFrontend();
+    virtual void didCreateFrontendAndBackend(InspectorFrontendChannel*, InspectorBackendDispatcher*) OVERRIDE;
+    virtual void willDestroyFrontendAndBackend() OVERRIDE;
 
     // Called from InspectorInstrumentation
     bool shouldPauseDedicatedWorkerOnStart() const;
@@ -74,7 +74,7 @@ private:
     void createWorkerFrontendChannel(WorkerGlobalScopeProxy*, const String& url);
     void destroyWorkerFrontendChannels();
 
-    InspectorFrontend* m_inspectorFrontend;
+    std::unique_ptr<InspectorWorkerFrontendDispatcher> m_frontendDispatcher;
     bool m_enabled;
     bool m_shouldPauseDedicatedWorkerOnStart;
 
index 41827b1..b883b98 100644 (file)
@@ -53,7 +53,6 @@ PageRuntimeAgent::PageRuntimeAgent(InstrumentingAgents* instrumentingAgents, Inj
     : InspectorRuntimeAgent(instrumentingAgents, injectedScriptManager)
     , m_inspectedPage(page)
     , m_pageAgent(pageAgent)
-    , m_frontend(0)
     , m_mainWorldContextCreated(false)
 {
     m_instrumentingAgents->setPageRuntimeAgent(this);
@@ -64,14 +63,16 @@ PageRuntimeAgent::~PageRuntimeAgent()
     m_instrumentingAgents->setPageRuntimeAgent(0);
 }
 
-void PageRuntimeAgent::setFrontend(InspectorFrontend* frontend)
+void PageRuntimeAgent::didCreateFrontendAndBackend(InspectorFrontendChannel* frontendChannel, InspectorBackendDispatcher* backendDispatcher)
 {
-    m_frontend = frontend->runtime();
+    m_frontendDispatcher = std::make_unique<InspectorRuntimeFrontendDispatcher>(frontendChannel);
+    backendDispatcher->registerAgent(this);
 }
 
-void PageRuntimeAgent::clearFrontend()
+void PageRuntimeAgent::willDestroyFrontendAndBackend()
 {
-    m_frontend = 0;
+    m_frontendDispatcher = nullptr;
+
     String errorString;
     disable(&errorString);
 }
@@ -104,7 +105,7 @@ void PageRuntimeAgent::didCreateMainWorldContext(Frame* frame)
 
     if (!m_enabled)
         return;
-    ASSERT(m_frontend);
+    ASSERT(m_frontendDispatcher);
     String frameId = m_pageAgent->frameId(frame);
     JSC::ExecState* scriptState = mainWorldExecState(frame);
     notifyContextCreated(frameId, scriptState, 0, true);
@@ -114,7 +115,7 @@ void PageRuntimeAgent::didCreateIsolatedContext(Frame* frame, JSC::ExecState* sc
 {
     if (!m_enabled)
         return;
-    ASSERT(m_frontend);
+    ASSERT(m_frontendDispatcher);
     String frameId = m_pageAgent->frameId(frame);
     notifyContextCreated(frameId, scriptState, origin, false);
 }
@@ -168,7 +169,7 @@ void PageRuntimeAgent::notifyContextCreated(const String& frameId, JSC::ExecStat
     ASSERT(securityOrigin || isPageContext);
     int executionContextId = injectedScriptManager()->injectedScriptIdFor(scriptState);
     String name = securityOrigin ? securityOrigin->toRawString() : "";
-    m_frontend->executionContextCreated(ExecutionContextDescription::create()
+    m_frontendDispatcher->executionContextCreated(ExecutionContextDescription::create()
         .setId(executionContextId)
         .setIsPageContext(isPageContext)
         .setName(name)
index cdd3467..e6b413d 100644 (file)
@@ -51,8 +51,8 @@ public:
         return adoptPtr(new PageRuntimeAgent(instrumentingAgents, injectedScriptManager, page, pageAgent));
     }
     virtual ~PageRuntimeAgent();
-    virtual void setFrontend(InspectorFrontend*);
-    virtual void clearFrontend();
+    virtual void didCreateFrontendAndBackend(InspectorFrontendChannel*, InspectorBackendDispatcher*) OVERRIDE;
+    virtual void willDestroyFrontendAndBackend() OVERRIDE;
     virtual void enable(ErrorString*);
     virtual void disable(ErrorString*);
 
@@ -70,7 +70,7 @@ private:
 
     Page* m_inspectedPage;
     InspectorPageAgent* m_pageAgent;
-    InspectorFrontend::Runtime* m_frontend;
+    std::unique_ptr<InspectorRuntimeFrontendDispatcher> m_frontendDispatcher;
     bool m_mainWorldContextCreated;
 };
 
index ca3341b..db44b1e 100644 (file)
@@ -41,7 +41,6 @@ namespace WebCore {
 
     class Event;
     class FloatQuad;
-    class InspectorFrontend;
     class InspectorObject;
     class IntRect;
     class ResourceRequest;
index dabfd0b..1af5429 100644 (file)
@@ -117,22 +117,19 @@ WorkerInspectorController::~WorkerInspectorController()
 
 void WorkerInspectorController::connectFrontend()
 {
-    ASSERT(!m_frontend);
+    ASSERT(!m_frontendChannel);
     m_frontendChannel = adoptPtr(new PageInspectorProxy(m_workerGlobalScope));
-    m_frontend = adoptPtr(new InspectorFrontend(m_frontendChannel.get()));
     m_backendDispatcher = InspectorBackendDispatcher::create(m_frontendChannel.get());
-    m_agents.registerInDispatcher(m_backendDispatcher.get());
-    m_agents.setFrontend(m_frontend.get());
+    m_agents.didCreateFrontendAndBackend(m_frontendChannel.get(), m_backendDispatcher.get());
 }
 
 void WorkerInspectorController::disconnectFrontend()
 {
-    if (!m_frontend)
+    if (!m_frontendChannel)
         return;
+    m_agents.willDestroyFrontendAndBackend();
     m_backendDispatcher->clearFrontend();
     m_backendDispatcher.clear();
-    m_agents.clearFrontend();
-    m_frontend.clear();
     m_frontendChannel.clear();
 }
 
index 3c93707..160f4ec 100644 (file)
@@ -45,7 +45,6 @@ namespace WebCore {
 
 class InjectedScriptManager;
 class InspectorBackendDispatcher;
-class InspectorFrontend;
 class InspectorFrontendChannel;
 class InspectorInstrumentation;
 class InspectorRuntimeAgent;
@@ -59,7 +58,7 @@ public:
     WorkerInspectorController(WorkerGlobalScope*);
     ~WorkerInspectorController();
 
-    bool hasFrontend() const { return m_frontend; }
+    bool hasFrontend() const { return m_frontendChannel; }
     void connectFrontend();
     void disconnectFrontend();
     void dispatchMessageFromFrontend(const String&);
@@ -76,7 +75,6 @@ private:
     InspectorRuntimeAgent* m_runtimeAgent;
     InspectorAgentRegistry m_agents;
     OwnPtr<InspectorFrontendChannel> m_frontendChannel;
-    OwnPtr<InspectorFrontend> m_frontend;
     RefPtr<InspectorBackendDispatcher> m_backendDispatcher;
 };
 
index b64340d..194c504 100644 (file)
@@ -57,6 +57,15 @@ WorkerRuntimeAgent::~WorkerRuntimeAgent()
     m_instrumentingAgents->setWorkerRuntimeAgent(0);
 }
 
+void WorkerRuntimeAgent::didCreateFrontendAndBackend(InspectorFrontendChannel*, InspectorBackendDispatcher* backendDispatcher)
+{
+    backendDispatcher->registerAgent(this);
+}
+
+void WorkerRuntimeAgent::willDestroyFrontendAndBackend()
+{
+}
+
 InjectedScript WorkerRuntimeAgent::injectedScriptForEval(ErrorString* error, const int* executionContextId)
 {
     if (executionContextId) {
index efe1a6b..6c326a6 100644 (file)
@@ -48,6 +48,9 @@ public:
     }
     virtual ~WorkerRuntimeAgent();
 
+    virtual void didCreateFrontendAndBackend(InspectorFrontendChannel*, InspectorBackendDispatcher*) OVERRIDE;
+    virtual void willDestroyFrontendAndBackend() OVERRIDE;
+
     // Protocol commands.
     virtual void run(ErrorString*);
 
index 4ee2587..7e3619b 100644 (file)
@@ -33,6 +33,5 @@
             ],
             "description": "Dispatches a mouse event to the page."
         }
-    ],
-    "events": []
+    ]
 }