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

Unified Diff: Source/modules/battery/BatteryManager.cpp

Issue 618673002: Oilpan: reliably track listening PlatformEventControllers. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Don't start updating in a stopped context Created 6 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/frame/PlatformEventDispatcher.cpp ('k') | Source/modules/gamepad/NavigatorGamepad.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/modules/battery/BatteryManager.cpp
diff --git a/Source/modules/battery/BatteryManager.cpp b/Source/modules/battery/BatteryManager.cpp
index 57cfa22ae62565d02832a0bc39f8f6625ef52e19..5a3383d4909c24b517305e217299337e353fdd70 100644
--- a/Source/modules/battery/BatteryManager.cpp
+++ b/Source/modules/battery/BatteryManager.cpp
@@ -41,8 +41,11 @@ ScriptPromise BatteryManager::startRequest(ScriptState* scriptState)
m_resolver = ScriptPromiseResolver::create(scriptState);
ScriptPromise promise = m_resolver->promise();
- if (m_state == Resolved) {
+ ASSERT(executionContext());
+ // If the context is in a stopped state already, do not start updating.
+ if (m_state == Resolved || executionContext()->activeDOMObjectsAreStopped()) {
// FIXME: Consider returning the same promise in this case. See crbug.com/385025.
+ m_state = Resolved;
m_resolver->resolve(this);
m_resolver = nullptr;
} else if (m_state == NotStarted) {
@@ -91,6 +94,7 @@ void BatteryManager::didUpdateData()
}
Document* document = toDocument(executionContext());
+ ASSERT(document);
if (document->activeDOMObjectsAreSuspended() || document->activeDOMObjectsAreStopped())
return;
@@ -150,6 +154,7 @@ bool BatteryManager::hasPendingActivity() const
void BatteryManager::trace(Visitor* visitor)
{
visitor->trace(m_batteryStatus);
+ PlatformEventController::trace(visitor);
EventTargetWithInlineData::trace(visitor);
}
« no previous file with comments | « Source/core/frame/PlatformEventDispatcher.cpp ('k') | Source/modules/gamepad/NavigatorGamepad.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698