| Index: device/geolocation/geolocation_provider_impl.cc
|
| diff --git a/content/browser/geolocation/geolocation_provider_impl.cc b/device/geolocation/geolocation_provider_impl.cc
|
| similarity index 86%
|
| rename from content/browser/geolocation/geolocation_provider_impl.cc
|
| rename to device/geolocation/geolocation_provider_impl.cc
|
| index 1f263976a914460ccb26e73750177388c0b7f05e..6abdaf1a7729becd97151522e5e67fb372ec5f65 100644
|
| --- a/content/browser/geolocation/geolocation_provider_impl.cc
|
| +++ b/device/geolocation/geolocation_provider_impl.cc
|
| @@ -2,7 +2,7 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| -#include "content/browser/geolocation/geolocation_provider_impl.h"
|
| +#include "device/geolocation/geolocation_provider_impl.h"
|
|
|
| #include "base/bind.h"
|
| #include "base/bind_helpers.h"
|
| @@ -13,12 +13,11 @@
|
| #include "base/memory/ptr_util.h"
|
| #include "base/memory/singleton.h"
|
| #include "base/single_thread_task_runner.h"
|
| -#include "content/browser/geolocation/location_arbitrator_impl.h"
|
| -#include "content/public/browser/browser_thread.h"
|
| -#include "content/public/browser/content_browser_client.h"
|
| -#include "content/public/browser/geolocation_delegate.h"
|
| +#include "base/threading/thread_task_runner_handle.h"
|
| +#include "device/geolocation/geolocation_delegate.h"
|
| +#include "device/geolocation/location_arbitrator_impl.h"
|
|
|
| -namespace content {
|
| +namespace device {
|
|
|
| namespace {
|
| base::LazyInstance<std::unique_ptr<GeolocationDelegate>>::Leaky g_delegate =
|
| @@ -41,7 +40,7 @@ std::unique_ptr<GeolocationProvider::Subscription>
|
| GeolocationProviderImpl::AddLocationUpdateCallback(
|
| const LocationUpdateCallback& callback,
|
| bool enable_high_accuracy) {
|
| - DCHECK_CURRENTLY_ON(BrowserThread::UI);
|
| + DCHECK(main_task_runner_->BelongsToCurrentThread());
|
| std::unique_ptr<GeolocationProvider::Subscription> subscription;
|
| if (enable_high_accuracy) {
|
| subscription = high_accuracy_callbacks_.Add(callback);
|
| @@ -59,7 +58,7 @@ GeolocationProviderImpl::AddLocationUpdateCallback(
|
| }
|
|
|
| void GeolocationProviderImpl::UserDidOptIntoLocationServices() {
|
| - DCHECK_CURRENTLY_ON(BrowserThread::UI);
|
| + DCHECK(main_task_runner_->BelongsToCurrentThread());
|
| bool was_permission_granted = user_did_opt_into_location_services_;
|
| user_did_opt_into_location_services_ = true;
|
| if (IsRunning() && !was_permission_granted)
|
| @@ -68,7 +67,7 @@ void GeolocationProviderImpl::UserDidOptIntoLocationServices() {
|
|
|
| void GeolocationProviderImpl::OverrideLocationForTesting(
|
| const Geoposition& position) {
|
| - DCHECK_CURRENTLY_ON(BrowserThread::UI);
|
| + DCHECK(main_task_runner_->BelongsToCurrentThread());
|
| ignore_location_updates_ = true;
|
| NotifyClients(position);
|
| }
|
| @@ -78,23 +77,22 @@ void GeolocationProviderImpl::OnLocationUpdate(const Geoposition& position) {
|
| // Will be true only in testing.
|
| if (ignore_location_updates_)
|
| return;
|
| - BrowserThread::PostTask(BrowserThread::UI,
|
| - FROM_HERE,
|
| - base::Bind(&GeolocationProviderImpl::NotifyClients,
|
| - base::Unretained(this), position));
|
| + main_task_runner_->PostTask(
|
| + FROM_HERE, base::Bind(&GeolocationProviderImpl::NotifyClients,
|
| + base::Unretained(this), position));
|
| }
|
|
|
| // static
|
| GeolocationProviderImpl* GeolocationProviderImpl::GetInstance() {
|
| - DCHECK_CURRENTLY_ON(BrowserThread::UI);
|
| return base::Singleton<GeolocationProviderImpl>::get();
|
| }
|
|
|
| GeolocationProviderImpl::GeolocationProviderImpl()
|
| : base::Thread("Geolocation"),
|
| user_did_opt_into_location_services_(false),
|
| - ignore_location_updates_(false) {
|
| - DCHECK_CURRENTLY_ON(BrowserThread::UI);
|
| + ignore_location_updates_(false),
|
| + main_task_runner_(base::ThreadTaskRunnerHandle::Get()) {
|
| + DCHECK(main_task_runner_->BelongsToCurrentThread());
|
| high_accuracy_callbacks_.set_removal_callback(
|
| base::Bind(&GeolocationProviderImpl::OnClientsChanged,
|
| base::Unretained(this)));
|
| @@ -113,7 +111,7 @@ bool GeolocationProviderImpl::OnGeolocationThread() const {
|
| }
|
|
|
| void GeolocationProviderImpl::OnClientsChanged() {
|
| - DCHECK_CURRENTLY_ON(BrowserThread::UI);
|
| + DCHECK(main_task_runner_->BelongsToCurrentThread());
|
| base::Closure task;
|
| if (high_accuracy_callbacks_.empty() && low_accuracy_callbacks_.empty()) {
|
| DCHECK(IsRunning());
|
| @@ -168,7 +166,7 @@ void GeolocationProviderImpl::InformProvidersPermissionGranted() {
|
| }
|
|
|
| void GeolocationProviderImpl::NotifyClients(const Geoposition& position) {
|
| - DCHECK_CURRENTLY_ON(BrowserThread::UI);
|
| + DCHECK(main_task_runner_->BelongsToCurrentThread());
|
| DCHECK(position.Validate() ||
|
| position.error_code != Geoposition::ERROR_CODE_NONE);
|
| position_ = position;
|
| @@ -199,4 +197,4 @@ GeolocationProviderImpl::CreateArbitrator() {
|
| new LocationArbitratorImpl(callback, g_delegate.Get().get()));
|
| }
|
|
|
| -} // namespace content
|
| +} // namespace device
|
|
|