Chromium Code Reviews| 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..6b984b41d43f56edb22fbff16be74176c988ee0d 100644 |
| --- a/content/browser/geolocation/geolocation_provider.cc |
| +++ b/content/browser/geolocation/geolocation_provider.cc |
| @@ -6,19 +6,24 @@ |
| #include "base/bind.h" |
| #include "base/bind_helpers.h" |
| +#include "base/callback.h" |
| +#include "base/location.h" |
| +#include "base/logging.h" |
| +#include "base/message_loop.h" |
|
Joao da Silva
2012/04/23 10:19:57
Nit: order
bartfab (slow)
2012/04/23 12:21:28
Done.
|
| #include "base/memory/singleton.h" |
| -#include "base/threading/thread_restrictions.h" |
| #include "content/browser/geolocation/location_arbitrator.h" |
| +#include "content/public/browser/browser_thread.h" |
| GeolocationProvider* GeolocationProvider::GetInstance() { |
| + DCHECK(OnIOThread()); |
| return Singleton<GeolocationProvider>::get(); |
| } |
| GeolocationProvider::GeolocationProvider() |
| : base::Thread("Geolocation"), |
| - client_loop_(base::MessageLoopProxy::current()), |
| is_permission_granted_(false), |
| arbitrator_(NULL) { |
| + DCHECK(OnIOThread()); |
| } |
| GeolocationProvider::~GeolocationProvider() { |
| @@ -29,7 +34,7 @@ GeolocationProvider::~GeolocationProvider() { |
| void GeolocationProvider::AddObserver(GeolocationObserver* observer, |
| const GeolocationObserverOptions& update_options) { |
| - DCHECK(OnClientThread()); |
| + DCHECK(OnIOThread()); |
| observers_[observer] = update_options; |
| OnObserversChanged(); |
| if (position_.IsInitialized()) |
| @@ -37,14 +42,14 @@ void GeolocationProvider::AddObserver(GeolocationObserver* observer, |
| } |
| bool GeolocationProvider::RemoveObserver(GeolocationObserver* observer) { |
| - DCHECK(OnClientThread()); |
| + DCHECK(OnIOThread()); |
| size_t remove = observers_.erase(observer); |
| OnObserversChanged(); |
| return remove > 0; |
| } |
| void GeolocationProvider::OnObserversChanged() { |
| - DCHECK(OnClientThread()); |
| + DCHECK(OnIOThread()); |
| base::Closure task; |
| if (observers_.empty()) { |
| DCHECK(IsRunning()); |
| @@ -67,7 +72,7 @@ void GeolocationProvider::OnObserversChanged() { |
| } |
| void GeolocationProvider::NotifyObservers(const Geoposition& position) { |
| - DCHECK(OnClientThread()); |
| + DCHECK(OnIOThread()); |
| DCHECK(position.IsInitialized()); |
| position_ = position; |
| ObserverMap::const_iterator it = observers_.begin(); |
| @@ -93,7 +98,7 @@ void GeolocationProvider::StopProviders() { |
| } |
| void GeolocationProvider::OnPermissionGranted() { |
| - DCHECK(OnClientThread()); |
| + DCHECK(OnIOThread()); |
| is_permission_granted_ = true; |
| if (IsRunning()) |
| InformProvidersPermissionGranted(); |
| @@ -127,19 +132,21 @@ 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(OnIOThread()); |
| return is_permission_granted_; |
| } |
| -bool GeolocationProvider::OnClientThread() const { |
| - return client_loop_->BelongsToCurrentThread(); |
| +// static |
| +bool GeolocationProvider::OnIOThread() { |
| + return content::BrowserThread::CurrentlyOn(content::BrowserThread::IO); |
|
Joao da Silva
2012/04/23 10:19:57
It's common to just
DCHECK(content::BrowserThrea
bartfab (slow)
2012/04/23 12:21:28
Done. Since you say it is common to add a using li
|
| } |
| bool GeolocationProvider::OnGeolocationThread() const { |