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

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

Issue 2471433002: Implement WebVR presentation pausing for VR Shell Menu Mode (Closed)
Patch Set: Address Comments Created 4 years, 1 month 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
Index: device/vr/android/gvr/gvr_device.cc
diff --git a/device/vr/android/gvr/gvr_device.cc b/device/vr/android/gvr/gvr_device.cc
index be3d657764f9e225620d4fe22dca6cb6b5c1d545..c70b9ceffe2ef9adedc93c693cc3f0bb40ae9d16 100644
--- a/device/vr/android/gvr/gvr_device.cc
+++ b/device/vr/android/gvr/gvr_device.cc
@@ -10,6 +10,7 @@
#include "base/time/time.h"
#include "base/trace_event/trace_event.h"
#include "device/vr/android/gvr/gvr_delegate.h"
+#include "device/vr/android/gvr/gvr_device_provider.h"
#include "device/vr/vr_device_manager.h"
#include "third_party/gvr-android-sdk/src/ndk/include/vr/gvr/capi/include/gvr.h"
#include "third_party/gvr-android-sdk/src/ndk/include/vr/gvr/capi/include/gvr_types.h"
@@ -24,8 +25,9 @@ static const uint64_t kPredictionTimeWithoutVsyncNanos = 50000000;
} // namespace
-GvrDevice::GvrDevice(GvrDeviceProvider* provider, GvrDelegate* delegate)
- : VRDevice(provider), delegate_(delegate), gvr_provider_(provider) {}
+GvrDevice::GvrDevice(GvrDeviceProvider* provider,
+ base::WeakPtr<GvrDelegate> delegate)
+ : VRDevice(), delegate_(delegate), gvr_provider_(provider) {}
GvrDevice::~GvrDevice() {}
@@ -153,6 +155,9 @@ mojom::VRPosePtr GvrDevice::GetPose(VRServiceImpl* service) {
return pose;
}
+ if (!delegate_)
+ return nullptr;
+
gvr::ClockTimePoint target_time = gvr::GvrApi::GetTimePointNow();
target_time.monotonic_system_time_nanos += kPredictionTimeWithoutVsyncNanos;
@@ -245,7 +250,7 @@ void GvrDevice::UpdateLayerBounds(VRServiceImpl* service,
rightBounds->width, rightBounds->height);
}
-void GvrDevice::SetDelegate(GvrDelegate* delegate) {
+void GvrDevice::SetDelegate(base::WeakPtr<GvrDelegate> delegate) {
delegate_ = delegate;
// Notify the clients that this device has changed

Powered by Google App Engine
This is Rietveld 408576698