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 #ifndef WakeLockController_h | |
| 6 #define WakeLockController_h | |
| 7 | |
| 8 #include "bindings/core/v8/ScriptPromise.h" | |
| 9 #include "core/page/Page.h" | |
| 10 #include "core/page/PageLifecycleObserver.h" | |
| 11 #include "public/platform/WebWakeLockRequestCallback.h" | |
| 12 #include "public/platform/WebWakeLockType.h" | |
| 13 #include "wtf/OwnPtr.h" | |
| 14 #include "wtf/Vector.h" | |
| 15 | |
| 16 namespace blink { | |
| 17 | |
| 18 class ScriptState; | |
| 19 class WakeLockPromiseResolver; | |
| 20 class WebWakeLockClient; | |
| 21 typedef WTF::OwnPtr<WakeLockPromiseResolver> WakeLockPromiseResolverOwnPtr; | |
| 22 | |
| 23 class WakeLockController FINAL | |
| 24 : public NoBaseWillBeGarbageCollectedFinalized<WakeLockController> | |
| 25 , public WillBeHeapSupplement<Page> | |
| 26 , public PageLifecycleObserver | |
| 27 , public WebWakeLockRequestCallback { | |
| 28 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(WakeLockController); | |
| 29 WTF_MAKE_NONCOPYABLE(WakeLockController); | |
| 30 | |
| 31 public: | |
| 32 virtual ~WakeLockController(); | |
| 33 | |
| 34 static PassOwnPtrWillBeRawPtr<WakeLockController> create(Page&, WebWakeLockC lient*); | |
| 35 | |
| 36 ScriptPromise requestWakeLock(ScriptState*, WebWakeLockType); | |
| 37 ScriptPromise requestWakeUnlock(ScriptState*, WebWakeLockType); | |
| 38 bool isHeld(WebWakeLockType); | |
| 39 | |
| 40 virtual void onCreatedWakeLockSuccessful(int); | |
|
mlamouri (slow - plz ping)
2014/08/18 12:15:53
nit: specify the interface you are implementing, l
redchenko
2014/08/19 16:42:20
Done.
| |
| 41 virtual void onCreatedWakeLockFailed(int); | |
| 42 virtual void onUnlockedWakeLockSuccessful(int); | |
| 43 virtual void onUnlockedWakeLockFailed(int); | |
| 44 | |
| 45 WebWakeLockClient* client() { return m_client; } | |
| 46 void resetClient(); | |
| 47 | |
| 48 static const char* supplementName(); | |
| 49 static WakeLockController* from(Page*); | |
| 50 static void provideWakeLockTo(Page&, WebWakeLockClient*); | |
| 51 // Inherited from PageLifecycleObserver. | |
| 52 virtual void trace(Visitor*) OVERRIDE; | |
| 53 virtual void willBeDestroyed() OVERRIDE; | |
| 54 | |
| 55 private: | |
| 56 WakeLockController(Page&, WebWakeLockClient*); | |
| 57 ScriptPromise requestLockOrUnlock(ScriptState*, WebWakeLockType, bool); | |
| 58 WebWakeLockType resolveOrRejectById(int id, bool successful); | |
| 59 | |
| 60 WebWakeLockClient* m_client; | |
| 61 Vector<WakeLockPromiseResolverOwnPtr> m_resolvers; | |
| 62 Vector<int> m_lockCounter; | |
| 63 }; | |
| 64 | |
| 65 } // namespace WebCore | |
| 66 | |
| 67 #endif // WakeLockController | |
| OLD | NEW |