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

Side by Side Diff: third_party/WebKit/Source/modules/battery/BatteryManager.cpp

Issue 2571193002: Signal no pending activity in destructed contexts. (Closed)
Patch Set: Created 4 years 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 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "modules/battery/BatteryManager.h" 5 #include "modules/battery/BatteryManager.h"
6 6
7 #include "core/dom/DOMException.h" 7 #include "core/dom/DOMException.h"
8 #include "core/dom/Document.h" 8 #include "core/dom/Document.h"
9 #include "core/events/Event.h" 9 #include "core/events/Event.h"
10 #include "modules/battery/BatteryDispatcher.h" 10 #include "modules/battery/BatteryDispatcher.h"
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 stopUpdating(); 102 stopUpdating();
103 } 103 }
104 104
105 void BatteryManager::resume() { 105 void BatteryManager::resume() {
106 m_hasEventListener = true; 106 m_hasEventListener = true;
107 startUpdating(); 107 startUpdating();
108 } 108 }
109 109
110 void BatteryManager::contextDestroyed() { 110 void BatteryManager::contextDestroyed() {
111 m_hasEventListener = false; 111 m_hasEventListener = false;
112 m_batteryProperty.clear(); 112 m_batteryProperty = nullptr;
113 stopUpdating(); 113 stopUpdating();
114 } 114 }
115 115
116 bool BatteryManager::hasPendingActivity() const { 116 bool BatteryManager::hasPendingActivity() const {
117 // Prevent V8 from garbage collecting the wrapper object if there are 117 // Prevent V8 from garbage collecting the wrapper object if there are
118 // event listeners attached to it. 118 // event listeners attached to it.
119 return hasEventListeners(); 119 return getExecutionContext() && hasEventListeners();
120 } 120 }
121 121
122 DEFINE_TRACE(BatteryManager) { 122 DEFINE_TRACE(BatteryManager) {
123 visitor->trace(m_batteryProperty); 123 visitor->trace(m_batteryProperty);
124 PlatformEventController::trace(visitor); 124 PlatformEventController::trace(visitor);
125 EventTargetWithInlineData::trace(visitor); 125 EventTargetWithInlineData::trace(visitor);
126 SuspendableObject::trace(visitor); 126 SuspendableObject::trace(visitor);
127 } 127 }
128 128
129 } // namespace blink 129 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/css/MediaQueryList.cpp ('k') | third_party/WebKit/Source/modules/imagecapture/ImageCapture.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698