| Index: content/browser/geolocation/geolocation_provider.cc
|
| diff --git a/content/browser/geolocation/geolocation_provider.cc b/content/browser/geolocation/geolocation_provider.cc
|
| index e090ac9b76c1175774a78908447ec86174098835..8222a8bc886272cdb75526af58b9f9264eec284d 100644
|
| --- a/content/browser/geolocation/geolocation_provider.cc
|
| +++ b/content/browser/geolocation/geolocation_provider.cc
|
| @@ -6,19 +6,26 @@
|
|
|
| #include "base/bind.h"
|
| #include "base/bind_helpers.h"
|
| +#include "base/callback.h"
|
| +#include "base/location.h"
|
| +#include "base/logging.h"
|
| #include "base/memory/singleton.h"
|
| -#include "base/threading/thread_restrictions.h"
|
| +#include "base/message_loop.h"
|
| #include "content/browser/geolocation/location_arbitrator.h"
|
| +#include "content/public/browser/browser_thread.h"
|
| +
|
| +using content::BrowserThread;
|
|
|
| GeolocationProvider* GeolocationProvider::GetInstance() {
|
| + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
|
| return Singleton<GeolocationProvider>::get();
|
| }
|
|
|
| GeolocationProvider::GeolocationProvider()
|
| : base::Thread("Geolocation"),
|
| - client_loop_(base::MessageLoopProxy::current()),
|
| is_permission_granted_(false),
|
| arbitrator_(NULL) {
|
| + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
|
| }
|
|
|
| GeolocationProvider::~GeolocationProvider() {
|
| @@ -29,7 +36,7 @@ GeolocationProvider::~GeolocationProvider() {
|
|
|
| void GeolocationProvider::AddObserver(GeolocationObserver* observer,
|
| const GeolocationObserverOptions& update_options) {
|
| - DCHECK(OnClientThread());
|
| + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
|
| observers_[observer] = update_options;
|
| OnObserversChanged();
|
| if (position_.IsInitialized())
|
| @@ -37,14 +44,14 @@ void GeolocationProvider::AddObserver(GeolocationObserver* observer,
|
| }
|
|
|
| bool GeolocationProvider::RemoveObserver(GeolocationObserver* observer) {
|
| - DCHECK(OnClientThread());
|
| + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
|
| size_t remove = observers_.erase(observer);
|
| OnObserversChanged();
|
| return remove > 0;
|
| }
|
|
|
| void GeolocationProvider::OnObserversChanged() {
|
| - DCHECK(OnClientThread());
|
| + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
|
| base::Closure task;
|
| if (observers_.empty()) {
|
| DCHECK(IsRunning());
|
| @@ -67,7 +74,7 @@ void GeolocationProvider::OnObserversChanged() {
|
| }
|
|
|
| void GeolocationProvider::NotifyObservers(const Geoposition& position) {
|
| - DCHECK(OnClientThread());
|
| + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
|
| DCHECK(position.IsInitialized());
|
| position_ = position;
|
| ObserverMap::const_iterator it = observers_.begin();
|
| @@ -93,7 +100,7 @@ void GeolocationProvider::StopProviders() {
|
| }
|
|
|
| void GeolocationProvider::OnPermissionGranted() {
|
| - DCHECK(OnClientThread());
|
| + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
|
| is_permission_granted_ = true;
|
| if (IsRunning())
|
| InformProvidersPermissionGranted();
|
| @@ -127,21 +134,18 @@ void GeolocationProvider::CleanUp() {
|
|
|
| void GeolocationProvider::OnLocationUpdate(const Geoposition& position) {
|
| DCHECK(OnGeolocationThread());
|
| - client_loop_->PostTask(
|
| + content::BrowserThread::PostTask(
|
| + content::BrowserThread::IO,
|
| FROM_HERE,
|
| base::Bind(&GeolocationProvider::NotifyObservers,
|
| base::Unretained(this), position));
|
| }
|
|
|
| bool GeolocationProvider::HasPermissionBeenGranted() const {
|
| - DCHECK(OnClientThread());
|
| + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
|
| return is_permission_granted_;
|
| }
|
|
|
| -bool GeolocationProvider::OnClientThread() const {
|
| - return client_loop_->BelongsToCurrentThread();
|
| -}
|
| -
|
| bool GeolocationProvider::OnGeolocationThread() const {
|
| return MessageLoop::current() == message_loop();
|
| }
|
|
|