Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2015 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 CONTENT_BROWSER_WAKE_LOCK_WAKE_LOCK_SERVICE_CONTEXT_H_ | |
| 6 #define CONTENT_BROWSER_WAKE_LOCK_WAKE_LOCK_SERVICE_CONTEXT_H_ | |
| 7 | |
| 8 #include <set> | |
| 9 | |
| 10 #include "base/memory/scoped_ptr.h" | |
| 11 #include "base/memory/weak_ptr.h" | |
| 12 #include "content/common/content_export.h" | |
| 13 #include "content/public/browser/web_contents_observer.h" | |
| 14 | |
| 15 namespace content { | |
| 16 | |
| 17 class PowerSaveBlocker; | |
| 18 class RenderFrameHost; | |
| 19 class WebContents; | |
| 20 | |
| 21 class CONTENT_EXPORT WakeLockServiceContext | |
| 22 : public WebContentsObserver { | |
| 23 public: | |
| 24 explicit WakeLockServiceContext(WebContents* web_contents); | |
| 25 ~WakeLockServiceContext() override; | |
| 26 | |
| 27 // WebContentsObserver implementation. | |
| 28 void RenderFrameCreated(RenderFrameHost* render_frame_host) override; | |
| 29 void RenderFrameDeleted(RenderFrameHost* render_frame_host) override; | |
| 30 void RenderFrameHostChanged(RenderFrameHost* old_host, | |
| 31 RenderFrameHost* new_host) override; | |
| 32 | |
| 33 // Requests wake lock for |render_frame_host|. | |
| 34 void RequestWakeLock(RenderFrameHost* render_frame_host); | |
| 35 // Cancels wake lock request for |render_frame_host|. | |
| 36 void CancelWakeLock(RenderFrameHost* render_frame_host); | |
| 37 | |
| 38 private: | |
| 39 friend class WakeLockServiceContextTest; | |
| 40 friend class WakeLockTest; | |
| 41 | |
| 42 void CreateWakeLock(); | |
| 43 void RemoveWakeLock(); | |
| 44 void UpdateWakeLock(); | |
| 45 | |
| 46 // Set of all frames currently requesting wake lock. | |
| 47 std::set<const RenderFrameHost*> frames_requesting_lock_; | |
| 48 // 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.
| |
| 49 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.
| |
| 50 | |
| 51 base::WeakPtrFactory<WakeLockServiceContext> weak_factory_; | |
| 52 | |
| 53 DISALLOW_COPY_AND_ASSIGN(WakeLockServiceContext); | |
| 54 }; | |
| 55 | |
| 56 } // namespace content | |
| 57 | |
| 58 #endif // CONTENT_BROWSER_WAKE_LOCK_WAKE_LOCK_SERVICE_CONTEXT_H_ | |
| OLD | NEW |