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

Side by Side Diff: chrome/test/android/javatests/src/org/chromium/chrome/test/ChromeInstrumentationTestRunner.java

Issue 2727873002: Implement lazy initialization for VrShellDelegate (Closed)
Patch Set: Fix FindBugs errors - neat! Created 3 years, 9 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 unified diff | Download patch
« no previous file with comments | « chrome/browser/android/vr_shell/vr_shell_gl.h ('k') | device/vr/android/gvr/gvr_delegate.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package org.chromium.chrome.test; 5 package org.chromium.chrome.test;
6 6
7 import android.content.Context; 7 import android.content.Context;
8 import android.os.Build; 8 import android.os.Build;
9 import android.os.Bundle; 9 import android.os.Bundle;
10 import android.text.TextUtils; 10 import android.text.TextUtils;
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 mAttemptedToGetApi = true; 71 mAttemptedToGetApi = true;
72 try { 72 try {
73 Class<? extends VrClassesWrapper> vrClassesBuilderClass = 73 Class<? extends VrClassesWrapper> vrClassesBuilderClass =
74 (Class<? extends VrClassesWrapper>) Class.forName( 74 (Class<? extends VrClassesWrapper>) Class.forName(
75 "org.chromium.chrome.browser.vr_shell.VrClas sesWrapperImpl"); 75 "org.chromium.chrome.browser.vr_shell.VrClas sesWrapperImpl");
76 Constructor<?> vrClassesBuilderConstructor = 76 Constructor<?> vrClassesBuilderConstructor =
77 vrClassesBuilderClass.getConstructor(Context.class); 77 vrClassesBuilderClass.getConstructor(Context.class);
78 VrClassesWrapper vrClassesBuilder = 78 VrClassesWrapper vrClassesBuilder =
79 (VrClassesWrapper) vrClassesBuilderConstructor.newIn stance( 79 (VrClassesWrapper) vrClassesBuilderConstructor.newIn stance(
80 getTargetContext()); 80 getTargetContext());
81 mDaydreamApi = vrClassesBuilder.createVrDaydreamApi(); 81 mDaydreamApi = vrClassesBuilder.createVrDaydreamApi(getTarge tContext());
82 } catch (ClassNotFoundException | InstantiationException | Illeg alAccessException 82 } catch (ClassNotFoundException | InstantiationException | Illeg alAccessException
83 | IllegalArgumentException | InvocationTargetException 83 | IllegalArgumentException | InvocationTargetException
84 | NoSuchMethodException e) { 84 | NoSuchMethodException e) {
85 return null; 85 return null;
86 } 86 }
87 } 87 }
88 return mDaydreamApi; 88 return mDaydreamApi;
89 } 89 }
90 90
91 private boolean isDaydreamReady() { 91 private boolean isDaydreamReady() {
92 return getDaydreamApi() == null ? false : 92 return getDaydreamApi() == null ? false :
93 getDaydreamApi().isDaydreamReadyDevice(); 93 getDaydreamApi().isDaydreamReadyDevice();
94 } 94 }
95 95
96 private boolean isDaydreamViewPaired() { 96 private boolean isDaydreamViewPaired() {
97 if (getDaydreamApi() == null) { 97 if (getDaydreamApi() == null) {
98 return false; 98 return false;
99 } 99 }
100 // isDaydreamCurrentViewer() creates a concrete instance of Daydream Api, 100 // isDaydreamCurrentViewer() creates a concrete instance of Daydream Api,
101 // which can only be done on the main thread 101 // which can only be done on the main thread
102 FutureTask<Boolean> checker = new FutureTask<Boolean>(new Callable<B oolean>() { 102 FutureTask<Boolean> checker = new FutureTask<>(new Callable<Boolean> () {
103 @Override 103 @Override
104 public Boolean call() { 104 public Boolean call() {
105 return getDaydreamApi().isDaydreamCurrentViewer(); 105 return getDaydreamApi().isDaydreamCurrentViewer();
106 } 106 }
107 }); 107 });
108 ThreadUtils.runOnUiThreadBlocking(checker); 108 ThreadUtils.runOnUiThreadBlocking(checker);
109 try { 109 try {
110 return checker.get().booleanValue(); 110 return checker.get().booleanValue();
111 } catch (CancellationException | InterruptedException | ExecutionExc eption 111 } catch (CancellationException | InterruptedException | ExecutionExc eption
112 | IllegalArgumentException e) { 112 | IllegalArgumentException e) {
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 return true; 198 return true;
199 } 199 }
200 if (TextUtils.equals(type, ChromeDisableIf.LARGETABLET) 200 if (TextUtils.equals(type, ChromeDisableIf.LARGETABLET)
201 && DeviceFormFactor.isLargeTablet(getTargetContext())) { 201 && DeviceFormFactor.isLargeTablet(getTargetContext())) {
202 return true; 202 return true;
203 } 203 }
204 return false; 204 return false;
205 } 205 }
206 } 206 }
207 } 207 }
OLDNEW
« no previous file with comments | « chrome/browser/android/vr_shell/vr_shell_gl.h ('k') | device/vr/android/gvr/gvr_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698