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

Unified Diff: device/geolocation/network_location_provider.h

Issue 2820863002: Geolocation: cleanup NetworkLocationProvider (Closed)
Patch Set: scheib@ comment, method order restored 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
« no previous file with comments | « no previous file | device/geolocation/network_location_provider.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: device/geolocation/network_location_provider.h
diff --git a/device/geolocation/network_location_provider.h b/device/geolocation/network_location_provider.h
index dc3fb217f7f02ee2cea4df46e978b68cb2b936ac..634da9a966586d9da773fdab28217e6163525bce 100644
--- a/device/geolocation/network_location_provider.h
+++ b/device/geolocation/network_location_provider.h
@@ -15,8 +15,8 @@
#include "base/memory/ref_counted.h"
#include "base/memory/weak_ptr.h"
#include "base/strings/string16.h"
-#include "base/threading/non_thread_safe.h"
#include "base/threading/thread.h"
+#include "base/threading/thread_checker.h"
#include "device/geolocation/geolocation_export.h"
#include "device/geolocation/geoposition.h"
#include "device/geolocation/location_provider.h"
@@ -26,8 +26,7 @@
namespace device {
class AccessTokenStore;
-class NetworkLocationProvider : public base::NonThreadSafe,
- public LocationProvider {
+class NetworkLocationProvider : public LocationProvider {
public:
// Cache of recently resolved locations. Public for tests.
class DEVICE_GEOLOCATION_EXPORT PositionCache {
@@ -71,23 +70,20 @@ class NetworkLocationProvider : public base::NonThreadSafe,
~NetworkLocationProvider() override;
// LocationProvider implementation
- void SetUpdateCallback(
- const LocationProviderUpdateCallback& callback) override;
+ void SetUpdateCallback(const LocationProviderUpdateCallback& cb) override;
bool StartProvider(bool high_accuracy) override;
void StopProvider() override;
const Geoposition& GetPosition() override;
void OnPermissionGranted() override;
private:
- // Satisfies a position request from cache or network.
+ // Tries to update |position_| request from cache or network.
void RequestPosition();
- // Gets called when new wifi data is available.
+ // Gets called when new wifi data is available, either via explicit request to
+ // or callback from |wifi_data_provider_manager_|.
void OnWifiDataUpdate();
- // Internal helper used by OnWifiDataUpdate.
- void OnWifiDataUpdated();
-
bool IsStarted() const;
void OnLocationResponse(const Geoposition& position,
@@ -97,7 +93,8 @@ class NetworkLocationProvider : public base::NonThreadSafe,
const scoped_refptr<AccessTokenStore> access_token_store_;
- // The wifi data provider, acquired via global factories.
+ // The wifi data provider, acquired via global factories. Valid between
+ // StartProvider() and StopProvider(), and checked via IsStarted().
WifiDataProviderManager* wifi_data_provider_manager_;
WifiDataProviderManager::WifiDataUpdateCallback wifi_data_update_callback_;
@@ -125,11 +122,13 @@ class NetworkLocationProvider : public base::NonThreadSafe,
bool is_new_data_available_;
// The network location request object, and the url it uses.
- std::unique_ptr<NetworkLocationRequest> request_;
+ const std::unique_ptr<NetworkLocationRequest> request_;
// The cache of positions.
const std::unique_ptr<PositionCache> position_cache_;
+ base::ThreadChecker thread_checker_;
+
base::WeakPtrFactory<NetworkLocationProvider> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(NetworkLocationProvider);
« no previous file with comments | « no previous file | device/geolocation/network_location_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698