Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / modules / battery / BatteryManager.cpp
index a100fe5..98091ee 100644 (file)
@@ -22,7 +22,9 @@ BatteryManager* BatteryManager::create(ExecutionContext* context)
 
 BatteryManager::~BatteryManager()
 {
+#if !ENABLE(OILPAN)
     stopUpdating();
+#endif
 }
 
 BatteryManager::BatteryManager(ExecutionContext* context)
@@ -41,8 +43,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);
     } else if (m_state == NotStarted) {
         m_state = Pending;
@@ -89,6 +94,7 @@ void BatteryManager::didUpdateData()
     }
 
     Document* document = toDocument(executionContext());
+    ASSERT(document);
     if (document->activeDOMObjectsAreSuspended() || document->activeDOMObjectsAreStopped())
         return;
 
@@ -148,6 +154,7 @@ bool BatteryManager::hasPendingActivity() const
 void BatteryManager::trace(Visitor* visitor)
 {
     visitor->trace(m_batteryStatus);
+    PlatformEventController::trace(visitor);
     EventTargetWithInlineData::trace(visitor);
 }