| Index: content/browser/wake_lock/wake_lock_dispatcher_host.h
|
| diff --git a/content/browser/wake_lock/wake_lock_dispatcher_host.h b/content/browser/wake_lock/wake_lock_dispatcher_host.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..487c7114cb0f690c93742956e69130e14d82a112
|
| --- /dev/null
|
| +++ b/content/browser/wake_lock/wake_lock_dispatcher_host.h
|
| @@ -0,0 +1,73 @@
|
| +// Copyright 2015 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 CONTENT_BROWSER_WAKE_LOCK_WAKE_LOCK_DISPATCHER_HOST_H_
|
| +#define CONTENT_BROWSER_WAKE_LOCK_WAKE_LOCK_DISPATCHER_HOST_H_
|
| +
|
| +#include "base/memory/scoped_ptr.h"
|
| +#include "base/memory/weak_ptr.h"
|
| +#include "base/observer_list.h"
|
| +#include "content/browser/wake_lock/wake_lock_state.h"
|
| +#include "content/common/content_export.h"
|
| +#include "content/public/browser/web_contents_observer.h"
|
| +
|
| +namespace content {
|
| +
|
| +class PowerSaveBlocker;
|
| +class RenderFrameHost;
|
| +class WebContents;
|
| +
|
| +class CONTENT_EXPORT WakeLockDispatcherHost
|
| + : public WebContentsObserver {
|
| + public:
|
| + explicit WakeLockDispatcherHost(WebContents* web_contents);
|
| + ~WakeLockDispatcherHost() override;
|
| +
|
| + // WebContentsObserver
|
| + void RenderFrameCreated(RenderFrameHost* render_frame_host) override;
|
| + void RenderFrameDeleted(RenderFrameHost* render_frame_host) override;
|
| + void RenderFrameHostChanged(RenderFrameHost* old_host,
|
| + RenderFrameHost* new_host) override;
|
| +
|
| + bool has_blocker_for_testing() const {
|
| + return blocker_;
|
| + }
|
| +
|
| + class CONTENT_EXPORT Observer {
|
| + public:
|
| + virtual void OnUpdate() = 0;
|
| + };
|
| +
|
| + void AddObserver(Observer* obs) {
|
| + observer_list_.AddObserver(obs);
|
| + }
|
| +
|
| + void RemoveObserver(Observer* obs) {
|
| + observer_list_.RemoveObserver(obs);
|
| + }
|
| +
|
| + private:
|
| + void OnKeepScreenAwake(RenderFrameHost* render_frame_host, bool intention);
|
| +
|
| + void CreateBlocker();
|
| + void RemoveBlocker();
|
| + void UpdateBlocker();
|
| +
|
| + void NotifyUpdate();
|
| +
|
| + WakeLockState wake_lock_state_;
|
| +
|
| + scoped_ptr<PowerSaveBlocker> blocker_;
|
| + ObserverList<Observer> observer_list_;
|
| +
|
| + friend class WakeLockDispatcherHostTest;
|
| +
|
| + base::WeakPtrFactory<WakeLockDispatcherHost> weak_factory_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(WakeLockDispatcherHost);
|
| +};
|
| +
|
| +} // namespace content
|
| +
|
| +#endif // CONTENT_BROWSER_WAKE_LOCK_WAKE_LOCK_DISPATCHER_HOST_H_
|
|
|