| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 CHROME_BROWSER_GEOLOCATION_NETWORK_LOCATION_PROVIDER_H_ | 5 #ifndef CHROME_BROWSER_GEOLOCATION_NETWORK_LOCATION_PROVIDER_H_ |
| 6 #define CHROME_BROWSER_GEOLOCATION_NETWORK_LOCATION_PROVIDER_H_ | 6 #define CHROME_BROWSER_GEOLOCATION_NETWORK_LOCATION_PROVIDER_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/ref_counted.h" | 12 #include "base/ref_counted.h" |
| 13 #include "base/scoped_ptr.h" | 13 #include "base/scoped_ptr.h" |
| 14 #include "base/string16.h" | 14 #include "base/string16.h" |
| 15 #include "base/thread.h" | 15 #include "base/thread.h" |
| 16 #include "chrome/browser/geolocation/device_data_provider.h" | 16 #include "chrome/browser/geolocation/device_data_provider.h" |
| 17 #include "chrome/browser/geolocation/location_provider.h" | 17 #include "chrome/browser/geolocation/location_provider.h" |
| 18 #include "chrome/browser/geolocation/network_location_request.h" | 18 #include "chrome/browser/geolocation/network_location_request.h" |
| 19 #include "chrome/common/geoposition.h" | 19 #include "chrome/common/geoposition.h" |
| 20 | 20 |
| 21 class URLFetcherProtectEntry; | 21 class URLFetcherProtectEntry; |
| 22 | 22 |
| 23 class NetworkLocationProvider | 23 class NetworkLocationProvider |
| 24 : public LocationProviderBase, | 24 : public LocationProviderBase, |
| 25 public GatewayDataProvider::ListenerInterface, |
| 25 public RadioDataProvider::ListenerInterface, | 26 public RadioDataProvider::ListenerInterface, |
| 26 public WifiDataProvider::ListenerInterface, | 27 public WifiDataProvider::ListenerInterface, |
| 27 public NetworkLocationRequest::ListenerInterface { | 28 public NetworkLocationRequest::ListenerInterface { |
| 28 public: | 29 public: |
| 29 NetworkLocationProvider(AccessTokenStore* access_token_store, | 30 NetworkLocationProvider(AccessTokenStore* access_token_store, |
| 30 URLRequestContextGetter* context, | 31 URLRequestContextGetter* context, |
| 31 const GURL& url, | 32 const GURL& url, |
| 32 const string16& access_token); | 33 const string16& access_token); |
| 33 virtual ~NetworkLocationProvider(); | 34 virtual ~NetworkLocationProvider(); |
| 34 | 35 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 45 | 46 |
| 46 // Satisfies a position request from cache or network. | 47 // Satisfies a position request from cache or network. |
| 47 void RequestPosition(); | 48 void RequestPosition(); |
| 48 | 49 |
| 49 // Internal helper used by DeviceDataUpdateAvailable | 50 // Internal helper used by DeviceDataUpdateAvailable |
| 50 void OnDeviceDataUpdated(); | 51 void OnDeviceDataUpdated(); |
| 51 | 52 |
| 52 bool IsStarted() const; | 53 bool IsStarted() const; |
| 53 | 54 |
| 54 // DeviceDataProvider::ListenerInterface implementation. | 55 // DeviceDataProvider::ListenerInterface implementation. |
| 56 virtual void DeviceDataUpdateAvailable(GatewayDataProvider* provider); |
| 55 virtual void DeviceDataUpdateAvailable(RadioDataProvider* provider); | 57 virtual void DeviceDataUpdateAvailable(RadioDataProvider* provider); |
| 56 virtual void DeviceDataUpdateAvailable(WifiDataProvider* provider); | 58 virtual void DeviceDataUpdateAvailable(WifiDataProvider* provider); |
| 57 | 59 |
| 58 // NetworkLocationRequest::ListenerInterface implementation. | 60 // NetworkLocationRequest::ListenerInterface implementation. |
| 59 virtual void LocationResponseAvailable(const Geoposition& position, | 61 virtual void LocationResponseAvailable(const Geoposition& position, |
| 60 bool server_error, | 62 bool server_error, |
| 61 const string16& access_token, | 63 const string16& access_token, |
| 64 const GatewayData& gateway_data, |
| 62 const RadioData& radio_data, | 65 const RadioData& radio_data, |
| 63 const WifiData& wifi_data); | 66 const WifiData& wifi_data); |
| 64 | 67 |
| 65 scoped_refptr<AccessTokenStore> access_token_store_; | 68 scoped_refptr<AccessTokenStore> access_token_store_; |
| 66 | 69 |
| 67 // The device data providers, acquired via global factories. | 70 // The device data providers, acquired via global factories. |
| 71 GatewayDataProvider* gateway_data_provider_; |
| 68 RadioDataProvider* radio_data_provider_; | 72 RadioDataProvider* radio_data_provider_; |
| 69 WifiDataProvider* wifi_data_provider_; | 73 WifiDataProvider* wifi_data_provider_; |
| 70 | 74 |
| 71 // The radio and wifi data, flags to indicate if each data set is complete. | 75 // The radio and wifi data, flags to indicate if each data set is complete. |
| 76 GatewayData gateway_data_; |
| 72 RadioData radio_data_; | 77 RadioData radio_data_; |
| 73 WifiData wifi_data_; | 78 WifiData wifi_data_; |
| 79 bool is_gateway_data_complete_; |
| 74 bool is_radio_data_complete_; | 80 bool is_radio_data_complete_; |
| 75 bool is_wifi_data_complete_; | 81 bool is_wifi_data_complete_; |
| 76 | 82 |
| 77 // The timestamp for the latest device data update. | 83 // The timestamp for the latest device data update. |
| 78 base::Time device_data_updated_timestamp_; | 84 base::Time device_data_updated_timestamp_; |
| 79 | 85 |
| 80 // Cached value loaded from the token store or set by a previous server | 86 // Cached value loaded from the token store or set by a previous server |
| 81 // response, and sent in each subsequent network request. | 87 // response, and sent in each subsequent network request. |
| 82 string16 access_token_; | 88 string16 access_token_; |
| 83 | 89 |
| 84 // The current best position estimate. | 90 // The current best position estimate. |
| 85 Geoposition position_; | 91 Geoposition position_; |
| 86 | 92 |
| 87 bool is_new_data_available_; | 93 bool is_new_data_available_; |
| 88 | 94 |
| 89 std::string most_recent_authorized_host_; | 95 std::string most_recent_authorized_host_; |
| 90 | 96 |
| 91 // The network location request object, and the url it uses. | 97 // The network location request object, and the url it uses. |
| 92 scoped_ptr<NetworkLocationRequest> request_; | 98 scoped_ptr<NetworkLocationRequest> request_; |
| 93 | 99 |
| 94 ScopedRunnableMethodFactory<NetworkLocationProvider> delayed_start_task_; | 100 ScopedRunnableMethodFactory<NetworkLocationProvider> delayed_start_task_; |
| 95 // The cache of positions. | 101 // The cache of positions. |
| 96 scoped_ptr<PositionCache> position_cache_; | 102 scoped_ptr<PositionCache> position_cache_; |
| 97 | 103 |
| 98 DISALLOW_COPY_AND_ASSIGN(NetworkLocationProvider); | 104 DISALLOW_COPY_AND_ASSIGN(NetworkLocationProvider); |
| 99 }; | 105 }; |
| 100 | 106 |
| 101 #endif // CHROME_BROWSER_GEOLOCATION_NETWORK_LOCATION_PROVIDER_H_ | 107 #endif // CHROME_BROWSER_GEOLOCATION_NETWORK_LOCATION_PROVIDER_H_ |
| OLD | NEW |