Web Inspector: get rid of InspectorInstrumentation::inspectorAgents() map
authoryurys@chromium.org <yurys@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 9 Aug 2011 13:03:20 +0000 (13:03 +0000)
committeryurys@chromium.org <yurys@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 9 Aug 2011 13:03:20 +0000 (13:03 +0000)
https://bugs.webkit.org/show_bug.cgi?id=54678

Added two functions for retrieving InstrumentingAgents from Page and WorkerContext.

Reviewed by Pavel Feldman.

* CMakeLists.txt:
* GNUmakefile.list.am:
* WebCore.gypi:
* WebCore.pro:
* WebCore.vcproj/WebCore.vcproj:
* WebCore.xcodeproj/project.pbxproj:
* inspector/InspectorController.cpp:
(WebCore::InspectorController::InspectorController):
(WebCore::InspectorController::inspectedPageDestroyed):
* inspector/InspectorController.h:
* inspector/InspectorInstrumentation.cpp:
(WebCore::InspectorInstrumentation::instrumentingAgentsForPage):
* inspector/InspectorInstrumentation.h:
* inspector/InstrumentingAgents.cpp: Copied from Source/WebCore/inspector/WorkerInspectorController.h.
(WebCore::instrumentationForPage):
(WebCore::instrumentationForWorkerContext):
* inspector/InstrumentingAgents.h:
* inspector/WorkerInspectorController.h:

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

14 files changed:
Source/WebCore/CMakeLists.txt
Source/WebCore/ChangeLog
Source/WebCore/GNUmakefile.list.am
Source/WebCore/WebCore.gypi
Source/WebCore/WebCore.pro
Source/WebCore/WebCore.vcproj/WebCore.vcproj
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/inspector/InspectorController.cpp
Source/WebCore/inspector/InspectorController.h
Source/WebCore/inspector/InspectorInstrumentation.cpp
Source/WebCore/inspector/InspectorInstrumentation.h
Source/WebCore/inspector/InstrumentingAgents.cpp [new file with mode: 0644]
Source/WebCore/inspector/InstrumentingAgents.h
Source/WebCore/inspector/WorkerInspectorController.h

index 4b83ada..e35be4a 100644 (file)
@@ -884,6 +884,7 @@ SET(WebCore_SOURCES
     inspector/InspectorTimelineAgent.cpp
     inspector/InspectorValues.cpp
     inspector/InspectorWorkerAgent.cpp
+    inspector/InstrumentingAgents.cpp
     inspector/NetworkResourcesData.cpp
     inspector/PageDebuggerAgent.cpp
     inspector/ScriptArguments.cpp
index c3bc9bc..ecbb0b8 100644 (file)
@@ -1,3 +1,31 @@
+2011-08-09  Yury Semikhatsky  <yurys@chromium.org>
+
+        Web Inspector: get rid of InspectorInstrumentation::inspectorAgents() map
+        https://bugs.webkit.org/show_bug.cgi?id=54678
+
+        Added two functions for retrieving InstrumentingAgents from Page and WorkerContext.
+
+        Reviewed by Pavel Feldman.
+
+        * CMakeLists.txt:
+        * GNUmakefile.list.am:
+        * WebCore.gypi:
+        * WebCore.pro:
+        * WebCore.vcproj/WebCore.vcproj:
+        * WebCore.xcodeproj/project.pbxproj:
+        * inspector/InspectorController.cpp:
+        (WebCore::InspectorController::InspectorController):
+        (WebCore::InspectorController::inspectedPageDestroyed):
+        * inspector/InspectorController.h:
+        * inspector/InspectorInstrumentation.cpp:
+        (WebCore::InspectorInstrumentation::instrumentingAgentsForPage):
+        * inspector/InspectorInstrumentation.h:
+        * inspector/InstrumentingAgents.cpp: Copied from Source/WebCore/inspector/WorkerInspectorController.h.
+        (WebCore::instrumentationForPage):
+        (WebCore::instrumentationForWorkerContext):
+        * inspector/InstrumentingAgents.h:
+        * inspector/WorkerInspectorController.h:
+
 2011-08-09  Vsevolod Vlasov  <vsevik@chromium.org>
 
         Web Inspector: Add "Refresh" to context menu of resources panel cookies view.
index a068c02..61fbdfb 100644 (file)
@@ -2027,6 +2027,7 @@ webcore_sources += \
        Source/WebCore/inspector/InspectorWorkerAgent.cpp \
        Source/WebCore/inspector/InspectorWorkerAgent.h \
        Source/WebCore/inspector/InspectorWorkerResource.h \
+       Source/WebCore/inspector/InstrumentingAgents.cpp \
        Source/WebCore/inspector/InstrumentingAgents.h \
        Source/WebCore/inspector/NetworkResourcesData.cpp \
        Source/WebCore/inspector/NetworkResourcesData.h \
index 79be9cd..6f7c2ed 100644 (file)
             'inspector/InspectorWorkerResource.h',
             'inspector/InspectorWorkerAgent.cpp',
             'inspector/InspectorWorkerAgent.h',
+            'inspector/InstrumentingAgents.cpp',
             'inspector/InstrumentingAgents.h',
             'inspector/NetworkResourcesData.cpp',
             'inspector/NetworkResourcesData.h',
index a6f89a4..dea1a56 100644 (file)
@@ -843,6 +843,7 @@ SOURCES += \
     inspector/InspectorTimelineAgent.cpp \
     inspector/InspectorValues.cpp \
     inspector/InspectorWorkerAgent.cpp \
+    inspector/InstrumentingAgents.cpp \
     inspector/NetworkResourcesData.cpp \
     inspector/PageDebuggerAgent.cpp \
     inspector/ScriptArguments.cpp \
index b2e69e0..44c9c84 100755 (executable)
                                >
                        </File>
                        <File
+                               RelativePath="..\inspector\InstrumentingAgents.cpp"
+                               >
+                       </File>
+                       <File
                                RelativePath="..\inspector\InstrumentingAgents.h"
                                >
                        </File>
index 7d6f7ae..feedf50 100644 (file)
                F34742E51343633C00531BC2 /* PageScriptDebugServer.h in Headers */ = {isa = PBXBuildFile; fileRef = F34742E31343633C00531BC2 /* PageScriptDebugServer.h */; };
                F34742E81343635000531BC2 /* WorkerScriptDebugServer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F34742E61343635000531BC2 /* WorkerScriptDebugServer.cpp */; };
                F34742E91343635000531BC2 /* WorkerScriptDebugServer.h in Headers */ = {isa = PBXBuildFile; fileRef = F34742E71343635000531BC2 /* WorkerScriptDebugServer.h */; };
+               F350B73513F1377D00880C43 /* InstrumentingAgents.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F350B73413F1377D00880C43 /* InstrumentingAgents.cpp */; };
                F3644AFF1119805900E0D537 /* InjectedScript.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F3644AFD1119805900E0D537 /* InjectedScript.cpp */; };
                F3644B001119805900E0D537 /* InjectedScript.h in Headers */ = {isa = PBXBuildFile; fileRef = F3644AFE1119805900E0D537 /* InjectedScript.h */; };
                F36E07A41358A8BE00AACBC9 /* WorkerInspectorController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F36E07A21358A8BE00AACBC9 /* WorkerInspectorController.cpp */; };
                F34742E31343633C00531BC2 /* PageScriptDebugServer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PageScriptDebugServer.h; sourceTree = "<group>"; };
                F34742E61343635000531BC2 /* WorkerScriptDebugServer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WorkerScriptDebugServer.cpp; sourceTree = "<group>"; };
                F34742E71343635000531BC2 /* WorkerScriptDebugServer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WorkerScriptDebugServer.h; sourceTree = "<group>"; };
+               F350B73413F1377D00880C43 /* InstrumentingAgents.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InstrumentingAgents.cpp; sourceTree = "<group>"; };
                F3644AFD1119805900E0D537 /* InjectedScript.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InjectedScript.cpp; sourceTree = "<group>"; };
                F3644AFE1119805900E0D537 /* InjectedScript.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InjectedScript.h; sourceTree = "<group>"; };
                F36E07A21358A8BE00AACBC9 /* WorkerInspectorController.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WorkerInspectorController.cpp; sourceTree = "<group>"; };
                                F3810C191365A49600ED6E33 /* InspectorWorkerAgent.cpp */,
                                F3810C1A1365A49600ED6E33 /* InspectorWorkerAgent.h */,
                                F375CC061150D300008DDB81 /* InspectorWorkerResource.h */,
+                               F350B73413F1377D00880C43 /* InstrumentingAgents.cpp */,
                                F3ABFE0B130E9DA000E7F7D1 /* InstrumentingAgents.h */,
                                1C81BA050E97348300266E07 /* JavaScriptCallFrame.idl */,
                                BCC64F5F0DCFB84E0081EF3B /* localizedStrings.js */,
                                754133AA102E00F400075D00 /* InspectorTimelineAgent.cpp in Sources */,
                                4F3289B511A42AAB005ABE7E /* InspectorValues.cpp in Sources */,
                                F3810C1B1365A49600ED6E33 /* InspectorWorkerAgent.cpp in Sources */,
+                               F350B73513F1377D00880C43 /* InstrumentingAgents.cpp in Sources */,
                                49EECDEB10503C2400099FAB /* Int16Array.cpp in Sources */,
                                49EECDE810503C2400099FAB /* Int32Array.cpp in Sources */,
                                49C7B9CB1042D32F0009D447 /* Int8Array.cpp in Sources */,
index 6291a33..ef9bc90 100644 (file)
@@ -141,8 +141,6 @@ InspectorController::InspectorController(Page* page, InspectorClient* inspectorC
 #if ENABLE(JAVASCRIPT_DEBUGGER)
     m_runtimeAgent->setScriptDebugServer(&m_debuggerAgent->scriptDebugServer());
 #endif
-
-    InspectorInstrumentation::bindInstrumentingAgents(m_page, m_instrumentingAgents.get());
 }
 
 InspectorController::~InspectorController()
@@ -152,7 +150,6 @@ InspectorController::~InspectorController()
 
 void InspectorController::inspectedPageDestroyed()
 {
-    InspectorInstrumentation::unbindInstrumentingAgents(m_page);
     disconnectFrontend();
 #if ENABLE(JAVASCRIPT_DEBUGGER)
     m_domDebuggerAgent.clear();
index 9d76835..a8fd447 100644 (file)
@@ -124,6 +124,7 @@ public:
 
 private:
     friend class PostWorkerNotificationToFrontendTask;
+    friend InstrumentingAgents* instrumentationForPage(Page*);
 
     OwnPtr<InstrumentingAgents> m_instrumentingAgents;
     OwnPtr<InjectedScriptManager> m_injectedScriptManager;
index 4a99732..8b18f0b 100644 (file)
@@ -69,12 +69,6 @@ static const char* const setTimerEventName = "setTimer";
 static const char* const clearTimerEventName = "clearTimer";
 static const char* const timerFiredEventName = "timerFired";
 
-InspectorInstrumentation::InstrumentingAgentsMap& InspectorInstrumentation::instrumentingAgents()
-{
-    DEFINE_STATIC_LOCAL(InstrumentingAgentsMap, agents, ());
-    return agents;
-}
-
 int InspectorInstrumentation::s_frontendCounter = 0;
 
 static bool eventHasListeners(const AtomicString& eventType, DOMWindow* window, Node* node, const Vector<EventContext>& ancestors)
@@ -874,6 +868,13 @@ InspectorTimelineAgent* InspectorInstrumentation::retrieveTimelineAgent(const In
     return 0;
 }
 
+InstrumentingAgents* InspectorInstrumentation::instrumentingAgentsForPage(Page* page)
+{
+    if (!page)
+        return 0;
+    return instrumentationForPage(page);
+}
+
 } // namespace WebCore
 
 #endif // !ENABLE(INSPECTOR)
index 5966485..3ad187a 100644 (file)
@@ -36,7 +36,6 @@
 #include "Frame.h"
 #include "Page.h"
 #include "ScriptExecutionContext.h"
-#include <wtf/HashMap.h>
 
 namespace WebCore {
 
@@ -188,8 +187,6 @@ public:
 #endif
 
 #if ENABLE(INSPECTOR)
-    static void bindInstrumentingAgents(Page* page, InstrumentingAgents* agents) { instrumentingAgents().set(page, agents); }
-    static void unbindInstrumentingAgents(Page* page) { instrumentingAgents().remove(page); }
     static void frontendCreated() { s_frontendCounter += 1; }
     static void frontendDeleted() { s_frontendCounter -= 1; }
     static bool hasFrontends() { return s_frontendCounter; }
@@ -326,8 +323,6 @@ private:
     static void cancelPauseOnNativeEvent(InstrumentingAgents*);
     static InspectorTimelineAgent* retrieveTimelineAgent(const InspectorInstrumentationCookie&);
 
-    typedef HashMap<Page*, InstrumentingAgents*> InstrumentingAgentsMap;
-    static InstrumentingAgentsMap& instrumentingAgents();
     static int s_frontendCounter;
 #endif
 };
@@ -1032,13 +1027,6 @@ inline InstrumentingAgents* InspectorInstrumentation::instrumentingAgentsForCont
     return 0;
 }
 
-inline InstrumentingAgents* InspectorInstrumentation::instrumentingAgentsForPage(Page* page)
-{
-    if (!page)
-        return 0;
-    return instrumentingAgents().get(page);
-}
-
 inline InstrumentingAgents* InspectorInstrumentation::instrumentingAgentsForFrame(Frame* frame)
 {
     if (frame)
diff --git a/Source/WebCore/inspector/InstrumentingAgents.cpp b/Source/WebCore/inspector/InstrumentingAgents.cpp
new file mode 100644 (file)
index 0000000..0aaed54
--- /dev/null
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2011 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "InstrumentingAgents.h"
+
+#if ENABLE(INSPECTOR)
+
+#include "InspectorController.h"
+#include "Page.h"
+#include "WorkerContext.h"
+#include "WorkerInspectorController.h"
+
+namespace WebCore {
+
+InstrumentingAgents* instrumentationForPage(Page* page)
+{
+    if (InspectorController* controller = page->inspectorController())
+        return controller->m_instrumentingAgents.get();
+    return 0;
+}
+
+#if ENABLE(WORKERS)
+InstrumentingAgents* instrumentationForWorkerContext(WorkerContext* workerContext)
+{
+    if (WorkerInspectorController* controller = workerContext->workerInspectorController())
+        return controller->m_instrumentingAgents.get();
+    return 0;
+}
+#endif
+
+} // namespace WebCore
+
+#endif // ENABLE(INSPECTOR)
index d1b0552..bc80905 100644 (file)
@@ -51,6 +51,8 @@ class InspectorResourceAgent;
 class InspectorRuntimeAgent;
 class InspectorTimelineAgent;
 class InspectorWorkerAgent;
+class Page;
+class WorkerContext;
 
 class InstrumentingAgents {
     WTF_MAKE_NONCOPYABLE(InstrumentingAgents);
@@ -164,6 +166,11 @@ private:
 #endif
 };
 
+InstrumentingAgents* instrumentationForPage(Page*);
+#if ENABLE(WORKERS)
+InstrumentingAgents* instrumentationForWorkerContext(WorkerContext*);
+#endif
+
 }
 
 #endif // !defined(InstrumentingAgents_h)
index edd3dbf..6169741 100644 (file)
@@ -66,6 +66,8 @@ public:
     void dispatchMessageFromFrontend(const String&);
 
 private:
+    friend InstrumentingAgents* instrumentationForWorkerContext(WorkerContext*);
+
     WorkerContext* m_workerContext;
     OwnPtr<InspectorState> m_state;
     OwnPtr<InstrumentingAgents> m_instrumentingAgents;