summaryrefslogtreecommitdiffstats
path: root/content/browser/geolocation
diff options
context:
space:
mode:
authorskyostil <skyostil@chromium.org>2015-06-05 08:26:08 -0700
committerCommit bot <commit-bot@chromium.org>2015-06-05 15:26:51 +0000
commit74f13dc2b62abb34e947093fe2600f9c539e60ef (patch)
treec298260fa8c56717943ff45efda601f312cc74c4 /content/browser/geolocation
parenta95af720637c609f33ed76d89d658041f354a222 (diff)
downloadchromium_src-74f13dc2b62abb34e947093fe2600f9c539e60ef.zip
chromium_src-74f13dc2b62abb34e947093fe2600f9c539e60ef.tar.gz
chromium_src-74f13dc2b62abb34e947093fe2600f9c539e60ef.tar.bz2
Revert "content: Remove use of MessageLoopProxy and deprecated MessageLoop APIs"
This reverts commit 5d18b2493af36d77d3c491854e3d56f46f5f747c. Reason: Broke iOS build: http://build.chromium.org/p/chromium.mac/builders/iOS_Simulator_%28dbg%29/builds/27843 NOTRY=true NOTREECHECKS=true BUG=465354 TBR=sievers@chromium.org,nick@chromium.org Review URL: https://codereview.chromium.org/1153503009 Cr-Commit-Position: refs/heads/master@{#333047}
Diffstat (limited to 'content/browser/geolocation')
-rw-r--r--content/browser/geolocation/fake_access_token_store.cc14
-rw-r--r--content/browser/geolocation/fake_access_token_store.h4
-rw-r--r--content/browser/geolocation/geolocation_provider_impl.cc6
-rw-r--r--content/browser/geolocation/geolocation_provider_impl_unittest.cc19
-rw-r--r--content/browser/geolocation/location_api_adapter_android.cc24
-rw-r--r--content/browser/geolocation/location_api_adapter_android.h7
-rw-r--r--content/browser/geolocation/mock_location_provider.cc23
-rw-r--r--content/browser/geolocation/mock_location_provider.h3
-rw-r--r--content/browser/geolocation/network_location_provider.cc10
-rw-r--r--content/browser/geolocation/wifi_data_provider.cc4
-rw-r--r--content/browser/geolocation/wifi_data_provider_common.cc9
11 files changed, 62 insertions, 61 deletions
diff --git a/content/browser/geolocation/fake_access_token_store.cc b/content/browser/geolocation/fake_access_token_store.cc
index 9e8704a..0e5fe40 100644
--- a/content/browser/geolocation/fake_access_token_store.cc
+++ b/content/browser/geolocation/fake_access_token_store.cc
@@ -7,14 +7,16 @@
#include "base/bind.h"
#include "base/location.h"
#include "base/logging.h"
-#include "base/thread_task_runner_handle.h"
+#include "base/message_loop/message_loop_proxy.h"
+using base::MessageLoopProxy;
using testing::_;
using testing::Invoke;
namespace content {
-FakeAccessTokenStore::FakeAccessTokenStore() : originating_task_runner_(NULL) {
+FakeAccessTokenStore::FakeAccessTokenStore()
+ : originating_message_loop_(NULL) {
ON_CALL(*this, LoadAccessTokens(_))
.WillByDefault(Invoke(this,
&FakeAccessTokenStore::DefaultLoadAccessTokens));
@@ -24,9 +26,9 @@ FakeAccessTokenStore::FakeAccessTokenStore() : originating_task_runner_(NULL) {
}
void FakeAccessTokenStore::NotifyDelegateTokensLoaded() {
- DCHECK(originating_task_runner_);
- if (!originating_task_runner_->BelongsToCurrentThread()) {
- originating_task_runner_->PostTask(
+ DCHECK(originating_message_loop_);
+ if (!originating_message_loop_->BelongsToCurrentThread()) {
+ originating_message_loop_->PostTask(
FROM_HERE,
base::Bind(&FakeAccessTokenStore::NotifyDelegateTokensLoaded, this));
return;
@@ -38,7 +40,7 @@ void FakeAccessTokenStore::NotifyDelegateTokensLoaded() {
void FakeAccessTokenStore::DefaultLoadAccessTokens(
const LoadAccessTokensCallbackType& callback) {
- originating_task_runner_ = base::ThreadTaskRunnerHandle::Get().get();
+ originating_message_loop_ = MessageLoopProxy::current().get();
callback_ = callback;
}
diff --git a/content/browser/geolocation/fake_access_token_store.h b/content/browser/geolocation/fake_access_token_store.h
index 423b317..30a0185 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/single_thread_task_runner.h"
+#include "base/message_loop/message_loop_proxy.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::SingleThreadTaskRunner* originating_task_runner_;
+ base::MessageLoopProxy* originating_message_loop_;
DISALLOW_COPY_AND_ASSIGN(FakeAccessTokenStore);
};
diff --git a/content/browser/geolocation/geolocation_provider_impl.cc b/content/browser/geolocation/geolocation_provider_impl.cc
index 4c32269..7375d57 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/single_thread_task_runner.h"
+#include "base/message_loop/message_loop.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);
}
- task_runner()->PostTask(FROM_HERE, task);
+ message_loop()->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()) {
- task_runner()->PostTask(
+ message_loop()->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 3ba4dae..685818b 100644
--- a/content/browser/geolocation/geolocation_provider_impl_unittest.cc
+++ b/content/browser/geolocation/geolocation_provider_impl_unittest.cc
@@ -4,10 +4,9 @@
#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/single_thread_task_runner.h"
+#include "base/message_loop/message_loop.h"
#include "base/strings/string16.h"
#include "base/time/time.h"
#include "content/browser/geolocation/geolocation_provider_impl.h"
@@ -141,9 +140,11 @@ bool GeolocationProviderTest::ProvidersStarted() {
DCHECK(provider_->IsRunning());
DCHECK(base::MessageLoop::current() == &message_loop_);
bool started;
- provider_->task_runner()->PostTaskAndReply(
- FROM_HERE, base::Bind(&GeolocationProviderTest::GetProvidersStarted,
- base::Unretained(this), &started),
+ provider_->message_loop_proxy()->PostTaskAndReply(
+ FROM_HERE,
+ base::Bind(&GeolocationProviderTest::GetProvidersStarted,
+ base::Unretained(this),
+ &started),
base::MessageLoop::QuitClosure());
message_loop_.Run();
return started;
@@ -157,9 +158,11 @@ void GeolocationProviderTest::GetProvidersStarted(bool* started) {
void GeolocationProviderTest::SendMockLocation(const Geoposition& position) {
DCHECK(provider_->IsRunning());
DCHECK(base::MessageLoop::current() == &message_loop_);
- provider_->task_runner()->PostTask(
- FROM_HERE, base::Bind(&GeolocationProviderImpl::OnLocationUpdate,
- base::Unretained(provider_.get()), position));
+ provider_->message_loop()
+ ->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 a78cae2..84cfd10 100644
--- a/content/browser/geolocation/location_api_adapter_android.cc
+++ b/content/browser/geolocation/location_api_adapter_android.cc
@@ -8,7 +8,6 @@
#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"
@@ -42,7 +41,7 @@ AndroidLocationApiAdapter::AndroidLocationApiAdapter()
AndroidLocationApiAdapter::~AndroidLocationApiAdapter() {
CHECK(!location_provider_);
- CHECK(!task_runner_.get());
+ CHECK(!message_loop_.get());
CHECK(java_location_provider_android_object_.is_null());
}
@@ -55,14 +54,14 @@ bool AndroidLocationApiAdapter::Start(
CreateJavaObject(env);
{
base::AutoLock lock(lock_);
- CHECK(!task_runner_.get());
- task_runner_ = base::ThreadTaskRunnerHandle::Get();
+ CHECK(!message_loop_.get());
+ message_loop_ = base::MessageLoopProxy::current();
}
}
// 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(task_runner_.get());
+ CHECK(message_loop_.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.
@@ -72,14 +71,14 @@ bool AndroidLocationApiAdapter::Start(
void AndroidLocationApiAdapter::Stop() {
if (!location_provider_) {
- CHECK(!task_runner_.get());
+ CHECK(!message_loop_.get());
CHECK(java_location_provider_android_object_.is_null());
return;
}
{
base::AutoLock lock(lock_);
- task_runner_ = NULL;
+ message_loop_ = NULL;
}
location_provider_ = NULL;
@@ -95,7 +94,7 @@ void AndroidLocationApiAdapter::NotifyProviderNewGeoposition(
const Geoposition& geoposition) {
// Called on the geolocation thread, safe to access location_provider_ here.
if (GetInstance()->location_provider_) {
- CHECK(GetInstance()->task_runner_->BelongsToCurrentThread());
+ CHECK(GetInstance()->message_loop_->BelongsToCurrentThread());
GetInstance()->location_provider_->NotifyNewGeoposition(geoposition);
}
}
@@ -153,12 +152,13 @@ void AndroidLocationApiAdapter::CreateJavaObject(JNIEnv* env) {
void AndroidLocationApiAdapter::OnNewGeopositionInternal(
const Geoposition& geoposition) {
base::AutoLock lock(lock_);
- if (!task_runner_.get())
+ if (!message_loop_.get())
return;
- task_runner_->PostTask(
+ message_loop_->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 8cba148..d1d2fa5 100644
--- a/content/browser/geolocation/location_api_adapter_android.h
+++ b/content/browser/geolocation/location_api_adapter_android.h
@@ -9,12 +9,9 @@
#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;
@@ -76,7 +73,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::SingleThreadTaskRunner> task_runner_;
+ scoped_refptr<base::MessageLoopProxy> message_loop_;
};
} // namespace content
diff --git a/content/browser/geolocation/mock_location_provider.cc b/content/browser/geolocation/mock_location_provider.cc
index 0bb760f..2953ba1 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/thread_task_runner_handle.h"
+#include "base/message_loop/message_loop.h"
+#include "base/message_loop/message_loop_proxy.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_task_runner_(base::ThreadTaskRunnerHandle::Get()) {
+ provider_loop_(base::MessageLoopProxy::current()) {
CHECK(self_ref_);
CHECK(*self_ref_ == NULL);
*self_ref_ = this;
@@ -34,15 +34,16 @@ MockLocationProvider::~MockLocationProvider() {
}
void MockLocationProvider::HandlePositionChanged(const Geoposition& position) {
- if (provider_task_runner_->BelongsToCurrentThread()) {
+ if (provider_loop_->BelongsToCurrentThread()) {
// The location arbitrator unit tests rely on this method running
// synchronously.
position_ = position;
NotifyCallback(position_);
} else {
- provider_task_runner_->PostTask(
- FROM_HERE, base::Bind(&MockLocationProvider::HandlePositionChanged,
- base::Unretained(this), position));
+ provider_loop_->PostTask(
+ FROM_HERE,
+ base::Bind(&MockLocationProvider::HandlePositionChanged,
+ base::Unretained(this), position));
}
}
@@ -103,9 +104,11 @@ class AutoMockLocationProvider : public MockLocationProvider {
void UpdateListenersIfNeeded() {
if (!listeners_updated_) {
listeners_updated_ = true;
- base::ThreadTaskRunnerHandle::Get()->PostTask(
- FROM_HERE, base::Bind(&MockLocationProvider::HandlePositionChanged,
- weak_factory_.GetWeakPtr(), position_));
+ base::MessageLoop::current()->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 bedd2a4..882a447 100644
--- a/content/browser/geolocation/mock_location_provider.h
+++ b/content/browser/geolocation/mock_location_provider.h
@@ -8,7 +8,6 @@
#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"
@@ -37,7 +36,7 @@ class MockLocationProvider : public LocationProviderBase {
bool is_permission_granted_;
MockLocationProvider** self_ref_;
- scoped_refptr<base::SingleThreadTaskRunner> provider_task_runner_;
+ scoped_refptr<base::MessageLoopProxy> provider_loop_;
// 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 5db43fa..13a6504 100644
--- a/content/browser/geolocation/network_location_provider.cc
+++ b/content/browser/geolocation/network_location_provider.cc
@@ -5,10 +5,7 @@
#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"
@@ -202,9 +199,10 @@ bool NetworkLocationProvider::StartProvider(bool high_accuracy) {
wifi_data_provider_manager_ =
WifiDataProviderManager::Register(&wifi_data_update_callback_);
- base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
- FROM_HERE, base::Bind(&NetworkLocationProvider::RequestPosition,
- weak_factory_.GetWeakPtr()),
+ base::MessageLoop::current()->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 71b78c4..cd739e7 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_->task_runner()->PostTask(
- FROM_HERE, base::Bind(&WifiDataProvider::DoRunCallbacks, this));
+ client_loop_->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 7bac7ab..388a17e 100644
--- a/content/browser/geolocation/wifi_data_provider_common.cc
+++ b/content/browser/geolocation/wifi_data_provider_common.cc
@@ -5,8 +5,6 @@
#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"
@@ -82,9 +80,10 @@ void WifiDataProviderCommon::DoWifiScanTask() {
}
void WifiDataProviderCommon::ScheduleNextScan(int interval) {
- client_loop()->task_runner()->PostDelayedTask(
- FROM_HERE, base::Bind(&WifiDataProviderCommon::DoWifiScanTask,
- weak_factory_.GetWeakPtr()),
+ client_loop()->PostDelayedTask(
+ FROM_HERE,
+ base::Bind(&WifiDataProviderCommon::DoWifiScanTask,
+ weak_factory_.GetWeakPtr()),
base::TimeDelta::FromMilliseconds(interval));
}