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

Side by Side Diff: Source/modules/wake_lock/NavigatorWakeLock.cpp

Issue 399313003: Initial implementation of API WakeLock. Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Implementation of WakeLock API on JavaScript side. Created 6 years, 4 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 unified diff | Download patch
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "config.h"
6 #include "modules/wake_lock/NavigatorWakeLock.h"
7
8 #include "core/frame/Navigator.h"
9 #include "modules/wake_lock/WakeLock.h"
10
11 namespace blink {
12
13 NavigatorWakeLock::NavigatorWakeLock()
14 {
15 }
16
17 NavigatorWakeLock::~NavigatorWakeLock()
18 {
19 }
20
21 const char* NavigatorWakeLock::supplementName()
22 {
23 return "NavigatorWakeLock";
24 }
25
26 NavigatorWakeLock& NavigatorWakeLock::from(Navigator& navigator)
27 {
28 NavigatorWakeLock* supplement = static_cast<NavigatorWakeLock*>(WillBeHeapSu pplement<Navigator>::from(navigator, supplementName()));
29 if (!supplement) {
30 supplement = new NavigatorWakeLock();
31 provideTo(navigator, supplementName(), adoptPtrWillBeNoop(supplement));
32 }
33 return *supplement;
34 }
35
36 WakeLock* NavigatorWakeLock::wakeLock(ScriptState* state, Navigator& navigator)
37 {
38 return NavigatorWakeLock::from(navigator).wakeLock(state);
39 }
40
41 WakeLock* NavigatorWakeLock::wakeLock(ScriptState* state)
42 {
43 if (!m_wakeLock && state)
44 m_wakeLock = WakeLock::create(state->executionContext());
45 return m_wakeLock.get();
46 }
47
48 void NavigatorWakeLock::trace(Visitor* visitor)
49 {
50 visitor->trace(m_wakeLock);
51 WillBeHeapSupplement<Navigator>::trace(visitor);
52 }
53
54 } // namespace blink
OLDNEW
« no previous file with comments | « Source/modules/wake_lock/NavigatorWakeLock.h ('k') | Source/modules/wake_lock/NavigatorWakeLock.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698