Chromium Code Reviews| Index: Source/modules/wake_lock/NavigatorWakeLock.cpp |
| diff --git a/Source/modules/wake_lock/NavigatorWakeLock.cpp b/Source/modules/wake_lock/NavigatorWakeLock.cpp |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..283546e33771ec340b680da66bda060180f6a422 |
| --- /dev/null |
| +++ b/Source/modules/wake_lock/NavigatorWakeLock.cpp |
| @@ -0,0 +1,58 @@ |
| +// Copyright 2014 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/NavigatorWakeLock.h" |
| + |
| +#include "core/dom/Document.h" |
| +#include "core/frame/LocalFrame.h" |
| +#include "core/frame/Navigator.h" |
| +#include "modules/wake_lock/WakeLock.h" |
| + |
| +namespace blink { |
| + |
| +NavigatorWakeLock::NavigatorWakeLock(LocalFrame* frame) |
| + : DOMWindowProperty(frame) |
|
mlamouri (slow - plz ping)
2014/08/18 12:15:52
I would keep this ctor as a default ctor (ie. no L
redchenko
2014/08/19 16:42:19
Done.
|
| +{ |
| +} |
| + |
| +NavigatorWakeLock::~NavigatorWakeLock() |
| +{ |
| +} |
| + |
| +const char* NavigatorWakeLock::supplementName() |
| +{ |
| + return "NavigatorWakeLock"; |
| +} |
| + |
| +NavigatorWakeLock& NavigatorWakeLock::from(Navigator& navigator) |
| +{ |
| + NavigatorWakeLock* supplement = static_cast<NavigatorWakeLock*>(WillBeHeapSupplement<Navigator>::from(navigator, supplementName())); |
| + if (!supplement) { |
| + supplement = new NavigatorWakeLock(navigator.frame()); |
| + provideTo(navigator, supplementName(), adoptPtrWillBeNoop(supplement)); |
| + } |
| + return *supplement; |
| +} |
| + |
| +WakeLock* NavigatorWakeLock::wakeLock(Navigator& navigator) |
| +{ |
| + return NavigatorWakeLock::from(navigator).wakeLock(); |
| +} |
| + |
| +WakeLock* NavigatorWakeLock::wakeLock() const |
| +{ |
| + if (!m_wakeLock && frame()) |
| + m_wakeLock = WakeLock::create(frame()->document()); |
|
mlamouri (slow - plz ping)
2014/08/18 12:15:52
It seems that what you really want here is not a f
redchenko
2014/08/19 16:42:19
Done.
|
| + return m_wakeLock.get(); |
| +} |
| + |
| +void NavigatorWakeLock::trace(Visitor* visitor) |
| +{ |
| + ASSERT(visitor); |
|
mlamouri (slow - plz ping)
2014/08/18 12:15:52
I don't think you need that.
redchenko
2014/08/19 16:42:19
Done.
|
| + visitor->trace(m_wakeLock); |
| + WillBeHeapSupplement<Navigator>::trace(visitor); |
| +} |
| + |
| +} // namespace WebCore |