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

Unified Diff: chrome/browser/geolocation/core_location_data_provider_mac.mm

Issue 6037016: Fix incorrect assertion following the move of Geolocation provider in to its own thread. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix nits. Created 9 years, 11 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: chrome/browser/geolocation/core_location_data_provider_mac.mm
diff --git a/chrome/browser/geolocation/core_location_data_provider_mac.mm b/chrome/browser/geolocation/core_location_data_provider_mac.mm
index b20230e9ba8332e7d9759c593b8de8216d97a514..a88c6c41ab9ee556b3a2524ab72cb4309a36bb2b 100644
--- a/chrome/browser/geolocation/core_location_data_provider_mac.mm
+++ b/chrome/browser/geolocation/core_location_data_provider_mac.mm
@@ -11,6 +11,7 @@
#include "chrome/browser/geolocation/core_location_data_provider_mac.h"
#include "chrome/browser/geolocation/core_location_provider_mac.h"
+#include "chrome/browser/geolocation/geolocation_provider.h"
#include "base/logging.h"
#include "base/time.h"
@@ -41,7 +42,7 @@ enum {
- (void)stopUpdatingLocation;
@end
-@interface CLLocation : NSObject <NSCopying, NSCoding>
+@interface CLLocation : NSObject<NSCopying, NSCoding>
@property(readonly) CLLocationCoordinate2D coordinate;
@property(readonly) CLLocationDistance altitude;
@property(readonly) CLLocationAccuracy horizontalAccuracy;
@@ -64,9 +65,9 @@ enum {
// CLLocationManager. The location manaager's start and stop updating
// methods must be called from a thread that has an active run loop (which
// seems to only be the UI thread)
-@interface CoreLocationWrapperMac : NSObject <CLLocationManagerDelegate>
+@interface CoreLocationWrapperMac : NSObject<CLLocationManagerDelegate>
{
-@private
+ @private
NSBundle* bundle_;
Class locationManagerClass_;
id locationManager_;
@@ -119,8 +120,8 @@ enum {
}
- (void)startLocation {
- if([self locationDataAvailable]) {
- if(!locationManager_) {
+ if ([self locationDataAvailable]) {
+ if (!locationManager_) {
locationManager_ = [[locationManagerClass_ alloc] init];
[locationManager_ setDelegate:self];
}
@@ -151,7 +152,7 @@ enum {
- (void)locationManager:(CLLocationManager*)manager
didFailWithError:(NSError*)error {
Geoposition position;
- switch([error code]) {
+ switch ([error code]) {
case kCLErrorLocationUnknown:
position.error_code = Geoposition::ERROR_CODE_POSITION_UNAVAILABLE;
break;
@@ -166,10 +167,10 @@ enum {
}
- (BOOL)loadCoreLocationBundle {
- if(!bundle_) {
+ if (!bundle_) {
bundle_ = [[NSBundle alloc]
initWithPath:@"/System/Library/Frameworks/CoreLocation.framework"];
- if(!bundle_) {
+ if (!bundle_) {
DLOG(WARNING) << "Couldn't load CoreLocation Framework";
return NO;
}
@@ -183,9 +184,11 @@ enum {
@end
CoreLocationDataProviderMac::CoreLocationDataProviderMac() {
- if(!BrowserThread::GetCurrentThreadIdentifier(&origin_thread_id_))
- NOTREACHED() <<
- "CoreLocation data provider must be created in a valid BrowserThread.";
+ if (MessageLoop::current() !=
+ GeolocationProvider::GetInstance()->message_loop()) {
+ NOTREACHED() << "CoreLocation data provider must be created on "
+ "the Geolocation thread.";
+ }
provider_ = NULL;
wrapper_.reset([[CoreLocationWrapperMac alloc] initWithDataProvider:this]);
}
@@ -200,7 +203,7 @@ bool CoreLocationDataProviderMac::
StartUpdating(CoreLocationProviderMac* provider) {
DCHECK(provider);
DCHECK(!provider_) << "StartUpdating called twice";
- if(![wrapper_ locationDataAvailable]) return false;
+ if (![wrapper_ locationDataAvailable]) return false;
provider_ = provider;
BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
NewRunnableMethod(this, &CoreLocationDataProviderMac::StartUpdatingTask));
@@ -216,7 +219,7 @@ void CoreLocationDataProviderMac::StopUpdating() {
}
void CoreLocationDataProviderMac::UpdatePosition(Geoposition *position) {
- BrowserThread::PostTask(origin_thread_id_, FROM_HERE,
+ GeolocationProvider::GetInstance()->message_loop()->PostTask(FROM_HERE,
NewRunnableMethod(this,
&CoreLocationDataProviderMac::PositionUpdated,
*position));
@@ -235,7 +238,8 @@ void CoreLocationDataProviderMac::StopUpdatingTask() {
}
void CoreLocationDataProviderMac::PositionUpdated(Geoposition position) {
- DCHECK(BrowserThread::CurrentlyOn(origin_thread_id_));
- if(provider_)
+ DCHECK(MessageLoop::current() ==
+ GeolocationProvider::GetInstance()->message_loop());
+ if (provider_)
provider_->SetPosition(&position);
}
« no previous file with comments | « chrome/browser/geolocation/core_location_data_provider_mac.h ('k') | chrome/browser/geolocation/core_location_provider_mac.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698