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

Side by Side Diff: content/public/android/java/src/org/chromium/content/browser/LocationProviderFactory.java

Issue 546633004: Refactoring the code for location manager. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Changes according to review Created 6 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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.content.browser; 5 package org.chromium.content.browser;
6 6
7 import android.content.Context; 7 import android.content.Context;
8 import android.location.Criteria; 8 import android.location.Criteria;
9 import android.location.Location; 9 import android.location.Location;
10 import android.location.LocationListener; 10 import android.location.LocationListener;
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 ensureLocationManagerCreated(); 143 ensureLocationManagerCreated();
144 if (usePassiveOneShotLocation()) return; 144 if (usePassiveOneShotLocation()) return;
145 145
146 assert !mIsRunning; 146 assert !mIsRunning;
147 mIsRunning = true; 147 mIsRunning = true;
148 148
149 // We're running on the main thread. The C++ side is responsible to 149 // We're running on the main thread. The C++ side is responsible to
150 // bounce notifications to the Geolocation thread as they arrive in the mainLooper. 150 // bounce notifications to the Geolocation thread as they arrive in the mainLooper.
151 try { 151 try {
152 Criteria criteria = new Criteria(); 152 Criteria criteria = new Criteria();
153 if (isGpsEnabled)
154 criteria.setAccuracy(Criteria.ACCURACY_FINE);
jdduke (slow) 2014/09/07 13:19:26 The if body should be on the same line as the if c
153 mLocationManager.requestLocationUpdates(0, 0, criteria, this, 155 mLocationManager.requestLocationUpdates(0, 0, criteria, this,
154 ThreadUtils.getUiThreadLooper()); 156 ThreadUtils.getUiThreadLooper());
155 if (isGpsEnabled) {
156 criteria.setAccuracy(Criteria.ACCURACY_FINE);
157 mLocationManager.requestLocationUpdates(0, 0, criteria, this ,
158 ThreadUtils.getUiThreadLooper());
159 }
160 } catch (SecurityException e) { 157 } catch (SecurityException e) {
161 Log.e(TAG, "Caught security exception registering for location u pdates from " + 158 Log.e(TAG, "Caught security exception registering for location u pdates from " +
162 "system. This should only happen in DumpRenderTree."); 159 "system. This should only happen in DumpRenderTree.");
163 } catch (IllegalArgumentException e) { 160 } catch (IllegalArgumentException e) {
164 Log.e(TAG, "Caught IllegalArgumentException registering for loca tion updates."); 161 Log.e(TAG, "Caught IllegalArgumentException registering for loca tion updates.");
165 } 162 }
166 } 163 }
167 164
168 /** 165 /**
169 * Unregisters this object from the location service. 166 * Unregisters this object from the location service.
(...skipping 30 matching lines...) Expand all
200 */ 197 */
201 private boolean isOnlyPassiveLocationProviderEnabled() { 198 private boolean isOnlyPassiveLocationProviderEnabled() {
202 List<String> providers = mLocationManager.getProviders(true); 199 List<String> providers = mLocationManager.getProviders(true);
203 return providers != null && providers.size() == 1 200 return providers != null && providers.size() == 1
204 && providers.get(0).equals(LocationManager.PASSIVE_PROVIDER) ; 201 && providers.get(0).equals(LocationManager.PASSIVE_PROVIDER) ;
205 } 202 }
206 } 203 }
207 } 204 }
208 205
209 206
OLDNEW
« 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