diff options
Diffstat (limited to 'content/browser/geolocation')
11 files changed, 61 insertions, 62 deletions
diff --git a/content/browser/geolocation/fake_access_token_store.cc b/content/browser/geolocation/fake_access_token_store.cc index 0e5fe40..9e8704a 100644 --- a/content/browser/geolocation/fake_access_token_store.cc +++ b/content/browser/geolocation/fake_access_token_store.cc @@ -7,16 +7,14 @@ #include "base/bind.h" #include "base/location.h" #include "base/logging.h" -#include "base/message_loop/message_loop_proxy.h" +#include "base/thread_task_runner_handle.h" -using base::MessageLoopProxy; using testing::_; using testing::Invoke; namespace content { -FakeAccessTokenStore::FakeAccessTokenStore() - : originating_message_loop_(NULL) { +FakeAccessTokenStore::FakeAccessTokenStore() : originating_task_runner_(NULL) { ON_CALL(*this, LoadAccessTokens(_)) .WillByDefault(Invoke(this, &FakeAccessTokenStore::DefaultLoadAccessTokens)); @@ -26,9 +24,9 @@ FakeAccessTokenStore::FakeAccessTokenStore() } void FakeAccessTokenStore::NotifyDelegateTokensLoaded() { - DCHECK(originating_message_loop_); - if (!originating_message_loop_->BelongsToCurrentThread()) { - originating_message_loop_->PostTask( + DCHECK(originating_task_runner_); + if (!originating_task_runner_->BelongsToCurrentThread()) { + originating_task_runner_->PostTask( FROM_HERE, base::Bind(&FakeAccessTokenStore::NotifyDelegateTokensLoaded, this)); return; @@ -40,7 +38,7 @@ void FakeAccessTokenStore::NotifyDelegateTokensLoaded() { void FakeAccessTokenStore::DefaultLoadAccessTokens( const LoadAccessTokensCallbackType& callback) { - originating_message_loop_ = MessageLoopProxy::current().get(); + originating_task_runner_ = base::ThreadTaskRunnerHandle::Get().get(); callback_ = callback; } diff --git a/content/browser/geolocation/fake_access_token_store.h b/content/browser/geolocation/fake_access_token_store.h index 30a0185..423b317 100644 --- a/content/browser/geolocation/fake_access_token_store.h +++ b/content/browser/geolocation/fake_access_token_store.h @@ -5,7 +5,7 @@ #ifndef CONTENT_BROWSER_GEOLOCATION_FAKE_ACCESS_TOKEN_STORE_H_ #define CONTENT_BROWSER_GEOLOCATION_FAKE_ACCESS_TOKEN_STORE_H_ -#include "base/message_loop/message_loop_proxy.h" +#include "base/single_thread_task_runner.h" #include "content/public/browser/access_token_store.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" @@ -42,7 +42,7 @@ class FakeAccessTokenStore : public AccessTokenStore { // In some tests, NotifyDelegateTokensLoaded() is called on a thread // other than the originating thread, in which case we must post // back to it. - base::MessageLoopProxy* originating_message_loop_; + base::SingleThreadTaskRunner* originating_task_runner_; DISALLOW_COPY_AND_ASSIGN(FakeAccessTokenStore); }; diff --git a/content/browser/geolocation/geolocation_provider_impl.cc b/content/browser/geolocation/geolocation_provider_impl.cc index 7375d57..4c32269 100644 --- a/content/browser/geolocation/geolocation_provider_impl.cc +++ b/content/browser/geolocation/geolocation_provider_impl.cc @@ -10,7 +10,7 @@ #include "base/location.h" #include "base/logging.h" #include "base/memory/singleton.h" -#include "base/message_loop/message_loop.h" +#include "base/single_thread_task_runner.h" #include "content/browser/geolocation/location_arbitrator_impl.h" #include "content/public/browser/browser_thread.h" @@ -121,7 +121,7 @@ void GeolocationProviderImpl::OnClientsChanged() { use_high_accuracy); } - message_loop()->PostTask(FROM_HERE, task); + task_runner()->PostTask(FROM_HERE, task); } void GeolocationProviderImpl::StopProviders() { @@ -139,7 +139,7 @@ void GeolocationProviderImpl::StartProviders(bool use_high_accuracy) { void GeolocationProviderImpl::InformProvidersPermissionGranted() { DCHECK(IsRunning()); if (!OnGeolocationThread()) { - message_loop()->PostTask( + task_runner()->PostTask( FROM_HERE, base::Bind(&GeolocationProviderImpl::InformProvidersPermissionGranted, base::Unretained(this))); diff --git a/content/browser/geolocation/geolocation_provider_impl_unittest.cc b/content/browser/geolocation/geolocation_provider_impl_unittest.cc index 685818b..3ba4dae 100644 --- a/content/browser/geolocation/geolocation_provider_impl_unittest.cc +++ b/content/browser/geolocation/geolocation_provider_impl_unittest.cc @@ -4,9 +4,10 @@ #include "base/bind.h" #include "base/bind_helpers.h" +#include "base/location.h" #include "base/memory/ref_counted.h" #include "base/memory/scoped_ptr.h" -#include "base/message_loop/message_loop.h" +#include "base/single_thread_task_runner.h" #include "base/strings/string16.h" #include "base/time/time.h" #include "content/browser/geolocation/geolocation_provider_impl.h" @@ -140,11 +141,9 @@ bool GeolocationProviderTest::ProvidersStarted() { DCHECK(provider_->IsRunning()); DCHECK(base::MessageLoop::current() == &message_loop_); bool started; - provider_->message_loop_proxy()->PostTaskAndReply( - FROM_HERE, - base::Bind(&GeolocationProviderTest::GetProvidersStarted, - base::Unretained(this), - &started), + provider_->task_runner()->PostTaskAndReply( + FROM_HERE, base::Bind(&GeolocationProviderTest::GetProvidersStarted, + base::Unretained(this), &started), base::MessageLoop::QuitClosure()); message_loop_.Run(); return started; @@ -158,11 +157,9 @@ void GeolocationProviderTest::GetProvidersStarted(bool* started) { void GeolocationProviderTest::SendMockLocation(const Geoposition& position) { DCHECK(provider_->IsRunning()); DCHECK(base::MessageLoop::current() == &message_loop_); - provider_->message_loop() - ->PostTask(FROM_HERE, - base::Bind(&GeolocationProviderImpl::OnLocationUpdate, - base::Unretained(provider_.get()), - position)); + provider_->task_runner()->PostTask( + FROM_HERE, base::Bind(&GeolocationProviderImpl::OnLocationUpdate, + base::Unretained(provider_.get()), position)); } // Regression test for http://crbug.com/59377 diff --git a/content/browser/geolocation/location_api_adapter_android.cc b/content/browser/geolocation/location_api_adapter_android.cc index 84cfd10..a78cae2 100644 --- a/content/browser/geolocation/location_api_adapter_android.cc +++ b/content/browser/geolocation/location_api_adapter_android.cc @@ -8,6 +8,7 @@ #include "base/android/jni_string.h" #include "base/bind.h" #include "base/location.h" +#include "base/thread_task_runner_handle.h" #include "content/browser/geolocation/location_provider_android.h" #include "jni/LocationProviderAdapter_jni.h" @@ -41,7 +42,7 @@ AndroidLocationApiAdapter::AndroidLocationApiAdapter() AndroidLocationApiAdapter::~AndroidLocationApiAdapter() { CHECK(!location_provider_); - CHECK(!message_loop_.get()); + CHECK(!task_runner_.get()); CHECK(java_location_provider_android_object_.is_null()); } @@ -54,14 +55,14 @@ bool AndroidLocationApiAdapter::Start( CreateJavaObject(env); { base::AutoLock lock(lock_); - CHECK(!message_loop_.get()); - message_loop_ = base::MessageLoopProxy::current(); + CHECK(!task_runner_.get()); + task_runner_ = base::ThreadTaskRunnerHandle::Get(); } } // At this point we should have all our pre-conditions ready, and they'd only // change in Stop() which must be called on the same thread as here. CHECK(location_provider_); - CHECK(message_loop_.get()); + CHECK(task_runner_.get()); CHECK(!java_location_provider_android_object_.is_null()); // We'll start receiving notifications from java in the main thread looper // until Stop() is called. @@ -71,14 +72,14 @@ bool AndroidLocationApiAdapter::Start( void AndroidLocationApiAdapter::Stop() { if (!location_provider_) { - CHECK(!message_loop_.get()); + CHECK(!task_runner_.get()); CHECK(java_location_provider_android_object_.is_null()); return; } { base::AutoLock lock(lock_); - message_loop_ = NULL; + task_runner_ = NULL; } location_provider_ = NULL; @@ -94,7 +95,7 @@ void AndroidLocationApiAdapter::NotifyProviderNewGeoposition( const Geoposition& geoposition) { // Called on the geolocation thread, safe to access location_provider_ here. if (GetInstance()->location_provider_) { - CHECK(GetInstance()->message_loop_->BelongsToCurrentThread()); + CHECK(GetInstance()->task_runner_->BelongsToCurrentThread()); GetInstance()->location_provider_->NotifyNewGeoposition(geoposition); } } @@ -152,13 +153,12 @@ void AndroidLocationApiAdapter::CreateJavaObject(JNIEnv* env) { void AndroidLocationApiAdapter::OnNewGeopositionInternal( const Geoposition& geoposition) { base::AutoLock lock(lock_); - if (!message_loop_.get()) + if (!task_runner_.get()) return; - message_loop_->PostTask( + task_runner_->PostTask( FROM_HERE, - base::Bind( - &AndroidLocationApiAdapter::NotifyProviderNewGeoposition, - geoposition)); + base::Bind(&AndroidLocationApiAdapter::NotifyProviderNewGeoposition, + geoposition)); } } // namespace content diff --git a/content/browser/geolocation/location_api_adapter_android.h b/content/browser/geolocation/location_api_adapter_android.h index d1d2fa5..8cba148 100644 --- a/content/browser/geolocation/location_api_adapter_android.h +++ b/content/browser/geolocation/location_api_adapter_android.h @@ -9,9 +9,12 @@ #include "base/android/scoped_java_ref.h" #include "base/memory/ref_counted.h" #include "base/memory/singleton.h" -#include "base/message_loop/message_loop_proxy.h" #include "base/synchronization/lock.h" +namespace base { +class SingleThreadTaskRunner; +} + namespace content { class LocationProviderAndroid; struct Geoposition; @@ -73,7 +76,7 @@ class AndroidLocationApiAdapter { // Guards against the following member which is accessed on Geolocation // thread and the JNI main thread looper. base::Lock lock_; - scoped_refptr<base::MessageLoopProxy> message_loop_; + scoped_refptr<base::SingleThreadTaskRunner> task_runner_; }; } // namespace content diff --git a/content/browser/geolocation/mock_location_provider.cc b/content/browser/geolocation/mock_location_provider.cc index 2953ba1..0bb760f 100644 --- a/content/browser/geolocation/mock_location_provider.cc +++ b/content/browser/geolocation/mock_location_provider.cc @@ -10,10 +10,10 @@ #include "base/bind.h" #include "base/bind_helpers.h" #include "base/compiler_specific.h" +#include "base/location.h" #include "base/logging.h" #include "base/memory/weak_ptr.h" -#include "base/message_loop/message_loop.h" -#include "base/message_loop/message_loop_proxy.h" +#include "base/thread_task_runner_handle.h" namespace content { MockLocationProvider* MockLocationProvider::instance_ = NULL; @@ -22,7 +22,7 @@ MockLocationProvider::MockLocationProvider(MockLocationProvider** self_ref) : state_(STOPPED), is_permission_granted_(false), self_ref_(self_ref), - provider_loop_(base::MessageLoopProxy::current()) { + provider_task_runner_(base::ThreadTaskRunnerHandle::Get()) { CHECK(self_ref_); CHECK(*self_ref_ == NULL); *self_ref_ = this; @@ -34,16 +34,15 @@ MockLocationProvider::~MockLocationProvider() { } void MockLocationProvider::HandlePositionChanged(const Geoposition& position) { - if (provider_loop_->BelongsToCurrentThread()) { + if (provider_task_runner_->BelongsToCurrentThread()) { // The location arbitrator unit tests rely on this method running // synchronously. position_ = position; NotifyCallback(position_); } else { - provider_loop_->PostTask( - FROM_HERE, - base::Bind(&MockLocationProvider::HandlePositionChanged, - base::Unretained(this), position)); + provider_task_runner_->PostTask( + FROM_HERE, base::Bind(&MockLocationProvider::HandlePositionChanged, + base::Unretained(this), position)); } } @@ -104,11 +103,9 @@ class AutoMockLocationProvider : public MockLocationProvider { void UpdateListenersIfNeeded() { if (!listeners_updated_) { listeners_updated_ = true; - base::MessageLoop::current()->PostTask( - FROM_HERE, - base::Bind(&MockLocationProvider::HandlePositionChanged, - weak_factory_.GetWeakPtr(), - position_)); + base::ThreadTaskRunnerHandle::Get()->PostTask( + FROM_HERE, base::Bind(&MockLocationProvider::HandlePositionChanged, + weak_factory_.GetWeakPtr(), position_)); } } diff --git a/content/browser/geolocation/mock_location_provider.h b/content/browser/geolocation/mock_location_provider.h index 882a447..bedd2a4 100644 --- a/content/browser/geolocation/mock_location_provider.h +++ b/content/browser/geolocation/mock_location_provider.h @@ -8,6 +8,7 @@ #include "base/compiler_specific.h" #include "base/memory/ref_counted.h" +#include "base/single_thread_task_runner.h" #include "base/threading/thread.h" #include "content/browser/geolocation/location_provider_base.h" #include "content/public/common/geoposition.h" @@ -36,7 +37,7 @@ class MockLocationProvider : public LocationProviderBase { bool is_permission_granted_; MockLocationProvider** self_ref_; - scoped_refptr<base::MessageLoopProxy> provider_loop_; + scoped_refptr<base::SingleThreadTaskRunner> provider_task_runner_; // Set when an instance of the mock is created via a factory function. static MockLocationProvider* instance_; diff --git a/content/browser/geolocation/network_location_provider.cc b/content/browser/geolocation/network_location_provider.cc index 13a6504..5db43fa 100644 --- a/content/browser/geolocation/network_location_provider.cc +++ b/content/browser/geolocation/network_location_provider.cc @@ -5,7 +5,10 @@ #include "content/browser/geolocation/network_location_provider.h" #include "base/bind.h" +#include "base/location.h" +#include "base/single_thread_task_runner.h" #include "base/strings/utf_string_conversions.h" +#include "base/thread_task_runner_handle.h" #include "base/time/time.h" #include "content/public/browser/access_token_store.h" @@ -199,10 +202,9 @@ bool NetworkLocationProvider::StartProvider(bool high_accuracy) { wifi_data_provider_manager_ = WifiDataProviderManager::Register(&wifi_data_update_callback_); - base::MessageLoop::current()->PostDelayedTask( - FROM_HERE, - base::Bind(&NetworkLocationProvider::RequestPosition, - weak_factory_.GetWeakPtr()), + base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( + FROM_HERE, base::Bind(&NetworkLocationProvider::RequestPosition, + weak_factory_.GetWeakPtr()), base::TimeDelta::FromSeconds(kDataCompleteWaitSeconds)); // Get the wifi data. is_wifi_data_complete_ = wifi_data_provider_manager_->GetData(&wifi_data_); diff --git a/content/browser/geolocation/wifi_data_provider.cc b/content/browser/geolocation/wifi_data_provider.cc index cd739e7..71b78c4 100644 --- a/content/browser/geolocation/wifi_data_provider.cc +++ b/content/browser/geolocation/wifi_data_provider.cc @@ -27,8 +27,8 @@ bool WifiDataProvider::has_callbacks() const { } void WifiDataProvider::RunCallbacks() { - client_loop_->PostTask(FROM_HERE, - base::Bind(&WifiDataProvider::DoRunCallbacks, this)); + client_loop_->task_runner()->PostTask( + FROM_HERE, base::Bind(&WifiDataProvider::DoRunCallbacks, this)); } bool WifiDataProvider::CalledOnClientThread() const { diff --git a/content/browser/geolocation/wifi_data_provider_common.cc b/content/browser/geolocation/wifi_data_provider_common.cc index 388a17e..7bac7ab 100644 --- a/content/browser/geolocation/wifi_data_provider_common.cc +++ b/content/browser/geolocation/wifi_data_provider_common.cc @@ -5,6 +5,8 @@ #include "content/browser/geolocation/wifi_data_provider_common.h" #include "base/bind.h" +#include "base/location.h" +#include "base/single_thread_task_runner.h" #include "base/strings/stringprintf.h" #include "base/strings/utf_string_conversions.h" @@ -80,10 +82,9 @@ void WifiDataProviderCommon::DoWifiScanTask() { } void WifiDataProviderCommon::ScheduleNextScan(int interval) { - client_loop()->PostDelayedTask( - FROM_HERE, - base::Bind(&WifiDataProviderCommon::DoWifiScanTask, - weak_factory_.GetWeakPtr()), + client_loop()->task_runner()->PostDelayedTask( + FROM_HERE, base::Bind(&WifiDataProviderCommon::DoWifiScanTask, + weak_factory_.GetWeakPtr()), base::TimeDelta::FromMilliseconds(interval)); } |