Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(396)

Unified Diff: content/browser/geolocation/geolocation_provider.cc

Issue 10103029: Add device location reporting (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Comments addressed. Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..fe68b3e48c569f2eedb006f06d67f3850b6017d7 100644
--- a/content/browser/geolocation/geolocation_provider.cc
+++ b/content/browser/geolocation/geolocation_provider.cc
@@ -5,20 +5,20 @@
#include "content/browser/geolocation/geolocation_provider.h"
#include "base/bind.h"
-#include "base/bind_helpers.h"
#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 +29,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 +37,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 +67,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 +93,7 @@ void GeolocationProvider::StopProviders() {
}
void GeolocationProvider::OnPermissionGranted() {
- DCHECK(OnClientThread());
+ DCHECK(OnIOThread());
is_permission_granted_ = true;
if (IsRunning())
InformProvidersPermissionGranted();
@@ -127,19 +127,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);
}
bool GeolocationProvider::OnGeolocationThread() const {

Powered by Google App Engine
This is Rietveld 408576698