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

Unified Diff: device/vr/android/java/src/org/chromium/device/vr/GvrDeviceProvider.java

Issue 2343023002: Switch WebVR to handle GvrApi management through VrShellDelegate (Closed)
Patch Set: Renamed onNativeLibraryReady to initializeNative 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
« no previous file with comments | « device/vr/android/gvr/gvr_device_provider.cc ('k') | device/vr/vr_client_dispatcher.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: device/vr/android/java/src/org/chromium/device/vr/GvrDeviceProvider.java
diff --git a/device/vr/android/java/src/org/chromium/device/vr/GvrDeviceProvider.java b/device/vr/android/java/src/org/chromium/device/vr/GvrDeviceProvider.java
index bf7db8ce024499e4c26392c0b133bf40ed8bbfd3..ba4f44c96acd2b8580ae7b2a2553587401d64c80 100644
--- a/device/vr/android/java/src/org/chromium/device/vr/GvrDeviceProvider.java
+++ b/device/vr/android/java/src/org/chromium/device/vr/GvrDeviceProvider.java
@@ -5,9 +5,11 @@
package org.chromium.device.vr;
import android.content.Context;
+import android.os.StrictMode;
import com.google.vr.ndk.base.GvrLayout;
+import org.chromium.base.Log;
import org.chromium.base.annotations.CalledByNative;
import org.chromium.base.annotations.JNINamespace;
@@ -18,21 +20,9 @@ import org.chromium.base.annotations.JNINamespace;
class GvrDeviceProvider {
private static final String TAG = "GvrDeviceProvider";
private final GvrLayout mLayout;
- private Thread mGvrInitThread;
private GvrDeviceProvider(Context context) {
mLayout = new GvrLayout(context);
-
- // Initialize the GVR API on a separate thread to avoid strict mode
- // violations. Note that this doesn't fix the underlying issue of
- // blocking on disk reads here.
- mGvrInitThread = new Thread(new Runnable() {
- @Override
- public void run() {
- mLayout.getGvrApi();
- }
- });
- mGvrInitThread.start();
}
@CalledByNative
@@ -42,11 +32,20 @@ class GvrDeviceProvider {
@CalledByNative
private long getNativeContext() {
+ long nativeGvrContext = 0;
+
+ StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskReads();
+
try {
- mGvrInitThread.join();
+ nativeGvrContext = mLayout.getGvrApi().getNativeGvrContext();
} catch (Exception ex) {
+ Log.e(TAG, "Unable to instantiate GvrApi", ex);
+ return 0;
+ } finally {
+ StrictMode.setThreadPolicy(oldPolicy);
}
- return mLayout.getGvrApi().getNativeGvrContext();
+
+ return nativeGvrContext;
}
@CalledByNative
« no previous file with comments | « device/vr/android/gvr/gvr_device_provider.cc ('k') | device/vr/vr_client_dispatcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698