Title: [91184] trunk/Source/WebCore
Revision
91184
Author
[email protected]
Date
2011-07-18 07:04:28 -0700 (Mon, 18 Jul 2011)

Log Message

Web Inspector: Web Inspector: provide unique identifiers for loaders
https://bugs.webkit.org/show_bug.cgi?id=64599

Reviewed by Pavel Feldman.

* inspector/InspectorInstrumentation.cpp:
(WebCore::InspectorInstrumentation::loaderDetachedFromFrameImpl):
* inspector/InspectorInstrumentation.h:
(WebCore::InspectorInstrumentation::frameDestroyed):
(WebCore::InspectorInstrumentation::loaderDetachedFromFrame):
* inspector/InspectorPageAgent.cpp:
(WebCore::InspectorPageAgent::loaderId):
(WebCore::InspectorPageAgent::loaderDetachedFromFrame):
* inspector/InspectorPageAgent.h:
* loader/DocumentLoader.cpp:
(WebCore::DocumentLoader::detachFromFrame):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (91183 => 91184)


--- trunk/Source/WebCore/ChangeLog	2011-07-18 13:43:55 UTC (rev 91183)
+++ trunk/Source/WebCore/ChangeLog	2011-07-18 14:04:28 UTC (rev 91184)
@@ -1,3 +1,22 @@
+2011-07-18  Vsevolod Vlasov  <[email protected]>
+
+        Web Inspector: Web Inspector: provide unique identifiers for loaders
+        https://bugs.webkit.org/show_bug.cgi?id=64599
+
+        Reviewed by Pavel Feldman.
+
+        * inspector/InspectorInstrumentation.cpp:
+        (WebCore::InspectorInstrumentation::loaderDetachedFromFrameImpl):
+        * inspector/InspectorInstrumentation.h:
+        (WebCore::InspectorInstrumentation::frameDestroyed):
+        (WebCore::InspectorInstrumentation::loaderDetachedFromFrame):
+        * inspector/InspectorPageAgent.cpp:
+        (WebCore::InspectorPageAgent::loaderId):
+        (WebCore::InspectorPageAgent::loaderDetachedFromFrame):
+        * inspector/InspectorPageAgent.h:
+        * loader/DocumentLoader.cpp:
+        (WebCore::DocumentLoader::detachFromFrame):
+
 2011-07-18  Pavel Feldman  <[email protected]>
 
         Web Inspector: "Reveal in Elements Panel" is broken.

Modified: trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp (91183 => 91184)


--- trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp	2011-07-18 13:43:55 UTC (rev 91183)
+++ trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp	2011-07-18 14:04:28 UTC (rev 91184)
@@ -646,6 +646,12 @@
         inspectorPageAgent->frameDestroyed(frame);
 }
 
+void InspectorInstrumentation::loaderDetachedFromFrameImpl(InstrumentingAgents* instrumentingAgents, DocumentLoader* loader)
+{
+    if (InspectorPageAgent* inspectorPageAgent = instrumentingAgents->inspectorPageAgent())
+        inspectorPageAgent->loaderDetachedFromFrame(loader);
+}
+
 InspectorInstrumentationCookie InspectorInstrumentation::willWriteHTMLImpl(InstrumentingAgents* instrumentingAgents, unsigned int length, unsigned int startLine)
 {
     int timelineAgentId = 0;

Modified: trunk/Source/WebCore/inspector/InspectorInstrumentation.h (91183 => 91184)


--- trunk/Source/WebCore/inspector/InspectorInstrumentation.h	2011-07-18 13:43:55 UTC (rev 91183)
+++ trunk/Source/WebCore/inspector/InspectorInstrumentation.h	2011-07-18 14:04:28 UTC (rev 91184)
@@ -139,6 +139,7 @@
     static void frameDetachedFromParent(Frame*);
     static void didCommitLoad(Frame*, DocumentLoader*);
     static void frameDestroyed(Frame*);
+    static void loaderDetachedFromFrame(Frame*, DocumentLoader*);
 
     static InspectorInstrumentationCookie willWriteHTML(Document*, unsigned int length, unsigned int startLine);
     static void didWriteHTML(const InspectorInstrumentationCookie&, unsigned int endLine);
@@ -267,6 +268,7 @@
     static void frameDetachedFromParentImpl(InstrumentingAgents*, Frame*);
     static void didCommitLoadImpl(InstrumentingAgents*, Page*, DocumentLoader*);
     static void frameDestroyedImpl(InstrumentingAgents*, Frame*);
+    static void loaderDetachedFromFrameImpl(InstrumentingAgents*, DocumentLoader*);
 
     static InspectorInstrumentationCookie willWriteHTMLImpl(InstrumentingAgents*, unsigned int length, unsigned int startLine);
     static void didWriteHTMLImpl(const InspectorInstrumentationCookie&, unsigned int endLine);
@@ -868,14 +870,19 @@
 inline void InspectorInstrumentation::frameDestroyed(Frame* frame)
 {
 #if ENABLE(INSPECTOR)
-    Page* page = frame->page();
-    if (!page)
-        return;
-    if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForPage(page))
+    if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
         frameDestroyedImpl(instrumentingAgents, frame);
 #endif
 }
 
+inline void InspectorInstrumentation::loaderDetachedFromFrame(Frame* frame, DocumentLoader* loader)
+{
+#if ENABLE(INSPECTOR)
+    if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
+        loaderDetachedFromFrameImpl(instrumentingAgents, loader);
+#endif
+}
+
 inline InspectorInstrumentationCookie InspectorInstrumentation::willWriteHTML(Document* document, unsigned int length, unsigned int startLine)
 {
 #if ENABLE(INSPECTOR)

Modified: trunk/Source/WebCore/inspector/InspectorPageAgent.cpp (91183 => 91184)


--- trunk/Source/WebCore/inspector/InspectorPageAgent.cpp	2011-07-18 13:43:55 UTC (rev 91183)
+++ trunk/Source/WebCore/inspector/InspectorPageAgent.cpp	2011-07-18 14:04:28 UTC (rev 91184)
@@ -558,13 +558,6 @@
     return m_page->mainFrame();
 }
 
-static String pointerAsId(void* pointer)
-{
-    unsigned long long address = reinterpret_cast<uintptr_t>(pointer);
-    // We want 0 to be "", so that _javascript_ checks for if (frameId) worked.
-    return String::format("%.0llX", address);
-}
-
 String InspectorPageAgent::createIdentifier()
 {
     return m_agentIdentifierPrefix + String::number(++s_lastUsedIdentifier);
@@ -590,7 +583,14 @@
 
 String InspectorPageAgent::loaderId(DocumentLoader* loader)
 {
-    return pointerAsId(loader);
+    if (!loader)
+        return "";
+    String identifier = m_loaderToIdentifier.get(loader);
+    if (identifier.isNull()) {
+        identifier = createIdentifier();
+        m_loaderToIdentifier.set(loader, identifier);
+    }
+    return identifier;
 }
 
 void InspectorPageAgent::frameDestroyed(Frame* frame)
@@ -602,6 +602,13 @@
     }
 }
 
+void InspectorPageAgent::loaderDetachedFromFrame(DocumentLoader* loader)
+{
+    HashMap<DocumentLoader*, String>::iterator iterator = m_loaderToIdentifier.find(loader);
+    if (iterator != m_loaderToIdentifier.end())
+        m_loaderToIdentifier.remove(iterator);
+}
+
 PassRefPtr<InspectorObject> InspectorPageAgent::buildObjectForFrame(Frame* frame)
 {
     RefPtr<InspectorObject> frameObject = InspectorObject::create();

Modified: trunk/Source/WebCore/inspector/InspectorPageAgent.h (91183 => 91184)


--- trunk/Source/WebCore/inspector/InspectorPageAgent.h	2011-07-18 13:43:55 UTC (rev 91183)
+++ trunk/Source/WebCore/inspector/InspectorPageAgent.h	2011-07-18 14:04:28 UTC (rev 91184)
@@ -103,6 +103,7 @@
     void frameNavigated(DocumentLoader*);
     void frameDetached(Frame*);
     void frameDestroyed(Frame*);
+    void loaderDetachedFromFrame(DocumentLoader*);
 
     // Inspector Controller API
     void setFrontend(InspectorFrontend*);
@@ -131,6 +132,7 @@
     Vector<String> m_scriptsToEvaluateOnLoad;
     HashMap<Frame*, String> m_frameToIdentifier;
     HashMap<String, Frame*> m_identifierToFrame;
+    HashMap<DocumentLoader*, String> m_loaderToIdentifier;
 };
 
 

Modified: trunk/Source/WebCore/loader/DocumentLoader.cpp (91183 => 91184)


--- trunk/Source/WebCore/loader/DocumentLoader.cpp	2011-07-18 13:43:55 UTC (rev 91183)
+++ trunk/Source/WebCore/loader/DocumentLoader.cpp	2011-07-18 14:04:28 UTC (rev 91184)
@@ -43,6 +43,7 @@
 #include "FrameLoaderClient.h"
 #include "FrameTree.h"
 #include "HistoryItem.h"
+#include "InspectorInstrumentation.h"
 #include "Logging.h"
 #include "MainResourceLoader.h"
 #include "Page.h"
@@ -403,6 +404,7 @@
 #if ENABLE(OFFLINE_WEB_APPLICATIONS)
     m_applicationCacheHost->setDOMApplicationCache(0);
 #endif
+    InspectorInstrumentation::loaderDetachedFromFrame(m_frame, this);
     m_frame = 0;
 }
 
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to