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

Unified Diff: third_party/WebKit/Source/core/dom/MutationObserver.cpp

Issue 1857713004: DevTools: simplify the async instrumentation harness. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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: third_party/WebKit/Source/core/dom/MutationObserver.cpp
diff --git a/third_party/WebKit/Source/core/dom/MutationObserver.cpp b/third_party/WebKit/Source/core/dom/MutationObserver.cpp
index 7b233e00d06c7b915d2d787c963c2587ce647217..66d217ca0ed39e821879d52b002b2682b51e44ce 100644
--- a/third_party/WebKit/Source/core/dom/MutationObserver.cpp
+++ b/third_party/WebKit/Source/core/dom/MutationObserver.cpp
@@ -69,8 +69,7 @@ MutationObserver::~MutationObserver()
#if !ENABLE(OILPAN)
ASSERT(m_registrations.isEmpty());
#endif
- if (!m_records.isEmpty())
- InspectorInstrumentation::didClearAllMutationRecords(m_callback->getExecutionContext(), this);
+ cancelInspectorAsyncTasks();
}
void MutationObserver::observe(Node* node, const MutationObserverInit& observerInit, ExceptionState& exceptionState)
@@ -133,15 +132,15 @@ void MutationObserver::observe(Node* node, const MutationObserverInit& observerI
MutationRecordVector MutationObserver::takeRecords()
{
MutationRecordVector records;
+ cancelInspectorAsyncTasks();
records.swap(m_records);
- InspectorInstrumentation::didClearAllMutationRecords(m_callback->getExecutionContext(), this);
return records;
}
void MutationObserver::disconnect()
{
+ cancelInspectorAsyncTasks();
m_records.clear();
- InspectorInstrumentation::didClearAllMutationRecords(m_callback->getExecutionContext(), this);
MutationObserverRegistrationSet registrations(m_registrations);
for (auto& registration : registrations) {
// The registration may be already unregistered while iteration.
@@ -189,7 +188,7 @@ void MutationObserver::enqueueMutationRecord(RawPtr<MutationRecord> mutation)
ASSERT(isMainThread());
m_records.append(mutation);
activateObserver(this);
- InspectorInstrumentation::didEnqueueMutationRecord(m_callback->getExecutionContext(), this);
+ InspectorInstrumentation::asyncTaskScheduled(m_callback->getExecutionContext(), mutation->type(), mutation);
}
void MutationObserver::setHasTransientRegistration()
@@ -211,6 +210,12 @@ bool MutationObserver::shouldBeSuspended() const
return m_callback->getExecutionContext() && m_callback->getExecutionContext()->activeDOMObjectsAreSuspended();
}
+void MutationObserver::cancelInspectorAsyncTasks()
+{
+ for (auto& record : m_records)
+ InspectorInstrumentation::asyncTaskCanceled(m_callback->getExecutionContext(), record);
+}
+
void MutationObserver::deliver()
{
ASSERT(!shouldBeSuspended());
@@ -231,9 +236,9 @@ void MutationObserver::deliver()
MutationRecordVector records;
records.swap(m_records);
- InspectorInstrumentation::willDeliverMutationRecords(m_callback->getExecutionContext(), this);
+ // Report the first (earliest) stack as the async cause.
+ InspectorInstrumentation::AsyncTask asyncTask(m_callback->getExecutionContext(), records.first());
m_callback->call(records, this);
- InspectorInstrumentation::didDeliverMutationRecords(m_callback->getExecutionContext());
}
void MutationObserver::resumeSuspendedObservers()

Powered by Google App Engine
This is Rietveld 408576698