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

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: same with scriptpromiseresolver 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..9b5fa65dd216d36fd9318c848ee038e462253b35 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::scheduleAsyncTask(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::cancelAsyncTask(m_callback->getExecutionContext(), record);
+}
+
void MutationObserver::deliver()
{
ASSERT(!shouldBeSuspended());
@@ -231,9 +236,15 @@ void MutationObserver::deliver()
MutationRecordVector records;
records.swap(m_records);
- InspectorInstrumentation::willDeliverMutationRecords(m_callback->getExecutionContext(), this);
+ if (InspectorInstrumentation::hasFrontends()) {
+ for (size_t i = 0; i < records.size(); ++i)
+ InspectorInstrumentation::asyncTaskStarted(m_callback->getExecutionContext(), records[i]);
dgozman 2016/04/06 02:31:08 Let's make a single call.
+ }
m_callback->call(records, this);
- InspectorInstrumentation::didDeliverMutationRecords(m_callback->getExecutionContext());
+ if (InspectorInstrumentation::hasFrontends()) {
+ for (size_t i = records.size(); i > 0; --i)
+ InspectorInstrumentation::asyncTaskFinished(m_callback->getExecutionContext(), records[i - 1]);
+ }
}
void MutationObserver::resumeSuspendedObservers()

Powered by Google App Engine
This is Rietveld 408576698