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

Side by Side Diff: chrome/browser/geolocation/network_location_provider.cc

Issue 603040: Add support for top level geolocation arbitrator, and access token persistenc... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 10 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 | Annotate | Revision Log
OLDNEW
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 #include "chrome/browser/geolocation/network_location_provider.h" 5 #include "chrome/browser/geolocation/network_location_provider.h"
6 6
7 #include "base/time.h" 7 #include "base/time.h"
8 #include "chrome/browser/geolocation/access_token_store.h"
8 9
9 namespace { 10 namespace {
10 // The maximum period of time we'll wait for a complete set of device data 11 // The maximum period of time we'll wait for a complete set of device data
11 // before sending the request. 12 // before sending the request.
12 const int kDataCompleteWaitPeriod = 1000 * 2; // 2 seconds 13 const int kDataCompleteWaitPeriod = 1000 * 2; // 2 seconds
13 14
14 // The maximum size of the cache of positions for previously requested device 15 // The maximum size of the cache of positions for previously requested device
15 // data. 16 // data.
16 const size_t kMaximumCacheSize = 10; 17 const size_t kMaximumCacheSize = 10;
17 18
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 // a string that represents a set of device data, the other is keyed on the 97 // a string that represents a set of device data, the other is keyed on the
97 // timestamp of the position. 98 // timestamp of the position.
98 typedef std::map<string16, Position> CacheMap; 99 typedef std::map<string16, Position> CacheMap;
99 CacheMap cache_; 100 CacheMap cache_;
100 typedef std::map<int64, CacheMap::iterator> CacheTimesMap; 101 typedef std::map<int64, CacheMap::iterator> CacheTimesMap;
101 CacheTimesMap cache_times_; 102 CacheTimesMap cache_times_;
102 }; 103 };
103 104
104 // NetworkLocationProvider factory function 105 // NetworkLocationProvider factory function
105 LocationProviderBase* NewNetworkLocationProvider( 106 LocationProviderBase* NewNetworkLocationProvider(
106 LocationProviderBase::AccessTokenStore* access_token_store, 107 AccessTokenStore* access_token_store,
107 URLRequestContextGetter* context, 108 URLRequestContextGetter* context,
108 const GURL& url, 109 const GURL& url,
109 const string16& host_name) { 110 const string16& host_name) {
110 return new NetworkLocationProvider(access_token_store, context, 111 return new NetworkLocationProvider(access_token_store, context,
111 url, host_name); 112 url, host_name);
112 } 113 }
113 114
114 // NetworkLocationProvider 115 // NetworkLocationProvider
115 NetworkLocationProvider::NetworkLocationProvider( 116 NetworkLocationProvider::NetworkLocationProvider(
116 AccessTokenStore* access_token_store, 117 AccessTokenStore* access_token_store,
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 void NetworkLocationProvider::OnDeviceDataUpdated() { 281 void NetworkLocationProvider::OnDeviceDataUpdated() {
281 DCHECK(CalledOnValidThread()); 282 DCHECK(CalledOnValidThread());
282 device_data_updated_timestamp_ = GetCurrentTimeMillis(); 283 device_data_updated_timestamp_ = GetCurrentTimeMillis();
283 284
284 is_new_data_available_ = is_radio_data_complete_ || is_radio_data_complete_; 285 is_new_data_available_ = is_radio_data_complete_ || is_radio_data_complete_;
285 if (delayed_start_task_.empty() || 286 if (delayed_start_task_.empty() ||
286 (is_radio_data_complete_ && is_radio_data_complete_)) { 287 (is_radio_data_complete_ && is_radio_data_complete_)) {
287 UpdatePosition(); 288 UpdatePosition();
288 } 289 }
289 } 290 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698