| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 DEVICE_POWER_SAVE_BLOCKER_POWER_SAVE_BLOCKER_H_ | 5 #ifndef DEVICE_POWER_SAVE_BLOCKER_POWER_SAVE_BLOCKER_H_ |
| 6 #define DEVICE_POWER_SAVE_BLOCKER_POWER_SAVE_BLOCKER_H_ | 6 #define DEVICE_POWER_SAVE_BLOCKER_POWER_SAVE_BLOCKER_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
| 12 #include "base/memory/weak_ptr.h" | |
| 13 #include "base/sequenced_task_runner.h" | 12 #include "base/sequenced_task_runner.h" |
| 14 #include "base/single_thread_task_runner.h" | 13 #include "base/single_thread_task_runner.h" |
| 15 #include "device/power_save_blocker/power_save_blocker_export.h" | 14 #include "device/power_save_blocker/power_save_blocker_export.h" |
| 16 | 15 |
| 17 #if defined(OS_ANDROID) | 16 #if defined(OS_ANDROID) |
| 18 #include "ui/android/view_android.h" | 17 #include "ui/android/view_android.h" |
| 19 #endif // OS_ANDROID | 18 #endif // OS_ANDROID |
| 20 | 19 |
| 21 namespace device { | 20 namespace device { |
| 22 | 21 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 PowerSaveBlockerType type, | 57 PowerSaveBlockerType type, |
| 59 Reason reason, | 58 Reason reason, |
| 60 const std::string& description, | 59 const std::string& description, |
| 61 scoped_refptr<base::SequencedTaskRunner> ui_task_runner, | 60 scoped_refptr<base::SequencedTaskRunner> ui_task_runner, |
| 62 scoped_refptr<base::SingleThreadTaskRunner> blocking_task_runner); | 61 scoped_refptr<base::SingleThreadTaskRunner> blocking_task_runner); |
| 63 virtual ~PowerSaveBlocker(); | 62 virtual ~PowerSaveBlocker(); |
| 64 | 63 |
| 65 #if defined(OS_ANDROID) | 64 #if defined(OS_ANDROID) |
| 66 // On Android, the kPowerSaveBlockPreventDisplaySleep type of | 65 // On Android, the kPowerSaveBlockPreventDisplaySleep type of |
| 67 // PowerSaveBlocker should associated with a View, so the blocker can be | 66 // PowerSaveBlocker should associated with a View, so the blocker can be |
| 68 // removed by the platform. | 67 // removed by the platform. Note that |view_android| is guaranteed to be |
| 68 // valid only for the lifetime of this call; hence it should not be cached |
| 69 // internally. |
| 69 DEVICE_POWER_SAVE_BLOCKER_EXPORT void InitDisplaySleepBlocker( | 70 DEVICE_POWER_SAVE_BLOCKER_EXPORT void InitDisplaySleepBlocker( |
| 70 const base::WeakPtr<ui::ViewAndroid>& view_android); | 71 ui::ViewAndroid* view_android); |
| 71 #endif | 72 #endif |
| 72 | 73 |
| 73 private: | 74 private: |
| 74 class Delegate; | 75 class Delegate; |
| 75 | 76 |
| 76 // Implementations of this class may need a second object with different | 77 // Implementations of this class may need a second object with different |
| 77 // lifetime than the RAII container, or additional storage. This member is | 78 // lifetime than the RAII container, or additional storage. This member is |
| 78 // here for that purpose. If not used, just define the class as an empty | 79 // here for that purpose. If not used, just define the class as an empty |
| 79 // RefCounted (or RefCountedThreadSafe) like so to make it compile: | 80 // RefCounted (or RefCountedThreadSafe) like so to make it compile: |
| 80 // class PowerSaveBlocker::Delegate | 81 // class PowerSaveBlocker::Delegate |
| (...skipping 13 matching lines...) Expand all Loading... |
| 94 | 95 |
| 95 scoped_refptr<base::SequencedTaskRunner> ui_task_runner_; | 96 scoped_refptr<base::SequencedTaskRunner> ui_task_runner_; |
| 96 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_; | 97 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_; |
| 97 | 98 |
| 98 DISALLOW_COPY_AND_ASSIGN(PowerSaveBlocker); | 99 DISALLOW_COPY_AND_ASSIGN(PowerSaveBlocker); |
| 99 }; | 100 }; |
| 100 | 101 |
| 101 } // namespace device | 102 } // namespace device |
| 102 | 103 |
| 103 #endif // DEVICE_POWER_SAVE_BLOCKER_POWER_SAVE_BLOCKER_H_ | 104 #endif // DEVICE_POWER_SAVE_BLOCKER_POWER_SAVE_BLOCKER_H_ |
| OLD | NEW |