| 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 DEVICE_GEOLOCATION_NETWORK_LOCATION_PROVIDER_H_ | 5 #ifndef DEVICE_GEOLOCATION_NETWORK_LOCATION_PROVIDER_H_ |
| 6 #define DEVICE_GEOLOCATION_NETWORK_LOCATION_PROVIDER_H_ | 6 #define DEVICE_GEOLOCATION_NETWORK_LOCATION_PROVIDER_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include <list> | 10 #include <list> |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 // The maximum size of the cache of positions. | 35 // The maximum size of the cache of positions. |
| 36 static const size_t kMaximumSize; | 36 static const size_t kMaximumSize; |
| 37 | 37 |
| 38 PositionCache(); | 38 PositionCache(); |
| 39 ~PositionCache(); | 39 ~PositionCache(); |
| 40 | 40 |
| 41 // Caches the current position response for the current set of cell ID and | 41 // Caches the current position response for the current set of cell ID and |
| 42 // WiFi data. In the case of the cache exceeding kMaximumSize this will | 42 // WiFi data. In the case of the cache exceeding kMaximumSize this will |
| 43 // evict old entries in FIFO orderer of being added. | 43 // evict old entries in FIFO orderer of being added. |
| 44 // Returns true on success, false otherwise. | 44 // Returns true on success, false otherwise. |
| 45 bool CachePosition(const WifiData& wifi_data, | 45 bool CachePosition(const WifiData& wifi_data, const Geoposition& position); |
| 46 const Geoposition& position); | |
| 47 | 46 |
| 48 // Searches for a cached position response for the current set of data. | 47 // Searches for a cached position response for the current set of data. |
| 49 // Returns NULL if the position is not in the cache, or the cached | 48 // Returns NULL if the position is not in the cache, or the cached |
| 50 // position if available. Ownership remains with the cache. | 49 // position if available. Ownership remains with the cache. |
| 51 const Geoposition* FindPosition(const WifiData& wifi_data); | 50 const Geoposition* FindPosition(const WifiData& wifi_data); |
| 52 | 51 |
| 53 private: | 52 private: |
| 54 // Makes the key for the map of cached positions, using a set of | 53 // Makes the key for the map of cached positions, using a set of |
| 55 // data. Returns true if a good key was generated, false otherwise. | 54 // data. Returns true if a good key was generated, false otherwise. |
| 56 static bool MakeKey(const WifiData& wifi_data, | 55 static bool MakeKey(const WifiData& wifi_data, base::string16* key); |
| 57 base::string16* key); | |
| 58 | 56 |
| 59 // The cache of positions. This is stored as a map keyed on a string that | 57 // The cache of positions. This is stored as a map keyed on a string that |
| 60 // represents a set of data, and a list to provide | 58 // represents a set of data, and a list to provide |
| 61 // least-recently-added eviction. | 59 // least-recently-added eviction. |
| 62 typedef std::map<base::string16, Geoposition> CacheMap; | 60 typedef std::map<base::string16, Geoposition> CacheMap; |
| 63 CacheMap cache_; | 61 CacheMap cache_; |
| 64 typedef std::list<CacheMap::iterator> CacheAgeList; | 62 typedef std::list<CacheMap::iterator> CacheAgeList; |
| 65 CacheAgeList cache_age_list_; // Oldest first. | 63 CacheAgeList cache_age_list_; // Oldest first. |
| 66 }; | 64 }; |
| 67 | 65 |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 // over the platform-dependent implementations. | 135 // over the platform-dependent implementations. |
| 138 DEVICE_GEOLOCATION_EXPORT LocationProviderBase* NewNetworkLocationProvider( | 136 DEVICE_GEOLOCATION_EXPORT LocationProviderBase* NewNetworkLocationProvider( |
| 139 const scoped_refptr<AccessTokenStore>& access_token_store, | 137 const scoped_refptr<AccessTokenStore>& access_token_store, |
| 140 const scoped_refptr<net::URLRequestContextGetter>& context, | 138 const scoped_refptr<net::URLRequestContextGetter>& context, |
| 141 const GURL& url, | 139 const GURL& url, |
| 142 const base::string16& access_token); | 140 const base::string16& access_token); |
| 143 | 141 |
| 144 } // namespace device | 142 } // namespace device |
| 145 | 143 |
| 146 #endif // DEVICE_GEOLOCATION_NETWORK_LOCATION_PROVIDER_H_ | 144 #endif // DEVICE_GEOLOCATION_NETWORK_LOCATION_PROVIDER_H_ |
| OLD | NEW |