| 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 | |
| 27 namespace content { | 23 namespace content { |
| 28 | 24 |
| 25 class PowerSaveBlocker; |
| 29 class RenderFrameHost; | 26 class RenderFrameHost; |
| 30 class WebContents; | 27 class WebContents; |
| 31 | 28 |
| 32 class CONTENT_EXPORT WakeLockServiceContext : public WebContentsObserver { | 29 class CONTENT_EXPORT WakeLockServiceContext : public WebContentsObserver { |
| 33 public: | 30 public: |
| 34 explicit WakeLockServiceContext(WebContents* web_contents); | 31 explicit WakeLockServiceContext(WebContents* web_contents); |
| 35 ~WakeLockServiceContext() override; | 32 ~WakeLockServiceContext() override; |
| 36 | 33 |
| 37 // Creates a WakeLockServiceImpl that is strongly bound to |request|. | 34 // Creates a WakeLockServiceImpl that is strongly bound to |request|. |
| 38 void CreateService( | 35 void CreateService( |
| (...skipping 19 matching lines...) Expand all Loading... |
| 58 private: | 55 private: |
| 59 void CreateWakeLock(); | 56 void CreateWakeLock(); |
| 60 void RemoveWakeLock(); | 57 void RemoveWakeLock(); |
| 61 void UpdateWakeLock(); | 58 void UpdateWakeLock(); |
| 62 | 59 |
| 63 // Set of (render_process_id, render_frame_id) pairs identifying all | 60 // Set of (render_process_id, render_frame_id) pairs identifying all |
| 64 // RenderFrames requesting wake lock. | 61 // RenderFrames requesting wake lock. |
| 65 std::set<std::pair<int, int>> frames_requesting_lock_; | 62 std::set<std::pair<int, int>> frames_requesting_lock_; |
| 66 | 63 |
| 67 // The actual power save blocker for screen. | 64 // The actual power save blocker for screen. |
| 68 std::unique_ptr<device::PowerSaveBlocker> wake_lock_; | 65 std::unique_ptr<PowerSaveBlocker> wake_lock_; |
| 69 #if defined(OS_ANDROID) | 66 #if defined(OS_ANDROID) |
| 70 std::unique_ptr<base::WeakPtrFactory<ui::ViewAndroid>> view_weak_factory_; | 67 std::unique_ptr<base::WeakPtrFactory<ui::ViewAndroid>> view_weak_factory_; |
| 71 #endif | 68 #endif |
| 72 | 69 |
| 73 base::WeakPtrFactory<WakeLockServiceContext> weak_factory_; | 70 base::WeakPtrFactory<WakeLockServiceContext> weak_factory_; |
| 74 | 71 |
| 75 DISALLOW_COPY_AND_ASSIGN(WakeLockServiceContext); | 72 DISALLOW_COPY_AND_ASSIGN(WakeLockServiceContext); |
| 76 }; | 73 }; |
| 77 | 74 |
| 78 } // namespace content | 75 } // namespace content |
| 79 | 76 |
| 80 #endif // CONTENT_BROWSER_WAKE_LOCK_WAKE_LOCK_SERVICE_CONTEXT_H_ | 77 #endif // CONTENT_BROWSER_WAKE_LOCK_WAKE_LOCK_SERVICE_CONTEXT_H_ |
| OLD | NEW |