OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CONTENT_BROWSER_WAKE_LOCK_WAKE_LOCK_SERVICE_CONTEXT_H_ | 5 #ifndef CONTENT_BROWSER_WAKE_LOCK_WAKE_LOCK_SERVICE_CONTEXT_H_ |
6 #define CONTENT_BROWSER_WAKE_LOCK_WAKE_LOCK_SERVICE_CONTEXT_H_ | 6 #define CONTENT_BROWSER_WAKE_LOCK_WAKE_LOCK_SERVICE_CONTEXT_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include <set> | 9 #include <set> |
10 #include <utility> | 10 #include <utility> |
11 | 11 |
12 #include "base/macros.h" | 12 #include "base/macros.h" |
13 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
14 #include "content/browser/wake_lock/wake_lock_service_impl.h" | 14 #include "content/browser/wake_lock/wake_lock_service_impl.h" |
15 #include "content/common/content_export.h" | 15 #include "content/common/content_export.h" |
16 #include "content/public/browser/web_contents_observer.h" | 16 #include "content/public/browser/web_contents_observer.h" |
17 #include "mojo/public/cpp/bindings/interface_request.h" | 17 #include "mojo/public/cpp/bindings/interface_request.h" |
18 | 18 |
19 #if defined(OS_ANDROID) | 19 #if defined(OS_ANDROID) |
20 #include "ui/android/view_android.h" | 20 #include "ui/android/view_android.h" |
21 #endif // OS_ANDROID | 21 #endif // OS_ANDROID |
22 | 22 |
| 23 namespace device { |
| 24 class PowerSaveBlocker; |
| 25 } // namespace device |
| 26 |
23 namespace content { | 27 namespace content { |
24 | 28 |
25 class PowerSaveBlocker; | |
26 class RenderFrameHost; | 29 class RenderFrameHost; |
27 class WebContents; | 30 class WebContents; |
28 | 31 |
29 class CONTENT_EXPORT WakeLockServiceContext : public WebContentsObserver { | 32 class CONTENT_EXPORT WakeLockServiceContext : public WebContentsObserver { |
30 public: | 33 public: |
31 explicit WakeLockServiceContext(WebContents* web_contents); | 34 explicit WakeLockServiceContext(WebContents* web_contents); |
32 ~WakeLockServiceContext() override; | 35 ~WakeLockServiceContext() override; |
33 | 36 |
34 // Creates a WakeLockServiceImpl that is strongly bound to |request|. | 37 // Creates a WakeLockServiceImpl that is strongly bound to |request|. |
35 void CreateService( | 38 void CreateService( |
(...skipping 19 matching lines...) Expand all Loading... |
55 private: | 58 private: |
56 void CreateWakeLock(); | 59 void CreateWakeLock(); |
57 void RemoveWakeLock(); | 60 void RemoveWakeLock(); |
58 void UpdateWakeLock(); | 61 void UpdateWakeLock(); |
59 | 62 |
60 // Set of (render_process_id, render_frame_id) pairs identifying all | 63 // Set of (render_process_id, render_frame_id) pairs identifying all |
61 // RenderFrames requesting wake lock. | 64 // RenderFrames requesting wake lock. |
62 std::set<std::pair<int, int>> frames_requesting_lock_; | 65 std::set<std::pair<int, int>> frames_requesting_lock_; |
63 | 66 |
64 // The actual power save blocker for screen. | 67 // The actual power save blocker for screen. |
65 std::unique_ptr<PowerSaveBlocker> wake_lock_; | 68 std::unique_ptr<device::PowerSaveBlocker> wake_lock_; |
66 #if defined(OS_ANDROID) | 69 #if defined(OS_ANDROID) |
67 std::unique_ptr<base::WeakPtrFactory<ui::ViewAndroid>> view_weak_factory_; | 70 std::unique_ptr<base::WeakPtrFactory<ui::ViewAndroid>> view_weak_factory_; |
68 #endif | 71 #endif |
69 | 72 |
70 base::WeakPtrFactory<WakeLockServiceContext> weak_factory_; | 73 base::WeakPtrFactory<WakeLockServiceContext> weak_factory_; |
71 | 74 |
72 DISALLOW_COPY_AND_ASSIGN(WakeLockServiceContext); | 75 DISALLOW_COPY_AND_ASSIGN(WakeLockServiceContext); |
73 }; | 76 }; |
74 | 77 |
75 } // namespace content | 78 } // namespace content |
76 | 79 |
77 #endif // CONTENT_BROWSER_WAKE_LOCK_WAKE_LOCK_SERVICE_CONTEXT_H_ | 80 #endif // CONTENT_BROWSER_WAKE_LOCK_WAKE_LOCK_SERVICE_CONTEXT_H_ |
OLD | NEW |