Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(995)

Unified Diff: device/vr/android/gvr/gvr_device_provider.cc

Issue 2570553004: Clean up some VrShell threading issues and remove unnecessary WeakPtr types. (Closed)
Patch Set: rebase Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « device/vr/android/gvr/gvr_device_provider.h ('k') | device/vr/android/gvr/gvr_gamepad_data_fetcher.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: device/vr/android/gvr/gvr_device_provider.cc
diff --git a/device/vr/android/gvr/gvr_device_provider.cc b/device/vr/android/gvr/gvr_device_provider.cc
index 13d84c29f9e9696e4f2b6b5d19581738f87fdde4..07726adad17ccece000647d0701a44edeac70fd1 100644
--- a/device/vr/android/gvr/gvr_device_provider.cc
+++ b/device/vr/android/gvr/gvr_device_provider.cc
@@ -25,7 +25,7 @@ using base::android::GetApplicationContext;
namespace device {
-GvrDeviceProvider::GvrDeviceProvider() : weak_ptr_factory_(this) {}
+GvrDeviceProvider::GvrDeviceProvider() {}
GvrDeviceProvider::~GvrDeviceProvider() {
GamepadDataFetcherManager::GetInstance()->RemoveSourceFactory(
@@ -36,6 +36,7 @@ GvrDeviceProvider::~GvrDeviceProvider() {
if (delegate_provider) {
delegate_provider->ExitWebVRPresent();
delegate_provider->DestroyNonPresentingDelegate();
+ delegate_provider->SetDeviceProvider(nullptr);
}
}
@@ -51,7 +52,7 @@ void GvrDeviceProvider::Initialize() {
device::GvrDelegateProvider::GetInstance();
if (!delegate_provider)
return;
- delegate_provider->SetDeviceProvider(weak_ptr_factory_.GetWeakPtr());
+ delegate_provider->SetDeviceProvider(this);
if (!vr_device_) {
vr_device_.reset(
new GvrDevice(this, delegate_provider->GetNonPresentingDelegate()));
@@ -78,8 +79,7 @@ void GvrDeviceProvider::ExitPresent() {
delegate_provider->ExitWebVRPresent();
}
-void GvrDeviceProvider::OnGvrDelegateReady(
- const base::WeakPtr<GvrDelegate>& delegate) {
+void GvrDeviceProvider::OnGvrDelegateReady(GvrDelegate* delegate) {
if (!vr_device_)
return;
VLOG(1) << "Switching to presenting delegate";
@@ -97,6 +97,12 @@ void GvrDeviceProvider::OnGvrDelegateRemoved() {
vr_device_->OnExitPresent();
}
+void GvrDeviceProvider::OnNonPresentingDelegateRemoved() {
+ if (!vr_device_)
+ return;
+ vr_device_->SetDelegate(nullptr);
+}
+
void GvrDeviceProvider::OnDisplayBlur() {
if (!vr_device_)
return;
« no previous file with comments | « device/vr/android/gvr/gvr_device_provider.h ('k') | device/vr/android/gvr/gvr_gamepad_data_fetcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698