Web Inspector: put inspector agents into a vector in the InspectorController.
authorpfeldman@chromium.org <pfeldman@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 29 Nov 2011 10:02:05 +0000 (10:02 +0000)
committerpfeldman@chromium.org <pfeldman@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 29 Nov 2011 10:02:05 +0000 (10:02 +0000)
https://bugs.webkit.org/show_bug.cgi?id=73225

Inspector controller should maintain agents in the vector, while accessing
them using the same base agent interface. We should not manually call
base agent methods on their concrete instances.

Reviewed by Yury Semikhatsky.

* inspector/CodeGeneratorInspector.py:
(DomainNameFixes.get_fixed_data.Res):
(DomainNameFixes):
(Generator.go):
* inspector/InspectorAgent.cpp:
(WebCore::InspectorAgent::InspectorAgent):
(WebCore::PostWorkerNotificationToFrontendTask::performTask):
* inspector/InspectorAgent.h:
(WebCore::InspectorAgent::create):
* inspector/InspectorApplicationCacheAgent.cpp:
(WebCore::InspectorApplicationCacheAgent::InspectorApplicationCacheAgent):
* inspector/InspectorApplicationCacheAgent.h:
(WebCore::InspectorApplicationCacheAgent::create):
* inspector/InspectorBaseAgent.cpp:
* inspector/InspectorBaseAgent.h:
(WebCore::InspectorBaseAgentInterface::InspectorBaseAgentInterface):
(WebCore::InspectorBaseAgentInterface::~InspectorBaseAgentInterface):
(WebCore::InspectorBaseAgentInterface::setFrontend):
(WebCore::InspectorBaseAgentInterface::clearFrontend):
(WebCore::InspectorBaseAgentInterface::restore):
(WebCore::InspectorBaseAgentInterface::inspectedPageDestroyed):
(WebCore::InspectorBaseAgent::~InspectorBaseAgent):
(WebCore::InspectorBaseAgent::registerDispatcher):
(WebCore::InspectorBaseAgent::InspectorBaseAgent):
* inspector/InspectorCSSAgent.cpp:
(WebCore::InspectorCSSAgent::InspectorCSSAgent):
* inspector/InspectorCSSAgent.h:
(WebCore::InspectorCSSAgent::create):
* inspector/InspectorConsoleAgent.cpp:
(WebCore::InspectorConsoleAgent::InspectorConsoleAgent):
* inspector/InspectorConsoleAgent.h:
* inspector/InspectorController.cpp:
(WebCore::InspectorController::InspectorController):
(WebCore::InspectorController::inspectedPageDestroyed):
(WebCore::InspectorController::connectFrontend):
(WebCore::InspectorController::disconnectFrontend):
(WebCore::InspectorController::restoreInspectorStateFromCookie):
* inspector/InspectorController.h:
* inspector/InspectorDOMAgent.cpp:
(WebCore::InspectorDOMAgent::InspectorDOMAgent):
* inspector/InspectorDOMAgent.h:
* inspector/InspectorDOMDebuggerAgent.cpp:
(WebCore::InspectorDOMDebuggerAgent::InspectorDOMDebuggerAgent):
* inspector/InspectorDOMDebuggerAgent.h:
(WebCore::InspectorDOMDebuggerAgent::inspectedPageDestroyed):
* inspector/InspectorDOMStorageAgent.cpp:
(WebCore::InspectorDOMStorageAgent::InspectorDOMStorageAgent):
* inspector/InspectorDOMStorageAgent.h:
* inspector/InspectorDatabaseAgent.cpp:
(WebCore::InspectorDatabaseAgent::InspectorDatabaseAgent):
* inspector/InspectorDatabaseAgent.h:
* inspector/InspectorDebuggerAgent.cpp:
(WebCore::InspectorDebuggerAgent::InspectorDebuggerAgent):
* inspector/InspectorDebuggerAgent.h:
(WebCore::InspectorDebuggerAgent::inspectedPageDestroyed):
* inspector/InspectorFileSystemAgent.cpp:
(WebCore::InspectorFileSystemAgent::InspectorFileSystemAgent):
* inspector/InspectorFileSystemAgent.h:
* inspector/InspectorPageAgent.cpp:
(WebCore::InspectorPageAgent::InspectorPageAgent):
* inspector/InspectorPageAgent.h:
* inspector/InspectorProfilerAgent.cpp:
(WebCore::InspectorProfilerAgent::InspectorProfilerAgent):
* inspector/InspectorProfilerAgent.h:
* inspector/InspectorResourceAgent.cpp:
(WebCore::InspectorResourceAgent::InspectorResourceAgent):
* inspector/InspectorResourceAgent.h:
(WebCore::InspectorResourceAgent::create):
* inspector/InspectorRuntimeAgent.cpp:
(WebCore::InspectorRuntimeAgent::InspectorRuntimeAgent):
* inspector/InspectorRuntimeAgent.h:
* inspector/InspectorTimelineAgent.cpp:
(WebCore::InspectorTimelineAgent::InspectorTimelineAgent):
* inspector/InspectorTimelineAgent.h:
* inspector/InspectorWorkerAgent.cpp:
(WebCore::InspectorWorkerAgent::InspectorWorkerAgent):
* inspector/InspectorWorkerAgent.h:
* inspector/PageConsoleAgent.h:
(WebCore::PageConsoleAgent::create):
* inspector/PageRuntimeAgent.h:
(WebCore::PageRuntimeAgent::create):
* inspector/WorkerConsoleAgent.h:
(WebCore::WorkerConsoleAgent::create):
* inspector/WorkerInspectorController.cpp:
(WebCore::WorkerInspectorController::WorkerInspectorController):
(WebCore::WorkerInspectorController::connectFrontend):
* inspector/WorkerRuntimeAgent.h:
(WebCore::WorkerRuntimeAgent::create):

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

47 files changed:
Source/WebCore/ChangeLog
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/inspector/CodeGeneratorInspector.py
Source/WebCore/inspector/InspectorAgent.cpp
Source/WebCore/inspector/InspectorAgent.h
Source/WebCore/inspector/InspectorApplicationCacheAgent.cpp
Source/WebCore/inspector/InspectorApplicationCacheAgent.h
Source/WebCore/inspector/InspectorBaseAgent.cpp
Source/WebCore/inspector/InspectorBaseAgent.h
Source/WebCore/inspector/InspectorCSSAgent.cpp
Source/WebCore/inspector/InspectorCSSAgent.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/InspectorDebuggerAgent.cpp
Source/WebCore/inspector/InspectorDebuggerAgent.h
Source/WebCore/inspector/InspectorFileSystemAgent.cpp
Source/WebCore/inspector/InspectorFileSystemAgent.h
Source/WebCore/inspector/InspectorInstrumentation.cpp
Source/WebCore/inspector/InspectorInstrumentation.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/PageConsoleAgent.h
Source/WebCore/inspector/PageRuntimeAgent.h
Source/WebCore/inspector/WorkerConsoleAgent.h
Source/WebCore/inspector/WorkerInspectorController.cpp
Source/WebCore/inspector/WorkerRuntimeAgent.h
Source/WebCore/page/Page.cpp

index fcf83ff..411f270 100644 (file)
@@ -1,3 +1,103 @@
+2011-11-28  Pavel Feldman  <pfeldman@google.com>
+
+        Web Inspector: put inspector agents into a vector in the InspectorController.
+        https://bugs.webkit.org/show_bug.cgi?id=73225
+
+        Inspector controller should maintain agents in the vector, while accessing
+        them using the same base agent interface. We should not manually call
+        base agent methods on their concrete instances.
+
+        Reviewed by Yury Semikhatsky.
+
+        * inspector/CodeGeneratorInspector.py:
+        (DomainNameFixes.get_fixed_data.Res):
+        (DomainNameFixes):
+        (Generator.go):
+        * inspector/InspectorAgent.cpp:
+        (WebCore::InspectorAgent::InspectorAgent):
+        (WebCore::PostWorkerNotificationToFrontendTask::performTask):
+        * inspector/InspectorAgent.h:
+        (WebCore::InspectorAgent::create):
+        * inspector/InspectorApplicationCacheAgent.cpp:
+        (WebCore::InspectorApplicationCacheAgent::InspectorApplicationCacheAgent):
+        * inspector/InspectorApplicationCacheAgent.h:
+        (WebCore::InspectorApplicationCacheAgent::create):
+        * inspector/InspectorBaseAgent.cpp:
+        * inspector/InspectorBaseAgent.h:
+        (WebCore::InspectorBaseAgentInterface::InspectorBaseAgentInterface):
+        (WebCore::InspectorBaseAgentInterface::~InspectorBaseAgentInterface):
+        (WebCore::InspectorBaseAgentInterface::setFrontend):
+        (WebCore::InspectorBaseAgentInterface::clearFrontend):
+        (WebCore::InspectorBaseAgentInterface::restore):
+        (WebCore::InspectorBaseAgentInterface::inspectedPageDestroyed):
+        (WebCore::InspectorBaseAgent::~InspectorBaseAgent):
+        (WebCore::InspectorBaseAgent::registerDispatcher):
+        (WebCore::InspectorBaseAgent::InspectorBaseAgent):
+        * inspector/InspectorCSSAgent.cpp:
+        (WebCore::InspectorCSSAgent::InspectorCSSAgent):
+        * inspector/InspectorCSSAgent.h:
+        (WebCore::InspectorCSSAgent::create):
+        * inspector/InspectorConsoleAgent.cpp:
+        (WebCore::InspectorConsoleAgent::InspectorConsoleAgent):
+        * inspector/InspectorConsoleAgent.h:
+        * inspector/InspectorController.cpp:
+        (WebCore::InspectorController::InspectorController):
+        (WebCore::InspectorController::inspectedPageDestroyed):
+        (WebCore::InspectorController::connectFrontend):
+        (WebCore::InspectorController::disconnectFrontend):
+        (WebCore::InspectorController::restoreInspectorStateFromCookie):
+        * inspector/InspectorController.h:
+        * inspector/InspectorDOMAgent.cpp:
+        (WebCore::InspectorDOMAgent::InspectorDOMAgent):
+        * inspector/InspectorDOMAgent.h:
+        * inspector/InspectorDOMDebuggerAgent.cpp:
+        (WebCore::InspectorDOMDebuggerAgent::InspectorDOMDebuggerAgent):
+        * inspector/InspectorDOMDebuggerAgent.h:
+        (WebCore::InspectorDOMDebuggerAgent::inspectedPageDestroyed):
+        * inspector/InspectorDOMStorageAgent.cpp:
+        (WebCore::InspectorDOMStorageAgent::InspectorDOMStorageAgent):
+        * inspector/InspectorDOMStorageAgent.h:
+        * inspector/InspectorDatabaseAgent.cpp:
+        (WebCore::InspectorDatabaseAgent::InspectorDatabaseAgent):
+        * inspector/InspectorDatabaseAgent.h:
+        * inspector/InspectorDebuggerAgent.cpp:
+        (WebCore::InspectorDebuggerAgent::InspectorDebuggerAgent):
+        * inspector/InspectorDebuggerAgent.h:
+        (WebCore::InspectorDebuggerAgent::inspectedPageDestroyed):
+        * inspector/InspectorFileSystemAgent.cpp:
+        (WebCore::InspectorFileSystemAgent::InspectorFileSystemAgent):
+        * inspector/InspectorFileSystemAgent.h:
+        * inspector/InspectorPageAgent.cpp:
+        (WebCore::InspectorPageAgent::InspectorPageAgent):
+        * inspector/InspectorPageAgent.h:
+        * inspector/InspectorProfilerAgent.cpp:
+        (WebCore::InspectorProfilerAgent::InspectorProfilerAgent):
+        * inspector/InspectorProfilerAgent.h:
+        * inspector/InspectorResourceAgent.cpp:
+        (WebCore::InspectorResourceAgent::InspectorResourceAgent):
+        * inspector/InspectorResourceAgent.h:
+        (WebCore::InspectorResourceAgent::create):
+        * inspector/InspectorRuntimeAgent.cpp:
+        (WebCore::InspectorRuntimeAgent::InspectorRuntimeAgent):
+        * inspector/InspectorRuntimeAgent.h:
+        * inspector/InspectorTimelineAgent.cpp:
+        (WebCore::InspectorTimelineAgent::InspectorTimelineAgent):
+        * inspector/InspectorTimelineAgent.h:
+        * inspector/InspectorWorkerAgent.cpp:
+        (WebCore::InspectorWorkerAgent::InspectorWorkerAgent):
+        * inspector/InspectorWorkerAgent.h:
+        * inspector/PageConsoleAgent.h:
+        (WebCore::PageConsoleAgent::create):
+        * inspector/PageRuntimeAgent.h:
+        (WebCore::PageRuntimeAgent::create):
+        * inspector/WorkerConsoleAgent.h:
+        (WebCore::WorkerConsoleAgent::create):
+        * inspector/WorkerInspectorController.cpp:
+        (WebCore::WorkerInspectorController::WorkerInspectorController):
+        (WebCore::WorkerInspectorController::connectFrontend):
+        * inspector/WorkerRuntimeAgent.h:
+        (WebCore::WorkerRuntimeAgent::create):
+
 2011-11-25  Philippe Normand  <pnormand@igalia.com>
 
         [GTK] Improve FontMetrics accuracy
index d62e988..4e92eae 100644 (file)
                4F6FDD641341DEDD001F8EE3 /* InspectorPageAgent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4F6FDD621341DEDD001F8EE3 /* InspectorPageAgent.cpp */; };
                4F6FDD651341DEDD001F8EE3 /* InspectorPageAgent.h in Headers */ = {isa = PBXBuildFile; fileRef = 4F6FDD631341DEDD001F8EE3 /* InspectorPageAgent.h */; };
                4F707A9911EF679400ACDA69 /* InspectorBackendDispatcher.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4F707A9711EF679400ACDA69 /* InspectorBackendDispatcher.cpp */; };
-               4F707A9A11EF679400ACDA69 /* InspectorBackendDispatcher.h in Headers */ = {isa = PBXBuildFile; fileRef = 4F707A9811EF679400ACDA69 /* InspectorBackendDispatcher.h */; };
+               4F707A9A11EF679400ACDA69 /* InspectorBackendDispatcher.h in Headers */ = {isa = PBXBuildFile; fileRef = 4F707A9811EF679400ACDA69 /* InspectorBackendDispatcher.h */; settings = {ATTRIBUTES = (Private, ); }; };
                4FA3B90A125CD12200300BAD /* InspectorState.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4FA3B908125CD12100300BAD /* InspectorState.cpp */; };
                4FA3B90B125CD12200300BAD /* InspectorState.h in Headers */ = {isa = PBXBuildFile; fileRef = 4FA3B909125CD12200300BAD /* InspectorState.h */; };
                4FD8D0F2119C718B002FA825 /* ScriptGCEvent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4FD8D0F0119C718B002FA825 /* ScriptGCEvent.cpp */; };
                7A74ECBB101839A600BF939E /* InspectorDOMStorageAgent.h in Headers */ = {isa = PBXBuildFile; fileRef = 7A74ECB9101839A600BF939E /* InspectorDOMStorageAgent.h */; };
                7A74ECBD101839DA00BF939E /* JSInspectorFrontendHostCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7A74ECBC101839DA00BF939E /* JSInspectorFrontendHostCustom.cpp */; };
                7AA365EE12E7265400DCA242 /* InspectorRuntimeAgent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7AA365ED12E7265400DCA242 /* InspectorRuntimeAgent.cpp */; };
-               7AA51B6E1483B61600AD2752 /* InspectorBaseAgent.h in Headers */ = {isa = PBXBuildFile; fileRef = 7AA51B6C1483B61600AD2752 /* InspectorBaseAgent.h */; };
+               7AA51B6E1483B61600AD2752 /* InspectorBaseAgent.h in Headers */ = {isa = PBXBuildFile; fileRef = 7AA51B6C1483B61600AD2752 /* InspectorBaseAgent.h */; settings = {ATTRIBUTES = (Private, ); }; };
                7AA51B6F1483B61600AD2752 /* InspectorBaseAgent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7AA51B6D1483B61600AD2752 /* InspectorBaseAgent.cpp */; };
                7AB0B1C01211A62200A76940 /* InspectorDatabaseAgent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7AB0B1BE1211A62200A76940 /* InspectorDatabaseAgent.cpp */; };
                7AB0B1C11211A62200A76940 /* InspectorDatabaseAgent.h in Headers */ = {isa = PBXBuildFile; fileRef = 7AB0B1BF1211A62200A76940 /* InspectorDatabaseAgent.h */; };
                1C81B94D0E9732D900266E07 /* inspector */ = {
                        isa = PBXGroup;
                        children = (
-                               7AA51B6C1483B61600AD2752 /* InspectorBaseAgent.h */,
-                               7AA51B6D1483B61600AD2752 /* InspectorBaseAgent.cpp */,
                                1C81B9590E97330800266E07 /* front-end */,
                                41F0618D0F5F069800A07EAC /* ConsoleMessage.cpp */,
                                41F0618C0F5F069800A07EAC /* ConsoleMessage.h */,
                                4F2D205212EAE7B3005C2874 /* InspectorAgent.h */,
                                B885E8D211E06DD2009FFBF4 /* InspectorApplicationCacheAgent.cpp */,
                                B885E8D311E06DD2009FFBF4 /* InspectorApplicationCacheAgent.h */,
+                               7AA51B6C1483B61600AD2752 /* InspectorBaseAgent.h */,
+                               7AA51B6D1483B61600AD2752 /* InspectorBaseAgent.cpp */,
                                7A1F2B51126C61B20006A7E6 /* InspectorClient.cpp */,
                                1C81B9580E97330800266E07 /* InspectorClient.h */,
                                F3335BF612E07DC300D33011 /* InspectorConsoleAgent.cpp */,
index 88196a1..d0d41e2 100755 (executable)
@@ -135,7 +135,6 @@ class DomainNameFixes:
 
         class Res(object):
             agent_type_name = agent_name_res
-            hidden = domain_name in cls.hidden_domains
             skip_js_bind = domain_name in cls.skip_js_bind_domains
             agent_field_name = field_name_res
 
@@ -157,8 +156,7 @@ class DomainNameFixes:
         return Res
 
     skip_js_bind_domains = set(["Runtime", "CSS", "DOMDebugger"])
-    hidden_domains = set(["Inspector"])
-    agent_type_map = {"Network": "InspectorResourceAgent"}
+    agent_type_map = {"Network": "InspectorResourceAgent", "Inspector": "InspectorAgent", }
 
 
 class CParamType(object):
@@ -505,9 +503,9 @@ ${fieldDeclarations}};
 #ifndef InspectorBackendDispatcher_h
 #define InspectorBackendDispatcher_h
 
-#include <PlatformString.h>
 #include <wtf/PassRefPtr.h>
 #include <wtf/RefCounted.h>
+#include <wtf/text/WTFString.h>
 
 namespace WebCore {
 
@@ -522,11 +520,13 @@ typedef String ErrorString;
 
 class InspectorBackendDispatcher: public RefCounted<InspectorBackendDispatcher> {
 public:
-    InspectorBackendDispatcher(InspectorFrontendChannel* inspectorFrontendChannel$constructorParams)
+    InspectorBackendDispatcher(InspectorFrontendChannel* inspectorFrontendChannel)
         : m_inspectorFrontendChannel(inspectorFrontendChannel)
 $constructorInit
     { }
 
+$setters
+
     void clearFrontend() { m_inspectorFrontendChannel = 0; }
 
     enum CommonErrorCode {
@@ -545,7 +545,6 @@ $constructorInit
     static bool getCommandName(const String& message, String* result);
 
     enum MethodNames {
-
 $methodNamesEnumContent
 };
 
@@ -585,8 +584,8 @@ $fieldDeclarations
 
 #include "InspectorAgent.h"
 #include "InspectorValues.h"
-#include "PlatformString.h"
 #include "InspectorFrontendChannel.h"
+#include <wtf/text/WTFString.h>
 $includes
 
 namespace WebCore {
@@ -916,7 +915,7 @@ bool InspectorBackendDispatcher::getCommandName(const String& message, String* r
 
 #include "InspectorFrontendChannel.h"
 #include "InspectorValues.h"
-#include "PlatformString.h"
+#include <wtf/text/WTFString.h>
 
 namespace WebCore {
 
@@ -1205,7 +1204,7 @@ class Generator:
     backend_js_domain_dispatcher_list = []
     backend_js_capabilities_list = []
 
-    backend_constructor_param_list = []
+    backend_setters_list = []
     backend_constructor_init_list = []
     backend_field_list = []
     backend_forward_list = []
@@ -1265,12 +1264,10 @@ class Generator:
             if domain_data.is_disabled(defines_map):
                 continue
 
-            if domain_data.hidden:
-                continue
             agent_type_name = domain_data.agent_type_name
             agent_field_name = domain_data.agent_field_name
-            Generator.backend_constructor_param_list.append(", %s* %s" % (agent_type_name, agent_field_name))
-            Generator.backend_constructor_init_list.append("        , m_%s(%s)" % (agent_field_name, agent_field_name))
+            Generator.backend_constructor_init_list.append("        , m_%s(0)" % agent_field_name)
+            Generator.backend_setters_list.append("    void registerAgent(%s* %s) { ASSERT(!m_%s); m_%s = %s; }" % (agent_type_name, agent_field_name, agent_field_name, agent_field_name, agent_field_name))
             Generator.backend_field_list.append("    %s* m_%s;" % (agent_type_name, agent_field_name))
             Generator.backend_forward_list.append("class %s;" % agent_type_name)
             Generator.backend_include_list.append("#include \"%s.h\"" % agent_type_name)
@@ -1426,7 +1423,7 @@ frontend_h_file.write(Templates.frontend_h.substitute(None,
 
 backend_h_file.write(Templates.backend_h.substitute(None,
     constructorInit=join(Generator.backend_constructor_init_list, "\n"),
-    constructorParams=join(Generator.backend_constructor_param_list, ""),
+    setters=join(Generator.backend_setters_list, "\n"),
     methodNamesEnumContent=join(Generator.method_name_enum_list, "\n"),
     methodDeclarations=join(Generator.backend_method_declaration_list, "\n"),
     fieldDeclarations=join(Generator.backend_field_list, "\n"),
index 129e070..dc921a1 100644 (file)
@@ -62,7 +62,7 @@ static const char consolePanelName[] = "console";
 static const char profilesPanelName[] = "profiles";
 
 InspectorAgent::InspectorAgent(Page* page, InjectedScriptManager* injectedScriptManager, InstrumentingAgents* instrumentingAgents, InspectorState* state)
-    : InspectorBaseAgent(instrumentingAgents, state)
+    : InspectorBaseAgent<InspectorAgent>(instrumentingAgents, state)
     , m_inspectedPage(page)
     , m_frontend(0)
     , m_injectedScriptManager(injectedScriptManager)
@@ -76,18 +76,9 @@ InspectorAgent::InspectorAgent(Page* page, InjectedScriptManager* injectedScript
 InspectorAgent::~InspectorAgent()
 {
     m_instrumentingAgents->setInspectorAgent(0);
-
-    // These should have been cleared in inspectedPageDestroyed().
-    ASSERT(!m_inspectedPage);
-}
-
-void InspectorAgent::inspectedPageDestroyed()
-{
-    ASSERT(m_inspectedPage);
-    m_inspectedPage = 0;
 }
 
-void InspectorAgent::restore()
+void InspectorAgent::emitCommitLoadIfNeeded()
 {
     if (m_didCommitLoadFired)
         InspectorInstrumentation::didCommitLoad(m_inspectedPage->mainFrame(), m_inspectedPage->mainFrame()->loader()->documentLoader());
@@ -164,7 +155,7 @@ private:
     virtual void performTask(ScriptExecutionContext* scriptContext)
     {
         if (scriptContext->isDocument()) {
-            if (InspectorAgent* inspectorAgent = static_cast<Document*>(scriptContext)->page()->inspectorController()->m_inspectorAgent.get())
+            if (InspectorAgent* inspectorAgent = static_cast<Document*>(scriptContext)->page()->inspectorController()->m_inspectorAgent)
                 inspectorAgent->postWorkerNotificationToFrontend(*m_worker, m_action);
         }
     }
index ec131cc..c5cf161 100644 (file)
@@ -34,6 +34,7 @@
 #include "PlatformString.h"
 #include <wtf/Forward.h>
 #include <wtf/HashMap.h>
+#include <wtf/PassOwnPtr.h>
 #include <wtf/Vector.h>
 
 namespace WebCore {
@@ -51,13 +52,15 @@ class Page;
 
 typedef String ErrorString;
 
-class InspectorAgent : public InspectorBaseAgent {
+class InspectorAgent : public InspectorBaseAgent<InspectorAgent> {
     WTF_MAKE_NONCOPYABLE(InspectorAgent);
 public:
-    InspectorAgent(Page*, InjectedScriptManager*, InstrumentingAgents*, InspectorState*);
-    virtual ~InspectorAgent();
+    static PassOwnPtr<InspectorAgent> create(Page* page, InjectedScriptManager* injectedScriptManager, InstrumentingAgents* instrumentingAgents, InspectorState* state)
+    {
+        return adoptPtr(new InspectorAgent(page, injectedScriptManager, instrumentingAgents, state));
+    }
 
-    void inspectedPageDestroyed();
+    virtual ~InspectorAgent();
 
     bool enabled() const;
 
@@ -68,12 +71,12 @@ public:
 
     virtual void setFrontend(InspectorFrontend*);
     virtual void clearFrontend();
-    virtual void restore();
 
     void didClearWindowObjectInWorld(Frame*, DOMWrapperWorld*);
 
     void didCommitLoad();
     void domContentLoadedEventFired();
+    void emitCommitLoadIfNeeded();
 
 #if ENABLE(WORKERS)
     enum WorkerAction { WorkerCreated, WorkerDestroyed };
@@ -91,6 +94,8 @@ public:
     void setInspectorExtensionAPI(const String& source);
 
 private:
+    InspectorAgent(Page*, InjectedScriptManager*, InstrumentingAgents*, InspectorState*);
+
     void unbindAllResources();
 
 #if ENABLE(JAVASCRIPT_DEBUGGER)
index d45819c..f3fa928 100644 (file)
@@ -48,8 +48,8 @@ namespace ApplicationCacheAgentState {
 static const char applicationCacheAgentEnabled[] = "applicationCacheAgentEnabled";
 }
 
-InspectorApplicationCacheAgent::InspectorApplicationCacheAgent(InstrumentingAgents* instrumentingAgents, InspectorPageAgent* pageAgent, InspectorState* state)
-    : InspectorBaseAgent(instrumentingAgents, state)
+InspectorApplicationCacheAgent::InspectorApplicationCacheAgent(InstrumentingAgents* instrumentingAgents, InspectorState* state, InspectorPageAgent* pageAgent)
+    : InspectorBaseAgent<InspectorApplicationCacheAgent>(instrumentingAgents, state)
     , m_pageAgent(pageAgent)
     , m_frontend(0)
 {
index 3c9cebc..c316744 100644 (file)
@@ -31,7 +31,7 @@
 #include "InspectorBaseAgent.h"
 #include "InspectorFrontend.h"
 #include <wtf/Noncopyable.h>
-#include <wtf/PassRefPtr.h>
+#include <wtf/PassOwnPtr.h>
 
 namespace WebCore {
 
@@ -49,10 +49,13 @@ class ResourceResponse;
 
 typedef String ErrorString;
 
-class InspectorApplicationCacheAgent : public InspectorBaseAgent {
+class InspectorApplicationCacheAgent : public InspectorBaseAgent<InspectorApplicationCacheAgent> {
     WTF_MAKE_NONCOPYABLE(InspectorApplicationCacheAgent); WTF_MAKE_FAST_ALLOCATED;
 public:
-    InspectorApplicationCacheAgent(InstrumentingAgents*, InspectorPageAgent*, InspectorState*);
+    static PassOwnPtr<InspectorApplicationCacheAgent> create(InstrumentingAgents* instrumentingAgents, InspectorState* state, InspectorPageAgent* pageAgent)
+    {
+        return adoptPtr(new InspectorApplicationCacheAgent(instrumentingAgents, state, pageAgent));
+    }
     ~InspectorApplicationCacheAgent() { }
 
     // InspectorBaseAgent
@@ -71,6 +74,7 @@ public:
     void getApplicationCacheForFrame(ErrorString*, const String& frameId, RefPtr<InspectorObject>* applicationCache);
 
 private:
+    InspectorApplicationCacheAgent(InstrumentingAgents*, InspectorState*, InspectorPageAgent*);
     PassRefPtr<InspectorObject> buildObjectForApplicationCache(const ApplicationCacheHost::ResourceInfoList&, const ApplicationCacheHost::CacheInfo&);
     PassRefPtr<InspectorArray> buildArrayForApplicationCacheResources(const ApplicationCacheHost::ResourceInfoList&);
     PassRefPtr<InspectorObject> buildObjectForApplicationCacheResource(const ApplicationCacheHost::ResourceInfo&);
index f6a501f..7496073 100644 (file)
 
 namespace WebCore {
 
-InspectorBaseAgent::InspectorBaseAgent(InstrumentingAgents* instrumentingAgents, InspectorState* inspectorState)
-    : m_instrumentingAgents(instrumentingAgents)
-    , m_state(inspectorState)
-{
-}
-
-InspectorBaseAgent::~InspectorBaseAgent()
-{
-}
-
 } // namespace WebCore
 
 #endif // ENABLE(INSPECTOR)
index 47f964b..81f079b 100644 (file)
 #ifndef InspectorBaseAgent_h
 #define InspectorBaseAgent_h
 
+#include "InspectorBackendDispatcher.h"
+
 namespace WebCore {
 
 class InspectorFrontend;
 class InspectorState;
 class InstrumentingAgents;
 
-class InspectorBaseAgent {
+class InspectorBaseAgentInterface {
+public:
+    InspectorBaseAgentInterface() { }
+    virtual ~InspectorBaseAgentInterface() { }
+    virtual void setFrontend(InspectorFrontend*) { }
+    virtual void clearFrontend() { }
+    virtual void restore() { }
+    virtual void registerInDispatcher(InspectorBackendDispatcher*) = 0;
+};
+
+template<typename T>
+class InspectorBaseAgent : public InspectorBaseAgentInterface {
 public:
-    virtual ~InspectorBaseAgent();
+    virtual ~InspectorBaseAgent() { }
 
-    virtual void setFrontend(InspectorFrontend*) = 0;
-    virtual void clearFrontend() = 0;
-    virtual void restore() = 0;
+    virtual void registerInDispatcher(InspectorBackendDispatcher* dispatcher)
+    {
+        dispatcher->registerAgent(static_cast<T*>(this));
+    }
 
 protected:
-    InspectorBaseAgent(InstrumentingAgents*, InspectorState*);
+    InspectorBaseAgent(InstrumentingAgents* instrumentingAgents, InspectorState* inspectorState)
+        : m_instrumentingAgents(instrumentingAgents)
+        , m_state(inspectorState)
+    {
+    }
 
     InstrumentingAgents* m_instrumentingAgents;
     InspectorState* m_state;
index 7db605c..27df695 100644 (file)
@@ -185,7 +185,7 @@ CSSStyleRule* InspectorCSSAgent::asCSSStyleRule(CSSRule* rule)
 }
 
 InspectorCSSAgent::InspectorCSSAgent(InstrumentingAgents* instrumentingAgents, InspectorState* state, InspectorDOMAgent* domAgent)
-    : InspectorBaseAgent(instrumentingAgents, state)
+    : InspectorBaseAgent<InspectorCSSAgent>(instrumentingAgents, state)
     , m_domAgent(domAgent)
     , m_lastPseudoState(0)
     , m_lastStyleSheetId(1)
index 2ec4cd1..918da6b 100644 (file)
@@ -52,19 +52,20 @@ class Node;
 
 #if ENABLE(INSPECTOR)
 
-class InspectorCSSAgent : public InspectorBaseAgent, public InspectorDOMAgent::DOMListener {
+class InspectorCSSAgent : public InspectorBaseAgent<InspectorCSSAgent>, public InspectorDOMAgent::DOMListener {
     WTF_MAKE_NONCOPYABLE(InspectorCSSAgent);
 public:
     static CSSStyleSheet* parentStyleSheet(CSSRule*);
     static CSSStyleRule* asCSSStyleRule(CSSRule*);
 
-    InspectorCSSAgent(InstrumentingAgents*, InspectorState*, InspectorDOMAgent*);
+    static PassOwnPtr<InspectorCSSAgent> create(InstrumentingAgents* instrumentingAgents, InspectorState* state, InspectorDOMAgent* domAgent)
+    {
+        return adoptPtr(new InspectorCSSAgent(instrumentingAgents, state, domAgent));
+    }
     ~InspectorCSSAgent();
 
     bool forcePseudoState(Element*, CSSSelector::PseudoType);
-    virtual void setFrontend(InspectorFrontend*) { }
     virtual void clearFrontend();
-    virtual void restore() { }
     void reset();
 
     void getComputedStyleForNode(ErrorString*, int nodeId, const RefPtr<InspectorArray>* forcedPseudoClasses, RefPtr<InspectorArray>* style);
@@ -81,6 +82,8 @@ public:
     void getSupportedCSSProperties(ErrorString*, RefPtr<InspectorArray>* result);
 
 private:
+    InspectorCSSAgent(InstrumentingAgents*, InspectorState*, InspectorDOMAgent*);
+
     typedef HashMap<String, RefPtr<InspectorStyleSheet> > IdToInspectorStyleSheet;
     typedef HashMap<CSSStyleSheet*, RefPtr<InspectorStyleSheet> > CSSStyleSheetToInspectorStyleSheet;
     typedef HashMap<Node*, RefPtr<InspectorStyleSheetForInlineStyle> > NodeToInspectorStyleSheet; // bogus "stylesheets" with elements' inline styles
index 1979a6b..683d89a 100644 (file)
@@ -57,7 +57,7 @@ static const char consoleMessagesEnabled[] = "consoleMessagesEnabled";
 }
 
 InspectorConsoleAgent::InspectorConsoleAgent(InstrumentingAgents* instrumentingAgents, InspectorState* state, InjectedScriptManager* injectedScriptManager)
-    : InspectorBaseAgent(instrumentingAgents, state)
+    : InspectorBaseAgent<InspectorConsoleAgent>(instrumentingAgents, state)
     , m_injectedScriptManager(injectedScriptManager)
     , m_frontend(0)
     , m_previousMessage(0)
index 41aaec2..7635a69 100644 (file)
@@ -52,7 +52,7 @@ class ScriptProfile;
 
 typedef String ErrorString;
 
-class InspectorConsoleAgent : public InspectorBaseAgent {
+class InspectorConsoleAgent : public InspectorBaseAgent<InspectorConsoleAgent> {
     WTF_MAKE_NONCOPYABLE(InspectorConsoleAgent);
 public:
     InspectorConsoleAgent(InstrumentingAgents*, InspectorState*, InjectedScriptManager*);
index 5c468ff..1107650 100644 (file)
@@ -41,6 +41,7 @@
 #include "InspectorAgent.h"
 #include "InspectorApplicationCacheAgent.h"
 #include "InspectorBackendDispatcher.h"
+#include "InspectorBaseAgent.h"
 #include "InspectorCSSAgent.h"
 #include "InspectorClient.h"
 #include "InspectorDOMAgent.h"
@@ -73,45 +74,79 @@ InspectorController::InspectorController(Page* page, InspectorClient* inspectorC
     : m_instrumentingAgents(adoptPtr(new InstrumentingAgents()))
     , m_injectedScriptManager(InjectedScriptManager::createForPage())
     , m_state(adoptPtr(new InspectorState(inspectorClient)))
-    , m_inspectorAgent(adoptPtr(new InspectorAgent(page, m_injectedScriptManager.get(), m_instrumentingAgents.get(), m_state.get())))
-    , m_pageAgent(InspectorPageAgent::create(m_instrumentingAgents.get(), page, m_state.get(), m_injectedScriptManager.get()))
-    , m_domAgent(InspectorDOMAgent::create(m_instrumentingAgents.get(), m_pageAgent.get(), inspectorClient, m_state.get(), m_injectedScriptManager.get()))
-    , m_cssAgent(adoptPtr(new InspectorCSSAgent(m_instrumentingAgents.get(), m_state.get(), m_domAgent.get())))
+    , m_page(page)
+    , m_inspectorClient(inspectorClient)
+    , m_openingFrontend(false)
+{
+    OwnPtr<InspectorAgent> inspectorAgentPtr(InspectorAgent::create(page, m_injectedScriptManager.get(), m_instrumentingAgents.get(), m_state.get()));
+    m_inspectorAgent = inspectorAgentPtr.get();
+    m_agents.append(inspectorAgentPtr.release());
+
+    OwnPtr<InspectorPageAgent> pageAgentPtr(InspectorPageAgent::create(m_instrumentingAgents.get(), page, m_state.get(), m_injectedScriptManager.get()));
+    InspectorPageAgent* pageAgent = pageAgentPtr.get();
+    m_agents.append(pageAgentPtr.release());
+
+    OwnPtr<InspectorDOMAgent> domAgentPtr(InspectorDOMAgent::create(m_instrumentingAgents.get(), pageAgent, inspectorClient, m_state.get(), m_injectedScriptManager.get()));
+    m_domAgent = domAgentPtr.get();
+    m_agents.append(domAgentPtr.release());
+
+    m_agents.append(InspectorCSSAgent::create(m_instrumentingAgents.get(), m_state.get(), m_domAgent));
+
 #if ENABLE(SQL_DATABASE)
-    , m_databaseAgent(InspectorDatabaseAgent::create(m_instrumentingAgents.get(), m_state.get()))
+    OwnPtr<InspectorDatabaseAgent> databaseAgentPtr(InspectorDatabaseAgent::create(m_instrumentingAgents.get(), m_state.get()));
+    InspectorDatabaseAgent* databaseAgent = databaseAgentPtr.get();
+    m_agents.append(databaseAgentPtr.release());
 #endif
+
 #if ENABLE(FILE_SYSTEM)
-    , m_fileSystemAgent(InspectorFileSystemAgent::create(m_instrumentingAgents.get(), m_state.get()))
+    m_agents.append(InspectorFileSystemAgent::create(m_instrumentingAgents.get(), m_state.get()));
 #endif
-    , m_domStorageAgent(InspectorDOMStorageAgent::create(m_instrumentingAgents.get(), m_state.get()))
-    , m_timelineAgent(InspectorTimelineAgent::create(m_instrumentingAgents.get(), m_state.get()))
-    , m_applicationCacheAgent(adoptPtr(new InspectorApplicationCacheAgent(m_instrumentingAgents.get(), m_pageAgent.get(), m_state.get())))
-    , m_resourceAgent(InspectorResourceAgent::create(m_instrumentingAgents.get(), m_pageAgent.get(), inspectorClient, m_state.get()))
-    , m_runtimeAgent(adoptPtr(new PageRuntimeAgent(m_instrumentingAgents.get(), m_state.get(), m_injectedScriptManager.get(), page, m_pageAgent.get())))
-    , m_consoleAgent(adoptPtr(new PageConsoleAgent(m_instrumentingAgents.get(), m_inspectorAgent.get(), m_state.get(), m_injectedScriptManager.get(), m_domAgent.get())))
+    OwnPtr<InspectorDOMStorageAgent> domStorageAgentPtr(InspectorDOMStorageAgent::create(m_instrumentingAgents.get(), m_state.get()));
+    InspectorDOMStorageAgent* domStorageAgent = domStorageAgentPtr.get();
+    m_agents.append(domStorageAgentPtr.release());
+
+    m_agents.append(InspectorTimelineAgent::create(m_instrumentingAgents.get(), m_state.get()));
+    m_agents.append(InspectorApplicationCacheAgent::create(m_instrumentingAgents.get(), m_state.get(), pageAgent));
+
+    OwnPtr<InspectorResourceAgent> resourceAgentPtr(InspectorResourceAgent::create(m_instrumentingAgents.get(), pageAgent, inspectorClient, m_state.get()));
+    m_resourceAgent = resourceAgentPtr.get();
+    m_agents.append(resourceAgentPtr.release());
+
+    OwnPtr<InspectorRuntimeAgent> runtimeAgentPtr(PageRuntimeAgent::create(m_instrumentingAgents.get(), m_state.get(), m_injectedScriptManager.get(), page, pageAgent));
+    InspectorRuntimeAgent* runtimeAgent = runtimeAgentPtr.get();
+    m_agents.append(runtimeAgentPtr.release());
+
+    OwnPtr<InspectorConsoleAgent> consoleAgentPtr(PageConsoleAgent::create(m_instrumentingAgents.get(), m_inspectorAgent, m_state.get(), m_injectedScriptManager.get(), m_domAgent));
+    InspectorConsoleAgent* consoleAgent = consoleAgentPtr.get();
+    m_agents.append(consoleAgentPtr.release());
+
 #if ENABLE(JAVASCRIPT_DEBUGGER)
-    , m_debuggerAgent(PageDebuggerAgent::create(m_instrumentingAgents.get(), m_state.get(), page, m_injectedScriptManager.get()))
-    , m_domDebuggerAgent(InspectorDOMDebuggerAgent::create(m_instrumentingAgents.get(), m_state.get(), m_domAgent.get(), m_debuggerAgent.get(), m_inspectorAgent.get()))
-    , m_profilerAgent(InspectorProfilerAgent::create(m_instrumentingAgents.get(), m_consoleAgent.get(), page, m_state.get(), m_injectedScriptManager.get()))
+    OwnPtr<InspectorDebuggerAgent> debuggerAgentPtr(PageDebuggerAgent::create(m_instrumentingAgents.get(), m_state.get(), page, m_injectedScriptManager.get()));
+    m_debuggerAgent = debuggerAgentPtr.get();
+    m_agents.append(debuggerAgentPtr.release());
+
+    m_agents.append(InspectorDOMDebuggerAgent::create(m_instrumentingAgents.get(), m_state.get(), m_domAgent, m_debuggerAgent, m_inspectorAgent));
+
+    OwnPtr<InspectorProfilerAgent> profilerAgentPtr(InspectorProfilerAgent::create(m_instrumentingAgents.get(), consoleAgent, page, m_state.get(), m_injectedScriptManager.get()));
+    m_profilerAgent = profilerAgentPtr.get();
+    m_agents.append(profilerAgentPtr.release());
 #endif
+
 #if ENABLE(WORKERS)
-    , m_workerAgent(InspectorWorkerAgent::create(m_instrumentingAgents.get(), m_state.get()))
+    m_agents.append(InspectorWorkerAgent::create(m_instrumentingAgents.get(), m_state.get()));
 #endif
-    , m_page(page)
-    , m_inspectorClient(inspectorClient)
-    , m_openingFrontend(false)
-{
+
     ASSERT_ARG(inspectorClient, inspectorClient);
-    m_injectedScriptManager->injectedScriptHost()->init(m_inspectorAgent.get()
-        , m_consoleAgent.get()
+    m_injectedScriptManager->injectedScriptHost()->init(m_inspectorAgent
+        , consoleAgent
 #if ENABLE(SQL_DATABASE)
-        , m_databaseAgent.get()
+        , databaseAgent
 #endif
-        , m_domStorageAgent.get()
+        , domStorageAgent
     );
 
 #if ENABLE(JAVASCRIPT_DEBUGGER)
-    m_runtimeAgent->setScriptDebugServer(&m_debuggerAgent->scriptDebugServer());
+    runtimeAgent->setScriptDebugServer(&m_debuggerAgent->scriptDebugServer());
 #endif
 }
 
@@ -123,10 +158,6 @@ InspectorController::~InspectorController()
 void InspectorController::inspectedPageDestroyed()
 {
     disconnectFrontend();
-#if ENABLE(JAVASCRIPT_DEBUGGER)
-    m_domDebuggerAgent.clear();
-    m_debuggerAgent.clear();
-#endif
     m_injectedScriptManager->disconnect();
     m_inspectorClient->inspectorDestroyed();
     m_inspectorClient = 0;
@@ -162,63 +193,20 @@ void InspectorController::connectFrontend()
     // We can reconnect to existing front-end -> unmute state.
     m_state->unmute();
 
-    m_applicationCacheAgent->setFrontend(m_inspectorFrontend.get());
-    m_pageAgent->setFrontend(m_inspectorFrontend.get());
-    m_domAgent->setFrontend(m_inspectorFrontend.get());
-    m_consoleAgent->setFrontend(m_inspectorFrontend.get());
-    m_timelineAgent->setFrontend(m_inspectorFrontend.get());
-    m_resourceAgent->setFrontend(m_inspectorFrontend.get());
-#if ENABLE(JAVASCRIPT_DEBUGGER)
-    m_debuggerAgent->setFrontend(m_inspectorFrontend.get());
-    m_profilerAgent->setFrontend(m_inspectorFrontend.get());
-#endif
-#if ENABLE(SQL_DATABASE)
-    m_databaseAgent->setFrontend(m_inspectorFrontend.get());
-#endif
-#if ENABLE(FILE_SYSTEM)
-    m_fileSystemAgent->setFrontend(m_inspectorFrontend.get());
-#endif
-    m_domStorageAgent->setFrontend(m_inspectorFrontend.get());
-#if ENABLE(WORKERS)
-    m_workerAgent->setFrontend(m_inspectorFrontend.get());
-#endif
-    m_inspectorAgent->setFrontend(m_inspectorFrontend.get());
+    InspectorFrontend* frontend = m_inspectorFrontend.get();
+    for (Agents::iterator it = m_agents.begin(); it != m_agents.end(); ++it)
+        (*it)->setFrontend(frontend);
 
     if (!InspectorInstrumentation::hasFrontends())
         ScriptController::setCaptureCallStackForUncaughtExceptions(true);
     InspectorInstrumentation::frontendCreated();
 
     ASSERT(m_inspectorClient);
-    m_inspectorBackendDispatcher = adoptRef(new InspectorBackendDispatcher(
-        m_inspectorClient,
-        m_applicationCacheAgent.get(),
-        m_cssAgent.get(),
-        m_consoleAgent.get(),
-        m_domAgent.get(),
-#if ENABLE(JAVASCRIPT_DEBUGGER)
-        m_domDebuggerAgent.get(),
-#endif
-        m_domStorageAgent.get(),
-#if ENABLE(SQL_DATABASE)
-        m_databaseAgent.get(),
-#endif
-#if ENABLE(JAVASCRIPT_DEBUGGER)
-        m_debuggerAgent.get(),
-#endif
-#if ENABLE(FILE_SYSTEM)
-        m_fileSystemAgent.get(),
-#endif
-        m_resourceAgent.get(),
-        m_pageAgent.get(),
-#if ENABLE(JAVASCRIPT_DEBUGGER)
-        m_profilerAgent.get(),
-#endif
-        m_runtimeAgent.get(),
-        m_timelineAgent.get()
-#if ENABLE(WORKERS)
-        , m_workerAgent.get()
-#endif
-    ));
+    m_inspectorBackendDispatcher = adoptRef(new InspectorBackendDispatcher(m_inspectorClient));
+
+    InspectorBackendDispatcher* dispatcher = m_inspectorBackendDispatcher.get();
+    for (Agents::iterator it = m_agents.begin(); it != m_agents.end(); ++it)
+        (*it)->registerInDispatcher(dispatcher);
 }
 
 void InspectorController::disconnectFrontend()
@@ -232,29 +220,9 @@ void InspectorController::disconnectFrontend()
     // Pre-disconnect state will be used to restore inspector agents.
     m_state->mute();
 
-    m_inspectorAgent->clearFrontend();
-#if ENABLE(JAVASCRIPT_DEBUGGER)
-    m_debuggerAgent->clearFrontend();
-    m_domDebuggerAgent->clearFrontend();
-    m_profilerAgent->clearFrontend();
-#endif
-    m_applicationCacheAgent->clearFrontend();
-    m_consoleAgent->clearFrontend();
-    m_domAgent->clearFrontend();
-    m_cssAgent->clearFrontend();
-    m_timelineAgent->clearFrontend();
-    m_resourceAgent->clearFrontend();
-#if ENABLE(SQL_DATABASE)
-    m_databaseAgent->clearFrontend();
-#endif
-#if ENABLE(FILE_SYSTEM)
-    m_fileSystemAgent->clearFrontend();
-#endif
-    m_domStorageAgent->clearFrontend();
-    m_pageAgent->clearFrontend();
-#if ENABLE(WORKERS)
-    m_workerAgent->clearFrontend();
-#endif
+    for (Agents::iterator it = m_agents.begin(); it != m_agents.end(); ++it)
+        (*it)->clearFrontend();
+
     m_injectedScriptManager->injectedScriptHost()->clearFrontend();
 
     m_inspectorFrontend.clear();
@@ -294,27 +262,9 @@ void InspectorController::restoreInspectorStateFromCookie(const String& inspecto
     connectFrontend();
     m_state->loadFromCookie(inspectorStateCookie);
 
-    m_pageAgent->restore();
-    m_domAgent->restore();
-    m_resourceAgent->restore();
-    m_timelineAgent->restore();
-    m_consoleAgent->restore();
-    m_applicationCacheAgent->restore();
-#if ENABLE(SQL_DATABASE)
-    m_databaseAgent->restore();
-#endif
-#if ENABLE(FILE_SYSTEM)
-    m_fileSystemAgent->restore();
-#endif
-    m_domStorageAgent->restore();
-#if ENABLE(WORKERS)
-    m_workerAgent->restore();
-#endif
-#if ENABLE(JAVASCRIPT_DEBUGGER)
-    m_debuggerAgent->restore();
-    m_profilerAgent->restore();
-#endif
-    m_inspectorAgent->restore();
+    for (Agents::iterator it = m_agents.begin(); it != m_agents.end(); ++it)
+        (*it)->restore();
+    m_inspectorAgent->emitCommitLoadIfNeeded();
 }
 
 void InspectorController::setProcessId(long processId)
index f855c71..fe77a4a 100644 (file)
@@ -45,25 +45,15 @@ class InjectedScriptManager;
 class InspectorAgent;
 class InspectorApplicationCacheAgent;
 class InspectorBackendDispatcher;
-class InspectorCSSAgent;
+class InspectorBaseAgentInterface;
 class InspectorClient;
-class InspectorConsoleAgent;
 class InspectorDOMAgent;
-class InspectorDOMDebuggerAgent;
-class InspectorDOMStorageAgent;
-class InspectorDatabaseAgent;
 class InspectorDebuggerAgent;
-class InspectorFileSystemAgent;
 class InspectorFrontend;
 class InspectorFrontendClient;
-class InspectorPageAgent;
 class InspectorProfilerAgent;
 class InspectorResourceAgent;
-class InspectorRuntimeAgent;
 class InspectorState;
-class InspectorStorageAgent;
-class InspectorTimelineAgent;
-class InspectorWorkerAgent;
 class InstrumentingAgents;
 class Page;
 class PostWorkerNotificationToFrontendTask;
@@ -120,30 +110,13 @@ private:
     OwnPtr<InstrumentingAgents> m_instrumentingAgents;
     OwnPtr<InjectedScriptManager> m_injectedScriptManager;
     OwnPtr<InspectorState> m_state;
-    OwnPtr<InspectorAgent> m_inspectorAgent;
 
-    OwnPtr<InspectorPageAgent> m_pageAgent;
-    OwnPtr<InspectorDOMAgent> m_domAgent;
-    OwnPtr<InspectorCSSAgent> m_cssAgent;
-#if ENABLE(SQL_DATABASE)
-    OwnPtr<InspectorDatabaseAgent> m_databaseAgent;
-#endif
-#if ENABLE(FILE_SYSTEM)
-    OwnPtr<InspectorFileSystemAgent> m_fileSystemAgent;
-#endif
-    OwnPtr<InspectorDOMStorageAgent> m_domStorageAgent;
-    OwnPtr<InspectorTimelineAgent> m_timelineAgent;
-    OwnPtr<InspectorApplicationCacheAgent> m_applicationCacheAgent;
-    RefPtr<InspectorResourceAgent> m_resourceAgent;
-    OwnPtr<InspectorRuntimeAgent> m_runtimeAgent;
-    OwnPtr<InspectorConsoleAgent> m_consoleAgent;
+    InspectorAgent* m_inspectorAgent;
+    InspectorDOMAgent* m_domAgent;
+    InspectorResourceAgent* m_resourceAgent;
 #if ENABLE(JAVASCRIPT_DEBUGGER)
-    OwnPtr<InspectorDebuggerAgent> m_debuggerAgent;
-    OwnPtr<InspectorDOMDebuggerAgent> m_domDebuggerAgent;
-    OwnPtr<InspectorProfilerAgent> m_profilerAgent;
-#endif
-#if ENABLE(WORKERS)
-    OwnPtr<InspectorWorkerAgent> m_workerAgent;
+    InspectorDebuggerAgent* m_debuggerAgent;
+    InspectorProfilerAgent* m_profilerAgent;
 #endif
 
     RefPtr<InspectorBackendDispatcher> m_inspectorBackendDispatcher;
@@ -152,6 +125,8 @@ private:
     Page* m_page;
     InspectorClient* m_inspectorClient;
     bool m_openingFrontend;
+    typedef Vector<OwnPtr<InspectorBaseAgentInterface> > Agents;
+    Agents m_agents;
 };
 
 }
index 1a2511e..8639c56 100644 (file)
@@ -172,7 +172,7 @@ void RevalidateStyleAttributeTask::onTimer(Timer<RevalidateStyleAttributeTask>*)
 }
 
 InspectorDOMAgent::InspectorDOMAgent(InstrumentingAgents* instrumentingAgents, InspectorPageAgent* pageAgent, InspectorClient* client, InspectorState* inspectorState, InjectedScriptManager* injectedScriptManager)
-    : InspectorBaseAgent(instrumentingAgents, inspectorState)
+    : InspectorBaseAgent<InspectorDOMAgent>(instrumentingAgents, inspectorState)
     , m_pageAgent(pageAgent)
     , m_client(client)
     , m_injectedScriptManager(injectedScriptManager)
index 525f8a1..50309d8 100644 (file)
@@ -87,7 +87,7 @@ struct EventListenerInfo {
     const EventListenerVector eventListenerVector;
 };
 
-class InspectorDOMAgent : public InspectorBaseAgent {
+class InspectorDOMAgent : public InspectorBaseAgent<InspectorDOMAgent> {
     WTF_MAKE_NONCOPYABLE(InspectorDOMAgent);
 public:
     struct DOMListener {
index a368fef..83e9cda 100644 (file)
@@ -75,7 +75,7 @@ PassOwnPtr<InspectorDOMDebuggerAgent> InspectorDOMDebuggerAgent::create(Instrume
 }
 
 InspectorDOMDebuggerAgent::InspectorDOMDebuggerAgent(InstrumentingAgents* instrumentingAgents, InspectorState* inspectorState, InspectorDOMAgent* domAgent, InspectorDebuggerAgent* debuggerAgent, InspectorAgent* inspectorAgent)
-    : InspectorBaseAgent(instrumentingAgents, inspectorState)
+    : InspectorBaseAgent<InspectorDOMDebuggerAgent>(instrumentingAgents, inspectorState)
     , m_domAgent(domAgent)
     , m_debuggerAgent(debuggerAgent)
     , m_inspectorAgent(inspectorAgent)
index d2d2f2e..926a3bb 100644 (file)
@@ -54,7 +54,7 @@ class Node;
 
 typedef String ErrorString;
 
-class InspectorDOMDebuggerAgent : public InspectorBaseAgent, public InspectorDebuggerAgent::Listener {
+class InspectorDOMDebuggerAgent : public InspectorBaseAgent<InspectorDOMDebuggerAgent>, public InspectorDebuggerAgent::Listener {
     WTF_MAKE_NONCOPYABLE(InspectorDOMDebuggerAgent);
 public:
     static PassOwnPtr<InspectorDOMDebuggerAgent> create(InstrumentingAgents*, InspectorState*, InspectorDOMAgent*, InspectorDebuggerAgent*, InspectorAgent*);
@@ -79,9 +79,7 @@ public:
     void willSendXMLHttpRequest(const String& url);
     void pauseOnNativeEventIfNeeded(const String& categoryType, const String& eventName, bool synchronous);
 
-    virtual void setFrontend(InspectorFrontend*) { }
     virtual void clearFrontend();
-    virtual void restore() { }
 
 private:
     InspectorDOMDebuggerAgent(InstrumentingAgents*, InspectorState*, InspectorDOMAgent*, InspectorDebuggerAgent*, InspectorAgent*);
index 2d06918..a3e0227 100644 (file)
@@ -56,7 +56,7 @@ static const char domStorageAgentEnabled[] = "domStorageAgentEnabled";
 typedef HashMap<int, RefPtr<InspectorDOMStorageResource> > DOMStorageResourcesMap;
 
 InspectorDOMStorageAgent::InspectorDOMStorageAgent(InstrumentingAgents* instrumentingAgents, InspectorState* state)
-    : InspectorBaseAgent(instrumentingAgents, state)
+    : InspectorBaseAgent<InspectorDOMStorageAgent>(instrumentingAgents, state)
     , m_frontend(0)
     , m_enabled(false)
 {
index 5f7ed02..e87ffe2 100644 (file)
@@ -47,7 +47,7 @@ class StorageArea;
 
 typedef String ErrorString;
 
-class InspectorDOMStorageAgent : public InspectorBaseAgent {
+class InspectorDOMStorageAgent : public InspectorBaseAgent<InspectorDOMStorageAgent> {
 public:
     static PassOwnPtr<InspectorDOMStorageAgent> create(InstrumentingAgents* instrumentingAgents, InspectorState* state)
     {
index d66a8bd..449a0ce 100644 (file)
@@ -243,7 +243,7 @@ void InspectorDatabaseAgent::clearResources()
 }
 
 InspectorDatabaseAgent::InspectorDatabaseAgent(InstrumentingAgents* instrumentingAgents, InspectorState* state)
-    : InspectorBaseAgent(instrumentingAgents, state)
+    : InspectorBaseAgent<InspectorDatabaseAgent>(instrumentingAgents, state)
     , m_enabled(false)
 {
     m_instrumentingAgents->setInspectorDatabaseAgent(this);
index c5d40f8..5e08fa8 100644 (file)
@@ -45,7 +45,7 @@ class InstrumentingAgents;
 
 typedef String ErrorString;
 
-class InspectorDatabaseAgent : public InspectorBaseAgent {
+class InspectorDatabaseAgent : public InspectorBaseAgent<InspectorDatabaseAgent> {
 public:
     class FrontendProvider;
 
index ccfecf0..cfecaec 100644 (file)
@@ -53,7 +53,7 @@ static const char javaScriptBreakpoints[] = "javaScriptBreakopints";
 const char* InspectorDebuggerAgent::backtraceObjectGroup = "backtrace-object-group";
 
 InspectorDebuggerAgent::InspectorDebuggerAgent(InstrumentingAgents* instrumentingAgents, InspectorState* inspectorState, InjectedScriptManager* injectedScriptManager)
-    : InspectorBaseAgent(instrumentingAgents, inspectorState)
+    : InspectorBaseAgent<InspectorDebuggerAgent>(instrumentingAgents, inspectorState)
     , m_injectedScriptManager(injectedScriptManager)
     , m_frontend(0)
     , m_pausedScriptState(0)
index b9050c9..1590803 100644 (file)
@@ -58,7 +58,7 @@ class ScriptValue;
 
 typedef String ErrorString;
 
-class InspectorDebuggerAgent : public InspectorBaseAgent, public ScriptDebugListener {
+class InspectorDebuggerAgent : public InspectorBaseAgent<InspectorDebuggerAgent>, public ScriptDebugListener {
     WTF_MAKE_NONCOPYABLE(InspectorDebuggerAgent); WTF_MAKE_FAST_ALLOCATED;
 public:
     static const char* backtraceObjectGroup;
index a64a1b3..96f03b6 100644 (file)
@@ -107,7 +107,7 @@ void InspectorFileSystemAgent::restore()
 }
 
 InspectorFileSystemAgent::InspectorFileSystemAgent(InstrumentingAgents* instrumentingAgents, InspectorState* state)
-    : InspectorBaseAgent(instrumentingAgents, state),
+    : InspectorBaseAgent<InspectorFileSystemAgent>(instrumentingAgents, state),
       m_frontend(0),
       m_enabled(false)
 {
index efa5583..003a9c5 100644 (file)
@@ -45,7 +45,7 @@ class InspectorFrontend;
 class InspectorState;
 class InstrumentingAgents;
 
-class InspectorFileSystemAgent : public InspectorBaseAgent {
+class InspectorFileSystemAgent : public InspectorBaseAgent<InspectorFileSystemAgent> {
 public:
     static PassOwnPtr<InspectorFileSystemAgent> create(InstrumentingAgents*, InspectorState*);
     virtual ~InspectorFileSystemAgent();
index e3e5869..cd3033b 100644 (file)
@@ -108,12 +108,6 @@ void InspectorInstrumentation::didClearWindowObjectInWorldImpl(InstrumentingAgen
 #endif
 }
 
-void InspectorInstrumentation::inspectedPageDestroyedImpl(InstrumentingAgents* instrumentingAgents)
-{
-    if (InspectorAgent* inspectorAgent = instrumentingAgents->inspectorAgent())
-        inspectorAgent->inspectedPageDestroyed();
-}
-
 void InspectorInstrumentation::willInsertDOMNodeImpl(InstrumentingAgents* instrumentingAgents, Node* node, Node* parent)
 {
 #if ENABLE(JAVASCRIPT_DEBUGGER)
index d966b75..395b6d3 100644 (file)
@@ -77,7 +77,6 @@ typedef pair<InstrumentingAgents*, int> InspectorInstrumentationCookie;
 class InspectorInstrumentation {
 public:
     static void didClearWindowObjectInWorld(Frame*, DOMWrapperWorld*);
-    static void inspectedPageDestroyed(Page*);
 
     static void willInsertDOMNode(Document*, Node*, Node* parent);
     static void didInsertDOMNode(Document*, Node*);
@@ -215,7 +214,6 @@ public:
 private:
 #if ENABLE(INSPECTOR)
     static void didClearWindowObjectInWorldImpl(InstrumentingAgents*, Frame*, DOMWrapperWorld*);
-    static void inspectedPageDestroyedImpl(InstrumentingAgents*);
 
     static void willInsertDOMNodeImpl(InstrumentingAgents*, Node*, Node* parent);
     static void didInsertDOMNodeImpl(InstrumentingAgents*, Node*);
@@ -362,14 +360,6 @@ inline void InspectorInstrumentation::didClearWindowObjectInWorld(Frame* frame,
 #endif
 }
 
-inline void InspectorInstrumentation::inspectedPageDestroyed(Page* page)
-{
-#if ENABLE(INSPECTOR)
-    if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForPage(page))
-        inspectedPageDestroyedImpl(instrumentingAgents);
-#endif
-}
-
 inline void InspectorInstrumentation::willInsertDOMNode(Document* document, Node* node, Node* parent)
 {
 #if ENABLE(INSPECTOR)
index 7061363..8a0380d 100644 (file)
@@ -262,7 +262,7 @@ String InspectorPageAgent::cachedResourceTypeString(const CachedResource& cached
 }
 
 InspectorPageAgent::InspectorPageAgent(InstrumentingAgents* instrumentingAgents, Page* page, InspectorState* inspectorState, InjectedScriptManager* injectedScriptManager)
-    : InspectorBaseAgent(instrumentingAgents, inspectorState)
+    : InspectorBaseAgent<InspectorPageAgent>(instrumentingAgents, inspectorState)
     , m_page(page)
     , m_injectedScriptManager(injectedScriptManager)
     , m_frontend(0)
index e613498..2fa21c0 100644 (file)
@@ -60,7 +60,7 @@ class SharedBuffer;
 
 typedef String ErrorString;
 
-class InspectorPageAgent : InspectorBaseAgent {
+class InspectorPageAgent : public InspectorBaseAgent<InspectorPageAgent> {
     WTF_MAKE_NONCOPYABLE(InspectorPageAgent);
 public:
     enum ResourceType {
index c0af16c..ecc6c81 100644 (file)
@@ -68,7 +68,7 @@ PassOwnPtr<InspectorProfilerAgent> InspectorProfilerAgent::create(InstrumentingA
 }
 
 InspectorProfilerAgent::InspectorProfilerAgent(InstrumentingAgents* instrumentingAgents, InspectorConsoleAgent* consoleAgent, Page* inspectedPage, InspectorState* inspectorState, InjectedScriptManager* injectedScriptManager)
-    : InspectorBaseAgent(instrumentingAgents, inspectorState)
+    : InspectorBaseAgent<InspectorProfilerAgent>(instrumentingAgents, inspectorState)
     , m_consoleAgent(consoleAgent)
     , m_inspectedPage(inspectedPage)
     , m_injectedScriptManager(injectedScriptManager)
index b0eb0fa..14064c6 100644 (file)
@@ -55,7 +55,7 @@ class ScriptProfile;
 
 typedef String ErrorString;
 
-class InspectorProfilerAgent : public InspectorBaseAgent {
+class InspectorProfilerAgent : public InspectorBaseAgent<InspectorProfilerAgent> {
     WTF_MAKE_NONCOPYABLE(InspectorProfilerAgent); WTF_MAKE_FAST_ALLOCATED;
 public:
     static PassOwnPtr<InspectorProfilerAgent> create(InstrumentingAgents*, InspectorConsoleAgent*, Page*, InspectorState*, InjectedScriptManager*);
index 3813286..6c102cc 100644 (file)
@@ -530,7 +530,7 @@ void InspectorResourceAgent::mainFrameNavigated(DocumentLoader* loader)
 }
 
 InspectorResourceAgent::InspectorResourceAgent(InstrumentingAgents* instrumentingAgents, InspectorPageAgent* pageAgent, InspectorClient* client, InspectorState* state)
-    : InspectorBaseAgent(instrumentingAgents, state)
+    : InspectorBaseAgent<InspectorResourceAgent>(instrumentingAgents, state)
     , m_pageAgent(pageAgent)
     , m_client(client)
     , m_frontend(0)
index b1b49f6..2828967 100644 (file)
@@ -35,7 +35,7 @@
 #include "InspectorFrontend.h"
 #include "PlatformString.h"
 
-#include <wtf/PassRefPtr.h>
+#include <wtf/PassOwnPtr.h>
 #include <wtf/RefCounted.h>
 #include <wtf/Vector.h>
 
@@ -73,11 +73,11 @@ class WebSocketHandshakeResponse;
 
 typedef String ErrorString;
 
-class InspectorResourceAgent : public InspectorBaseAgent, public RefCounted<InspectorResourceAgent> {
+class InspectorResourceAgent : public InspectorBaseAgent<InspectorResourceAgent> {
 public:
-    static PassRefPtr<InspectorResourceAgent> create(InstrumentingAgents* instrumentingAgents, InspectorPageAgent* pageAgent, InspectorClient* client, InspectorState* state)
+    static PassOwnPtr<InspectorResourceAgent> create(InstrumentingAgents* instrumentingAgents, InspectorPageAgent* pageAgent, InspectorClient* client, InspectorState* state)
     {
-        return adoptRef(new InspectorResourceAgent(instrumentingAgents, pageAgent, client, state));
+        return adoptPtr(new InspectorResourceAgent(instrumentingAgents, pageAgent, client, state));
     }
 
     virtual void setFrontend(InspectorFrontend*);
index f4b21e7..e6dd06c 100644 (file)
@@ -56,7 +56,7 @@ static bool asBool(const bool* const b)
 }
 
 InspectorRuntimeAgent::InspectorRuntimeAgent(InstrumentingAgents* instrumentingAgents, InspectorState* state, InjectedScriptManager* injectedScriptManager)
-    : InspectorBaseAgent(instrumentingAgents, state)
+    : InspectorBaseAgent<InspectorRuntimeAgent>(instrumentingAgents, state)
     , m_injectedScriptManager(injectedScriptManager)
 #if ENABLE(JAVASCRIPT_DEBUGGER)
     , m_scriptDebugServer(0)
index ea548ac..9145c6c 100644 (file)
@@ -51,7 +51,7 @@ class WorkerContext;
 
 typedef String ErrorString;
 
-class InspectorRuntimeAgent : public InspectorBaseAgent {
+class InspectorRuntimeAgent : public InspectorBaseAgent<InspectorRuntimeAgent> {
     WTF_MAKE_NONCOPYABLE(InspectorRuntimeAgent);
 public:
     virtual ~InspectorRuntimeAgent();
@@ -78,10 +78,6 @@ public:
     void releaseObjectGroup(ErrorString*, const String& objectGroup);
     void run(ErrorString*);
 
-    virtual void setFrontend(InspectorFrontend*) { }
-    virtual void clearFrontend() { }
-    virtual void restore() { }
-
 #if ENABLE(JAVASCRIPT_DEBUGGER)
     void setScriptDebugServer(ScriptDebugServer*);
 #if ENABLE(WORKERS)
index 1dde000..cc24b9e 100644 (file)
@@ -400,7 +400,7 @@ void InspectorTimelineAgent::didCompleteCurrentRecord(const String& type)
 }
 
 InspectorTimelineAgent::InspectorTimelineAgent(InstrumentingAgents* instrumentingAgents, InspectorState* state)
-    : InspectorBaseAgent(instrumentingAgents, state)
+    : InspectorBaseAgent<InspectorTimelineAgent>(instrumentingAgents, state)
     , m_frontend(0)
     , m_id(1)
     , m_maxCallStackDepth(5)
index 1a5203c..78af02d 100644 (file)
@@ -53,7 +53,7 @@ class ResourceResponse;
 
 typedef String ErrorString;
 
-class InspectorTimelineAgent : public InspectorBaseAgent, ScriptGCEventListener {
+class InspectorTimelineAgent : public InspectorBaseAgent<InspectorTimelineAgent>, ScriptGCEventListener {
     WTF_MAKE_NONCOPYABLE(InspectorTimelineAgent);
 public:
     static PassOwnPtr<InspectorTimelineAgent> create(InstrumentingAgents* instrumentingAgents, InspectorState* state)
index 2557450..9b7290c 100644 (file)
@@ -111,7 +111,7 @@ PassOwnPtr<InspectorWorkerAgent> InspectorWorkerAgent::create(InstrumentingAgent
 }
 
 InspectorWorkerAgent::InspectorWorkerAgent(InstrumentingAgents* instrumentingAgents, InspectorState* inspectorState)
-    : InspectorBaseAgent(instrumentingAgents, inspectorState)
+    : InspectorBaseAgent<InspectorWorkerAgent>(instrumentingAgents, inspectorState)
     , m_inspectorFrontend(0)
 {
     m_instrumentingAgents->setInspectorWorkerAgent(this);
index f757caa..596ff16 100644 (file)
@@ -47,7 +47,7 @@ class WorkerContextProxy;
 
 typedef String ErrorString;
 
-class InspectorWorkerAgent : public InspectorBaseAgent {
+class InspectorWorkerAgent : public InspectorBaseAgent<InspectorWorkerAgent> {
 public:
     static PassOwnPtr<InspectorWorkerAgent> create(InstrumentingAgents*, InspectorState*);
     ~InspectorWorkerAgent();
index a914752..bb48fae 100644 (file)
@@ -32,6 +32,7 @@
 #define PageConsoleAgent_h
 
 #include "InspectorConsoleAgent.h"
+#include <wtf/PassOwnPtr.h>
 
 #if ENABLE(INSPECTOR)
 
@@ -43,10 +44,14 @@ class InspectorDOMAgent;
 class PageConsoleAgent : public InspectorConsoleAgent {
     WTF_MAKE_NONCOPYABLE(PageConsoleAgent);
 public:
-    PageConsoleAgent(InstrumentingAgents*, InspectorAgent*, InspectorState*, InjectedScriptManager*, InspectorDOMAgent*);
+    static PassOwnPtr<PageConsoleAgent> create(InstrumentingAgents* instrumentingAgents, InspectorAgent* agent, InspectorState* state, InjectedScriptManager* injectedScriptManager, InspectorDOMAgent* domAgent)
+    {
+        return adoptPtr(new PageConsoleAgent(instrumentingAgents, agent, state, injectedScriptManager, domAgent));
+    }
     virtual ~PageConsoleAgent();
 
 private:
+    PageConsoleAgent(InstrumentingAgents*, InspectorAgent*, InspectorState*, InjectedScriptManager*, InspectorDOMAgent*);
     virtual void clearMessages(ErrorString*);
     virtual void addInspectedNode(ErrorString*, int nodeId);
     virtual bool developerExtrasEnabled();
index b5c41c7..ffe290c 100644 (file)
@@ -34,6 +34,7 @@
 #if ENABLE(INSPECTOR)
 
 #include "InspectorRuntimeAgent.h"
+#include <wtf/PassOwnPtr.h>
 
 namespace WebCore {
 
@@ -42,10 +43,15 @@ class Page;
 
 class PageRuntimeAgent : public InspectorRuntimeAgent {
 public:
-    PageRuntimeAgent(InstrumentingAgents*, InspectorState*, InjectedScriptManager*, Page*, InspectorPageAgent*);
+    static PassOwnPtr<PageRuntimeAgent> create(InstrumentingAgents* instrumentingAgents, InspectorState* state, InjectedScriptManager* injectedScriptManager, Page* page, InspectorPageAgent* pageAgent)
+    {
+        return adoptPtr(new PageRuntimeAgent(instrumentingAgents, state, injectedScriptManager, page, pageAgent));
+    }
     virtual ~PageRuntimeAgent();
 
 private:
+    PageRuntimeAgent(InstrumentingAgents*, InspectorState*, InjectedScriptManager*, Page*, InspectorPageAgent*);
+
     virtual ScriptState* scriptStateForFrameId(const String& frameId);
     virtual ScriptState* getDefaultInspectedState();
     Page* m_inspectedPage;
index 360eca7..6f60d42 100644 (file)
@@ -32,6 +32,7 @@
 #define WorkerConsoleAgent_h
 
 #include "InspectorConsoleAgent.h"
+#include <wtf/PassOwnPtr.h>
 
 #if ENABLE(INSPECTOR) && ENABLE(WORKERS)
 
@@ -40,10 +41,14 @@ namespace WebCore {
 class WorkerConsoleAgent : public InspectorConsoleAgent {
     WTF_MAKE_NONCOPYABLE(WorkerConsoleAgent);
 public:
-    WorkerConsoleAgent(InstrumentingAgents*, InspectorState*, InjectedScriptManager*);
+    static PassOwnPtr<WorkerConsoleAgent> create(InstrumentingAgents* instrumentingAgents, InspectorState* state, InjectedScriptManager* injectedScriptManager)
+    {
+        return adoptPtr(new WorkerConsoleAgent(instrumentingAgents, state, injectedScriptManager));
+    }
     virtual ~WorkerConsoleAgent();
 
 private:
+    WorkerConsoleAgent(InstrumentingAgents*, InspectorState*, InjectedScriptManager*);
     virtual void addInspectedNode(ErrorString*, int nodeId);
     virtual bool developerExtrasEnabled();
 };
index 7a016b0..8b5f4a7 100644 (file)
@@ -91,12 +91,14 @@ WorkerInspectorController::WorkerInspectorController(WorkerContext* workerContex
     , m_state(adoptPtr(new InspectorState(m_stateClient.get())))
     , m_instrumentingAgents(adoptPtr(new InstrumentingAgents()))
     , m_injectedScriptManager(InjectedScriptManager::createForWorker())
+{
+
 #if ENABLE(JAVASCRIPT_DEBUGGER)
-    , m_debuggerAgent(WorkerDebuggerAgent::create(m_instrumentingAgents.get(), m_state.get(), workerContext, m_injectedScriptManager.get()))
+    m_debuggerAgent = WorkerDebuggerAgent::create(m_instrumentingAgents.get(), m_state.get(), workerContext, m_injectedScriptManager.get());
 #endif
-    , m_runtimeAgent(adoptPtr(new WorkerRuntimeAgent(m_instrumentingAgents.get(), m_state.get(), m_injectedScriptManager.get(), workerContext)))
-    , m_consoleAgent(adoptPtr(new WorkerConsoleAgent(m_instrumentingAgents.get(), m_state.get(), m_injectedScriptManager.get())))
-{
+    m_runtimeAgent = WorkerRuntimeAgent::create(m_instrumentingAgents.get(), m_state.get(), m_injectedScriptManager.get(), workerContext);
+    m_consoleAgent = WorkerConsoleAgent::create(m_instrumentingAgents.get(), m_state.get(), m_injectedScriptManager.get());
+
     m_injectedScriptManager->injectedScriptHost()->init(0
         , 0
 #if ENABLE(SQL_DATABASE)
@@ -121,34 +123,12 @@ void WorkerInspectorController::connectFrontend()
     m_state->unmute();
     m_frontendChannel = adoptPtr(new PageInspectorProxy(m_workerContext));
     m_frontend = adoptPtr(new InspectorFrontend(m_frontendChannel.get()));
-    m_backendDispatcher = adoptRef(new InspectorBackendDispatcher(
-        m_frontendChannel.get(),
-        0, // InspectorApplicationCacheAgent
-        0, // InspectorCSSAgent
-        m_consoleAgent.get(),
-        0, // InspectorDOMAgent
-#if ENABLE(JAVASCRIPT_DEBUGGER)
-        0, // InspectorDOMDebuggerAgent
-#endif
-        0, // InspectorDOMStorageAgent
-#if ENABLE(SQL_DATABASE)
-        0, // InspectorDatabaseAgent
-#endif
-#if ENABLE(JAVASCRIPT_DEBUGGER)
-        m_debuggerAgent.get(),
-#endif
-#if ENABLE(FILE_SYSTEM)
-        0, // InspectorFileSystemAgent
-#endif
-        0, // InspectorResourceAgent
-        0, // InspectorPageAgent
+    m_backendDispatcher = adoptRef(new InspectorBackendDispatcher(m_frontendChannel.get()));
+    m_consoleAgent->registerInDispatcher(m_backendDispatcher.get());
 #if ENABLE(JAVASCRIPT_DEBUGGER)
-        0, // InspectorProfilerAgent
+    m_debuggerAgent->registerInDispatcher(m_backendDispatcher.get());
 #endif
-        m_runtimeAgent.get(),
-        0, // InspectorTimelineAgent
-        0 // InspectorWorkerAgent
-    ));
+    m_runtimeAgent->registerInDispatcher(m_backendDispatcher.get());
 
     m_injectedScriptManager->injectedScriptHost()->setFrontend(m_frontend.get());
 #if ENABLE(JAVASCRIPT_DEBUGGER)
index f1b538a..d269a2f 100644 (file)
@@ -34,6 +34,7 @@
 #if ENABLE(INSPECTOR) && ENABLE(WORKERS)
 
 #include "InspectorRuntimeAgent.h"
+#include <wtf/PassOwnPtr.h>
 
 namespace WebCore {
 
@@ -41,10 +42,14 @@ class WorkerContext;
 
 class WorkerRuntimeAgent : public InspectorRuntimeAgent {
 public:
-    WorkerRuntimeAgent(InstrumentingAgents*, InspectorState*, InjectedScriptManager*, WorkerContext*);
+    static PassOwnPtr<WorkerRuntimeAgent> create(InstrumentingAgents* instrumentingAgents, InspectorState* state, InjectedScriptManager* injectedScriptManager, WorkerContext* context)
+    {
+        return adoptPtr(new WorkerRuntimeAgent(instrumentingAgents, state, injectedScriptManager, context));
+    }
     virtual ~WorkerRuntimeAgent();
 
 private:
+    WorkerRuntimeAgent(InstrumentingAgents*, InspectorState*, InjectedScriptManager*, WorkerContext*);
     virtual ScriptState* scriptStateForFrameId(const String& frameId);
     virtual ScriptState* getDefaultInspectedState();
     WorkerContext* m_workerContext;
index 46599fc..c08812c 100644 (file)
@@ -210,7 +210,6 @@ Page::~Page()
 
     m_editorClient->pageDestroyed();
 
-    InspectorInstrumentation::inspectedPageDestroyed(this);
 #if ENABLE(INSPECTOR)
     m_inspectorController->inspectedPageDestroyed();
 #endif