| 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..a5f1f77876e2b0f05aa9f18cbc71cd86852b9b41 100644
|
| --- a/device/geolocation/geolocation_provider_impl.cc
|
| +++ b/device/geolocation/geolocation_provider_impl.cc
|
| @@ -4,6 +4,8 @@
|
|
|
| #include "device/geolocation/geolocation_provider_impl.h"
|
|
|
| +#include <utility>
|
| +
|
| #include "base/bind.h"
|
| #include "base/bind_helpers.h"
|
| #include "base/callback.h"
|
| @@ -104,6 +106,11 @@ GeolocationProviderImpl::~GeolocationProviderImpl() {
|
| DCHECK(!arbitrator_);
|
| }
|
|
|
| +void GeolocationProviderImpl::SetArbitratorForTesting(
|
| + std::unique_ptr<LocationProvider> arbitrator) {
|
| + arbitrator_ = std::move(arbitrator);
|
| +}
|
| +
|
| bool GeolocationProviderImpl::OnGeolocationThread() const {
|
| return task_runner()->BelongsToCurrentThread();
|
| }
|
| @@ -140,13 +147,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 +181,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::MakeUnique<LocationArbitratorImpl>(
|
| + callback, g_delegate.Get().get());
|
| + }
|
| }
|
|
|
| void GeolocationProviderImpl::CleanUp() {
|
| @@ -183,16 +199,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
|
|
|