Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1220)

Unified Diff: Source/core/inspector/AsyncCallTracker.cpp

Issue 1198863006: First version of PerformanceObserver (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Code review comments. Name changes and moving statics to PerformanceBase. Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/core/inspector/AsyncCallTracker.cpp
diff --git a/Source/core/inspector/AsyncCallTracker.cpp b/Source/core/inspector/AsyncCallTracker.cpp
index bc3395a0c203236f1d81525da561304a13610599..3f80bc5caab02a1ee181507ab174d1e95e7ab34e 100644
--- a/Source/core/inspector/AsyncCallTracker.cpp
+++ b/Source/core/inspector/AsyncCallTracker.cpp
@@ -38,6 +38,7 @@
#include "core/events/EventTarget.h"
#include "core/inspector/AsyncOperationMap.h"
#include "core/inspector/InspectorDebuggerAgent.h"
+#include "core/timing/PerformanceObserver.h"
#include "core/xmlhttprequest/XMLHttpRequest.h"
#include "core/xmlhttprequest/XMLHttpRequestUpload.h"
#include "wtf/text/StringBuilder.h"
@@ -50,6 +51,7 @@ static const char setIntervalName[] = "setInterval";
static const char requestAnimationFrameName[] = "requestAnimationFrame";
static const char xhrSendName[] = "XMLHttpRequest.send";
static const char enqueueMutationRecordName[] = "Mutation";
+static const char enqueuePerformanceObservationsName[] = "PerformanceObservation";
}
@@ -67,6 +69,7 @@ public:
, m_eventCallChains(tracker->m_debuggerAgent)
, m_xhrCallChains(tracker->m_debuggerAgent)
, m_mutationObserverCallChains(tracker->m_debuggerAgent)
+ , m_performanceObserverCallChains(tracker->m_debuggerAgent)
, m_executionContextTaskCallChains(tracker->m_debuggerAgent)
, m_asyncOperations(tracker->m_debuggerAgent)
{
@@ -99,6 +102,7 @@ public:
visitor->trace(m_executionContextTaskCallChains);
visitor->trace(m_asyncOperations);
#endif
+ visitor->trace(m_performanceObserverCallChains);
ContextLifecycleObserver::trace(visitor);
}
@@ -109,6 +113,7 @@ public:
AsyncOperationMap<RawPtrWillBeMember<Event> > m_eventCallChains;
AsyncOperationMap<RawPtrWillBeMember<EventTarget> > m_xhrCallChains;
AsyncOperationMap<RawPtrWillBeMember<MutationObserver> > m_mutationObserverCallChains;
+ AsyncOperationMap<Member<PerformanceObserver>, HeapHashMap<Member<PerformanceObserver>, int>> m_performanceObserverCallChains;
AsyncOperationMap<ExecutionContextTask*> m_executionContextTaskCallChains;
AsyncOperationMap<int> m_asyncOperations;
@@ -120,6 +125,7 @@ private:
m_eventCallChains.dispose();
m_xhrCallChains.dispose();
m_mutationObserverCallChains.dispose();
+ m_performanceObserverCallChains.dispose();
m_executionContextTaskCallChains.dispose();
m_asyncOperations.dispose();
}
@@ -328,6 +334,37 @@ void AsyncCallTracker::willDeliverMutationRecords(ExecutionContext* context, Mut
}
}
+void AsyncCallTracker::didEnqueuePerformanceObserverEntries(ExecutionContext* context, PerformanceObserver* observer)
adamk 2015/07/24 21:26:30 Seems sad to have to duplicate all these calls. Wo
+{
+ ASSERT(context);
+ ASSERT(m_debuggerAgent->trackingAsyncCalls());
+ ExecutionContextData* data = createContextDataIfNeeded(context);
+ if (data->m_performanceObserverCallChains.contains(observer))
+ return;
+ int operationId = m_debuggerAgent->traceAsyncOperationStarting(enqueuePerformanceObservationsName);
+ data->m_performanceObserverCallChains.set(observer, operationId);
+}
+
+void AsyncCallTracker::didClearAllPerformanceObservations(ExecutionContext* context, PerformanceObserver* observer)
+{
+ ASSERT(context);
+ ASSERT(m_debuggerAgent->trackingAsyncCalls());
+ if (ExecutionContextData* data = m_executionContextDataMap.get(context))
+ data->m_performanceObserverCallChains.remove(observer);
+}
+
+void AsyncCallTracker::willDeliverPerformanceObservations(ExecutionContext* context, PerformanceObserver* observer)
+{
+ ASSERT(context);
+ ASSERT(m_debuggerAgent->trackingAsyncCalls());
+ if (ExecutionContextData* data = m_executionContextDataMap.get(context)) {
+ willFireAsyncCall(data->m_performanceObserverCallChains.get(observer));
+ data->m_performanceObserverCallChains.remove(observer);
+ } else {
+ willFireAsyncCall(InspectorDebuggerAgent::unknownAsyncOperationId);
+ }
+}
+
void AsyncCallTracker::didPostExecutionContextTask(ExecutionContext* context, ExecutionContextTask* task)
{
ASSERT(context);

Powered by Google App Engine
This is Rietveld 408576698