Title: [121908] trunk/Source/WebCore
Revision
121908
Author
ca...@chromium.org
Date
2012-07-05 09:13:48 -0700 (Thu, 05 Jul 2012)

Log Message

Web Inspector: added low-level instrumentation support for TimelineAgent
https://bugs.webkit.org/show_bug.cgi?id=90264

Patch by Sergey Rogulenko <rogule...@google.com> on 2012-07-05
Reviewed by Pavel Feldman.

* inspector/InspectorInstrumentation.cpp:
(WebCore::InspectorInstrumentation::timelineAgentForOrphanEvents):
(WebCore::InspectorInstrumentation::setTimelineAgentForOrphanEvents):
(WebCore::InspectorInstrumentation::threadSpecificTimelineAgentForOrphanEvents):
* inspector/InspectorInstrumentation.h:
(InspectorInstrumentation):
* inspector/InspectorTimelineAgent.cpp:
(WebCore::InspectorTimelineAgent::didCompleteCurrentRecord):
(WebCore::InspectorTimelineAgent::InspectorTimelineAgent):
(WebCore::InspectorTimelineAgent::pushCurrentRecord):
* inspector/InspectorTimelineAgent.h:
(InspectorTimelineAgent):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (121907 => 121908)


--- trunk/Source/WebCore/ChangeLog	2012-07-05 15:38:10 UTC (rev 121907)
+++ trunk/Source/WebCore/ChangeLog	2012-07-05 16:13:48 UTC (rev 121908)
@@ -1,3 +1,23 @@
+2012-07-05  Sergey Rogulenko  <rogule...@google.com>
+
+        Web Inspector: added low-level instrumentation support for TimelineAgent
+        https://bugs.webkit.org/show_bug.cgi?id=90264
+
+        Reviewed by Pavel Feldman.
+
+        * inspector/InspectorInstrumentation.cpp:
+        (WebCore::InspectorInstrumentation::timelineAgentForOrphanEvents):
+        (WebCore::InspectorInstrumentation::setTimelineAgentForOrphanEvents):
+        (WebCore::InspectorInstrumentation::threadSpecificTimelineAgentForOrphanEvents):
+        * inspector/InspectorInstrumentation.h:
+        (InspectorInstrumentation):
+        * inspector/InspectorTimelineAgent.cpp:
+        (WebCore::InspectorTimelineAgent::didCompleteCurrentRecord):
+        (WebCore::InspectorTimelineAgent::InspectorTimelineAgent):
+        (WebCore::InspectorTimelineAgent::pushCurrentRecord):
+        * inspector/InspectorTimelineAgent.h:
+        (InspectorTimelineAgent):
+
 2012-07-05  John Mellor  <joh...@chromium.org>
 
         Text Autosizing: Add test framework and simple test.

Modified: trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp (121907 => 121908)


--- trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp	2012-07-05 15:38:10 UTC (rev 121907)
+++ trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp	2012-07-05 16:13:48 UTC (rev 121908)
@@ -68,6 +68,7 @@
 #include "WorkerThread.h"
 #include "XMLHttpRequest.h"
 #include <wtf/StdLibExtras.h>
+#include <wtf/ThreadSpecific.h>
 #include <wtf/text/CString.h>
 
 namespace WebCore {
@@ -1136,6 +1137,22 @@
         timelineAgent->didFireAnimationFrame();
 }
 
+InspectorTimelineAgent* InspectorInstrumentation::timelineAgentForOrphanEvents()
+{
+    return *threadSpecificTimelineAgentForOrphanEvents();
+}
+
+void InspectorInstrumentation::setTimelineAgentForOrphanEvents(InspectorTimelineAgent* inspectorTimelineAgent)
+{
+    *threadSpecificTimelineAgentForOrphanEvents() = inspectorTimelineAgent;
+}
+
+WTF::ThreadSpecific<InspectorTimelineAgent*>& InspectorInstrumentation::threadSpecificTimelineAgentForOrphanEvents()
+{
+    AtomicallyInitializedStatic(WTF::ThreadSpecific<InspectorTimelineAgent*>*, instance = new WTF::ThreadSpecific<InspectorTimelineAgent*>());
+    return *instance;
+}
+
 InspectorTimelineAgent* InspectorInstrumentation::retrieveTimelineAgent(const InspectorInstrumentationCookie& cookie)
 {
     if (!cookie.first)

Modified: trunk/Source/WebCore/inspector/InspectorInstrumentation.h (121907 => 121908)


--- trunk/Source/WebCore/inspector/InspectorInstrumentation.h	2012-07-05 15:38:10 UTC (rev 121907)
+++ trunk/Source/WebCore/inspector/InspectorInstrumentation.h	2012-07-05 16:13:48 UTC (rev 121908)
@@ -252,6 +252,8 @@
     static bool hasFrontends() { return s_frontendCounter; }
     static bool hasFrontendForScriptContext(ScriptExecutionContext*);
     static bool collectingHTMLParseErrors(Page*);
+    static InspectorTimelineAgent* timelineAgentForOrphanEvents();
+    static void setTimelineAgentForOrphanEvents(InspectorTimelineAgent*);
 #else
     static bool hasFrontends() { return false; }
     static bool hasFrontendForScriptContext(ScriptExecutionContext*) { return false; }
@@ -260,6 +262,8 @@
 
 private:
 #if ENABLE(INSPECTOR)
+    static WTF::ThreadSpecific<InspectorTimelineAgent*>& threadSpecificTimelineAgentForOrphanEvents();
+
     static void didClearWindowObjectInWorldImpl(InstrumentingAgents*, Frame*, DOMWrapperWorld*);
     static bool isDebuggerPausedImpl(InstrumentingAgents*);
 

Modified: trunk/Source/WebCore/inspector/InspectorTimelineAgent.cpp (121907 => 121908)


--- trunk/Source/WebCore/inspector/InspectorTimelineAgent.cpp	2012-07-05 15:38:10 UTC (rev 121907)
+++ trunk/Source/WebCore/inspector/InspectorTimelineAgent.cpp	2012-07-05 16:13:48 UTC (rev 121908)
@@ -40,6 +40,7 @@
 #include "InspectorClient.h"
 #include "InspectorCounters.h"
 #include "InspectorFrontend.h"
+#include "InspectorInstrumentation.h"
 #include "InspectorPageAgent.h"
 #include "InspectorState.h"
 #include "InstrumentingAgents.h"
@@ -244,7 +245,7 @@
 
 void InspectorTimelineAgent::willPaint(const LayoutRect& rect, Frame* frame)
 {
-    pushCurrentRecord(TimelineRecordFactory::createPaintData(rect), TimelineRecordType::Paint, true, frame);
+    pushCurrentRecord(TimelineRecordFactory::createPaintData(rect), TimelineRecordType::Paint, true, frame, true);
 }
 
 void InspectorTimelineAgent::didPaint()
@@ -320,7 +321,7 @@
 {
     pushCurrentRecord(TimelineRecordFactory::createEvaluateScriptData(url, lineNumber), TimelineRecordType::EvaluateScript, true, frame);
 }
-    
+
 void InspectorTimelineAgent::didEvaluateScript()
 {
     didCompleteCurrentRecord(TimelineRecordType::EvaluateScript);
@@ -358,7 +359,7 @@
 {
     didCompleteCurrentRecord(TimelineRecordType::ResourceReceivedData);
 }
-    
+
 void InspectorTimelineAgent::willReceiveResourceResponse(unsigned long identifier, const ResourceResponse& response, Frame* frame)
 {
     String requestId = IdentifiersFactory::requestId(identifier);
@@ -481,6 +482,11 @@
     // An empty stack could merely mean that the timeline agent was turned on in the middle of
     // an event.  Don't treat as an error.
     if (!m_recordStack.isEmpty()) {
+        if (m_orphanEventsEnabledStackMark == m_recordStack.size()) {
+            m_orphanEventsEnabledStackMark = 0;
+            InspectorInstrumentation::setTimelineAgentForOrphanEvents(0);
+        }
+
         pushGCEventRecords();
         TimelineRecordEntry entry = m_recordStack.last();
         m_recordStack.removeLast();
@@ -499,6 +505,7 @@
     , m_timestampOffset(0)
     , m_id(1)
     , m_maxCallStackDepth(5)
+    , m_orphanEventsEnabledStackMark(0)
     , m_inspectorType(type)
     , m_client(client)
 {
@@ -516,7 +523,7 @@
     addRecordToTimeline(record.release(), type, frameId);
 }
 
-void InspectorTimelineAgent::pushCurrentRecord(PassRefPtr<InspectorObject> data, const String& type, bool captureCallStack, Frame* frame)
+void InspectorTimelineAgent::pushCurrentRecord(PassRefPtr<InspectorObject> data, const String& type, bool captureCallStack, Frame* frame, bool hasOrphanDetails)
 {
     pushGCEventRecords();
     commitCancelableRecords();
@@ -525,6 +532,10 @@
     if (frame && m_pageAgent)
         frameId = m_pageAgent->frameId(frame);
     m_recordStack.append(TimelineRecordEntry(record.release(), data, InspectorArray::create(), type, frameId));
+    if (hasOrphanDetails && !m_orphanEventsEnabledStackMark && !InspectorInstrumentation::timelineAgentForOrphanEvents()) {
+        m_orphanEventsEnabledStackMark = m_recordStack.size();
+        InspectorInstrumentation::setTimelineAgentForOrphanEvents(this);
+    }
 }
 
 void InspectorTimelineAgent::pushCancelableRecord(PassRefPtr<InspectorObject> data, const String& type, Frame* frame)

Modified: trunk/Source/WebCore/inspector/InspectorTimelineAgent.h (121907 => 121908)


--- trunk/Source/WebCore/inspector/InspectorTimelineAgent.h	2012-07-05 15:38:10 UTC (rev 121907)
+++ trunk/Source/WebCore/inspector/InspectorTimelineAgent.h	2012-07-05 16:13:48 UTC (rev 121908)
@@ -162,7 +162,7 @@
         
     InspectorTimelineAgent(InstrumentingAgents*, InspectorPageAgent*, InspectorState*, InspectorType, InspectorClient*);
 
-    void pushCurrentRecord(PassRefPtr<InspectorObject>, const String& type, bool captureCallStack, Frame*);
+    void pushCurrentRecord(PassRefPtr<InspectorObject>, const String& type, bool captureCallStack, Frame*, bool hasOrphanDetails = false);
     void setHeapSizeStatistic(InspectorObject* record);
         
     void didCompleteCurrentRecord(const String& type);
@@ -199,6 +199,7 @@
     typedef Vector<GCEvent> GCEvents;
     GCEvents m_gcEvents;
     int m_maxCallStackDepth;
+    unsigned m_orphanEventsEnabledStackMark;
     InspectorType m_inspectorType;
     InspectorClient* m_client;
 };
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to