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

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

Issue 916033002: Oilpan: Move LifecycleNotifier's hierarchy to Oilpan's heap Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 10 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/ContextLifecycleNotifier.h ('k') | Source/core/dom/DocumentLifecycleNotifier.h » ('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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 RELEASE_ASSERT(m_iterating != IteratingOverActiveDOMObjects); 46 RELEASE_ASSERT(m_iterating != IteratingOverActiveDOMObjects);
47 m_activeDOMObjects.add(static_cast<ActiveDOMObject*>(observer)); 47 m_activeDOMObjects.add(static_cast<ActiveDOMObject*>(observer));
48 } 48 }
49 } 49 }
50 50
51 void ContextLifecycleNotifier::removeObserver(ContextLifecycleNotifier::Observer * observer) 51 void ContextLifecycleNotifier::removeObserver(ContextLifecycleNotifier::Observer * observer)
52 { 52 {
53 LifecycleNotifier<ExecutionContext>::removeObserver(observer); 53 LifecycleNotifier<ExecutionContext>::removeObserver(observer);
54 54
55 if (observer->observerType() == Observer::ActiveDOMObjectType) { 55 if (observer->observerType() == Observer::ActiveDOMObjectType) {
56 #if ENABLE(OILPAN)
57 RELEASE_ASSERT(m_iterating != IteratingOverActiveDOMObjects);
58 #endif
56 m_activeDOMObjects.remove(static_cast<ActiveDOMObject*>(observer)); 59 m_activeDOMObjects.remove(static_cast<ActiveDOMObject*>(observer));
57 } 60 }
58 } 61 }
59 62
60 void ContextLifecycleNotifier::notifyResumingActiveDOMObjects() 63 void ContextLifecycleNotifier::notifyResumingActiveDOMObjects()
61 { 64 {
62 TemporaryChange<IterationType> scope(this->m_iterating, IteratingOverActiveD OMObjects); 65 TemporaryChange<IterationType> scope(this->m_iterating, IteratingOverActiveD OMObjects);
66 #if ENABLE(OILPAN)
67 for (ActiveDOMObject* obj : m_activeDOMObjects) {
68 ASSERT(obj->executionContext() == context());
69 ASSERT(obj->suspendIfNeededCalled());
70 obj->resume();
71 }
72 #else
63 Vector<ActiveDOMObject*> snapshotOfActiveDOMObjects; 73 Vector<ActiveDOMObject*> snapshotOfActiveDOMObjects;
64 copyToVector(m_activeDOMObjects, snapshotOfActiveDOMObjects); 74 copyToVector(m_activeDOMObjects, snapshotOfActiveDOMObjects);
65 for (ActiveDOMObject* obj : snapshotOfActiveDOMObjects) { 75 for (ActiveDOMObject* obj : snapshotOfActiveDOMObjects) {
66 // FIXME: Oilpan: At the moment, it's possible that the ActiveDOMObject 76 // FIXME: Oilpan: At the moment, it's possible that the ActiveDOMObject
67 // is destructed during the iteration. Once we enable Oilpan by default 77 // is destructed during the iteration. Once we enable Oilpan by default
68 // for ActiveDOMObjects, we can remove the hack by making 78 // for ActiveDOMObjects, we can remove the hack by making
69 // m_activeDOMObjects a HeapHashSet<WeakMember<ActiveDOMObjects>>. 79 // m_activeDOMObjects a HeapHashSet<WeakMember<ActiveDOMObjects>>.
70 // (i.e., we can just iterate m_activeDOMObjects without taking 80 // (i.e., we can just iterate m_activeDOMObjects without taking
71 // a snapshot). 81 // a snapshot).
72 // For more details, see https://codereview.chromium.org/247253002/. 82 // For more details, see https://codereview.chromium.org/247253002/.
73 if (m_activeDOMObjects.contains(obj)) { 83 if (m_activeDOMObjects.contains(obj)) {
74 ASSERT(obj->executionContext() == context()); 84 ASSERT(obj->executionContext() == context());
75 ASSERT(obj->suspendIfNeededCalled()); 85 ASSERT(obj->suspendIfNeededCalled());
76 obj->resume(); 86 obj->resume();
77 } 87 }
78 } 88 }
89 #endif
79 } 90 }
80 91
81 void ContextLifecycleNotifier::notifySuspendingActiveDOMObjects() 92 void ContextLifecycleNotifier::notifySuspendingActiveDOMObjects()
82 { 93 {
83 TemporaryChange<IterationType> scope(this->m_iterating, IteratingOverActiveD OMObjects); 94 TemporaryChange<IterationType> scope(this->m_iterating, IteratingOverActiveD OMObjects);
95 #if ENABLE(OILPAN)
96 for (ActiveDOMObject* obj : m_activeDOMObjects) {
97 ASSERT(obj->executionContext() == context());
98 ASSERT(obj->suspendIfNeededCalled());
99 obj->suspend();
100 }
101 #else
84 Vector<ActiveDOMObject*> snapshotOfActiveDOMObjects; 102 Vector<ActiveDOMObject*> snapshotOfActiveDOMObjects;
85 copyToVector(m_activeDOMObjects, snapshotOfActiveDOMObjects); 103 copyToVector(m_activeDOMObjects, snapshotOfActiveDOMObjects);
86 for (ActiveDOMObject* obj : snapshotOfActiveDOMObjects) { 104 for (ActiveDOMObject* obj : snapshotOfActiveDOMObjects) {
87 // It's possible that the ActiveDOMObject is already destructed. 105 // It's possible that the ActiveDOMObject is already destructed.
88 // See a FIXME above. 106 // See a FIXME above.
89 if (m_activeDOMObjects.contains(obj)) { 107 if (m_activeDOMObjects.contains(obj)) {
90 ASSERT(obj->executionContext() == context()); 108 ASSERT(obj->executionContext() == context());
91 ASSERT(obj->suspendIfNeededCalled()); 109 ASSERT(obj->suspendIfNeededCalled());
92 obj->suspend(); 110 obj->suspend();
93 } 111 }
94 } 112 }
113 #endif
95 } 114 }
96 115
97 void ContextLifecycleNotifier::notifyStoppingActiveDOMObjects() 116 void ContextLifecycleNotifier::notifyStoppingActiveDOMObjects()
98 { 117 {
99 TemporaryChange<IterationType> scope(this->m_iterating, IteratingOverActiveD OMObjects); 118 TemporaryChange<IterationType> scope(this->m_iterating, IteratingOverActiveD OMObjects);
119 #if ENABLE(OILPAN)
120 for (ActiveDOMObject* obj : m_activeDOMObjects) {
121 ASSERT(obj->executionContext() == context());
122 ASSERT(obj->suspendIfNeededCalled());
123 obj->stop();
124 }
125 #else
100 Vector<ActiveDOMObject*> snapshotOfActiveDOMObjects; 126 Vector<ActiveDOMObject*> snapshotOfActiveDOMObjects;
101 copyToVector(m_activeDOMObjects, snapshotOfActiveDOMObjects); 127 copyToVector(m_activeDOMObjects, snapshotOfActiveDOMObjects);
102 for (ActiveDOMObject* obj : snapshotOfActiveDOMObjects) { 128 for (ActiveDOMObject* obj : snapshotOfActiveDOMObjects) {
103 // It's possible that the ActiveDOMObject is already destructed. 129 // It's possible that the ActiveDOMObject is already destructed.
104 // See a FIXME above. 130 // See a FIXME above.
105 if (m_activeDOMObjects.contains(obj)) { 131 if (m_activeDOMObjects.contains(obj)) {
106 ASSERT(obj->executionContext() == context()); 132 ASSERT(obj->executionContext() == context());
107 ASSERT(obj->suspendIfNeededCalled()); 133 ASSERT(obj->suspendIfNeededCalled());
108 obj->stop(); 134 obj->stop();
109 } 135 }
110 } 136 }
137 #endif
111 } 138 }
112 139
113 bool ContextLifecycleNotifier::hasPendingActivity() const 140 bool ContextLifecycleNotifier::hasPendingActivity() const
114 { 141 {
115 for (ActiveDOMObject* obj : m_activeDOMObjects) { 142 for (ActiveDOMObject* obj : m_activeDOMObjects) {
116 if (obj->hasPendingActivity()) 143 if (obj->hasPendingActivity())
117 return true; 144 return true;
118 } 145 }
119 return false; 146 return false;
120 } 147 }
121 148
149 void ContextLifecycleNotifier::trace(Visitor* visitor)
150 {
151 visitor->trace(m_activeDOMObjects);
152 LifecycleNotifier<ExecutionContext>::trace(visitor);
153 }
154
122 } // namespace blink 155 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/dom/ContextLifecycleNotifier.h ('k') | Source/core/dom/DocumentLifecycleNotifier.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698