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

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

Issue 2317483002: Add support of vrdisplayconnect and vrdisplaydisconnect event (Closed)
Patch Set: Fix typo of Event reason Created 4 years, 3 months 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 2de6b12f0c8de234f8cee89354b35d8e0b0028d3..2357e785da9b9dd90670c6d582cf12bf669ee210 100644
--- a/device/vr/android/gvr/gvr_device.cc
+++ b/device/vr/android/gvr/gvr_device.cc
@@ -23,7 +23,9 @@ static const uint64_t kPredictionTimeWithoutVsyncNanos = 50000000;
} // namespace
GvrDevice::GvrDevice(VRDeviceProvider* provider, gvr::GvrApi* gvr_api)
- : VRDevice(provider), gvr_api_(gvr_api) {}
+ : VRDevice(provider), gvr_api_(gvr_api) {
+ isConnected = false;
+}
GvrDevice::~GvrDevice() {}
@@ -133,4 +135,22 @@ void GvrDevice::ResetPose() {
gvr_api_->ResetTracking();
}
+// There are two conditions which hint that connection status has been changed.
+// First, if the GvrApi pointer is valid and nativeContext could be acquired,
+// the
mthiesse 2016/09/06 23:39:24 nit: fix comment formatting.
+// connection may be built.
+// Second, if the GvrApi pointer is invalid or nativeContext couldn't be
+// acquired, the
+// connection may be lost.
+void GvrDevice::PollEvents() {
bajones 2016/09/06 23:57:26 Sorry, I'm also realizing that this is a signal th
shaobo.yan 2016/09/07 00:49:19 Hi, brandon, thx for reviewing! I agree that OnGvr
+ if (!client())
+ return;
+
+ if ((!isConnected && gvr_api_ && gvr_api_->GetContext()) ||
+ (isConnected && (!gvr_api_ || (gvr_api_ && !gvr_api_->GetContext())))) {
+ isConnected = !isConnected;
+ client()->OnDeviceConnectionStatusChanged(this, isConnected);
+ }
+}
+
} // namespace device

Powered by Google App Engine
This is Rietveld 408576698