Chromium Code Reviews| OLD | NEW |
|---|---|
| (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/dom/Document.h" | |
| 9 #include "core/frame/LocalFrame.h" | |
| 10 #include "core/frame/Navigator.h" | |
| 11 #include "modules/wake_lock/WakeLock.h" | |
| 12 | |
| 13 namespace blink { | |
| 14 | |
| 15 NavigatorWakeLock::NavigatorWakeLock(LocalFrame* frame) | |
| 16 : 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.
| |
| 17 { | |
| 18 } | |
| 19 | |
| 20 NavigatorWakeLock::~NavigatorWakeLock() | |
| 21 { | |
| 22 } | |
| 23 | |
| 24 const char* NavigatorWakeLock::supplementName() | |
| 25 { | |
| 26 return "NavigatorWakeLock"; | |
| 27 } | |
| 28 | |
| 29 NavigatorWakeLock& NavigatorWakeLock::from(Navigator& navigator) | |
| 30 { | |
| 31 NavigatorWakeLock* supplement = static_cast<NavigatorWakeLock*>(WillBeHeapSu pplement<Navigator>::from(navigator, supplementName())); | |
| 32 if (!supplement) { | |
| 33 supplement = new NavigatorWakeLock(navigator.frame()); | |
| 34 provideTo(navigator, supplementName(), adoptPtrWillBeNoop(supplement)); | |
| 35 } | |
| 36 return *supplement; | |
| 37 } | |
| 38 | |
| 39 WakeLock* NavigatorWakeLock::wakeLock(Navigator& navigator) | |
| 40 { | |
| 41 return NavigatorWakeLock::from(navigator).wakeLock(); | |
| 42 } | |
| 43 | |
| 44 WakeLock* NavigatorWakeLock::wakeLock() const | |
| 45 { | |
| 46 if (!m_wakeLock && frame()) | |
| 47 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.
| |
| 48 return m_wakeLock.get(); | |
| 49 } | |
| 50 | |
| 51 void NavigatorWakeLock::trace(Visitor* visitor) | |
| 52 { | |
| 53 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.
| |
| 54 visitor->trace(m_wakeLock); | |
| 55 WillBeHeapSupplement<Navigator>::trace(visitor); | |
| 56 } | |
| 57 | |
| 58 } // namespace WebCore | |
| OLD | NEW |