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

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: Forgot to exclude CrOS-only sources from build on other OSes. 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..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();
}

Powered by Google App Engine
This is Rietveld 408576698