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