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

Side by Side Diff: device/geolocation/geolocation_provider_impl.cc

Issue 2226143002: Gets rid of the LocationArbitrator interface, in preference for LocationProvider. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removes LocationArbitrator.h Created 4 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
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 "device/geolocation/geolocation_provider_impl.h" 5 #include "device/geolocation/geolocation_provider_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/lazy_instance.h" 10 #include "base/lazy_instance.h"
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 task = base::Bind(&GeolocationProviderImpl::StartProviders, 133 task = base::Bind(&GeolocationProviderImpl::StartProviders,
134 base::Unretained(this), enable_high_accuracy); 134 base::Unretained(this), enable_high_accuracy);
135 } 135 }
136 136
137 task_runner()->PostTask(FROM_HERE, task); 137 task_runner()->PostTask(FROM_HERE, task);
138 } 138 }
139 139
140 void GeolocationProviderImpl::StopProviders() { 140 void GeolocationProviderImpl::StopProviders() {
141 DCHECK(OnGeolocationThread()); 141 DCHECK(OnGeolocationThread());
142 DCHECK(arbitrator_); 142 DCHECK(arbitrator_);
143 arbitrator_->StopProviders(); 143 arbitrator_->StopProvider();
144 } 144 }
145 145
146 void GeolocationProviderImpl::StartProviders(bool enable_high_accuracy) { 146 void GeolocationProviderImpl::StartProviders(bool enable_high_accuracy) {
147 DCHECK(OnGeolocationThread()); 147 DCHECK(OnGeolocationThread());
148 DCHECK(arbitrator_); 148 DCHECK(arbitrator_);
149 arbitrator_->StartProviders(enable_high_accuracy); 149 arbitrator_->StartProvider(enable_high_accuracy);
150 } 150 }
151 151
152 void GeolocationProviderImpl::InformProvidersPermissionGranted() { 152 void GeolocationProviderImpl::InformProvidersPermissionGranted() {
153 DCHECK(IsRunning()); 153 DCHECK(IsRunning());
154 if (!OnGeolocationThread()) { 154 if (!OnGeolocationThread()) {
155 task_runner()->PostTask( 155 task_runner()->PostTask(
156 FROM_HERE, 156 FROM_HERE,
157 base::Bind(&GeolocationProviderImpl::InformProvidersPermissionGranted, 157 base::Bind(&GeolocationProviderImpl::InformProvidersPermissionGranted,
158 base::Unretained(this))); 158 base::Unretained(this)));
159 return; 159 return;
(...skipping 16 matching lines...) Expand all
176 DCHECK(OnGeolocationThread()); 176 DCHECK(OnGeolocationThread());
177 DCHECK(!arbitrator_); 177 DCHECK(!arbitrator_);
178 arbitrator_ = CreateArbitrator(); 178 arbitrator_ = CreateArbitrator();
179 } 179 }
180 180
181 void GeolocationProviderImpl::CleanUp() { 181 void GeolocationProviderImpl::CleanUp() {
182 DCHECK(OnGeolocationThread()); 182 DCHECK(OnGeolocationThread());
183 arbitrator_.reset(); 183 arbitrator_.reset();
184 } 184 }
185 185
186 std::unique_ptr<LocationArbitrator> 186 std::unique_ptr<LocationProvider>
187 GeolocationProviderImpl::CreateArbitrator() { 187 GeolocationProviderImpl::CreateArbitrator() {
188 LocationArbitratorImpl::LocationUpdateCallback callback = base::Bind( 188 LocationArbitratorImpl::LocationUpdateCallback callback = base::Bind(
189 &GeolocationProviderImpl::OnLocationUpdate, base::Unretained(this)); 189 &GeolocationProviderImpl::OnLocationUpdate, base::Unretained(this));
190 // Use the embedder's |g_delegate| or fall back to the default one. 190 // Use the embedder's |g_delegate| or fall back to the default one.
191 if (!g_delegate.Get()) 191 if (!g_delegate.Get())
192 g_delegate.Get().reset(new GeolocationDelegate); 192 g_delegate.Get().reset(new GeolocationDelegate);
193 193
194 return base::WrapUnique( 194 return base::WrapUnique(
195 new LocationArbitratorImpl(callback, g_delegate.Get().get())); 195 new LocationArbitratorImpl(callback, g_delegate.Get().get()));
196 } 196 }
197 197
198 } // namespace device 198 } // namespace device
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698