Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/vr/android/gvr/gvr_device_provider.h" | 5 #include "device/vr/android/gvr/gvr_device_provider.h" |
| 6 | 6 |
| 7 #include <jni.h> | 7 #include <jni.h> |
| 8 | 8 |
| 9 #include "base/android/context_utils.h" | 9 #include "base/android/context_utils.h" |
| 10 #include "base/android/jni_android.h" | 10 #include "base/android/jni_android.h" |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 100 base::Unretained(delegate))); | 100 base::Unretained(delegate))); |
| 101 } | 101 } |
| 102 | 102 |
| 103 void GvrDeviceProvider::OnGvrDelegateRemoved() { | 103 void GvrDeviceProvider::OnGvrDelegateRemoved() { |
| 104 DCHECK(main_thread_task_runner_->BelongsToCurrentThread()); | 104 DCHECK(main_thread_task_runner_->BelongsToCurrentThread()); |
| 105 if (!vr_device_) | 105 if (!vr_device_) |
| 106 return; | 106 return; |
| 107 ExitPresent(); | 107 ExitPresent(); |
| 108 } | 108 } |
| 109 | 109 |
| 110 void GvrDeviceProvider::OnDisplayBlur() { | |
| 111 if (!main_thread_task_runner_->BelongsToCurrentThread()) { | |
| 112 main_thread_task_runner_->PostTask( | |
| 113 FROM_HERE, | |
| 114 base::Bind(&GvrDeviceProvider::OnDisplayBlur, base::Unretained(this))); | |
|
dcheng
2016/11/04 05:24:46
Can you explain why this used of Unretained() is s
mthiesse
2016/11/04 17:20:36
As Brandon wrote this class and I was really just
| |
| 115 return; | |
| 116 } | |
| 117 if (client_) | |
| 118 client_->OnDisplayBlur(vr_device_.get()); | |
| 119 } | |
| 120 | |
| 121 void GvrDeviceProvider::OnDisplayFocus() { | |
| 122 if (!main_thread_task_runner_->BelongsToCurrentThread()) { | |
| 123 main_thread_task_runner_->PostTask( | |
| 124 FROM_HERE, | |
| 125 base::Bind(&GvrDeviceProvider::OnDisplayFocus, base::Unretained(this))); | |
| 126 return; | |
| 127 } | |
| 128 if (client_) | |
| 129 client_->OnDisplayFocus(vr_device_.get()); | |
| 130 } | |
| 131 | |
| 110 void GvrDeviceProvider::GvrDelegateReady(GvrDelegate* delegate) { | 132 void GvrDeviceProvider::GvrDelegateReady(GvrDelegate* delegate) { |
| 111 DCHECK(main_thread_task_runner_->BelongsToCurrentThread()); | 133 DCHECK(main_thread_task_runner_->BelongsToCurrentThread()); |
| 112 | 134 |
| 113 vr_device_->SetDelegate(delegate); | 135 vr_device_->SetDelegate(delegate); |
| 114 GamepadDataFetcherManager::GetInstance()->AddFactory( | 136 GamepadDataFetcherManager::GetInstance()->AddFactory( |
| 115 new GvrGamepadDataFetcher::Factory(delegate, vr_device_->id())); | 137 new GvrGamepadDataFetcher::Factory(delegate, vr_device_->id())); |
| 116 } | 138 } |
| 117 | 139 |
| 118 } // namespace device | 140 } // namespace device |
| OLD | NEW |