Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #ifndef CONTENT_BROWSER_GEOLOCATION_NETWORK_LOCATION_PROVIDER_H_ | 5 #ifndef CONTENT_BROWSER_GEOLOCATION_NETWORK_LOCATION_PROVIDER_H_ |
| 6 #define CONTENT_BROWSER_GEOLOCATION_NETWORK_LOCATION_PROVIDER_H_ | 6 #define CONTENT_BROWSER_GEOLOCATION_NETWORK_LOCATION_PROVIDER_H_ |
| 7 | 7 |
| 8 #include <list> | 8 #include <list> |
| 9 #include <map> | 9 #include <map> |
| 10 | 10 |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
| 13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 14 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
| 15 #include "base/strings/string16.h" | 15 #include "base/strings/string16.h" |
| 16 #include "base/threading/non_thread_safe.h" | 16 #include "base/threading/non_thread_safe.h" |
| 17 #include "base/threading/thread.h" | 17 #include "base/threading/thread.h" |
| 18 #include "content/browser/geolocation/location_provider_base.h" | 18 #include "content/browser/geolocation/location_provider_base.h" |
| 19 #include "content/browser/geolocation/network_location_request.h" | 19 #include "content/browser/geolocation/network_location_request.h" |
| 20 #include "content/browser/geolocation/wifi_data_provider.h" | 20 #include "content/browser/geolocation/wifi_data_provider_manager.h" |
| 21 #include "content/common/content_export.h" | 21 #include "content/common/content_export.h" |
| 22 #include "content/public/common/geoposition.h" | 22 #include "content/public/common/geoposition.h" |
| 23 | 23 |
| 24 namespace content { | 24 namespace content { |
| 25 class AccessTokenStore; | 25 class AccessTokenStore; |
| 26 | 26 |
| 27 | 27 |
| 28 class NetworkLocationProvider | 28 class NetworkLocationProvider |
| 29 : public base::NonThreadSafe, | 29 : public base::NonThreadSafe, |
| 30 public LocationProviderBase { | 30 public LocationProviderBase { |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 76 virtual void StopProvider() OVERRIDE; | 76 virtual void StopProvider() OVERRIDE; |
| 77 virtual void GetPosition(Geoposition *position) OVERRIDE; | 77 virtual void GetPosition(Geoposition *position) OVERRIDE; |
| 78 virtual void RequestRefresh() OVERRIDE; | 78 virtual void RequestRefresh() OVERRIDE; |
| 79 virtual void OnPermissionGranted() OVERRIDE; | 79 virtual void OnPermissionGranted() OVERRIDE; |
| 80 | 80 |
| 81 private: | 81 private: |
| 82 // Satisfies a position request from cache or network. | 82 // Satisfies a position request from cache or network. |
| 83 void RequestPosition(); | 83 void RequestPosition(); |
| 84 | 84 |
| 85 // Gets called when new wifi data is available. | 85 // Gets called when new wifi data is available. |
| 86 void OnWifiDataUpdate(WifiDataProvider* provider); | 86 void OnWifiDataUpdate(WifiDataProviderManager* provider); |
|
timvolodine
2014/08/18 15:21:42
provider -> manager as argument name would probabl
Michael van Ouwerkerk
2014/08/19 13:02:39
Done.
| |
| 87 | 87 |
| 88 // Internal helper used by OnWifiDataUpdate. | 88 // Internal helper used by OnWifiDataUpdate. |
| 89 void OnWifiDataUpdated(); | 89 void OnWifiDataUpdated(); |
| 90 | 90 |
| 91 bool IsStarted() const; | 91 bool IsStarted() const; |
| 92 | 92 |
| 93 void OnLocationResponse(const Geoposition& position, | 93 void OnLocationResponse(const Geoposition& position, |
| 94 bool server_error, | 94 bool server_error, |
| 95 const base::string16& access_token, | 95 const base::string16& access_token, |
| 96 const WifiData& wifi_data); | 96 const WifiData& wifi_data); |
| 97 | 97 |
| 98 scoped_refptr<AccessTokenStore> access_token_store_; | 98 scoped_refptr<AccessTokenStore> access_token_store_; |
| 99 | 99 |
| 100 // The wifi data provider, acquired via global factories. | 100 // The wifi data provider, acquired via global factories. |
| 101 WifiDataProvider* wifi_data_provider_; | 101 WifiDataProviderManager* wifi_data_provider_manager_; |
| 102 | 102 |
| 103 WifiDataProvider::WifiDataUpdateCallback wifi_data_update_callback_; | 103 WifiDataProviderManager::WifiDataUpdateCallback wifi_data_update_callback_; |
| 104 | 104 |
| 105 // The wifi data and a flag to indicate if the data set is complete. | 105 // The wifi data and a flag to indicate if the data set is complete. |
| 106 WifiData wifi_data_; | 106 WifiData wifi_data_; |
| 107 bool is_wifi_data_complete_; | 107 bool is_wifi_data_complete_; |
| 108 | 108 |
| 109 // The timestamp for the latest wifi data update. | 109 // The timestamp for the latest wifi data update. |
| 110 base::Time wifi_data_updated_timestamp_; | 110 base::Time wifi_data_updated_timestamp_; |
| 111 | 111 |
| 112 // Cached value loaded from the token store or set by a previous server | 112 // Cached value loaded from the token store or set by a previous server |
| 113 // response, and sent in each subsequent network request. | 113 // response, and sent in each subsequent network request. |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 136 // over the platform-dependent implementations. | 136 // over the platform-dependent implementations. |
| 137 CONTENT_EXPORT LocationProviderBase* NewNetworkLocationProvider( | 137 CONTENT_EXPORT LocationProviderBase* NewNetworkLocationProvider( |
| 138 AccessTokenStore* access_token_store, | 138 AccessTokenStore* access_token_store, |
| 139 net::URLRequestContextGetter* context, | 139 net::URLRequestContextGetter* context, |
| 140 const GURL& url, | 140 const GURL& url, |
| 141 const base::string16& access_token); | 141 const base::string16& access_token); |
| 142 | 142 |
| 143 } // namespace content | 143 } // namespace content |
| 144 | 144 |
| 145 #endif // CONTENT_BROWSER_GEOLOCATION_NETWORK_LOCATION_PROVIDER_H_ | 145 #endif // CONTENT_BROWSER_GEOLOCATION_NETWORK_LOCATION_PROVIDER_H_ |
| OLD | NEW |