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

Side by Side Diff: third_party/WebKit/Source/core/dom/MutationObserver.cpp

Issue 2727633006: DevTools: Rename InspectorInstrumentation:: namespace into probe:: (Closed)
Patch Set: Created 3 years, 9 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 211
212 static void activateObserver(MutationObserver* observer) { 212 static void activateObserver(MutationObserver* observer) {
213 ensureEnqueueMicrotask(); 213 ensureEnqueueMicrotask();
214 activeMutationObservers().insert(observer); 214 activeMutationObservers().insert(observer);
215 } 215 }
216 216
217 void MutationObserver::enqueueMutationRecord(MutationRecord* mutation) { 217 void MutationObserver::enqueueMutationRecord(MutationRecord* mutation) {
218 DCHECK(isMainThread()); 218 DCHECK(isMainThread());
219 m_records.push_back(mutation); 219 m_records.push_back(mutation);
220 activateObserver(this); 220 activateObserver(this);
221 InspectorInstrumentation::asyncTaskScheduled( 221 probe::asyncTaskScheduled(m_callback->getExecutionContext(), mutation->type(),
222 m_callback->getExecutionContext(), mutation->type(), mutation); 222 mutation);
223 } 223 }
224 224
225 void MutationObserver::setHasTransientRegistration() { 225 void MutationObserver::setHasTransientRegistration() {
226 DCHECK(isMainThread()); 226 DCHECK(isMainThread());
227 activateObserver(this); 227 activateObserver(this);
228 } 228 }
229 229
230 HeapHashSet<Member<Node>> MutationObserver::getObservedNodes() const { 230 HeapHashSet<Member<Node>> MutationObserver::getObservedNodes() const {
231 HeapHashSet<Member<Node>> observedNodes; 231 HeapHashSet<Member<Node>> observedNodes;
232 for (const auto& registration : m_registrations) 232 for (const auto& registration : m_registrations)
233 registration->addRegistrationNodesToSet(observedNodes); 233 registration->addRegistrationNodesToSet(observedNodes);
234 return observedNodes; 234 return observedNodes;
235 } 235 }
236 236
237 bool MutationObserver::shouldBeSuspended() const { 237 bool MutationObserver::shouldBeSuspended() const {
238 return m_callback->getExecutionContext() && 238 return m_callback->getExecutionContext() &&
239 m_callback->getExecutionContext()->isContextSuspended(); 239 m_callback->getExecutionContext()->isContextSuspended();
240 } 240 }
241 241
242 void MutationObserver::cancelInspectorAsyncTasks() { 242 void MutationObserver::cancelInspectorAsyncTasks() {
243 for (auto& record : m_records) 243 for (auto& record : m_records)
244 InspectorInstrumentation::asyncTaskCanceled( 244 probe::asyncTaskCanceled(m_callback->getExecutionContext(), record);
245 m_callback->getExecutionContext(), record);
246 } 245 }
247 246
248 void MutationObserver::deliver() { 247 void MutationObserver::deliver() {
249 DCHECK(!shouldBeSuspended()); 248 DCHECK(!shouldBeSuspended());
250 249
251 // Calling clearTransientRegistrations() can modify m_registrations, so it's 250 // Calling clearTransientRegistrations() can modify m_registrations, so it's
252 // necessary to make a copy of the transient registrations before operating on 251 // necessary to make a copy of the transient registrations before operating on
253 // them. 252 // them.
254 HeapVector<Member<MutationObserverRegistration>, 1> transientRegistrations; 253 HeapVector<Member<MutationObserverRegistration>, 1> transientRegistrations;
255 for (auto& registration : m_registrations) { 254 for (auto& registration : m_registrations) {
256 if (registration->hasTransientRegistrations()) 255 if (registration->hasTransientRegistrations())
257 transientRegistrations.push_back(registration); 256 transientRegistrations.push_back(registration);
258 } 257 }
259 for (const auto& registration : transientRegistrations) 258 for (const auto& registration : transientRegistrations)
260 registration->clearTransientRegistrations(); 259 registration->clearTransientRegistrations();
261 260
262 if (m_records.isEmpty()) 261 if (m_records.isEmpty())
263 return; 262 return;
264 263
265 MutationRecordVector records; 264 MutationRecordVector records;
266 records.swap(m_records); 265 records.swap(m_records);
267 266
268 // Report the first (earliest) stack as the async cause. 267 // Report the first (earliest) stack as the async cause.
269 InspectorInstrumentation::AsyncTask asyncTask( 268 probe::AsyncTask asyncTask(m_callback->getExecutionContext(),
270 m_callback->getExecutionContext(), records.front()); 269 records.front());
271 m_callback->call(records, this); 270 m_callback->call(records, this);
272 } 271 }
273 272
274 void MutationObserver::resumeSuspendedObservers() { 273 void MutationObserver::resumeSuspendedObservers() {
275 DCHECK(isMainThread()); 274 DCHECK(isMainThread());
276 if (suspendedMutationObservers().isEmpty()) 275 if (suspendedMutationObservers().isEmpty())
277 return; 276 return;
278 277
279 MutationObserverVector suspended; 278 MutationObserverVector suspended;
280 copyToVector(suspendedMutationObservers(), suspended); 279 copyToVector(suspendedMutationObservers(), suspended);
(...skipping 30 matching lines...) Expand all
311 slot->dispatchSlotChangeEvent(); 310 slot->dispatchSlotChangeEvent();
312 } 311 }
313 312
314 DEFINE_TRACE(MutationObserver) { 313 DEFINE_TRACE(MutationObserver) {
315 visitor->trace(m_callback); 314 visitor->trace(m_callback);
316 visitor->trace(m_records); 315 visitor->trace(m_records);
317 visitor->trace(m_registrations); 316 visitor->trace(m_registrations);
318 } 317 }
319 318
320 } // namespace blink 319 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698