| 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" |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 | 57 |
| 58 if (!view_android_) | 58 if (!view_android_) |
| 59 return; | 59 return; |
| 60 | 60 |
| 61 JNIEnv* env = AttachCurrentThread(); | 61 JNIEnv* env = AttachCurrentThread(); |
| 62 anchor_view_ = view_android_->AcquireAnchorView(); | 62 anchor_view_ = view_android_->AcquireAnchorView(); |
| 63 const ScopedJavaLocalRef<jobject> popup_view = anchor_view_.view(); | 63 const ScopedJavaLocalRef<jobject> popup_view = anchor_view_.view(); |
| 64 if (popup_view.is_null()) | 64 if (popup_view.is_null()) |
| 65 return; | 65 return; |
| 66 ScopedJavaLocalRef<jobject> obj(java_power_save_blocker_); | 66 ScopedJavaLocalRef<jobject> obj(java_power_save_blocker_); |
| 67 Java_PowerSaveBlocker_applyBlock(env, obj.obj(), popup_view.obj()); | 67 Java_PowerSaveBlocker_applyBlock(env, obj, popup_view); |
| 68 } | 68 } |
| 69 | 69 |
| 70 void PowerSaveBlocker::Delegate::RemoveBlock() { | 70 void PowerSaveBlocker::Delegate::RemoveBlock() { |
| 71 DCHECK(ui_task_runner_->RunsTasksOnCurrentThread()); | 71 DCHECK(ui_task_runner_->RunsTasksOnCurrentThread()); |
| 72 ScopedJavaLocalRef<jobject> obj(java_power_save_blocker_); | 72 ScopedJavaLocalRef<jobject> obj(java_power_save_blocker_); |
| 73 Java_PowerSaveBlocker_removeBlock(AttachCurrentThread(), obj.obj()); | 73 Java_PowerSaveBlocker_removeBlock(AttachCurrentThread(), obj); |
| 74 anchor_view_.Reset(); | 74 anchor_view_.Reset(); |
| 75 } | 75 } |
| 76 | 76 |
| 77 PowerSaveBlocker::PowerSaveBlocker( | 77 PowerSaveBlocker::PowerSaveBlocker( |
| 78 PowerSaveBlockerType type, | 78 PowerSaveBlockerType type, |
| 79 Reason reason, | 79 Reason reason, |
| 80 const std::string& description, | 80 const std::string& description, |
| 81 scoped_refptr<base::SequencedTaskRunner> ui_task_runner, | 81 scoped_refptr<base::SequencedTaskRunner> ui_task_runner, |
| 82 scoped_refptr<base::SingleThreadTaskRunner> blocking_task_runner) | 82 scoped_refptr<base::SingleThreadTaskRunner> blocking_task_runner) |
| 83 : ui_task_runner_(ui_task_runner), | 83 : ui_task_runner_(ui_task_runner), |
| (...skipping 12 matching lines...) Expand all Loading... |
| 96 const base::WeakPtr<ui::ViewAndroid>& view_android) { | 96 const base::WeakPtr<ui::ViewAndroid>& view_android) { |
| 97 DCHECK(ui_task_runner_->RunsTasksOnCurrentThread()); | 97 DCHECK(ui_task_runner_->RunsTasksOnCurrentThread()); |
| 98 if (!view_android) | 98 if (!view_android) |
| 99 return; | 99 return; |
| 100 | 100 |
| 101 delegate_ = new Delegate(view_android, ui_task_runner_); | 101 delegate_ = new Delegate(view_android, ui_task_runner_); |
| 102 delegate_->ApplyBlock(); | 102 delegate_->ApplyBlock(); |
| 103 } | 103 } |
| 104 | 104 |
| 105 } // namespace device | 105 } // namespace device |
| OLD | NEW |