| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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_POWER_SAVE_BLOCKER_IMPL_H_ | 5 #ifndef CONTENT_BROWSER_POWER_SAVE_BLOCKER_IMPL_H_ |
| 6 #define CONTENT_BROWSER_POWER_SAVE_BLOCKER_IMPL_H_ | 6 #define CONTENT_BROWSER_POWER_SAVE_BLOCKER_IMPL_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
| 12 #include "base/memory/weak_ptr.h" |
| 12 #include "base/sequenced_task_runner.h" | 13 #include "base/sequenced_task_runner.h" |
| 13 #include "base/single_thread_task_runner.h" | 14 #include "base/single_thread_task_runner.h" |
| 14 #include "build/build_config.h" | 15 #include "build/build_config.h" |
| 15 #include "content/public/browser/power_save_blocker.h" | 16 #include "content/public/browser/power_save_blocker.h" |
| 16 | 17 |
| 18 #if defined(OS_ANDROID) |
| 19 #include "ui/android/view_android.h" |
| 20 #endif // OS_ANDROID |
| 21 |
| 17 namespace content { | 22 namespace content { |
| 18 | 23 |
| 19 class WebContents; | 24 class WebContents; |
| 20 | 25 |
| 21 class PowerSaveBlockerImpl : public PowerSaveBlocker { | 26 class PowerSaveBlockerImpl : public PowerSaveBlocker { |
| 22 public: | 27 public: |
| 23 PowerSaveBlockerImpl( | 28 PowerSaveBlockerImpl( |
| 24 PowerSaveBlockerType type, | 29 PowerSaveBlockerType type, |
| 25 Reason reason, | 30 Reason reason, |
| 26 const std::string& description, | 31 const std::string& description, |
| 27 scoped_refptr<base::SequencedTaskRunner> ui_task_runner, | 32 scoped_refptr<base::SequencedTaskRunner> ui_task_runner, |
| 28 scoped_refptr<base::SingleThreadTaskRunner> blocking_task_runner); | 33 scoped_refptr<base::SingleThreadTaskRunner> blocking_task_runner); |
| 29 ~PowerSaveBlockerImpl() override; | 34 ~PowerSaveBlockerImpl() override; |
| 30 | 35 |
| 31 #if defined(OS_ANDROID) | 36 #if defined(OS_ANDROID) |
| 32 // In Android platform, the kPowerSaveBlockPreventDisplaySleep type of | 37 // On Android, the kPowerSaveBlockPreventDisplaySleep type of |
| 33 // PowerSaveBlocker should associated with a WebContents, so the blocker | 38 // PowerSaveBlocker should associated with a View, so the blocker can be |
| 34 // could be removed by platform if the WebContents is hidden. | 39 // removed by the platform. |
| 35 void InitDisplaySleepBlocker(WebContents* web_contents); | 40 void InitDisplaySleepBlocker(base::WeakPtr<ui::ViewAndroid> view_android); |
| 36 #endif | 41 #endif |
| 37 | 42 |
| 38 private: | 43 private: |
| 39 class Delegate; | 44 class Delegate; |
| 40 | 45 |
| 41 // Implementations of this class may need a second object with different | 46 // Implementations of this class may need a second object with different |
| 42 // lifetime than the RAII container, or additional storage. This member is | 47 // lifetime than the RAII container, or additional storage. This member is |
| 43 // here for that purpose. If not used, just define the class as an empty | 48 // here for that purpose. If not used, just define the class as an empty |
| 44 // RefCounted (or RefCountedThreadSafe) like so to make it compile: | 49 // RefCounted (or RefCountedThreadSafe) like so to make it compile: |
| 45 // class PowerSaveBlocker::Delegate | 50 // class PowerSaveBlocker::Delegate |
| (...skipping 13 matching lines...) Expand all Loading... |
| 59 | 64 |
| 60 scoped_refptr<base::SequencedTaskRunner> ui_task_runner_; | 65 scoped_refptr<base::SequencedTaskRunner> ui_task_runner_; |
| 61 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_; | 66 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_; |
| 62 | 67 |
| 63 DISALLOW_COPY_AND_ASSIGN(PowerSaveBlockerImpl); | 68 DISALLOW_COPY_AND_ASSIGN(PowerSaveBlockerImpl); |
| 64 }; | 69 }; |
| 65 | 70 |
| 66 } // namespace content | 71 } // namespace content |
| 67 | 72 |
| 68 #endif // CONTENT_BROWSER_POWER_SAVE_BLOCKER_IMPL_H_ | 73 #endif // CONTENT_BROWSER_POWER_SAVE_BLOCKER_IMPL_H_ |
| OLD | NEW |