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

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

Issue 329723005: Battery Status API: blink promise implementation and layout tests. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: fix fast/dom/Window/property-access-on-cached* tests. Created 6 years, 6 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
Index: Source/modules/battery/NavigatorBattery.cpp
diff --git a/Source/modules/battery/NavigatorBattery.cpp b/Source/modules/battery/NavigatorBattery.cpp
index caaff759521c652ec60c0a3cd7d7c2bc01d6a656..37e4bc40820b9a688911b96b90f9e40c1ec8265c 100644
--- a/Source/modules/battery/NavigatorBattery.cpp
+++ b/Source/modules/battery/NavigatorBattery.cpp
@@ -18,16 +18,20 @@ NavigatorBattery::~NavigatorBattery()
{
}
-BatteryManager* NavigatorBattery::battery(Navigator& navigator)
+ScriptPromise NavigatorBattery::getBattery(ScriptState* scriptState, Navigator& navigator)
{
- return NavigatorBattery::from(navigator).batteryManager(navigator);
+ return NavigatorBattery::from(navigator).getBattery(scriptState);
}
-BatteryManager* NavigatorBattery::batteryManager(Navigator& navigator)
+ScriptPromise NavigatorBattery::getBattery(ScriptState* scriptState)
{
- if (!m_batteryManager && navigator.frame())
- m_batteryManager = BatteryManager::create(navigator.frame()->document());
- return m_batteryManager.get();
+ if (!m_batteryManager) {
+ m_batteryManager = BatteryManager::create(scriptState->executionContext());
+ // Create a wrapper to expose this object to the V8 GC so that hasPendingActivity takes effect.
+ toV8NoInline(m_batteryManager.get(), scriptState->context()->Global(), scriptState->isolate());
abarth-chromium 2014/06/11 19:44:34 Why is this necessary? We're already holding m_ba
timvolodine 2014/06/12 16:38:46 Done.
+ }
+
+ return m_batteryManager->startRequest(scriptState);
}
const char* NavigatorBattery::supplementName()

Powered by Google App Engine
This is Rietveld 408576698