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

Unified Diff: device/geolocation/android/java/src/org/chromium/device/geolocation/LocationProviderFactory.java

Issue 2809813002: GeoLocation: add support for GmsCore location provider (Closed)
Patch Set: Parameterized test and removed unused variable assignment Created 3 years, 8 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/geolocation/android/java/src/org/chromium/device/geolocation/LocationProviderFactory.java
diff --git a/device/geolocation/android/java/src/org/chromium/device/geolocation/LocationProviderFactory.java b/device/geolocation/android/java/src/org/chromium/device/geolocation/LocationProviderFactory.java
index 3ffc36af9dbcdfa4e6d41a423772a568009bad44..bf80cae4e4af2536dabe7c992cafa0eafe56799f 100644
--- a/device/geolocation/android/java/src/org/chromium/device/geolocation/LocationProviderFactory.java
+++ b/device/geolocation/android/java/src/org/chromium/device/geolocation/LocationProviderFactory.java
@@ -9,8 +9,7 @@ import android.content.Context;
import org.chromium.base.VisibleForTesting;
/**
- * Factory to create a LocationProvider to allow us to inject
- * a mock for tests.
+ * Factory to create a LocationProvider to allow us to inject a mock for tests.
*/
public class LocationProviderFactory {
private static LocationProviderFactory.LocationProvider sProviderImpl;
@@ -20,8 +19,9 @@ public class LocationProviderFactory {
*/
public interface LocationProvider {
/**
- * Start listening for location updates.
- * @param enableHighAccuracy Whether or not to enable high accuracy location providers.
+ * Start listening for location updates. Calling several times before stop() is interpreted
+ * as restart.
+ * @param enableHighAccuracy Whether or not to enable high accuracy location.
*/
public void start(boolean enableHighAccuracy);
@@ -40,11 +40,13 @@ public class LocationProviderFactory {
@VisibleForTesting
public static void setLocationProviderImpl(LocationProviderFactory.LocationProvider provider) {
Reilly Grant (use Gerrit) 2017/04/20 00:53:32 I'm confused that we have both this and LocationPr
mcasas 2017/04/20 15:05:16 There's several levels of injection for testing.
- assert sProviderImpl == null;
sProviderImpl = provider;
}
public static LocationProvider create(Context context) {
+ if (sProviderImpl != null) return sProviderImpl;
+
+ sProviderImpl = new LocationProviderGmsCore(context);
if (sProviderImpl == null) {
agrieve 2017/04/20 15:22:23 This will never be true since it's assigned on the
mcasas 2017/04/20 18:59:32 Hmm yeah, that's not what I meant. Added a stati
sProviderImpl = new LocationProviderAndroid(context);
}

Powered by Google App Engine
This is Rietveld 408576698