OLD | NEW |
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 "config.h" | 5 #include "config.h" |
6 #include "modules/battery/BatteryManager.h" | 6 #include "modules/battery/BatteryManager.h" |
7 | 7 |
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 25 matching lines...) Loading... |
36 } | 36 } |
37 | 37 |
38 ScriptPromise BatteryManager::startRequest(ScriptState* scriptState) | 38 ScriptPromise BatteryManager::startRequest(ScriptState* scriptState) |
39 { | 39 { |
40 if (m_state == Pending) | 40 if (m_state == Pending) |
41 return m_resolver->promise(); | 41 return m_resolver->promise(); |
42 | 42 |
43 m_resolver = ScriptPromiseResolver::create(scriptState); | 43 m_resolver = ScriptPromiseResolver::create(scriptState); |
44 ScriptPromise promise = m_resolver->promise(); | 44 ScriptPromise promise = m_resolver->promise(); |
45 | 45 |
46 ASSERT(executionContext()); | |
47 // If the context is in a stopped state already, do not start updating. | 46 // If the context is in a stopped state already, do not start updating. |
48 if (m_state == Resolved || executionContext()->activeDOMObjectsAreStopped())
{ | 47 if (m_state == Resolved || !executionContext() || executionContext()->active
DOMObjectsAreStopped()) { |
49 // FIXME: Consider returning the same promise in this case. See crbug.co
m/385025. | 48 // FIXME: Consider returning the same promise in this case. See crbug.co
m/385025. |
50 m_state = Resolved; | 49 m_state = Resolved; |
51 m_resolver->resolve(this); | 50 m_resolver->resolve(this); |
52 } else if (m_state == NotStarted) { | 51 } else if (m_state == NotStarted) { |
53 m_state = Pending; | 52 m_state = Pending; |
54 m_hasEventListener = true; | 53 m_hasEventListener = true; |
55 startUpdating(); | 54 startUpdating(); |
56 } | 55 } |
57 | 56 |
58 return promise; | 57 return promise; |
(...skipping 95 matching lines...) Loading... |
154 DEFINE_TRACE(BatteryManager) | 153 DEFINE_TRACE(BatteryManager) |
155 { | 154 { |
156 visitor->trace(m_resolver); | 155 visitor->trace(m_resolver); |
157 visitor->trace(m_batteryStatus); | 156 visitor->trace(m_batteryStatus); |
158 PlatformEventController::trace(visitor); | 157 PlatformEventController::trace(visitor); |
159 RefCountedGarbageCollectedEventTargetWithInlineData<BatteryManager>::trace(v
isitor); | 158 RefCountedGarbageCollectedEventTargetWithInlineData<BatteryManager>::trace(v
isitor); |
160 ActiveDOMObject::trace(visitor); | 159 ActiveDOMObject::trace(visitor); |
161 } | 160 } |
162 | 161 |
163 } // namespace blink | 162 } // namespace blink |
OLD | NEW |