Index: Source/core/inspector/AsyncCallStackTracker.cpp |
diff --git a/Source/core/inspector/AsyncCallStackTracker.cpp b/Source/core/inspector/AsyncCallStackTracker.cpp |
index 7bdaf7342363d2b784b9155110eedac91376cd65..608341182f71fd14302c5cc3292a679614d1b703 100644 |
--- a/Source/core/inspector/AsyncCallStackTracker.cpp |
+++ b/Source/core/inspector/AsyncCallStackTracker.cpp |
@@ -56,8 +56,8 @@ static const char enqueueMutationRecordName[] = "Mutation"; |
namespace blink { |
-class AsyncCallStackTracker::ExecutionContextData FINAL : public ContextLifecycleObserver { |
- WTF_MAKE_FAST_ALLOCATED; |
+class AsyncCallStackTracker::ExecutionContextData FINAL : public NoBaseWillBeGarbageCollectedFinalized<AsyncCallStackTracker::ExecutionContextData>, public ContextLifecycleObserver { |
+ WTF_MAKE_FAST_ALLOCATED_WILL_BE_REMOVED; |
public: |
ExecutionContextData(AsyncCallStackTracker* tracker, ExecutionContext* executionContext) |
: ContextLifecycleObserver(executionContext) |
@@ -69,10 +69,9 @@ public: |
virtual void contextDestroyed() OVERRIDE |
{ |
ASSERT(executionContext()); |
- ExecutionContextData* self = m_tracker->m_executionContextDataMap.take(executionContext()); |
+ OwnPtrWillBeRawPtr<ExecutionContextData> self = m_tracker->m_executionContextDataMap.take(executionContext()); |
ASSERT(self == this); |
ContextLifecycleObserver::contextDestroyed(); |
- delete self; |
} |
int circularSequentialID() |
@@ -83,20 +82,33 @@ public: |
return m_circularSequentialID; |
} |
+ void trace(Visitor* visitor) |
+ { |
+ visitor->trace(m_tracker); |
+ visitor->trace(m_timerCallChains); |
+ visitor->trace(m_animationFrameCallChains); |
+ visitor->trace(m_eventCallChains); |
+ visitor->trace(m_xhrCallChains); |
+ visitor->trace(m_mutationObserverCallChains); |
+ visitor->trace(m_executionContextTaskCallChains); |
+ visitor->trace(m_v8AsyncTaskCallChains); |
+ visitor->trace(m_asyncOperationCallChains); |
+ } |
+ |
private: |
int m_circularSequentialID; |
public: |
- AsyncCallStackTracker* m_tracker; |
+ RawPtrWillBeMember<AsyncCallStackTracker> m_tracker; |
HashSet<int> m_intervalTimerIds; |
- HashMap<int, RefPtr<AsyncCallChain> > m_timerCallChains; |
- HashMap<int, RefPtr<AsyncCallChain> > m_animationFrameCallChains; |
- HashMap<Event*, RefPtr<AsyncCallChain> > m_eventCallChains; |
- HashMap<EventTarget*, RefPtr<AsyncCallChain> > m_xhrCallChains; |
- HashMap<MutationObserver*, RefPtr<AsyncCallChain> > m_mutationObserverCallChains; |
- HashMap<ExecutionContextTask*, RefPtr<AsyncCallChain> > m_executionContextTaskCallChains; |
- HashMap<String, RefPtr<AsyncCallChain> > m_v8AsyncTaskCallChains; |
- HashMap<int, RefPtr<AsyncCallChain> > m_asyncOperationCallChains; |
+ WillBeHeapHashMap<int, RefPtrWillBeMember<AsyncCallChain> > m_timerCallChains; |
+ WillBeHeapHashMap<int, RefPtrWillBeMember<AsyncCallChain> > m_animationFrameCallChains; |
+ WillBeHeapHashMap<RawPtrWillBeMember<Event>, RefPtrWillBeMember<AsyncCallChain> > m_eventCallChains; |
+ WillBeHeapHashMap<RawPtrWillBeMember<EventTarget>, RefPtrWillBeMember<AsyncCallChain> > m_xhrCallChains; |
+ WillBeHeapHashMap<RawPtrWillBeMember<MutationObserver>, RefPtrWillBeMember<AsyncCallChain> > m_mutationObserverCallChains; |
+ WillBeHeapHashMap<ExecutionContextTask*, RefPtrWillBeMember<AsyncCallChain> > m_executionContextTaskCallChains; |
+ WillBeHeapHashMap<String, RefPtrWillBeMember<AsyncCallChain> > m_v8AsyncTaskCallChains; |
+ WillBeHeapHashMap<int, RefPtrWillBeMember<AsyncCallChain> > m_asyncOperationCallChains; |
}; |
static XMLHttpRequest* toXmlHttpRequest(EventTarget* eventTarget) |
@@ -109,6 +121,11 @@ static XMLHttpRequest* toXmlHttpRequest(EventTarget* eventTarget) |
return 0; |
} |
+void AsyncCallStackTracker::AsyncCallChain::trace(Visitor* visitor) |
+{ |
+ visitor->trace(m_callStacks); |
+} |
+ |
AsyncCallStackTracker::AsyncCallStack::AsyncCallStack(const String& description, const ScriptValue& callFrames) |
: m_description(description) |
, m_callFrames(callFrames) |
@@ -411,19 +428,19 @@ void AsyncCallStackTracker::didFireAsyncCall() |
clearCurrentAsyncCallChain(); |
} |
-PassRefPtr<AsyncCallStackTracker::AsyncCallChain> AsyncCallStackTracker::createAsyncCallChain(const String& description, const ScriptValue& callFrames) |
+PassRefPtrWillBeRawPtr<AsyncCallStackTracker::AsyncCallChain> AsyncCallStackTracker::createAsyncCallChain(const String& description, const ScriptValue& callFrames) |
{ |
if (callFrames.isEmpty()) { |
ASSERT(m_currentAsyncCallChain); |
return m_currentAsyncCallChain; // Propogate async call stack chain. |
} |
- RefPtr<AsyncCallChain> chain = adoptRef(m_currentAsyncCallChain ? new AsyncCallStackTracker::AsyncCallChain(*m_currentAsyncCallChain) : new AsyncCallStackTracker::AsyncCallChain()); |
+ RefPtrWillBeRawPtr<AsyncCallChain> chain = adoptRefWillBeNoop(m_currentAsyncCallChain ? new AsyncCallStackTracker::AsyncCallChain(*m_currentAsyncCallChain) : new AsyncCallStackTracker::AsyncCallChain()); |
ensureMaxAsyncCallChainDepth(chain.get(), m_maxAsyncCallStackDepth - 1); |
- chain->m_callStacks.prepend(adoptRef(new AsyncCallStackTracker::AsyncCallStack(description, callFrames))); |
+ chain->m_callStacks.prepend(adoptRefWillBeNoop(new AsyncCallStackTracker::AsyncCallStack(description, callFrames))); |
return chain.release(); |
} |
-void AsyncCallStackTracker::setCurrentAsyncCallChain(ExecutionContext* context, PassRefPtr<AsyncCallChain> chain) |
+void AsyncCallStackTracker::setCurrentAsyncCallChain(ExecutionContext* context, PassRefPtrWillBeRawPtr<AsyncCallChain> chain) |
{ |
if (chain && !V8RecursionScope::recursionLevel(toIsolate(context))) { |
// Current AsyncCallChain corresponds to the bottommost JS call frame. |
@@ -458,10 +475,8 @@ bool AsyncCallStackTracker::validateCallFrames(const ScriptValue& callFrames) |
AsyncCallStackTracker::ExecutionContextData* AsyncCallStackTracker::createContextDataIfNeeded(ExecutionContext* context) |
{ |
ExecutionContextData* data = m_executionContextDataMap.get(context); |
- if (!data) { |
- data = new AsyncCallStackTracker::ExecutionContextData(this, context); |
- m_executionContextDataMap.set(context, data); |
- } |
+ if (!data) |
+ data = m_executionContextDataMap.set(context, adoptPtrWillBeNoop(new AsyncCallStackTracker::ExecutionContextData(this, context))).storedValue->value.get(); |
haraken
2014/08/12 08:38:17
Break up this line. It looks a bit too complex.
keishi
2014/08/12 08:50:56
Done.
|
return data; |
} |
@@ -469,10 +484,13 @@ void AsyncCallStackTracker::clear() |
{ |
m_currentAsyncCallChain.clear(); |
m_nestedAsyncCallCount = 0; |
- ExecutionContextDataMap copy; |
- m_executionContextDataMap.swap(copy); |
- for (ExecutionContextDataMap::const_iterator it = copy.begin(); it != copy.end(); ++it) |
- delete it->value; |
+ m_executionContextDataMap.clear(); |
+} |
+ |
+void AsyncCallStackTracker::trace(Visitor* visitor) |
+{ |
+ visitor->trace(m_currentAsyncCallChain); |
+ visitor->trace(m_executionContextDataMap); |
} |
} // namespace blink |