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

Side by Side Diff: Source/core/dom/ContextLifecycleNotifier.cpp

Issue 194923007: Explicit notification and removal of lifecycle observers. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Perform ThreadState detachment last Created 6 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) 2008 Apple Inc. All Rights Reserved. 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved.
3 * Copyright (C) 2013 Google Inc. All Rights Reserved. 3 * Copyright (C) 2013 Google Inc. All Rights Reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 { 57 {
58 LifecycleNotifier<ExecutionContext>::removeObserver(observer); 58 LifecycleNotifier<ExecutionContext>::removeObserver(observer);
59 59
60 RELEASE_ASSERT(m_iterating != IteratingOverContextObservers); 60 RELEASE_ASSERT(m_iterating != IteratingOverContextObservers);
61 if (observer->observerType() == Observer::ActiveDOMObjectType) { 61 if (observer->observerType() == Observer::ActiveDOMObjectType) {
62 RELEASE_ASSERT(m_iterating != IteratingOverActiveDOMObjects); 62 RELEASE_ASSERT(m_iterating != IteratingOverActiveDOMObjects);
63 m_activeDOMObjects.remove(static_cast<ActiveDOMObject*>(observer)); 63 m_activeDOMObjects.remove(static_cast<ActiveDOMObject*>(observer));
64 } 64 }
65 } 65 }
66 66
67 void ContextLifecycleNotifier::removeAndNotifyAllObservers()
68 {
69 LifecycleNotifier<ExecutionContext>::removeAndNotifyAllObservers();
70 m_activeDOMObjects.clear();
71 }
72
67 void ContextLifecycleNotifier::notifyResumingActiveDOMObjects() 73 void ContextLifecycleNotifier::notifyResumingActiveDOMObjects()
68 { 74 {
69 TemporaryChange<IterationType> scope(this->m_iterating, IteratingOverActiveD OMObjects); 75 TemporaryChange<IterationType> scope(this->m_iterating, IteratingOverActiveD OMObjects);
70 ActiveDOMObjectSet::iterator activeObjectsEnd = m_activeDOMObjects.end(); 76 ActiveDOMObjectSet::iterator activeObjectsEnd = m_activeDOMObjects.end();
71 for (ActiveDOMObjectSet::iterator iter = m_activeDOMObjects.begin(); iter != activeObjectsEnd; ++iter) { 77 for (ActiveDOMObjectSet::iterator iter = m_activeDOMObjects.begin(); iter != activeObjectsEnd; ++iter) {
72 ASSERT((*iter)->executionContext() == context()); 78 ASSERT((*iter)->executionContext() == context());
73 ASSERT((*iter)->suspendIfNeededCalled()); 79 ASSERT((*iter)->suspendIfNeededCalled());
74 (*iter)->resume(); 80 (*iter)->resume();
75 } 81 }
76 } 82 }
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 ActiveDOMObjectSet::const_iterator activeObjectsEnd = activeDOMObjects().end (); 119 ActiveDOMObjectSet::const_iterator activeObjectsEnd = activeDOMObjects().end ();
114 for (ActiveDOMObjectSet::const_iterator iter = activeDOMObjects().begin(); i ter != activeObjectsEnd; ++iter) { 120 for (ActiveDOMObjectSet::const_iterator iter = activeDOMObjects().begin(); i ter != activeObjectsEnd; ++iter) {
115 if ((*iter)->hasPendingActivity()) 121 if ((*iter)->hasPendingActivity())
116 return true; 122 return true;
117 } 123 }
118 124
119 return false; 125 return false;
120 } 126 }
121 127
122 } // namespace WebCore 128 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698