Index: Source/core/inspector/InspectorTimelineAgent.cpp |
diff --git a/Source/core/inspector/InspectorTimelineAgent.cpp b/Source/core/inspector/InspectorTimelineAgent.cpp |
index f2002cc2daccc56e96aa410fbd3cbfbfb30bb0d8..341e198c80c3747711aad55b15ae7464c976572a 100644 |
--- a/Source/core/inspector/InspectorTimelineAgent.cpp |
+++ b/Source/core/inspector/InspectorTimelineAgent.cpp |
@@ -157,7 +157,7 @@ struct TimelineRecordEntry { |
bool skipWhenUnbalanced; |
}; |
-class TimelineRecordStack { |
+class TimelineRecordStack : public NoBaseWillBeGarbageCollectedFinalized<TimelineRecordStack> { |
tkent
2014/06/11 05:48:49
You don't need to make TimelineRecordStack on-heap
keishi
2014/06/19 04:36:22
Done.
|
private: |
struct Entry { |
Entry(PassRefPtr<TimelineEvent> record, const String& type) |
@@ -177,7 +177,7 @@ private: |
}; |
public: |
- TimelineRecordStack() : m_timelineAgent(0) { } |
+ TimelineRecordStack() : m_timelineAgent(nullptr) { } |
TimelineRecordStack(InspectorTimelineAgent*); |
void addScopedRecord(PassRefPtr<TimelineEvent> record, const String& type); |
@@ -188,24 +188,28 @@ public: |
bool isOpenRecordOfType(const String& type); |
#endif |
+ void trace(Visitor*); |
+ |
private: |
void send(PassRefPtr<JSONObject>); |
- InspectorTimelineAgent* m_timelineAgent; |
+ RawPtrWillBeMember<InspectorTimelineAgent> m_timelineAgent; |
Vector<Entry> m_stack; |
}; |
-struct TimelineThreadState { |
+struct TimelineThreadState : public NoBaseWillBeGarbageCollectedFinalized<TimelineThreadState> { |
TimelineThreadState() { } |
TimelineThreadState(InspectorTimelineAgent* timelineAgent) |
- : recordStack(timelineAgent) |
+ : recordStack(adoptPtrWillBeNoop(new TimelineRecordStack(timelineAgent))) |
, inKnownLayerTask(false) |
, decodedPixelRefId(0) |
{ |
} |
- TimelineRecordStack recordStack; |
+ void trace(Visitor*); |
+ |
+ OwnPtrWillBeMember<TimelineRecordStack> recordStack; |
bool inKnownLayerTask; |
unsigned long long decodedPixelRefId; |
}; |
@@ -265,6 +269,7 @@ void InspectorTimelineAgent::trace(Visitor* visitor) |
{ |
visitor->trace(m_pageAgent); |
visitor->trace(m_layerTreeAgent); |
+ visitor->trace(m_threadStates); |
InspectorBaseAgent::trace(visitor); |
} |
@@ -893,7 +898,7 @@ void InspectorTimelineAgent::onBeginImplSideFrame(const TraceEventDispatcher::Tr |
if (layerTreeId != m_layerTreeId) |
return; |
TimelineThreadState& state = threadState(event.threadIdentifier()); |
- state.recordStack.addInstantRecord(createRecordForEvent(event, TimelineRecordType::BeginFrame, JSONObject::create())); |
+ state.recordStack->addInstantRecord(createRecordForEvent(event, TimelineRecordType::BeginFrame, JSONObject::create())); |
} |
void InspectorTimelineAgent::onPaintSetupBegin(const TraceEventDispatcher::TraceEvent& event) |
@@ -920,7 +925,7 @@ void InspectorTimelineAgent::onRasterTaskBegin(const TraceEventDispatcher::Trace |
double timestamp = event.timestamp() * msPerSecond; |
RefPtr<JSONObject> data = TimelineRecordFactory::createLayerData(m_layerToNodeMap.get(layerId)); |
RefPtr<TimelineEvent> record = TimelineRecordFactory::createBackgroundRecord(timestamp, String::number(event.threadIdentifier()), TimelineRecordType::Rasterize, data); |
- state.recordStack.addScopedRecord(record, TimelineRecordType::Rasterize); |
+ state.recordStack->addScopedRecord(record, TimelineRecordType::Rasterize); |
} |
void InspectorTimelineAgent::onRasterTaskEnd(const TraceEventDispatcher::TraceEvent& event) |
@@ -928,8 +933,8 @@ void InspectorTimelineAgent::onRasterTaskEnd(const TraceEventDispatcher::TraceEv |
TimelineThreadState& state = threadState(event.threadIdentifier()); |
if (!state.inKnownLayerTask) |
return; |
- ASSERT(state.recordStack.isOpenRecordOfType(TimelineRecordType::Rasterize)); |
- state.recordStack.closeScopedRecord(event.timestamp() * msPerSecond); |
+ ASSERT(state.recordStack->isOpenRecordOfType(TimelineRecordType::Rasterize)); |
+ state.recordStack->closeScopedRecord(event.timestamp() * msPerSecond); |
state.inKnownLayerTask = false; |
} |
@@ -949,7 +954,7 @@ void InspectorTimelineAgent::onImageDecodeBegin(const TraceEventDispatcher::Trac |
RefPtr<JSONObject> data = JSONObject::create(); |
TimelineRecordFactory::setImageDetails(data.get(), imageInfo.backendNodeId, imageInfo.url); |
double timeestamp = event.timestamp() * msPerSecond; |
- state.recordStack.addScopedRecord(TimelineRecordFactory::createBackgroundRecord(timeestamp, String::number(event.threadIdentifier()), TimelineRecordType::DecodeImage, data), TimelineRecordType::DecodeImage); |
+ state.recordStack->addScopedRecord(TimelineRecordFactory::createBackgroundRecord(timeestamp, String::number(event.threadIdentifier()), TimelineRecordType::DecodeImage, data), TimelineRecordType::DecodeImage); |
} |
void InspectorTimelineAgent::onImageDecodeEnd(const TraceEventDispatcher::TraceEvent& event) |
@@ -957,8 +962,8 @@ void InspectorTimelineAgent::onImageDecodeEnd(const TraceEventDispatcher::TraceE |
TimelineThreadState& state = threadState(event.threadIdentifier()); |
if (!state.decodedPixelRefId) |
return; |
- ASSERT(state.recordStack.isOpenRecordOfType(TimelineRecordType::DecodeImage)); |
- state.recordStack.closeScopedRecord(event.timestamp() * msPerSecond); |
+ ASSERT(state.recordStack->isOpenRecordOfType(TimelineRecordType::DecodeImage)); |
+ state.recordStack->closeScopedRecord(event.timestamp() * msPerSecond); |
} |
void InspectorTimelineAgent::onRequestMainThreadFrame(const TraceEventDispatcher::TraceEvent& event) |
@@ -967,7 +972,7 @@ void InspectorTimelineAgent::onRequestMainThreadFrame(const TraceEventDispatcher |
if (layerTreeId != m_layerTreeId) |
return; |
TimelineThreadState& state = threadState(event.threadIdentifier()); |
- state.recordStack.addInstantRecord(createRecordForEvent(event, TimelineRecordType::RequestMainThreadFrame, JSONObject::create())); |
+ state.recordStack->addInstantRecord(createRecordForEvent(event, TimelineRecordType::RequestMainThreadFrame, JSONObject::create())); |
} |
void InspectorTimelineAgent::onActivateLayerTree(const TraceEventDispatcher::TraceEvent& event) |
@@ -977,7 +982,7 @@ void InspectorTimelineAgent::onActivateLayerTree(const TraceEventDispatcher::Tra |
return; |
unsigned long long frameId = event.asUInt(InstrumentationEventArguments::FrameId); |
TimelineThreadState& state = threadState(event.threadIdentifier()); |
- state.recordStack.addInstantRecord(createRecordForEvent(event, TimelineRecordType::ActivateLayerTree, TimelineRecordFactory::createFrameData(frameId))); |
+ state.recordStack->addInstantRecord(createRecordForEvent(event, TimelineRecordType::ActivateLayerTree, TimelineRecordFactory::createFrameData(frameId))); |
} |
void InspectorTimelineAgent::onDrawFrame(const TraceEventDispatcher::TraceEvent& event) |
@@ -986,7 +991,7 @@ void InspectorTimelineAgent::onDrawFrame(const TraceEventDispatcher::TraceEvent& |
if (layerTreeId != m_layerTreeId) |
return; |
TimelineThreadState& state = threadState(event.threadIdentifier()); |
- state.recordStack.addInstantRecord(createRecordForEvent(event, TimelineRecordType::DrawFrame, JSONObject::create())); |
+ state.recordStack->addInstantRecord(createRecordForEvent(event, TimelineRecordType::DrawFrame, JSONObject::create())); |
} |
void InspectorTimelineAgent::onLayerDeleted(const TraceEventDispatcher::TraceEvent& event) |
@@ -1051,13 +1056,13 @@ void InspectorTimelineAgent::onEmbedderCallbackBegin(const TraceEventDispatcher: |
double timestamp = event.timestamp() * msPerSecond; |
RefPtr<JSONObject> data = TimelineRecordFactory::createEmbedderCallbackData(event.asString(InstrumentationEventArguments::CallbackName)); |
RefPtr<TimelineEvent> record = TimelineRecordFactory::createGenericRecord(timestamp, 0, TimelineRecordType::EmbedderCallback, data); |
- state.recordStack.addScopedRecord(record, TimelineRecordType::EmbedderCallback); |
+ state.recordStack->addScopedRecord(record, TimelineRecordType::EmbedderCallback); |
} |
void InspectorTimelineAgent::onEmbedderCallbackEnd(const TraceEventDispatcher::TraceEvent& event) |
{ |
TimelineThreadState& state = threadState(event.threadIdentifier()); |
- state.recordStack.closeScopedRecord(event.timestamp() * msPerSecond); |
+ state.recordStack->closeScopedRecord(event.timestamp() * msPerSecond); |
} |
void InspectorTimelineAgent::addRecordToTimeline(PassRefPtr<TimelineEvent> record, double ts) |
@@ -1208,8 +1213,8 @@ TimelineThreadState& InspectorTimelineAgent::threadState(ThreadIdentifier thread |
{ |
ThreadStateMap::iterator it = m_threadStates.find(thread); |
if (it != m_threadStates.end()) |
- return it->value; |
- return m_threadStates.add(thread, TimelineThreadState(this)).storedValue->value; |
+ return *(it->value); |
+ return *(m_threadStates.add(thread, adoptPtrWillBeNoop(new TimelineThreadState(this))).storedValue->value); |
} |
void InspectorTimelineAgent::commitFrameRecord() |
@@ -1317,5 +1322,15 @@ bool TimelineRecordStack::isOpenRecordOfType(const String& type) |
} |
#endif |
+void TimelineRecordStack::trace(Visitor* visitor) |
+{ |
+ visitor->trace(m_timelineAgent); |
+} |
+ |
+void TimelineThreadState::trace(Visitor* visitor) |
+{ |
+ visitor->trace(recordStack); |
+} |
+ |
} // namespace WebCore |