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

Side by Side Diff: content/browser/geolocation/location_arbitrator_impl.cc

Issue 477633002: Rename various Geolocation bits for clarity and consistency. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: One more rename. Created 6 years, 4 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) 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 #include "content/browser/geolocation/location_arbitrator_impl.h" 5 #include "content/browser/geolocation/location_arbitrator_impl.h"
6 6
7 #include <map> 7 #include <map>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 10 matching lines...) Expand all
21 "https://www.googleapis.com/geolocation/v1/geolocate"; 21 "https://www.googleapis.com/geolocation/v1/geolocate";
22 } // namespace 22 } // namespace
23 23
24 // To avoid oscillations, set this to twice the expected update interval of a 24 // To avoid oscillations, set this to twice the expected update interval of a
25 // a GPS-type location provider (in case it misses a beat) plus a little. 25 // a GPS-type location provider (in case it misses a beat) plus a little.
26 const int64 LocationArbitratorImpl::kFixStaleTimeoutMilliseconds = 26 const int64 LocationArbitratorImpl::kFixStaleTimeoutMilliseconds =
27 11 * base::Time::kMillisecondsPerSecond; 27 11 * base::Time::kMillisecondsPerSecond;
28 28
29 LocationArbitratorImpl::LocationArbitratorImpl( 29 LocationArbitratorImpl::LocationArbitratorImpl(
30 const LocationUpdateCallback& callback) 30 const LocationUpdateCallback& callback)
31 : callback_(callback), 31 : arbitrator_update_callback_(callback),
32 provider_callback_( 32 provider_update_callback_(
33 base::Bind(&LocationArbitratorImpl::LocationUpdateAvailable, 33 base::Bind(&LocationArbitratorImpl::OnLocationUpdate,
34 base::Unretained(this))), 34 base::Unretained(this))),
35 position_provider_(NULL), 35 position_provider_(NULL),
36 is_permission_granted_(false), 36 is_permission_granted_(false),
37 is_running_(false) { 37 is_running_(false) {
38 } 38 }
39 39
40 LocationArbitratorImpl::~LocationArbitratorImpl() { 40 LocationArbitratorImpl::~LocationArbitratorImpl() {
41 } 41 }
42 42
43 GURL LocationArbitratorImpl::DefaultNetworkProviderURL() { 43 GURL LocationArbitratorImpl::DefaultNetworkProviderURL() {
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 if (!provider) 109 if (!provider)
110 provider = NewSystemLocationProvider(); 110 provider = NewSystemLocationProvider();
111 RegisterProvider(provider); 111 RegisterProvider(provider);
112 DoStartProviders(); 112 DoStartProviders();
113 } 113 }
114 114
115 void LocationArbitratorImpl::RegisterProvider( 115 void LocationArbitratorImpl::RegisterProvider(
116 LocationProvider* provider) { 116 LocationProvider* provider) {
117 if (!provider) 117 if (!provider)
118 return; 118 return;
119 provider->SetUpdateCallback(provider_callback_); 119 provider->SetUpdateCallback(provider_update_callback_);
120 if (is_permission_granted_) 120 if (is_permission_granted_)
121 provider->OnPermissionGranted(); 121 provider->OnPermissionGranted();
122 providers_.push_back(provider); 122 providers_.push_back(provider);
123 } 123 }
124 124
125 void LocationArbitratorImpl::LocationUpdateAvailable( 125 void LocationArbitratorImpl::OnLocationUpdate(const LocationProvider* provider,
126 const LocationProvider* provider, 126 const Geoposition& new_position) {
127 const Geoposition& new_position) {
128 DCHECK(new_position.Validate() || 127 DCHECK(new_position.Validate() ||
129 new_position.error_code != Geoposition::ERROR_CODE_NONE); 128 new_position.error_code != Geoposition::ERROR_CODE_NONE);
130 if (!IsNewPositionBetter(position_, new_position, 129 if (!IsNewPositionBetter(position_, new_position,
131 provider == position_provider_)) 130 provider == position_provider_))
132 return; 131 return;
133 position_provider_ = provider; 132 position_provider_ = provider;
134 position_ = new_position; 133 position_ = new_position;
135 callback_.Run(position_); 134 arbitrator_update_callback_.Run(position_);
136 } 135 }
137 136
138 AccessTokenStore* LocationArbitratorImpl::NewAccessTokenStore() { 137 AccessTokenStore* LocationArbitratorImpl::NewAccessTokenStore() {
139 return GetContentClient()->browser()->CreateAccessTokenStore(); 138 return GetContentClient()->browser()->CreateAccessTokenStore();
140 } 139 }
141 140
142 AccessTokenStore* LocationArbitratorImpl::GetAccessTokenStore() { 141 AccessTokenStore* LocationArbitratorImpl::GetAccessTokenStore() {
143 if (!access_token_store_.get()) 142 if (!access_token_store_.get())
144 access_token_store_ = NewAccessTokenStore(); 143 access_token_store_ = NewAccessTokenStore();
145 return access_token_store_.get(); 144 return access_token_store_.get();
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 } 194 }
196 } 195 }
197 return false; 196 return false;
198 } 197 }
199 198
200 bool LocationArbitratorImpl::HasPermissionBeenGranted() const { 199 bool LocationArbitratorImpl::HasPermissionBeenGranted() const {
201 return is_permission_granted_; 200 return is_permission_granted_;
202 } 201 }
203 202
204 } // namespace content 203 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698