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

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

Issue 674553002: Move parts of core/dom to C++11 (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Make Windows shut up when I just try following the style guide Created 6 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/dom/ContainerNode.cpp ('k') | Source/core/dom/DatasetDOMStringMap.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 if (observer->observerType() == Observer::ActiveDOMObjectType) { 61 if (observer->observerType() == Observer::ActiveDOMObjectType) {
62 m_activeDOMObjects.remove(static_cast<ActiveDOMObject*>(observer)); 62 m_activeDOMObjects.remove(static_cast<ActiveDOMObject*>(observer));
63 } 63 }
64 } 64 }
65 65
66 void ContextLifecycleNotifier::notifyResumingActiveDOMObjects() 66 void ContextLifecycleNotifier::notifyResumingActiveDOMObjects()
67 { 67 {
68 TemporaryChange<IterationType> scope(this->m_iterating, IteratingOverActiveD OMObjects); 68 TemporaryChange<IterationType> scope(this->m_iterating, IteratingOverActiveD OMObjects);
69 Vector<ActiveDOMObject*> snapshotOfActiveDOMObjects; 69 Vector<ActiveDOMObject*> snapshotOfActiveDOMObjects;
70 copyToVector(m_activeDOMObjects, snapshotOfActiveDOMObjects); 70 copyToVector(m_activeDOMObjects, snapshotOfActiveDOMObjects);
71 for (Vector<ActiveDOMObject*>::iterator iter = snapshotOfActiveDOMObjects.be gin(); iter != snapshotOfActiveDOMObjects.end(); iter++) { 71 for (ActiveDOMObject* obj : snapshotOfActiveDOMObjects) {
72 // FIXME: Oilpan: At the moment, it's possible that the ActiveDOMObject is destructed 72 // FIXME: Oilpan: At the moment, it's possible that the ActiveDOMObject is destructed
73 // during the iteration. Once we move ActiveDOMObject to the heap and 73 // during the iteration. Once we move ActiveDOMObject to the heap and
74 // make m_activeDOMObjects a HeapHashSet<WeakMember<ActiveDOMObject>>, 74 // make m_activeDOMObjects a HeapHashSet<WeakMember<ActiveDOMObject>>,
75 // it's no longer possible that ActiveDOMObject is destructed during the iteration, 75 // it's no longer possible that ActiveDOMObject is destructed during the iteration,
76 // so we can remove the hack (i.e., we can just iterate m_activeDOMObjec ts without 76 // so we can remove the hack (i.e., we can just iterate m_activeDOMObjec ts without
77 // taking a snapshot). For more details, see https://codereview.chromium .org/247253002/. 77 // taking a snapshot). For more details, see https://codereview.chromium .org/247253002/.
78 if (m_activeDOMObjects.contains(*iter)) { 78 if (m_activeDOMObjects.contains(obj)) {
79 ASSERT((*iter)->executionContext() == context()); 79 ASSERT(obj->executionContext() == context());
80 ASSERT((*iter)->suspendIfNeededCalled()); 80 ASSERT(obj->suspendIfNeededCalled());
81 (*iter)->resume(); 81 obj->resume();
82 } 82 }
83 } 83 }
84 } 84 }
85 85
86 void ContextLifecycleNotifier::notifySuspendingActiveDOMObjects() 86 void ContextLifecycleNotifier::notifySuspendingActiveDOMObjects()
87 { 87 {
88 TemporaryChange<IterationType> scope(this->m_iterating, IteratingOverActiveD OMObjects); 88 TemporaryChange<IterationType> scope(this->m_iterating, IteratingOverActiveD OMObjects);
89 Vector<ActiveDOMObject*> snapshotOfActiveDOMObjects; 89 Vector<ActiveDOMObject*> snapshotOfActiveDOMObjects;
90 copyToVector(m_activeDOMObjects, snapshotOfActiveDOMObjects); 90 copyToVector(m_activeDOMObjects, snapshotOfActiveDOMObjects);
91 for (Vector<ActiveDOMObject*>::iterator iter = snapshotOfActiveDOMObjects.be gin(); iter != snapshotOfActiveDOMObjects.end(); iter++) { 91 for (ActiveDOMObject* obj : snapshotOfActiveDOMObjects) {
92 // It's possible that the ActiveDOMObject is already destructed. 92 // It's possible that the ActiveDOMObject is already destructed.
93 // See a FIXME above. 93 // See a FIXME above.
94 if (m_activeDOMObjects.contains(*iter)) { 94 if (m_activeDOMObjects.contains(obj)) {
95 ASSERT((*iter)->executionContext() == context()); 95 ASSERT(obj->executionContext() == context());
96 ASSERT((*iter)->suspendIfNeededCalled()); 96 ASSERT(obj->suspendIfNeededCalled());
97 (*iter)->suspend(); 97 obj->suspend();
98 } 98 }
99 } 99 }
100 } 100 }
101 101
102 void ContextLifecycleNotifier::notifyStoppingActiveDOMObjects() 102 void ContextLifecycleNotifier::notifyStoppingActiveDOMObjects()
103 { 103 {
104 TemporaryChange<IterationType> scope(this->m_iterating, IteratingOverActiveD OMObjects); 104 TemporaryChange<IterationType> scope(this->m_iterating, IteratingOverActiveD OMObjects);
105 Vector<ActiveDOMObject*> snapshotOfActiveDOMObjects; 105 Vector<ActiveDOMObject*> snapshotOfActiveDOMObjects;
106 copyToVector(m_activeDOMObjects, snapshotOfActiveDOMObjects); 106 copyToVector(m_activeDOMObjects, snapshotOfActiveDOMObjects);
107 for (Vector<ActiveDOMObject*>::iterator iter = snapshotOfActiveDOMObjects.be gin(); iter != snapshotOfActiveDOMObjects.end(); iter++) { 107 for (ActiveDOMObject* obj : snapshotOfActiveDOMObjects) {
108 // It's possible that the ActiveDOMObject is already destructed. 108 // It's possible that the ActiveDOMObject is already destructed.
109 // See a FIXME above. 109 // See a FIXME above.
110 if (m_activeDOMObjects.contains(*iter)) { 110 if (m_activeDOMObjects.contains(obj)) {
111 ASSERT((*iter)->executionContext() == context()); 111 ASSERT(obj->executionContext() == context());
112 ASSERT((*iter)->suspendIfNeededCalled()); 112 ASSERT(obj->suspendIfNeededCalled());
113 (*iter)->stop(); 113 obj->stop();
114 } 114 }
115 } 115 }
116 } 116 }
117 117
118 bool ContextLifecycleNotifier::hasPendingActivity() const 118 bool ContextLifecycleNotifier::hasPendingActivity() const
119 { 119 {
120 for (ActiveDOMObjectSet::const_iterator iter = m_activeDOMObjects.begin(); i ter != m_activeDOMObjects.end(); ++iter) { 120 for (ActiveDOMObject* obj : m_activeDOMObjects) {
121 if ((*iter)->hasPendingActivity()) 121 if (obj->hasPendingActivity())
122 return true; 122 return true;
123 } 123 }
124 return false; 124 return false;
125 } 125 }
126 126
127 } // namespace blink 127 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/dom/ContainerNode.cpp ('k') | Source/core/dom/DatasetDOMStringMap.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698