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;
};