Chromium Code Reviews| Index: content/browser/wake_lock/wake_lock_service_context.h |
| diff --git a/content/browser/wake_lock/wake_lock_service_context.h b/content/browser/wake_lock/wake_lock_service_context.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..a4cc2f84445d6b632e072b4e3615cd734d20cd0e |
| --- /dev/null |
| +++ b/content/browser/wake_lock/wake_lock_service_context.h |
| @@ -0,0 +1,58 @@ |
| +// 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_SERVICE_CONTEXT_H_ |
| +#define CONTENT_BROWSER_WAKE_LOCK_WAKE_LOCK_SERVICE_CONTEXT_H_ |
| + |
| +#include <set> |
| + |
| +#include "base/memory/scoped_ptr.h" |
| +#include "base/memory/weak_ptr.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 WakeLockServiceContext |
| + : public WebContentsObserver { |
| + public: |
| + explicit WakeLockServiceContext(WebContents* web_contents); |
| + ~WakeLockServiceContext() override; |
| + |
| + // WebContentsObserver implementation. |
| + void RenderFrameCreated(RenderFrameHost* render_frame_host) override; |
| + void RenderFrameDeleted(RenderFrameHost* render_frame_host) override; |
| + void RenderFrameHostChanged(RenderFrameHost* old_host, |
| + RenderFrameHost* new_host) override; |
| + |
| + // Requests wake lock for |render_frame_host|. |
| + void RequestWakeLock(RenderFrameHost* render_frame_host); |
| + // Cancels wake lock request for |render_frame_host|. |
| + void CancelWakeLock(RenderFrameHost* render_frame_host); |
| + |
| + private: |
| + friend class WakeLockServiceContextTest; |
| + friend class WakeLockTest; |
| + |
| + void CreateWakeLock(); |
| + void RemoveWakeLock(); |
| + void UpdateWakeLock(); |
| + |
| + // Set of all frames currently requesting wake lock. |
| + std::set<const RenderFrameHost*> frames_requesting_lock_; |
| + // The actual power save blocker for screen. |
|
mlamouri (slow - plz ping)
2015/08/31 14:59:15
nit: leave empty line. between two members.
alogvinov
2015/09/02 17:06:22
Done.
|
| + scoped_ptr<PowerSaveBlocker> wake_lock_; |
|
mlamouri (slow - plz ping)
2015/08/31 14:59:15
You seem to check that scoped_ptr<> isn't null in
alogvinov
2015/09/02 17:06:22
Done.
|
| + |
| + base::WeakPtrFactory<WakeLockServiceContext> weak_factory_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(WakeLockServiceContext); |
| +}; |
| + |
| +} // namespace content |
| + |
| +#endif // CONTENT_BROWSER_WAKE_LOCK_WAKE_LOCK_SERVICE_CONTEXT_H_ |