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 #include "device/power_save_blocker/power_save_blocker.h" | 5 #include "device/power_save_blocker/power_save_blocker.h" |
6 | 6 |
7 #include "base/android/jni_android.h" | 7 #include "base/android/jni_android.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/location.h" | 9 #include "base/location.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "base/macros.h" | 11 #include "base/macros.h" |
12 #include "jni/PowerSaveBlocker_jni.h" | 12 #include "jni/PowerSaveBlocker_jni.h" |
13 #include "ui/android/view_android.h" | 13 #include "ui/android/view_android.h" |
14 | 14 |
15 namespace device { | 15 namespace device { |
16 | 16 |
17 using base::android::AttachCurrentThread; | 17 using base::android::AttachCurrentThread; |
| 18 using base::android::ScopedJavaLocalRef; |
18 | 19 |
19 class PowerSaveBlocker::Delegate | 20 class PowerSaveBlocker::Delegate |
20 : public base::RefCountedThreadSafe<PowerSaveBlocker::Delegate> { | 21 : public base::RefCountedThreadSafe<PowerSaveBlocker::Delegate> { |
21 public: | 22 public: |
22 Delegate(base::WeakPtr<ui::ViewAndroid> view_android, | 23 Delegate(base::WeakPtr<ui::ViewAndroid> view_android, |
23 scoped_refptr<base::SequencedTaskRunner> ui_task_runner); | 24 scoped_refptr<base::SequencedTaskRunner> ui_task_runner); |
24 | 25 |
25 // Does the actual work to apply or remove the desired power save block. | 26 // Does the actual work to apply or remove the desired power save block. |
26 void ApplyBlock(); | 27 void ApplyBlock(); |
27 void RemoveBlock(); | 28 void RemoveBlock(); |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 const base::WeakPtr<ui::ViewAndroid>& view_android) { | 93 const base::WeakPtr<ui::ViewAndroid>& view_android) { |
93 DCHECK(ui_task_runner_->RunsTasksOnCurrentThread()); | 94 DCHECK(ui_task_runner_->RunsTasksOnCurrentThread()); |
94 if (!view_android) | 95 if (!view_android) |
95 return; | 96 return; |
96 | 97 |
97 delegate_ = new Delegate(view_android, ui_task_runner_); | 98 delegate_ = new Delegate(view_android, ui_task_runner_); |
98 delegate_->ApplyBlock(); | 99 delegate_->ApplyBlock(); |
99 } | 100 } |
100 | 101 |
101 } // namespace device | 102 } // namespace device |
OLD | NEW |