Index: device/geolocation/geolocation_provider_impl.cc |
diff --git a/device/geolocation/geolocation_provider_impl.cc b/device/geolocation/geolocation_provider_impl.cc |
index 1c025d0614157b201d1264feef9f2f23af0b9148..3002bfea5ead30fd32d92d12e8dd063b14039b48 100644 |
--- a/device/geolocation/geolocation_provider_impl.cc |
+++ b/device/geolocation/geolocation_provider_impl.cc |
@@ -104,6 +104,11 @@ GeolocationProviderImpl::~GeolocationProviderImpl() { |
DCHECK(!arbitrator_); |
} |
+void GeolocationProviderImpl::SetArbitratorForTesting( |
+ LocationProvider* arbitrator) { |
+ arbitrator_ = base::WrapUnique(arbitrator); |
+} |
+ |
bool GeolocationProviderImpl::OnGeolocationThread() const { |
return task_runner()->BelongsToCurrentThread(); |
} |
@@ -140,13 +145,13 @@ void GeolocationProviderImpl::OnClientsChanged() { |
void GeolocationProviderImpl::StopProviders() { |
DCHECK(OnGeolocationThread()); |
DCHECK(arbitrator_); |
- arbitrator_->StopProviders(); |
+ arbitrator_->StopProvider(); |
} |
void GeolocationProviderImpl::StartProviders(bool enable_high_accuracy) { |
DCHECK(OnGeolocationThread()); |
DCHECK(arbitrator_); |
- arbitrator_->StartProviders(enable_high_accuracy); |
+ arbitrator_->StartProvider(enable_high_accuracy); |
} |
void GeolocationProviderImpl::InformProvidersPermissionGranted() { |
@@ -174,8 +179,17 @@ void GeolocationProviderImpl::NotifyClients(const Geoposition& position) { |
void GeolocationProviderImpl::Init() { |
DCHECK(OnGeolocationThread()); |
- DCHECK(!arbitrator_); |
- arbitrator_ = CreateArbitrator(); |
+ |
+ if (!arbitrator_) { |
+ LocationArbitratorImpl::LocationUpdateCallback callback = base::Bind( |
+ &GeolocationProviderImpl::OnLocationUpdate, base::Unretained(this)); |
+ // Use the embedder's |g_delegate| or fall back to the default one. |
+ if (!g_delegate.Get()) |
+ g_delegate.Get().reset(new GeolocationDelegate); |
+ |
+ arbitrator_ = base::WrapUnique( |
+ new LocationArbitratorImpl(callback, g_delegate.Get().get())); |
Wez
2016/08/12 00:33:44
nit: You can use MakeUnique here. :)
CJ
2016/08/12 20:22:46
Done.
|
+ } |
} |
void GeolocationProviderImpl::CleanUp() { |
@@ -183,16 +197,4 @@ void GeolocationProviderImpl::CleanUp() { |
arbitrator_.reset(); |
} |
-std::unique_ptr<LocationArbitrator> |
-GeolocationProviderImpl::CreateArbitrator() { |
- LocationArbitratorImpl::LocationUpdateCallback callback = base::Bind( |
- &GeolocationProviderImpl::OnLocationUpdate, base::Unretained(this)); |
- // Use the embedder's |g_delegate| or fall back to the default one. |
- if (!g_delegate.Get()) |
- g_delegate.Get().reset(new GeolocationDelegate); |
- |
- return base::WrapUnique( |
- new LocationArbitratorImpl(callback, g_delegate.Get().get())); |
-} |
- |
} // namespace device |