Chromium Code Reviews| Index: Source/modules/wake_lock/WakeLockController.h |
| diff --git a/Source/modules/wake_lock/WakeLockController.h b/Source/modules/wake_lock/WakeLockController.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..a772cb40be17d038f45e809616e747b08e8ce237 |
| --- /dev/null |
| +++ b/Source/modules/wake_lock/WakeLockController.h |
| @@ -0,0 +1,67 @@ |
| +// 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. |
| + |
| +#ifndef WakeLockController_h |
| +#define WakeLockController_h |
| + |
| +#include "bindings/core/v8/ScriptPromise.h" |
| +#include "core/page/Page.h" |
| +#include "core/page/PageLifecycleObserver.h" |
| +#include "public/platform/WebWakeLockRequestCallback.h" |
| +#include "public/platform/WebWakeLockType.h" |
| +#include "wtf/OwnPtr.h" |
| +#include "wtf/Vector.h" |
| + |
| +namespace blink { |
| + |
| +class ScriptState; |
| +class WakeLockPromiseResolver; |
| +class WebWakeLockClient; |
| +typedef WTF::OwnPtr<WakeLockPromiseResolver> WakeLockPromiseResolverOwnPtr; |
| + |
| +class WakeLockController FINAL |
| + : public NoBaseWillBeGarbageCollectedFinalized<WakeLockController> |
| + , public WillBeHeapSupplement<Page> |
| + , public PageLifecycleObserver |
| + , public WebWakeLockRequestCallback { |
| + WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(WakeLockController); |
| + WTF_MAKE_NONCOPYABLE(WakeLockController); |
| + |
| +public: |
| + virtual ~WakeLockController(); |
| + |
| + static PassOwnPtrWillBeRawPtr<WakeLockController> create(Page&, WebWakeLockClient*); |
| + |
| + ScriptPromise requestWakeLock(ScriptState*, WebWakeLockType); |
| + ScriptPromise requestWakeUnlock(ScriptState*, WebWakeLockType); |
| + bool isHeld(WebWakeLockType); |
| + |
| + 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.
|
| + virtual void onCreatedWakeLockFailed(int); |
| + virtual void onUnlockedWakeLockSuccessful(int); |
| + virtual void onUnlockedWakeLockFailed(int); |
| + |
| + WebWakeLockClient* client() { return m_client; } |
| + void resetClient(); |
| + |
| + static const char* supplementName(); |
| + static WakeLockController* from(Page*); |
| + static void provideWakeLockTo(Page&, WebWakeLockClient*); |
| + // Inherited from PageLifecycleObserver. |
| + virtual void trace(Visitor*) OVERRIDE; |
| + virtual void willBeDestroyed() OVERRIDE; |
| + |
| +private: |
| + WakeLockController(Page&, WebWakeLockClient*); |
| + ScriptPromise requestLockOrUnlock(ScriptState*, WebWakeLockType, bool); |
| + WebWakeLockType resolveOrRejectById(int id, bool successful); |
| + |
| + WebWakeLockClient* m_client; |
| + Vector<WakeLockPromiseResolverOwnPtr> m_resolvers; |
| + Vector<int> m_lockCounter; |
| +}; |
| + |
| +} // namespace WebCore |
| + |
| +#endif // WakeLockController |