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

Unified Diff: Source/modules/wake_lock/WakeLockController.cpp

Issue 1084923002: Wake Lock API implementation (Blink part) (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Applied review comments Created 5 years, 7 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/wake_lock/WakeLockController.cpp
diff --git a/Source/modules/wake_lock/WakeLockController.cpp b/Source/modules/wake_lock/WakeLockController.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..2203e08d61ee414aacd7a6f8f27cdc73f29419ae
--- /dev/null
+++ b/Source/modules/wake_lock/WakeLockController.cpp
@@ -0,0 +1,48 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "config.h"
+#include "modules/wake_lock/WakeLockController.h"
+
+#include "public/platform/modules/wake_lock/WebWakeLockClient.h"
+
+namespace blink {
+
+WakeLockController::WakeLockController(LocalFrame& frame, WebWakeLockClient* client)
+ : m_client(client)
+{
+}
+
+// static
+PassOwnPtrWillBeRawPtr<WakeLockController> WakeLockController::create(LocalFrame& frame, WebWakeLockClient* client)
mlamouri (slow - plz ping) 2015/05/05 13:45:44 You only use this method in ::provideTo(). It seem
+{
+ return adoptPtrWillBeNoop(new WakeLockController(frame, client));
+}
+
+// static
+const char* WakeLockController::supplementName()
+{
+ return "WakeLockController";
+}
+
+// static
+WakeLockController* WakeLockController::from(LocalFrame* frame)
+{
+ return static_cast<WakeLockController*>(WillBeHeapSupplement<LocalFrame>::from(frame, supplementName()));
+}
+
+// static
+void WakeLockController::provideTo(LocalFrame& frame, WebWakeLockClient* client)
+{
+ WillBeHeapSupplement<LocalFrame>::provideTo(frame, WakeLockController::supplementName(), WakeLockController::create(frame, client));
mlamouri (slow - plz ping) 2015/05/05 13:45:44 Could you add an ASSERT() checking that RuntimeEna
+}
+
+void WakeLockController::requestKeepScreenAwake(bool keepScreenAwake)
+{
+ if (m_client) {
+ m_client->requestKeepScreenAwake(keepScreenAwake);
mlamouri (slow - plz ping) 2015/05/05 13:45:44 It seems that you will have problems when the fram
alogvinov 2015/05/06 09:12:34 Could you please elaborate? It seems that e.g. Geo
mlamouri (slow - plz ping) 2015/05/06 10:03:42 Geolocation.cpp will do early returns if there is
+ }
mlamouri (slow - plz ping) 2015/05/05 13:45:44 nit: no need for {}
+}
+
+} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698