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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/vr_shell/VrShellDelegate.java

Issue 2898373005: Cache result of mVrDaydreamApi.isDaydreamCurrentViewer. (Closed)
Patch Set: Nit Created 3 years, 7 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/android/java/src/org/chromium/chrome/browser/vr_shell/VrShellDelegate.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/vr_shell/VrShellDelegate.java b/chrome/android/java/src/org/chromium/chrome/browser/vr_shell/VrShellDelegate.java
index 82f96c32d103c98920250cb675de89dacdd470e0..472cd505e534312999d67eb092e4088aad2da2dd 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/vr_shell/VrShellDelegate.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/vr_shell/VrShellDelegate.java
@@ -118,6 +118,7 @@ public class VrShellDelegate implements ApplicationStatus.ActivityStateListener,
private VrShell mVrShell;
private NonPresentingGvrContext mNonPresentingGvrContext;
private VrDaydreamApi mVrDaydreamApi;
+ private Boolean mIsDaydreamCurrentViewer;
private VrCoreVersionChecker mVrCoreVersionChecker;
private TabModelSelector mTabModelSelector;
@@ -703,7 +704,7 @@ public class VrShellDelegate implements ApplicationStatus.ActivityStateListener,
if (mInVr) return ENTER_VR_NOT_NECESSARY;
if (!canEnterVr(mActivity.getActivityTab())) return ENTER_VR_CANCELLED;
- if (mVrSupportLevel == VR_CARDBOARD || !mVrDaydreamApi.isDaydreamCurrentViewer()) {
+ if (mVrSupportLevel == VR_CARDBOARD || !isDaydreamCurrentViewer()) {
// Avoid using launchInVr which would trigger DON flow regardless current viewer type
// due to the lack of support for unexported activities.
enterVr(false);
@@ -723,9 +724,9 @@ public class VrShellDelegate implements ApplicationStatus.ActivityStateListener,
@CalledByNative
private boolean exitWebVRPresent() {
if (!mInVr) return false;
- if (!isVrShellEnabled(mVrSupportLevel) || !mVrDaydreamApi.isDaydreamCurrentViewer()
+ if (!isVrShellEnabled(mVrSupportLevel) || !isDaydreamCurrentViewer()
|| !activitySupportsVrBrowsing(mActivity)) {
- if (mVrDaydreamApi.isDaydreamCurrentViewer()
+ if (isDaydreamCurrentViewer()
&& mVrDaydreamApi.exitFromVr(EXIT_VR_RESULT, new Intent())) {
mShowingDaydreamDoff = true;
return false;
@@ -767,7 +768,7 @@ public class VrShellDelegate implements ApplicationStatus.ActivityStateListener,
return;
}
- if (mVrDaydreamApi.isDaydreamCurrentViewer()
+ if (isDaydreamCurrentViewer()
&& mLastVrExit + REENTER_VR_TIMEOUT_MS > SystemClock.uptimeMillis()) {
mDonSucceeded = true;
}
@@ -815,6 +816,7 @@ public class VrShellDelegate implements ApplicationStatus.ActivityStateListener,
// home, pause instead of exiting VR here. For now, because VR Apps shouldn't show up in the
// non-VR recents, and we don't want ChromeTabbedActivity disappearing, exit VR.
shutdownVr(true /* disableVrMode */, true /* canReenter */, false /* stayingInChrome */);
+ mIsDaydreamCurrentViewer = null;
}
private boolean onBackPressedInternal() {
@@ -843,6 +845,13 @@ public class VrShellDelegate implements ApplicationStatus.ActivityStateListener,
mExitingCct = false;
}
+ private boolean isDaydreamCurrentViewer() {
+ if (mIsDaydreamCurrentViewer == null) {
+ mIsDaydreamCurrentViewer = mVrDaydreamApi.isDaydreamCurrentViewer();
+ }
+ return mIsDaydreamCurrentViewer;
+ }
+
@CalledByNative
private long createNonPresentingNativeContext() {
if (mVrClassesWrapper == null) return 0;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698