summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-29 03:01:49 +0000
committerjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-29 03:01:49 +0000
commit6bd4083b2fbaa7eb92a549aa2c78950adee2ae9e (patch)
tree107491ca0b140e596c9e7d5ceb4b200d31f8d607
parent95e8108cbc0c398b9499c54974d49ebabeb3be00 (diff)
downloadchromium_src-6bd4083b2fbaa7eb92a549aa2c78950adee2ae9e.zip
chromium_src-6bd4083b2fbaa7eb92a549aa2c78950adee2ae9e.tar.gz
chromium_src-6bd4083b2fbaa7eb92a549aa2c78950adee2ae9e.tar.bz2
Move geolocation code to content namespace.
TBR=scottmg Review URL: https://codereview.chromium.org/11276058 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@164586 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/geolocation/wifi_data_provider_chromeos.cc7
-rw-r--r--chrome/browser/geolocation/wifi_data_provider_chromeos.h18
-rw-r--r--chrome/browser/geolocation/wifi_data_provider_unittest_chromeos.cc4
-rw-r--r--content/browser/android/browser_jni_registrar.cc2
-rw-r--r--content/browser/geolocation/arbitrator_dependency_factories_for_test.cc3
-rw-r--r--content/browser/geolocation/arbitrator_dependency_factories_for_test.h5
-rw-r--r--content/browser/geolocation/arbitrator_dependency_factory.cc12
-rw-r--r--content/browser/geolocation/arbitrator_dependency_factory.h19
-rw-r--r--content/browser/geolocation/core_location_data_provider_mac.h10
-rw-r--r--content/browser/geolocation/core_location_data_provider_mac.mm24
-rw-r--r--content/browser/geolocation/core_location_provider_mac.h9
-rw-r--r--content/browser/geolocation/core_location_provider_mac.mm12
-rw-r--r--content/browser/geolocation/device_data_provider.cc4
-rw-r--r--content/browser/geolocation/device_data_provider.h4
-rw-r--r--content/browser/geolocation/device_data_provider_unittest.cc4
-rw-r--r--content/browser/geolocation/empty_device_data_provider.cc4
-rw-r--r--content/browser/geolocation/empty_device_data_provider.h4
-rw-r--r--content/browser/geolocation/geolocation_dispatcher_host.cc5
-rw-r--r--content/browser/geolocation/geolocation_dispatcher_host.h2
-rw-r--r--content/browser/geolocation/geolocation_observer.h5
-rw-r--r--content/browser/geolocation/geolocation_provider.cc17
-rw-r--r--content/browser/geolocation/geolocation_provider.h19
-rw-r--r--content/browser/geolocation/geolocation_provider_unittest.cc38
-rw-r--r--content/browser/geolocation/gps_location_provider_linux.cc20
-rw-r--r--content/browser/geolocation/gps_location_provider_linux.h8
-rw-r--r--content/browser/geolocation/gps_location_provider_unittest_linux.cc33
-rw-r--r--content/browser/geolocation/libgps_wrapper_linux.cc177
-rw-r--r--content/browser/geolocation/libgps_wrapper_linux.h58
-rw-r--r--content/browser/geolocation/location_api_adapter_android.cc16
-rw-r--r--content/browser/geolocation/location_api_adapter_android.h11
-rw-r--r--content/browser/geolocation/location_arbitrator.cc8
-rw-r--r--content/browser/geolocation/location_arbitrator.h24
-rw-r--r--content/browser/geolocation/location_arbitrator_unittest.cc11
-rw-r--r--content/browser/geolocation/location_provider.cc4
-rw-r--r--content/browser/geolocation/location_provider.h15
-rw-r--r--content/browser/geolocation/location_provider_android.cc8
-rw-r--r--content/browser/geolocation/location_provider_android.h9
-rw-r--r--content/browser/geolocation/mock_location_provider.cc11
-rw-r--r--content/browser/geolocation/mock_location_provider.h10
-rw-r--r--content/browser/geolocation/network_location_provider.cc6
-rw-r--r--content/browser/geolocation/network_location_provider.h20
-rw-r--r--content/browser/geolocation/network_location_provider_unittest.cc7
-rw-r--r--content/browser/geolocation/network_location_request.cc19
-rw-r--r--content/browser/geolocation/network_location_request.h11
-rw-r--r--content/browser/geolocation/wifi_data_provider_common.cc4
-rw-r--r--content/browser/geolocation/wifi_data_provider_common.h4
-rw-r--r--content/browser/geolocation/wifi_data_provider_common_unittest.cc5
-rw-r--r--content/browser/geolocation/wifi_data_provider_common_win.cc4
-rw-r--r--content/browser/geolocation/wifi_data_provider_common_win.h4
-rw-r--r--content/browser/geolocation/wifi_data_provider_corewlan_mac.mm4
-rw-r--r--content/browser/geolocation/wifi_data_provider_linux.cc3
-rw-r--r--content/browser/geolocation/wifi_data_provider_linux.h4
-rw-r--r--content/browser/geolocation/wifi_data_provider_linux_unittest.cc4
-rw-r--r--content/browser/geolocation/wifi_data_provider_mac.cc3
-rw-r--r--content/browser/geolocation/wifi_data_provider_mac.h4
-rw-r--r--content/browser/geolocation/wifi_data_provider_unittest_win.cc4
-rw-r--r--content/browser/geolocation/wifi_data_provider_win.cc3
-rw-r--r--content/browser/geolocation/wifi_data_provider_win.h3
-rw-r--r--content/browser/geolocation/win7_location_api_unittest_win.cc12
-rw-r--r--content/browser/geolocation/win7_location_api_win.cc16
-rw-r--r--content/browser/geolocation/win7_location_api_win.h7
-rw-r--r--content/browser/geolocation/win7_location_provider_unittest_win.cc19
-rw-r--r--content/browser/geolocation/win7_location_provider_win.cc17
-rw-r--r--content/browser/geolocation/win7_location_provider_win.h8
64 files changed, 602 insertions, 247 deletions
diff --git a/chrome/browser/geolocation/wifi_data_provider_chromeos.cc b/chrome/browser/geolocation/wifi_data_provider_chromeos.cc
index a415c66..265ddc1 100644
--- a/chrome/browser/geolocation/wifi_data_provider_chromeos.cc
+++ b/chrome/browser/geolocation/wifi_data_provider_chromeos.cc
@@ -12,7 +12,14 @@
#include "chrome/browser/chromeos/cros/network_library.h"
#include "content/public/browser/browser_thread.h"
+using content::AccessPointData;
using content::BrowserThread;
+using content::GenericPollingPolicy;
+using content::PollingPolicyInterface;
+using content::WifiData;
+using content::WifiDataProvider;
+using content::WifiDataProviderCommon;
+using content::WifiDataProviderImplBase;
namespace {
// The time periods between successive polls of the wifi data.
diff --git a/chrome/browser/geolocation/wifi_data_provider_chromeos.h b/chrome/browser/geolocation/wifi_data_provider_chromeos.h
index 2d9fa7d..5d6ecae 100644
--- a/chrome/browser/geolocation/wifi_data_provider_chromeos.h
+++ b/chrome/browser/geolocation/wifi_data_provider_chromeos.h
@@ -12,17 +12,17 @@ namespace chromeos {
class NetworkLibrary;
}
-class WifiDataProviderChromeOs : public WifiDataProviderImplBase {
+class WifiDataProviderChromeOs : public content::WifiDataProviderImplBase {
public:
WifiDataProviderChromeOs();
// WifiDataProviderImplBase
virtual bool StartDataProvider() OVERRIDE;
virtual void StopDataProvider() OVERRIDE;
- virtual bool GetData(WifiData* data) OVERRIDE;
+ virtual bool GetData(content::WifiData* data) OVERRIDE;
// Allows injection of |lib| for testing.
- static WifiDataProviderCommon::WlanApiInterface* NewWlanApi(
+ static content::WifiDataProviderCommon::WlanApiInterface* NewWlanApi(
chromeos::NetworkLibrary* lib);
private:
@@ -35,13 +35,13 @@ class WifiDataProviderChromeOs : public WifiDataProviderImplBase {
// Client thread
void DidWifiScanTaskNoResults();
- void DidWifiScanTask(const WifiData& new_data);
+ void DidWifiScanTask(const content::WifiData& new_data);
void MaybeNotifyListeners(bool update_available);
void DidStartFailed();
// WifiDataProviderCommon
- virtual WifiDataProviderCommon::WlanApiInterface* NewWlanApi();
- virtual PollingPolicyInterface* NewPollingPolicy();
+ virtual content::WifiDataProviderCommon::WlanApiInterface* NewWlanApi();
+ virtual content::PollingPolicyInterface* NewPollingPolicy();
// Will schedule a scan; i.e. enqueue DoWifiScanTask deferred task.
void ScheduleNextScan(int interval);
@@ -53,13 +53,13 @@ class WifiDataProviderChromeOs : public WifiDataProviderImplBase {
void ScheduleStop();
// Underlying OS wifi API. (UI thread)
- scoped_ptr<WifiDataProviderCommon::WlanApiInterface> wlan_api_;
+ scoped_ptr<content::WifiDataProviderCommon::WlanApiInterface> wlan_api_;
// Controls the polling update interval. (client thread)
- scoped_ptr<PollingPolicyInterface> polling_policy_;
+ scoped_ptr<content::PollingPolicyInterface> polling_policy_;
// The latest wifi data. (client thread)
- WifiData wifi_data_;
+ content::WifiData wifi_data_;
// Whether we have strated the data provider. (client thread)
bool started_;
diff --git a/chrome/browser/geolocation/wifi_data_provider_unittest_chromeos.cc b/chrome/browser/geolocation/wifi_data_provider_unittest_chromeos.cc
index 1407449..fbd9925 100644
--- a/chrome/browser/geolocation/wifi_data_provider_unittest_chromeos.cc
+++ b/chrome/browser/geolocation/wifi_data_provider_unittest_chromeos.cc
@@ -40,8 +40,8 @@ class GeolocationChromeOsWifiDataProviderTest : public testing::Test {
}
chromeos::MockNetworkLibrary net_lib_;
- scoped_ptr<WifiDataProviderCommon::WlanApiInterface> api_;
- WifiData::AccessPointDataSet ap_data_;
+ scoped_ptr<content::WifiDataProviderCommon::WlanApiInterface> api_;
+ content::WifiData::AccessPointDataSet ap_data_;
};
TEST_F(GeolocationChromeOsWifiDataProviderTest, WifiPoweredOff) {
diff --git a/content/browser/android/browser_jni_registrar.cc b/content/browser/android/browser_jni_registrar.cc
index 1ee779d..e539472 100644
--- a/content/browser/android/browser_jni_registrar.cc
+++ b/content/browser/android/browser_jni_registrar.cc
@@ -26,7 +26,7 @@ using content::SurfaceTexturePeerBrowserImpl;
namespace {
base::android::RegistrationMethod kContentRegisteredMethods[] = {
{ "AndroidLocationApiAdapter",
- AndroidLocationApiAdapter::RegisterGeolocationService },
+ content::AndroidLocationApiAdapter::RegisterGeolocationService },
{ "AndroidBrowserProcess", content::RegisterAndroidBrowserProcess },
{ "BrowserProcessSurfaceTexture",
SurfaceTexturePeerBrowserImpl::RegisterBrowserProcessSurfaceTexture },
diff --git a/content/browser/geolocation/arbitrator_dependency_factories_for_test.cc b/content/browser/geolocation/arbitrator_dependency_factories_for_test.cc
index fcdd095..8257d8a 100644
--- a/content/browser/geolocation/arbitrator_dependency_factories_for_test.cc
+++ b/content/browser/geolocation/arbitrator_dependency_factories_for_test.cc
@@ -4,7 +4,7 @@
#include "content/browser/geolocation/arbitrator_dependency_factories_for_test.h"
-using content::AccessTokenStore;
+namespace content {
GeolocationArbitratorDependencyFactoryWithLocationProvider::
GeolocationArbitratorDependencyFactoryWithLocationProvider(
@@ -32,3 +32,4 @@ GeolocationArbitratorDependencyFactoryWithLocationProvider::
~GeolocationArbitratorDependencyFactoryWithLocationProvider() {
}
+} // namespace content
diff --git a/content/browser/geolocation/arbitrator_dependency_factories_for_test.h b/content/browser/geolocation/arbitrator_dependency_factories_for_test.h
index e3797f3..b57d78e 100644
--- a/content/browser/geolocation/arbitrator_dependency_factories_for_test.h
+++ b/content/browser/geolocation/arbitrator_dependency_factories_for_test.h
@@ -7,6 +7,8 @@
#include "content/browser/geolocation/arbitrator_dependency_factory.h"
+namespace content {
+
class GeolocationArbitratorDependencyFactoryWithLocationProvider
: public DefaultGeolocationArbitratorDependencyFactory {
public:
@@ -16,7 +18,7 @@ class GeolocationArbitratorDependencyFactoryWithLocationProvider
LocationProviderFactoryFunction factory_function);
virtual LocationProviderBase* NewNetworkLocationProvider(
- content::AccessTokenStore* access_token_store,
+ AccessTokenStore* access_token_store,
net::URLRequestContextGetter* context,
const GURL& url,
const string16& access_token) OVERRIDE;
@@ -29,5 +31,6 @@ class GeolocationArbitratorDependencyFactoryWithLocationProvider
LocationProviderFactoryFunction factory_function_;
};
+} // namespace content
#endif // CONTENT_BROWSER_GEOLOCATION_ARBITRATOR_DEPENDENCY_FACTORIES_FOR_TEST_H_
diff --git a/content/browser/geolocation/arbitrator_dependency_factory.cc b/content/browser/geolocation/arbitrator_dependency_factory.cc
index 170f6d3..3a77112 100644
--- a/content/browser/geolocation/arbitrator_dependency_factory.cc
+++ b/content/browser/geolocation/arbitrator_dependency_factory.cc
@@ -9,7 +9,7 @@
#include "content/public/browser/access_token_store.h"
#include "content/public/browser/content_browser_client.h"
-using content::AccessTokenStore;
+namespace content {
// GeolocationArbitratorDependencyFactory
GeolocationArbitratorDependencyFactory::
@@ -24,7 +24,7 @@ DefaultGeolocationArbitratorDependencyFactory::GetTimeFunction() {
AccessTokenStore*
DefaultGeolocationArbitratorDependencyFactory::NewAccessTokenStore() {
- return content::GetContentClient()->browser()->CreateAccessTokenStore();
+ return GetContentClient()->browser()->CreateAccessTokenStore();
}
LocationProviderBase*
@@ -37,16 +37,18 @@ DefaultGeolocationArbitratorDependencyFactory::NewNetworkLocationProvider(
// Android uses its own SystemLocationProvider.
return NULL;
#else
- return ::NewNetworkLocationProvider(access_token_store, context,
- url, access_token);
+ return NewNetworkLocationProvider(access_token_store, context, url,
+ access_token);
#endif
}
LocationProviderBase*
DefaultGeolocationArbitratorDependencyFactory::NewSystemLocationProvider() {
- return ::NewSystemLocationProvider();
+ return NewSystemLocationProvider();
}
DefaultGeolocationArbitratorDependencyFactory::
~DefaultGeolocationArbitratorDependencyFactory() {
}
+
+} // namespace content
diff --git a/content/browser/geolocation/arbitrator_dependency_factory.h b/content/browser/geolocation/arbitrator_dependency_factory.h
index 952726c..4affa8f 100644
--- a/content/browser/geolocation/arbitrator_dependency_factory.h
+++ b/content/browser/geolocation/arbitrator_dependency_factory.h
@@ -10,20 +10,19 @@
#include "content/common/content_export.h"
class GURL;
-class LocationProviderBase;
namespace base {
class Time;
}
-namespace content {
-class AccessTokenStore;
-}
-
namespace net {
class URLRequestContextGetter;
}
+namespace content {
+class AccessTokenStore;
+class LocationProviderBase;
+
// Allows injection of factory methods for creating the location providers.
// RefCounted for simplicity of writing tests.
class CONTENT_EXPORT GeolocationArbitratorDependencyFactory
@@ -33,9 +32,9 @@ class CONTENT_EXPORT GeolocationArbitratorDependencyFactory
typedef base::Time (*GetTimeNow)();
virtual GetTimeNow GetTimeFunction() = 0;
- virtual content::AccessTokenStore* NewAccessTokenStore() = 0;
+ virtual AccessTokenStore* NewAccessTokenStore() = 0;
virtual LocationProviderBase* NewNetworkLocationProvider(
- content::AccessTokenStore* access_token_store,
+ AccessTokenStore* access_token_store,
net::URLRequestContextGetter* context,
const GURL& url,
const string16& access_token) = 0;
@@ -53,9 +52,9 @@ class CONTENT_EXPORT DefaultGeolocationArbitratorDependencyFactory
public:
// GeolocationArbitratorDependencyFactory
virtual GetTimeNow GetTimeFunction() OVERRIDE;
- virtual content::AccessTokenStore* NewAccessTokenStore() OVERRIDE;
+ virtual AccessTokenStore* NewAccessTokenStore() OVERRIDE;
virtual LocationProviderBase* NewNetworkLocationProvider(
- content::AccessTokenStore* access_token_store,
+ AccessTokenStore* access_token_store,
net::URLRequestContextGetter* context,
const GURL& url,
const string16& access_token) OVERRIDE;
@@ -65,4 +64,6 @@ class CONTENT_EXPORT DefaultGeolocationArbitratorDependencyFactory
virtual ~DefaultGeolocationArbitratorDependencyFactory();
};
+} // namespace content
+
#endif // CONTENT_BROWSER_GEOLOCATION_ARBITRATOR_DEPENDENCY_FACTORY_H_
diff --git a/content/browser/geolocation/core_location_data_provider_mac.h b/content/browser/geolocation/core_location_data_provider_mac.h
index 1ad64c6..eab0e88 100644
--- a/content/browser/geolocation/core_location_data_provider_mac.h
+++ b/content/browser/geolocation/core_location_data_provider_mac.h
@@ -16,9 +16,11 @@
#import <Foundation/Foundation.h>
-class CoreLocationProviderMac;
@class CoreLocationWrapperMac;
+namespace content {
+class CoreLocationProviderMac;
+
// Data provider class that allows CoreLocation to run in Chrome's UI thread
// while existing on any of Chrome's threads (in this case the IO thread)
class CoreLocationDataProviderMac
@@ -29,7 +31,7 @@ class CoreLocationDataProviderMac
bool StartUpdating(CoreLocationProviderMac* provider);
void StopUpdating();
- void UpdatePosition(content::Geoposition* position);
+ void UpdatePosition(Geoposition* position);
protected:
friend class base::RefCountedThreadSafe<CoreLocationDataProviderMac>;
@@ -40,7 +42,7 @@ class CoreLocationDataProviderMac
void StartUpdatingTask();
void StopUpdatingTask();
// This must execute in the origin thread (IO thread)
- void PositionUpdated(content::Geoposition position);
+ void PositionUpdated(Geoposition position);
// The wrapper class that supplies this class with position data
scoped_nsobject<CoreLocationWrapperMac> wrapper_;
@@ -48,4 +50,6 @@ class CoreLocationDataProviderMac
CoreLocationProviderMac* provider_;
};
+} // namespace content
+
#endif // CONTENT_BROWSER_GEOLOCATION_CORE_LOCATION_DATA_PROVIDER_H_
diff --git a/content/browser/geolocation/core_location_data_provider_mac.mm b/content/browser/geolocation/core_location_data_provider_mac.mm
index de07254..51d09ad 100644
--- a/content/browser/geolocation/core_location_data_provider_mac.mm
+++ b/content/browser/geolocation/core_location_data_provider_mac.mm
@@ -17,7 +17,8 @@
#include "content/browser/geolocation/core_location_provider_mac.h"
#include "content/browser/geolocation/geolocation_provider.h"
-using content::BrowserThread;
+using content::CoreLocationDataProviderMac;
+using content::Geoposition;
// A few required declarations since the CoreLocation headers are not available
// with the Mac OS X 10.5 SDK.
@@ -140,7 +141,7 @@ enum {
- (void)locationManager:(CLLocationManager*)manager
didUpdateToLocation:(CLLocation*)newLocation
fromLocation:(CLLocation*)oldLocation {
- content::Geoposition position;
+ Geoposition position;
position.latitude = [newLocation coordinate].latitude;
position.longitude = [newLocation coordinate].longitude;
position.altitude = [newLocation altitude];
@@ -149,20 +150,19 @@ enum {
position.speed = [newLocation speed];
position.heading = [newLocation course];
position.timestamp = base::Time::Now();
- position.error_code = content::Geoposition::ERROR_CODE_NONE;
+ position.error_code = Geoposition::ERROR_CODE_NONE;
dataProvider_->UpdatePosition(&position);
}
- (void)locationManager:(CLLocationManager*)manager
didFailWithError:(NSError*)error {
- content::Geoposition position;
+ Geoposition position;
switch ([error code]) {
case kCLErrorLocationUnknown:
- position.error_code =
- content::Geoposition::ERROR_CODE_POSITION_UNAVAILABLE;
+ position.error_code = Geoposition::ERROR_CODE_POSITION_UNAVAILABLE;
break;
case kCLErrorDenied:
- position.error_code = content::Geoposition::ERROR_CODE_PERMISSION_DENIED;
+ position.error_code = Geoposition::ERROR_CODE_PERMISSION_DENIED;
break;
default:
NOTREACHED() << "Unknown CoreLocation error: " << [error code];
@@ -188,6 +188,8 @@ enum {
@end
+namespace content {
+
CoreLocationDataProviderMac::CoreLocationDataProviderMac() {
if (MessageLoop::current() !=
GeolocationProvider::GetInstance()->message_loop()) {
@@ -224,8 +226,7 @@ void CoreLocationDataProviderMac::StopUpdating() {
base::Bind(&CoreLocationDataProviderMac::StopUpdatingTask, this));
}
-void CoreLocationDataProviderMac::UpdatePosition(
- content::Geoposition *position) {
+void CoreLocationDataProviderMac::UpdatePosition(Geoposition *position) {
GeolocationProvider::GetInstance()->message_loop()->PostTask(
FROM_HERE,
base::Bind(&CoreLocationDataProviderMac::PositionUpdated, this,
@@ -244,10 +245,11 @@ void CoreLocationDataProviderMac::StopUpdatingTask() {
[wrapper_ stopLocation];
}
-void CoreLocationDataProviderMac::PositionUpdated(
- content::Geoposition position) {
+void CoreLocationDataProviderMac::PositionUpdated(Geoposition position) {
DCHECK(MessageLoop::current() ==
GeolocationProvider::GetInstance()->message_loop());
if (provider_)
provider_->SetPosition(&position);
}
+
+} // namespace content
diff --git a/content/browser/geolocation/core_location_provider_mac.h b/content/browser/geolocation/core_location_provider_mac.h
index 999ce11..e18b815 100644
--- a/content/browser/geolocation/core_location_provider_mac.h
+++ b/content/browser/geolocation/core_location_provider_mac.h
@@ -12,6 +12,7 @@
#include "content/browser/geolocation/location_provider.h"
#include "content/public/common/geoposition.h"
+namespace content {
class CoreLocationDataProviderMac;
class CoreLocationProviderMac : public LocationProviderBase {
@@ -22,15 +23,17 @@ class CoreLocationProviderMac : public LocationProviderBase {
// LocationProvider
virtual bool StartProvider(bool high_accuracy) OVERRIDE;
virtual void StopProvider() OVERRIDE;
- virtual void GetPosition(content::Geoposition* position) OVERRIDE;
+ virtual void GetPosition(Geoposition* position) OVERRIDE;
// Receives new positions and calls UpdateListeners
- void SetPosition(content::Geoposition* position);
+ void SetPosition(Geoposition* position);
private:
bool is_updating_;
CoreLocationDataProviderMac* data_provider_;
- content::Geoposition position_;
+ Geoposition position_;
};
+} // namespace content
+
#endif // CONTENT_BROWSER_GEOLOCATION_CORE_LOCATION_PROVIDER_MAC_H_
diff --git a/content/browser/geolocation/core_location_provider_mac.mm b/content/browser/geolocation/core_location_provider_mac.mm
index 80ffef9..0380247 100644
--- a/content/browser/geolocation/core_location_provider_mac.mm
+++ b/content/browser/geolocation/core_location_provider_mac.mm
@@ -9,6 +9,8 @@
#include "content/browser/geolocation/core_location_data_provider_mac.h"
#include "content/public/common/content_switches.h"
+namespace content {
+
CoreLocationProviderMac::CoreLocationProviderMac()
: is_updating_(false) {
data_provider_ = new CoreLocationDataProviderMac();
@@ -36,18 +38,18 @@ void CoreLocationProviderMac::StopProvider() {
is_updating_ = false;
}
-void CoreLocationProviderMac::GetPosition(content::Geoposition* position) {
+void CoreLocationProviderMac::GetPosition(Geoposition* position) {
DCHECK(position);
*position = position_;
DCHECK(position->Validate() ||
- position->error_code != content::Geoposition::ERROR_CODE_NONE);
+ position->error_code != Geoposition::ERROR_CODE_NONE);
}
-void CoreLocationProviderMac::SetPosition(content::Geoposition* position) {
+void CoreLocationProviderMac::SetPosition(Geoposition* position) {
DCHECK(position);
position_ = *position;
DCHECK(position->Validate() ||
- position->error_code != content::Geoposition::ERROR_CODE_NONE);
+ position->error_code != Geoposition::ERROR_CODE_NONE);
UpdateListeners();
}
@@ -58,3 +60,5 @@ LocationProviderBase* NewSystemLocationProvider() {
}
return NULL;
}
+
+} // namespace content
diff --git a/content/browser/geolocation/device_data_provider.cc b/content/browser/geolocation/device_data_provider.cc
index 4d98d5b..00c585b 100644
--- a/content/browser/geolocation/device_data_provider.cc
+++ b/content/browser/geolocation/device_data_provider.cc
@@ -4,6 +4,8 @@
#include "content/browser/geolocation/device_data_provider.h"
+namespace content {
+
// statics
template<> DeviceDataProvider<WifiData>*
DeviceDataProvider<WifiData>::instance_ = NULL;
@@ -48,3 +50,5 @@ bool WifiData::DiffersSignificantly(const WifiData& other) const {
// Test how many have changed.
return max_ap_count > num_common + difference_threadhold;
}
+
+} // namespace content
diff --git a/content/browser/geolocation/device_data_provider.h b/content/browser/geolocation/device_data_provider.h
index 36b3ec8..b1014ad 100644
--- a/content/browser/geolocation/device_data_provider.h
+++ b/content/browser/geolocation/device_data_provider.h
@@ -33,6 +33,8 @@
#include "base/threading/non_thread_safe.h"
#include "content/common/content_export.h"
+namespace content {
+
// Wifi data relating to a single access point.
struct CONTENT_EXPORT AccessPointData {
AccessPointData();
@@ -302,4 +304,6 @@ class DeviceDataProvider : public base::NonThreadSafe {
typedef DeviceDataProvider<WifiData> WifiDataProvider;
+} // namespace content
+
#endif // CONTENT_BROWSER_GEOLOCATION_DEVICE_DATA_PROVIDER_H_
diff --git a/content/browser/geolocation/device_data_provider_unittest.cc b/content/browser/geolocation/device_data_provider_unittest.cc
index 640a8fc..87b896c 100644
--- a/content/browser/geolocation/device_data_provider_unittest.cc
+++ b/content/browser/geolocation/device_data_provider_unittest.cc
@@ -7,7 +7,7 @@
#include "content/browser/geolocation/wifi_data_provider_common.h"
#include "testing/gtest/include/gtest/gtest.h"
-namespace {
+namespace content {
class NullWifiDataListenerInterface
: public WifiDataProviderCommon::ListenerInterface {
@@ -38,4 +38,4 @@ TEST(GeolocationDeviceDataProviderWifiData, CreateDestroy) {
}
}
-} // namespace
+} // namespace content
diff --git a/content/browser/geolocation/empty_device_data_provider.cc b/content/browser/geolocation/empty_device_data_provider.cc
index 11fce6d..57e25b0 100644
--- a/content/browser/geolocation/empty_device_data_provider.cc
+++ b/content/browser/geolocation/empty_device_data_provider.cc
@@ -4,6 +4,8 @@
#include "content/browser/geolocation/empty_device_data_provider.h"
+namespace content {
+
// Only define for platforms that lack a real wifi data provider.
#if !defined(OS_WIN) && !defined(OS_MACOSX) && !defined(OS_LINUX)
// static
@@ -12,3 +14,5 @@ WifiDataProviderImplBase* WifiDataProvider::DefaultFactoryFunction() {
return new EmptyDeviceDataProvider<WifiData>();
}
#endif
+
+} // namespace content
diff --git a/content/browser/geolocation/empty_device_data_provider.h b/content/browser/geolocation/empty_device_data_provider.h
index 2aac394..76653f5 100644
--- a/content/browser/geolocation/empty_device_data_provider.h
+++ b/content/browser/geolocation/empty_device_data_provider.h
@@ -7,6 +7,8 @@
#include "content/browser/geolocation/device_data_provider.h"
+namespace content {
+
// An implementation of DeviceDataProviderImplBase that does not provide any
// data. Used on platforms where a given data type is not available.
@@ -29,4 +31,6 @@ class EmptyDeviceDataProvider : public DeviceDataProviderImplBase<DataType> {
DISALLOW_COPY_AND_ASSIGN(EmptyDeviceDataProvider);
};
+} // namespace content
+
#endif // CONTENT_BROWSER_GEOLOCATION_EMPTY_DEVICE_DATA_PROVIDER_H_
diff --git a/content/browser/geolocation/geolocation_dispatcher_host.cc b/content/browser/geolocation/geolocation_dispatcher_host.cc
index e052541..c5591cd 100644
--- a/content/browser/geolocation/geolocation_dispatcher_host.cc
+++ b/content/browser/geolocation/geolocation_dispatcher_host.cc
@@ -18,7 +18,6 @@
#include "content/common/geolocation_messages.h"
namespace content {
-
namespace {
void NotifyArbitratorPermissionGranted() {
@@ -68,7 +67,7 @@ class GeolocationDispatcherHostImpl : public GeolocationDispatcherHost,
const GURL& requesting_frame);
void OnStartUpdating(int render_view_id,
const GURL& requesting_frame,
- bool enable_high_accuracy);
+ bool enable_high_accuracy);
void OnStopUpdating(int render_view_id);
// Updates the |location_arbitrator_| with the currently required update
@@ -162,7 +161,7 @@ void GeolocationDispatcherHostImpl::OnCancelPermissionRequest(
DVLOG(1) << __FUNCTION__ << " " << render_process_id_ << ":"
<< render_view_id << ":" << bridge_id;
if (geolocation_permission_context_) {
- geolocation_permission_context_->CancelGeolocationPermissionRequest(
+ geolocation_permission_context_->CancelGeolocationPermissionRequest(
render_process_id_, render_view_id, bridge_id, requesting_frame);
}
}
diff --git a/content/browser/geolocation/geolocation_dispatcher_host.h b/content/browser/geolocation/geolocation_dispatcher_host.h
index f3e03af..0631c87 100644
--- a/content/browser/geolocation/geolocation_dispatcher_host.h
+++ b/content/browser/geolocation/geolocation_dispatcher_host.h
@@ -17,7 +17,7 @@ class GeolocationDispatcherHost : public BrowserMessageFilter {
public:
static GeolocationDispatcherHost* New(
int render_process_id,
- content::GeolocationPermissionContext* geolocation_permission_context);
+ GeolocationPermissionContext* geolocation_permission_context);
protected:
GeolocationDispatcherHost();
diff --git a/content/browser/geolocation/geolocation_observer.h b/content/browser/geolocation/geolocation_observer.h
index 0411ad0..f498ff8 100644
--- a/content/browser/geolocation/geolocation_observer.h
+++ b/content/browser/geolocation/geolocation_observer.h
@@ -10,7 +10,6 @@
namespace content {
struct Geoposition;
-}
// This interface is implemented by observers of GeolocationProvider as
// well as GeolocationProvider itself as an observer of GeolocationArbitrator.
@@ -19,7 +18,7 @@ class CONTENT_EXPORT GeolocationObserver {
// This will be called whenever the 'best available' location is updated,
// or when an error is encountered meaning no location data will be
// available in the forseeable future.
- virtual void OnLocationUpdate(const content::Geoposition& position) = 0;
+ virtual void OnLocationUpdate(const Geoposition& position) = 0;
protected:
GeolocationObserver() {}
@@ -55,4 +54,6 @@ struct GeolocationObserverOptions {
bool use_high_accuracy;
};
+} // namespace content
+
#endif // CONTENT_BROWSER_GEOLOCATION_GEOLOCATION_OBSERVER_H_
diff --git a/content/browser/geolocation/geolocation_provider.cc b/content/browser/geolocation/geolocation_provider.cc
index f1d2dd5..2b626d8 100644
--- a/content/browser/geolocation/geolocation_provider.cc
+++ b/content/browser/geolocation/geolocation_provider.cc
@@ -14,7 +14,7 @@
#include "content/browser/geolocation/location_arbitrator.h"
#include "content/public/browser/browser_thread.h"
-using content::BrowserThread;
+namespace content {
void GeolocationProvider::AddObserver(GeolocationObserver* observer,
const GeolocationObserverOptions& update_options) {
@@ -22,7 +22,7 @@ void GeolocationProvider::AddObserver(GeolocationObserver* observer,
observers_[observer] = update_options;
OnClientsChanged();
if (position_.Validate() ||
- position_.error_code != content::Geoposition::ERROR_CODE_NONE)
+ position_.error_code != Geoposition::ERROR_CODE_NONE)
observer->OnLocationUpdate(position_);
}
@@ -35,7 +35,7 @@ bool GeolocationProvider::RemoveObserver(GeolocationObserver* observer) {
}
void GeolocationProvider::RequestCallback(
- const content::GeolocationUpdateCallback& callback) {
+ const GeolocationUpdateCallback& callback) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
callbacks_.push_back(callback);
OnClientsChanged();
@@ -55,8 +55,7 @@ bool GeolocationProvider::HasPermissionBeenGranted() const {
return is_permission_granted_;
}
-void GeolocationProvider::OnLocationUpdate(
- const content::Geoposition& position) {
+void GeolocationProvider::OnLocationUpdate(const Geoposition& position) {
DCHECK(OnGeolocationThread());
// Will be true only in testing.
if (ignore_location_updates_)
@@ -68,7 +67,7 @@ void GeolocationProvider::OnLocationUpdate(
}
void GeolocationProvider::OverrideLocationForTesting(
- const content::Geoposition& position) {
+ const Geoposition& position) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
position_ = position;
ignore_location_updates_ = true;
@@ -155,10 +154,10 @@ void GeolocationProvider::InformProvidersPermissionGranted() {
arbitrator_->OnPermissionGranted();
}
-void GeolocationProvider::NotifyClients(const content::Geoposition& position) {
+void GeolocationProvider::NotifyClients(const Geoposition& position) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
DCHECK(position.Validate() ||
- position.error_code != content::Geoposition::ERROR_CODE_NONE);
+ position.error_code != Geoposition::ERROR_CODE_NONE);
position_ = position;
ObserverMap::const_iterator it = observers_.begin();
while (it != observers_.end()) {
@@ -192,3 +191,5 @@ void GeolocationProvider::CleanUp() {
delete arbitrator_;
arbitrator_ = NULL;
}
+
+} // namespace content
diff --git a/content/browser/geolocation/geolocation_provider.h b/content/browser/geolocation/geolocation_provider.h
index 1c01063..a7f7c2d 100644
--- a/content/browser/geolocation/geolocation_provider.h
+++ b/content/browser/geolocation/geolocation_provider.h
@@ -16,9 +16,11 @@
#include "content/public/browser/geolocation.h"
#include "content/public/common/geoposition.h"
+template<typename Type> struct DefaultSingletonTraits;
+
+namespace content {
class GeolocationArbitrator;
class GeolocationProviderTest;
-template<typename Type> struct DefaultSingletonTraits;
// This is the main API to the geolocation subsystem. The application will hold
// a single instance of this class and can register multiple clients to be
@@ -51,19 +53,18 @@ class CONTENT_EXPORT GeolocationProvider
// Request a single callback when the next location update becomes available.
// Callbacks must only be requested by code that is allowed to access the
// location. No further permission checks will be made.
- void RequestCallback(const content::GeolocationUpdateCallback& callback);
+ void RequestCallback(const GeolocationUpdateCallback& callback);
void OnPermissionGranted();
bool HasPermissionBeenGranted() const;
// GeolocationObserver implementation.
- virtual void OnLocationUpdate(const content::Geoposition& position) OVERRIDE;
+ virtual void OnLocationUpdate(const Geoposition& position) OVERRIDE;
// Overrides the location for automation/testing. Suppresses any further
// updates from the actual providers and sends an update with the overridden
// position to all registered clients.
- void OverrideLocationForTesting(
- const content::Geoposition& override_position);
+ void OverrideLocationForTesting(const Geoposition& override_position);
// Gets a pointer to the singleton instance of the location relayer, which
// is in turn bound to the browser's global context objects. This must only be
@@ -80,7 +81,7 @@ class CONTENT_EXPORT GeolocationProvider
typedef std::map<GeolocationObserver*, GeolocationObserverOptions>
ObserverMap;
- typedef std::vector<content::GeolocationUpdateCallback> CallbackList;
+ typedef std::vector<GeolocationUpdateCallback> CallbackList;
bool OnGeolocationThread() const;
@@ -100,7 +101,7 @@ class CONTENT_EXPORT GeolocationProvider
void InformProvidersPermissionGranted();
// Notifies all registered clients that a position update is available.
- void NotifyClients(const content::Geoposition& position);
+ void NotifyClients(const Geoposition& position);
// Thread
virtual void Init() OVERRIDE;
@@ -110,7 +111,7 @@ class CONTENT_EXPORT GeolocationProvider
ObserverMap observers_;
CallbackList callbacks_;
bool is_permission_granted_;
- content::Geoposition position_;
+ Geoposition position_;
// True only in testing, where we want to use a custom position.
bool ignore_location_updates_;
@@ -121,4 +122,6 @@ class CONTENT_EXPORT GeolocationProvider
DISALLOW_COPY_AND_ASSIGN(GeolocationProvider);
};
+} // namespace content
+
#endif // CONTENT_BROWSER_GEOLOCATION_GEOLOCATION_PROVIDER_H_
diff --git a/content/browser/geolocation/geolocation_provider_unittest.cc b/content/browser/geolocation/geolocation_provider_unittest.cc
index 6fe87ee..d0e36c1 100644
--- a/content/browser/geolocation/geolocation_provider_unittest.cc
+++ b/content/browser/geolocation/geolocation_provider_unittest.cc
@@ -22,13 +22,12 @@
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
-using content::Geoposition;
using testing::MakeMatcher;
using testing::Matcher;
using testing::MatcherInterface;
using testing::MatchResultListener;
-namespace {
+namespace content {
class NonSingletonGeolocationProvider : public GeolocationProvider {
public:
NonSingletonGeolocationProvider() {}
@@ -55,7 +54,7 @@ class StartStopMockLocationProvider : public MockLocationProvider {
// existing FakeAccessTokenStore class cannot be used here because it is based
// on gmock and gmock is not thread-safe on Windows.
// See: http://code.google.com/p/googlemock/issues/detail?id=156
-class TestingAccessTokenStore : public content::AccessTokenStore {
+class TestingAccessTokenStore : public AccessTokenStore {
public:
TestingAccessTokenStore(base::WaitableEvent* event) : event_(event) {}
@@ -80,12 +79,12 @@ class TestingDependencyFactory
public:
TestingDependencyFactory(base::WaitableEvent* event) : event_(event) {}
- virtual content::AccessTokenStore* NewAccessTokenStore() OVERRIDE {
+ virtual AccessTokenStore* NewAccessTokenStore() OVERRIDE {
return new TestingAccessTokenStore(event_);
}
virtual LocationProviderBase* NewNetworkLocationProvider(
- content::AccessTokenStore* access_token_store,
+ AccessTokenStore* access_token_store,
net::URLRequestContextGetter* context,
const GURL& url,
const string16& access_token) OVERRIDE {
@@ -106,27 +105,27 @@ class TestingDependencyFactory
class NullGeolocationObserver : public GeolocationObserver {
public:
// GeolocationObserver
- virtual void OnLocationUpdate(const content::Geoposition& position) {}
+ virtual void OnLocationUpdate(const Geoposition& position) {}
};
class MockGeolocationObserver : public GeolocationObserver {
public:
// GeolocationObserver
- MOCK_METHOD1(OnLocationUpdate, void(const content::Geoposition& position));
+ MOCK_METHOD1(OnLocationUpdate, void(const Geoposition& position));
};
class MockGeolocationCallbackWrapper {
public:
- MOCK_METHOD1(Callback, void(const content::Geoposition& position));
+ MOCK_METHOD1(Callback, void(const Geoposition& position));
};
class GeopositionEqMatcher
- : public MatcherInterface<const content::Geoposition&> {
+ : public MatcherInterface<const Geoposition&> {
public:
- explicit GeopositionEqMatcher(const content::Geoposition& expected)
+ explicit GeopositionEqMatcher(const Geoposition& expected)
: expected_(expected) {}
- virtual bool MatchAndExplain(const content::Geoposition& actual,
+ virtual bool MatchAndExplain(const Geoposition& actual,
MatchResultListener* listener) const OVERRIDE {
return actual.latitude == expected_.latitude &&
actual.longitude == expected_.longitude &&
@@ -149,13 +148,12 @@ class GeopositionEqMatcher
}
private:
- content::Geoposition expected_;
+ Geoposition expected_;
DISALLOW_COPY_AND_ASSIGN(GeopositionEqMatcher);
};
-Matcher<const content::Geoposition&> GeopositionEq(
- const content::Geoposition& expected) {
+Matcher<const Geoposition&> GeopositionEq(const Geoposition& expected) {
return MakeMatcher(new GeopositionEqMatcher(expected));
}
@@ -163,7 +161,7 @@ class GeolocationProviderTest : public testing::Test {
protected:
GeolocationProviderTest()
: message_loop_(),
- io_thread_(content::BrowserThread::IO, &message_loop_),
+ io_thread_(BrowserThread::IO, &message_loop_),
event_(false, false),
dependency_factory_(new TestingDependencyFactory(&event_)),
provider_(new NonSingletonGeolocationProvider) {
@@ -181,7 +179,7 @@ class GeolocationProviderTest : public testing::Test {
}
MessageLoop message_loop_;
- content::TestBrowserThread io_thread_;
+ TestBrowserThread io_thread_;
base::WaitableEvent event_;
scoped_refptr<TestingDependencyFactory> dependency_factory_;
@@ -213,8 +211,8 @@ TEST_F(GeolocationProviderTest, StartStop) {
}
TEST_F(GeolocationProviderTest, OverrideLocationForTesting) {
- content::Geoposition position;
- position.error_code = content::Geoposition::ERROR_CODE_POSITION_UNAVAILABLE;
+ Geoposition position;
+ position.error_code = Geoposition::ERROR_CODE_POSITION_UNAVAILABLE;
provider_->OverrideLocationForTesting(position);
// Adding an observer when the location is overridden should synchronously
// update the observer with our overridden position.
@@ -237,7 +235,7 @@ TEST_F(GeolocationProviderTest, Callback) {
// Wait for token load request from the arbitrator to come through.
WaitAndReset();
- content::Geoposition position;
+ Geoposition position;
position.latitude = 12;
position.longitude = 34;
position.accuracy = 56;
@@ -248,4 +246,4 @@ TEST_F(GeolocationProviderTest, Callback) {
WaitAndReset();
}
-} // namespace
+} // namespace content
diff --git a/content/browser/geolocation/gps_location_provider_linux.cc b/content/browser/geolocation/gps_location_provider_linux.cc
index 6b23b90..b9c8ec3 100644
--- a/content/browser/geolocation/gps_location_provider_linux.cc
+++ b/content/browser/geolocation/gps_location_provider_linux.cc
@@ -22,6 +22,7 @@
#include "third_party/gpsd/release-3.1/gps.h"
#endif // defined(USE_LIBGPS)
+namespace content {
namespace {
const int kGpsdReconnectRetryIntervalMillis = 10 * 1000;
@@ -39,8 +40,8 @@ const int kMovementThresholdMeters = 20;
// The arbitrary delta is decreased (Gears used 100 meters); if we need to
// decrease it any further we'll likely want to do some smarter filtering to
// remove GPS location jitter noise.
-bool PositionsDifferSiginificantly(const content::Geoposition& position_1,
- const content::Geoposition& position_2) {
+bool PositionsDifferSiginificantly(const Geoposition& position_1,
+ const Geoposition& position_2) {
const bool pos_1_valid = position_1.Validate();
if (pos_1_valid != position_2.Validate())
return true;
@@ -275,7 +276,7 @@ bool GpsLocationProviderLinux::StartProvider(bool high_accuracy) {
DCHECK(weak_factory_.HasWeakPtrs());
return true;
}
- position_.error_code = content::Geoposition::ERROR_CODE_POSITION_UNAVAILABLE;
+ position_.error_code = Geoposition::ERROR_CODE_POSITION_UNAVAILABLE;
gps_.reset(libgps_factory_());
if (gps_ == NULL) {
DLOG(WARNING) << "libgps could not be loaded";
@@ -290,11 +291,11 @@ void GpsLocationProviderLinux::StopProvider() {
gps_.reset();
}
-void GpsLocationProviderLinux::GetPosition(content::Geoposition* position) {
+void GpsLocationProviderLinux::GetPosition(Geoposition* position) {
DCHECK(position);
*position = position_;
DCHECK(position->Validate() ||
- position->error_code != content::Geoposition::ERROR_CODE_NONE);
+ position->error_code != Geoposition::ERROR_CODE_NONE);
}
void GpsLocationProviderLinux::UpdatePosition() {
@@ -308,19 +309,18 @@ void GpsLocationProviderLinux::DoGpsPollTask() {
return;
}
- content::Geoposition new_position;
+ Geoposition new_position;
if (!gps_->Read(&new_position)) {
ScheduleNextGpsPoll(poll_period_stationary_millis_);
return;
}
DCHECK(new_position.Validate() ||
- new_position.error_code != content::Geoposition::ERROR_CODE_NONE);
+ new_position.error_code != Geoposition::ERROR_CODE_NONE);
const bool differ = PositionsDifferSiginificantly(position_, new_position);
ScheduleNextGpsPoll(differ ? poll_period_moving_millis_ :
poll_period_stationary_millis_);
- if (differ ||
- new_position.error_code != content::Geoposition::ERROR_CODE_NONE) {
+ if (differ || new_position.error_code != Geoposition::ERROR_CODE_NONE) {
// Update if the new location is interesting or we have an error to report.
position_ = new_position;
UpdateListeners();
@@ -339,3 +339,5 @@ void GpsLocationProviderLinux::ScheduleNextGpsPoll(int interval) {
LocationProviderBase* NewSystemLocationProvider() {
return new GpsLocationProviderLinux(LibGps::New);
}
+
+} // namespace content
diff --git a/content/browser/geolocation/gps_location_provider_linux.h b/content/browser/geolocation/gps_location_provider_linux.h
index 61936de..c6c1eba 100644
--- a/content/browser/geolocation/gps_location_provider_linux.h
+++ b/content/browser/geolocation/gps_location_provider_linux.h
@@ -17,6 +17,8 @@
#include "content/common/content_export.h"
#include "content/public/common/geoposition.h"
+namespace content {
+
// Defines a wrapper around the C libgps API (gps.h). Similar to the libgpsmm.h
// API provided by that package.
class CONTENT_EXPORT LibGps {
@@ -83,7 +85,7 @@ class CONTENT_EXPORT GpsLocationProviderLinux : public LocationProviderBase {
// LocationProvider
virtual bool StartProvider(bool high_accuracy) OVERRIDE;
virtual void StopProvider() OVERRIDE;
- virtual void GetPosition(content::Geoposition* position) OVERRIDE;
+ virtual void GetPosition(Geoposition* position) OVERRIDE;
virtual void UpdatePosition() OVERRIDE;
private:
@@ -99,10 +101,12 @@ class CONTENT_EXPORT GpsLocationProviderLinux : public LocationProviderBase {
const LibGpsFactory libgps_factory_;
scoped_ptr<LibGps> gps_;
- content::Geoposition position_;
+ Geoposition position_;
// Holder for the tasks which run on the thread; takes care of cleanup.
base::WeakPtrFactory<GpsLocationProviderLinux> weak_factory_;
};
+} // namespace content
+
#endif // CONTENT_BROWSER_GEOLOCATION_GPS_LOCATION_PROVIDER_LINUX_H_
diff --git a/content/browser/geolocation/gps_location_provider_unittest_linux.cc b/content/browser/geolocation/gps_location_provider_unittest_linux.cc
index 6f4053c..4cba202 100644
--- a/content/browser/geolocation/gps_location_provider_unittest_linux.cc
+++ b/content/browser/geolocation/gps_location_provider_unittest_linux.cc
@@ -8,16 +8,14 @@
#include "base/bind.h"
-using content::BrowserThread;
-using content::BrowserThreadImpl;
+namespace content {
-namespace {
class MockLibGps : public LibGps {
public:
MockLibGps();
~MockLibGps();
- virtual bool GetPositionIfFixed(content::Geoposition* position) {
+ virtual bool GetPositionIfFixed(Geoposition* position) {
CHECK(position);
++get_position_calls_;
*position = get_position_;
@@ -46,7 +44,7 @@ class MockLibGps : public LibGps {
int gps_open_ret_;
int gps_read_calls_;
int gps_read_ret_;
- content::Geoposition get_position_;
+ Geoposition get_position_;
static MockLibGps* g_instance_;
};
@@ -77,8 +75,8 @@ class GeolocationGpsProviderLinuxTests : public testing::Test {
scoped_ptr<GpsLocationProviderLinux> provider_;
};
-void CheckValidPosition(const content::Geoposition& expected,
- const content::Geoposition& actual) {
+void CheckValidPosition(const Geoposition& expected,
+ const Geoposition& actual) {
EXPECT_TRUE(actual.Validate());
EXPECT_DOUBLE_EQ(expected.latitude, actual.latitude);
EXPECT_DOUBLE_EQ(expected.longitude, actual.longitude);
@@ -95,8 +93,7 @@ MockLibGps::MockLibGps()
gps_open_ret_(0),
gps_read_calls_(0),
gps_read_ret_(0) {
- get_position_.error_code =
- content::Geoposition::ERROR_CODE_POSITION_UNAVAILABLE;
+ get_position_.error_code = Geoposition::ERROR_CODE_POSITION_UNAVAILABLE;
EXPECT_FALSE(g_instance_);
g_instance_ = this;
}
@@ -121,11 +118,10 @@ TEST_F(GeolocationGpsProviderLinuxTests, NoLibGpsInstalled) {
ASSERT_TRUE(provider_.get());
const bool ok = provider_->StartProvider(true);
EXPECT_FALSE(ok);
- content::Geoposition position;
+ Geoposition position;
provider_->GetPosition(&position);
EXPECT_FALSE(position.Validate());
- EXPECT_EQ(content::Geoposition::ERROR_CODE_POSITION_UNAVAILABLE,
- position.error_code);
+ EXPECT_EQ(Geoposition::ERROR_CODE_POSITION_UNAVAILABLE, position.error_code);
}
#if defined(OS_CHROMEOS)
@@ -138,13 +134,12 @@ TEST_F(GeolocationGpsProviderLinuxTests, GetPosition) {
EXPECT_EQ(0, MockLibGps::g_instance_->get_position_calls_);
EXPECT_EQ(0, MockLibGps::g_instance_->gps_open_calls_);
EXPECT_EQ(0, MockLibGps::g_instance_->gps_read_calls_);
- content::Geoposition position;
+ Geoposition position;
provider_->GetPosition(&position);
EXPECT_FALSE(position.Validate());
- EXPECT_EQ(content::Geoposition::ERROR_CODE_POSITION_UNAVAILABLE,
- position.error_code);
+ EXPECT_EQ(Geoposition::ERROR_CODE_POSITION_UNAVAILABLE, position.error_code);
MockLibGps::g_instance_->get_position_.error_code =
- content::Geoposition::ERROR_CODE_NONE;
+ Geoposition::ERROR_CODE_NONE;
MockLibGps::g_instance_->get_position_.latitude = 4.5;
MockLibGps::g_instance_->get_position_.longitude = -34.1;
MockLibGps::g_instance_->get_position_.accuracy = 345;
@@ -183,9 +178,9 @@ TEST_F(GeolocationGpsProviderLinuxTests, LibGpsReconnect) {
// Let gps_open() fails, and so will LibGps::Start().
// Reconnect will happen in 1000ms.
MockLibGps::g_instance_->gps_open_ret_ = 1;
- content::Geoposition position;
+ Geoposition position;
MockLibGps::g_instance_->get_position_.error_code =
- content::Geoposition::ERROR_CODE_NONE;
+ Geoposition::ERROR_CODE_NONE;
MockLibGps::g_instance_->get_position_.latitude = 4.5;
MockLibGps::g_instance_->get_position_.longitude = -34.1;
MockLibGps::g_instance_->get_position_.accuracy = 345;
@@ -209,4 +204,4 @@ TEST_F(GeolocationGpsProviderLinuxTests, LibGpsReconnect) {
#endif // #if defined(OS_CHROMEOS)
-} // namespace
+} // namespace content
diff --git a/content/browser/geolocation/libgps_wrapper_linux.cc b/content/browser/geolocation/libgps_wrapper_linux.cc
new file mode 100644
index 0000000..a1eb9d1
--- /dev/null
+++ b/content/browser/geolocation/libgps_wrapper_linux.cc
@@ -0,0 +1,177 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "content/browser/geolocation/libgps_wrapper_linux.h"
+
+#include <math.h>
+#include <dlfcn.h>
+#include <errno.h>
+
+#include "base/logging.h"
+#include "base/stringprintf.h"
+#include "content/public/common/geoposition.h"
+#include "third_party/gpsd/release-3.1/gps.h"
+
+COMPILE_ASSERT(GPSD_API_MAJOR_VERSION == 5, GPSD_API_version_is_not_5);
+
+namespace content {
+namespace {
+const char kLibGpsName[] = "libgps.so.20";
+} // namespace
+
+LibGps::LibGps(void* dl_handle,
+ gps_open_fn gps_open,
+ gps_close_fn gps_close,
+ gps_read_fn gps_read)
+ : dl_handle_(dl_handle),
+ gps_open_(gps_open),
+ gps_close_(gps_close),
+ gps_read_(gps_read),
+ gps_data_(new gps_data_t),
+ is_open_(false) {
+ DCHECK(gps_open_);
+ DCHECK(gps_close_);
+ DCHECK(gps_read_);
+}
+
+LibGps::~LibGps() {
+ Stop();
+ if (dl_handle_) {
+ const int err = dlclose(dl_handle_);
+ DCHECK_EQ(0, err) << "Error closing dl handle: " << err;
+ }
+}
+
+LibGps* LibGps::New() {
+ void* dl_handle = dlopen(kLibGpsName, RTLD_LAZY);
+ if (!dl_handle) {
+ DLOG(WARNING) << "Could not open " << kLibGpsName << ": " << dlerror();
+ return NULL;
+ }
+
+ DLOG(INFO) << "Loaded " << kLibGpsName;
+
+ #define DECLARE_FN_POINTER(function) \
+ function##_fn function = reinterpret_cast<function##_fn>( \
+ dlsym(dl_handle, #function)); \
+ if (!function) { \
+ DLOG(WARNING) << "libgps " << #function << " error: " << dlerror(); \
+ dlclose(dl_handle); \
+ return NULL; \
+ }
+ DECLARE_FN_POINTER(gps_open);
+ DECLARE_FN_POINTER(gps_close);
+ DECLARE_FN_POINTER(gps_read);
+ // We don't use gps_shm_read() directly, just to make sure that libgps has
+ // the shared memory support.
+ typedef int (*gps_shm_read_fn)(struct gps_data_t*);
+ DECLARE_FN_POINTER(gps_shm_read);
+ #undef DECLARE_FN_POINTER
+
+ return new LibGps(dl_handle, gps_open, gps_close, gps_read);
+}
+
+bool LibGps::Start() {
+ if (is_open_)
+ return true;
+
+#if defined(OS_CHROMEOS)
+ errno = 0;
+ if (gps_open_(GPSD_SHARED_MEMORY, 0, gps_data_.get()) != 0) {
+ // See gps.h NL_NOxxx for definition of gps_open() error numbers.
+ DLOG(WARNING) << "gps_open() failed " << errno;
+ return false;
+ } else {
+ is_open_ = true;
+ return true;
+ }
+#else // drop the support for desktop linux for now
+ DLOG(WARNING) << "LibGps is only supported on ChromeOS";
+ return false;
+#endif
+}
+void LibGps::Stop() {
+ if (is_open_)
+ gps_close_(gps_data_.get());
+ is_open_ = false;
+}
+
+bool LibGps::Read(Geoposition* position) {
+ DCHECK(position);
+ position->error_code = Geoposition::ERROR_CODE_POSITION_UNAVAILABLE;
+ if (!is_open_) {
+ DLOG(WARNING) << "No gpsd connection";
+ position->error_message = "No gpsd connection";
+ return false;
+ }
+
+ if (gps_read_(gps_data_.get()) < 0) {
+ DLOG(WARNING) << "gps_read() fails";
+ position->error_message = "gps_read() fails";
+ return false;
+ }
+
+ if (!GetPositionIfFixed(position)) {
+ DLOG(WARNING) << "No fixed position";
+ position->error_message = "No fixed position";
+ return false;
+ }
+
+ position->error_code = Geoposition::ERROR_CODE_NONE;
+ position->timestamp = base::Time::Now();
+ if (!position->Validate()) {
+ // GetPositionIfFixed returned true, yet we've not got a valid fix.
+ // This shouldn't happen; something went wrong in the conversion.
+ NOTREACHED() << "Invalid position from GetPositionIfFixed: lat,long "
+ << position->latitude << "," << position->longitude
+ << " accuracy " << position->accuracy << " time "
+ << position->timestamp.ToDoubleT();
+ position->error_code = Geoposition::ERROR_CODE_POSITION_UNAVAILABLE;
+ position->error_message = "Bad fix from gps";
+ return false;
+ }
+ return true;
+}
+
+bool LibGps::GetPositionIfFixed(Geoposition* position) {
+ DCHECK(position);
+ if (gps_data_->status == STATUS_NO_FIX) {
+ DVLOG(2) << "Status_NO_FIX";
+ return false;
+ }
+
+ if (isnan(gps_data_->fix.latitude) || isnan(gps_data_->fix.longitude)) {
+ DVLOG(2) << "No valid lat/lon value";
+ return false;
+ }
+
+ position->latitude = gps_data_->fix.latitude;
+ position->longitude = gps_data_->fix.longitude;
+
+ if (!isnan(gps_data_->fix.epx) && !isnan(gps_data_->fix.epy)) {
+ position->accuracy = std::max(gps_data_->fix.epx, gps_data_->fix.epy);
+ } else if (isnan(gps_data_->fix.epx) && !isnan(gps_data_->fix.epy)) {
+ position->accuracy = gps_data_->fix.epy;
+ } else if (!isnan(gps_data_->fix.epx) && isnan(gps_data_->fix.epy)) {
+ position->accuracy = gps_data_->fix.epx;
+ } else {
+ // TODO(joth): Fixme. This is a workaround for http://crbug.com/99326
+ DVLOG(2) << "libgps reported accuracy NaN, forcing to zero";
+ position->accuracy = 0;
+ }
+
+ if (gps_data_->fix.mode == MODE_3D && !isnan(gps_data_->fix.altitude)) {
+ position->altitude = gps_data_->fix.altitude;
+ if (!isnan(gps_data_->fix.epv))
+ position->altitude_accuracy = gps_data_->fix.epv;
+ }
+
+ if (!isnan(gps_data_->fix.track))
+ position->heading = gps_data_->fix.track;
+ if (!isnan(gps_data_->fix.speed))
+ position->speed = gps_data_->fix.speed;
+ return true;
+}
+
+} // namespace content
diff --git a/content/browser/geolocation/libgps_wrapper_linux.h b/content/browser/geolocation/libgps_wrapper_linux.h
new file mode 100644
index 0000000..08ad1a5
--- /dev/null
+++ b/content/browser/geolocation/libgps_wrapper_linux.h
@@ -0,0 +1,58 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Defines a wrapper around the C libgps API (gps.h). Similar to the libgpsmm.h
+// API provided by that package.
+
+#ifndef CONTENT_BROWSER_GEOLOCATION_LIBGPS_WRAPPER_LINUX_H_
+#define CONTENT_BROWSER_GEOLOCATION_LIBGPS_WRAPPER_LINUX_H_
+
+#include "base/basictypes.h"
+#include "base/memory/scoped_ptr.h"
+#include "content/common/content_export.h"
+
+struct gps_data_t;
+
+namespace content {
+struct Geoposition;
+
+class CONTENT_EXPORT LibGps {
+ public:
+ virtual ~LibGps();
+ // Attempts to dynamically load the libgps.so library and returns NULL on
+ // failure.
+ static LibGps* New();
+
+ bool Start();
+ void Stop();
+ bool Read(Geoposition* position);
+
+ protected:
+ typedef int (*gps_open_fn)(const char*, const char*, struct gps_data_t*);
+ typedef int (*gps_close_fn)(struct gps_data_t*);
+ typedef int (*gps_read_fn)(struct gps_data_t*);
+
+ explicit LibGps(void* dl_handle,
+ gps_open_fn gps_open,
+ gps_close_fn gps_close,
+ gps_read_fn gps_read);
+
+ // Returns false if there is not fix available.
+ virtual bool GetPositionIfFixed(Geoposition* position);
+
+ private:
+ void* dl_handle_;
+ gps_open_fn gps_open_;
+ gps_close_fn gps_close_;
+ gps_read_fn gps_read_;
+
+ scoped_ptr<gps_data_t> gps_data_;
+ bool is_open_;
+
+ DISALLOW_COPY_AND_ASSIGN(LibGps);
+};
+
+} // namespace content
+
+#endif // CONTENT_BROWSER_GEOLOCATION_LIBGPS_WRAPPER_LINUX_H_
diff --git a/content/browser/geolocation/location_api_adapter_android.cc b/content/browser/geolocation/location_api_adapter_android.cc
index 0e71a9f..7d01502 100644
--- a/content/browser/geolocation/location_api_adapter_android.cc
+++ b/content/browser/geolocation/location_api_adapter_android.cc
@@ -14,6 +14,7 @@
using base::android::AttachCurrentThread;
using base::android::CheckException;
using base::android::ClearException;
+using content::AndroidLocationApiAdapter;
static void NewLocationAvailable(JNIEnv* env, jclass,
jdouble latitude,
@@ -32,6 +33,8 @@ static void NewErrorAvailable(JNIEnv* env, jclass, jstring message) {
AndroidLocationApiAdapter::OnNewErrorAvailable(env, message);
}
+namespace content {
+
AndroidLocationApiAdapter::AndroidLocationApiAdapter()
: location_provider_(NULL) {
}
@@ -87,7 +90,7 @@ void AndroidLocationApiAdapter::Stop() {
// static
void AndroidLocationApiAdapter::NotifyProviderNewGeoposition(
- const content::Geoposition& geoposition) {
+ const Geoposition& geoposition) {
// Called on the geolocation thread, safe to access location_provider_ here.
if (GetInstance()->location_provider_) {
CHECK(GetInstance()->message_loop_->BelongsToCurrentThread());
@@ -102,7 +105,7 @@ void AndroidLocationApiAdapter::OnNewLocationAvailable(
bool has_accuracy, double accuracy,
bool has_heading, double heading,
bool has_speed, double speed) {
- content::Geoposition position;
+ Geoposition position;
position.latitude = latitude;
position.longitude = longitude;
position.timestamp = base::Time::FromDoubleT(time_stamp);
@@ -120,9 +123,8 @@ void AndroidLocationApiAdapter::OnNewLocationAvailable(
// static
void AndroidLocationApiAdapter::OnNewErrorAvailable(JNIEnv* env,
jstring message) {
- content::Geoposition position_error;
- position_error.error_code =
- content::Geoposition::ERROR_CODE_POSITION_UNAVAILABLE;
+ Geoposition position_error;
+ position_error.error_code = Geoposition::ERROR_CODE_POSITION_UNAVAILABLE;
position_error.error_message =
base::android::ConvertJavaStringToUTF8(env, message);
GetInstance()->OnNewGeopositionInternal(position_error);
@@ -147,7 +149,7 @@ void AndroidLocationApiAdapter::CreateJavaObject(JNIEnv* env) {
}
void AndroidLocationApiAdapter::OnNewGeopositionInternal(
- const content::Geoposition& geoposition) {
+ const Geoposition& geoposition) {
base::AutoLock lock(lock_);
if (!message_loop_)
return;
@@ -157,3 +159,5 @@ void AndroidLocationApiAdapter::OnNewGeopositionInternal(
&AndroidLocationApiAdapter::NotifyProviderNewGeoposition,
geoposition));
}
+
+} // namespace content
diff --git a/content/browser/geolocation/location_api_adapter_android.h b/content/browser/geolocation/location_api_adapter_android.h
index 54bffd2..ede23ce 100644
--- a/content/browser/geolocation/location_api_adapter_android.h
+++ b/content/browser/geolocation/location_api_adapter_android.h
@@ -13,10 +13,8 @@
#include "base/synchronization/lock.h"
namespace content {
-struct Geoposition;
-}
-
class LocationProviderAndroid;
+struct Geoposition;
// Interacts with JNI and reports back to AndroidLocationProvider.
// This class creates a LocationProvider java object and listens for
@@ -63,11 +61,10 @@ class AndroidLocationApiAdapter {
void CreateJavaObject(JNIEnv* env);
// Called on the JNI main thread looper.
- void OnNewGeopositionInternal(const content::Geoposition& geoposition);
+ void OnNewGeopositionInternal(const Geoposition& geoposition);
/// Called on the Geolocation thread.
- static void NotifyProviderNewGeoposition(
- const content::Geoposition& geoposition);
+ static void NotifyProviderNewGeoposition(const Geoposition& geoposition);
base::android::ScopedJavaGlobalRef<jobject>
java_location_provider_android_object_;
@@ -79,4 +76,6 @@ class AndroidLocationApiAdapter {
scoped_refptr<base::MessageLoopProxy> message_loop_;
};
+} // namespace content
+
#endif // CONTENT_BROWSER_GEOLOCATION_LOCATION_API_ADAPTER_ANDROID_H_
diff --git a/content/browser/geolocation/location_arbitrator.cc b/content/browser/geolocation/location_arbitrator.cc
index 237fcd0..423ee44 100644
--- a/content/browser/geolocation/location_arbitrator.cc
+++ b/content/browser/geolocation/location_arbitrator.cc
@@ -12,9 +12,7 @@
#include "content/public/browser/access_token_store.h"
#include "googleurl/src/gurl.h"
-using content::AccessTokenStore;
-using content::Geoposition;
-
+namespace content {
namespace {
const char* kDefaultNetworkProviderUrl =
@@ -131,7 +129,7 @@ void GeolocationArbitrator::LocationUpdateAvailable(
Geoposition new_position;
provider->GetPosition(&new_position);
DCHECK(new_position.Validate() ||
- new_position.error_code != content::Geoposition::ERROR_CODE_NONE);
+ new_position.error_code != Geoposition::ERROR_CODE_NONE);
if (!IsNewPositionBetter(position_, new_position,
provider == position_provider_))
return;
@@ -174,3 +172,5 @@ void GeolocationArbitrator::SetDependencyFactoryForTest(
GeolocationArbitratorDependencyFactory* dependency_factory) {
g_dependency_factory_for_test = dependency_factory;
}
+
+} // namespace content
diff --git a/content/browser/geolocation/location_arbitrator.h b/content/browser/geolocation/location_arbitrator.h
index 6dfa774..6a612af 100644
--- a/content/browser/geolocation/location_arbitrator.h
+++ b/content/browser/geolocation/location_arbitrator.h
@@ -15,17 +15,15 @@
#include "content/public/common/geoposition.h"
#include "net/url_request/url_request_context_getter.h"
-class GeolocationArbitratorDependencyFactory;
-class LocationProviderBase;
-
-namespace content {
-class AccessTokenStore;
-}
-
namespace net {
class URLRequestContextGetter;
}
+namespace content {
+class AccessTokenStore;
+class GeolocationArbitratorDependencyFactory;
+class LocationProviderBase;
+
// This class is responsible for handling updates from multiple underlying
// providers and resolving them to a single 'best' location fix at any given
// moment.
@@ -77,18 +75,18 @@ class CONTENT_EXPORT GeolocationArbitrator
// |providers_| or deleted on error (e.g. it fails to start).
void RegisterProvider(LocationProviderBase* provider);
void OnAccessTokenStoresLoaded(
- content::AccessTokenStore::AccessTokenSet access_token_store,
+ AccessTokenStore::AccessTokenSet access_token_store,
net::URLRequestContextGetter* context_getter);
void DoStartProviders();
// Returns true if |new_position| is an improvement over |old_position|.
// Set |from_same_provider| to true if both the positions came from the same
// provider.
- bool IsNewPositionBetter(const content::Geoposition& old_position,
- const content::Geoposition& new_position,
+ bool IsNewPositionBetter(const Geoposition& old_position,
+ const Geoposition& new_position,
bool from_same_provider) const;
scoped_refptr<GeolocationArbitratorDependencyFactory> dependency_factory_;
- scoped_refptr<content::AccessTokenStore> access_token_store_;
+ scoped_refptr<AccessTokenStore> access_token_store_;
GetTimeNow get_time_now_;
GeolocationObserver* observer_;
ScopedVector<LocationProviderBase> providers_;
@@ -97,9 +95,11 @@ class CONTENT_EXPORT GeolocationArbitrator
const LocationProviderBase* position_provider_;
bool is_permission_granted_;
// The current best estimate of our position.
- content::Geoposition position_;
+ Geoposition position_;
DISALLOW_COPY_AND_ASSIGN(GeolocationArbitrator);
};
+} // namespace content
+
#endif // CONTENT_BROWSER_GEOLOCATION_LOCATION_ARBITRATOR_H_
diff --git a/content/browser/geolocation/location_arbitrator_unittest.cc b/content/browser/geolocation/location_arbitrator_unittest.cc
index 1504343..16441b3 100644
--- a/content/browser/geolocation/location_arbitrator_unittest.cc
+++ b/content/browser/geolocation/location_arbitrator_unittest.cc
@@ -13,12 +13,9 @@
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
-using content::AccessTokenStore;
-using content::FakeAccessTokenStore;
-using content::Geoposition;
using ::testing::NiceMock;
-namespace {
+namespace content {
class MockLocationObserver : public GeolocationObserver {
public:
@@ -188,14 +185,14 @@ TEST_F(GeolocationLocationArbitratorTest, NormalUsage) {
EXPECT_EQ(MockLocationProvider::LOW_ACCURACY, cell()->state_);
EXPECT_EQ(MockLocationProvider::LOW_ACCURACY, gps()->state_);
EXPECT_FALSE(observer_->last_position_.Validate());
- EXPECT_EQ(content::Geoposition::ERROR_CODE_NONE,
+ EXPECT_EQ(Geoposition::ERROR_CODE_NONE,
observer_->last_position_.error_code);
SetReferencePosition(cell());
EXPECT_TRUE(observer_->last_position_.Validate() ||
observer_->last_position_.error_code !=
- content::Geoposition::ERROR_CODE_NONE);
+ Geoposition::ERROR_CODE_NONE);
EXPECT_EQ(cell()->position_.latitude,
observer_->last_position_.latitude);
@@ -297,4 +294,4 @@ TEST_F(GeolocationLocationArbitratorTest, Arbitration) {
CheckLastPositionInfo(3.5658700, 139.069979, 1000);
}
-} // namespace
+} // namespace content
diff --git a/content/browser/geolocation/location_provider.cc b/content/browser/geolocation/location_provider.cc
index d587b55..c90f055 100644
--- a/content/browser/geolocation/location_provider.cc
+++ b/content/browser/geolocation/location_provider.cc
@@ -6,6 +6,8 @@
#include "base/logging.h"
+namespace content {
+
LocationProviderBase::LocationProviderBase() {
}
@@ -61,3 +63,5 @@ LocationProviderBase* NewSystemLocationProvider() {
return NULL;
}
#endif
+
+} // namespace content
diff --git a/content/browser/geolocation/location_provider.h b/content/browser/geolocation/location_provider.h
index 11824e6..67b124a 100644
--- a/content/browser/geolocation/location_provider.h
+++ b/content/browser/geolocation/location_provider.h
@@ -20,15 +20,14 @@
class GURL;
-namespace content {
-class AccessTokenStore;
-struct Geoposition;
-}
-
namespace net {
class URLRequestContextGetter;
}
+namespace content {
+class AccessTokenStore;
+struct Geoposition;
+
// The base class used by all location providers.
class CONTENT_EXPORT LocationProviderBase
: NON_EXPORTED_BASE(public base::NonThreadSafe) {
@@ -68,7 +67,7 @@ class CONTENT_EXPORT LocationProviderBase
virtual bool StartProvider(bool high_accuracy) = 0;
virtual void StopProvider() = 0;
// Gets the current best position estimate.
- virtual void GetPosition(content::Geoposition* position) = 0;
+ virtual void GetPosition(Geoposition* position) = 0;
// Provides a hint to the provider that new location data is needed as soon
// as possible. Default implementation does nothing.
virtual void UpdatePosition() {}
@@ -95,10 +94,12 @@ class CONTENT_EXPORT LocationProviderBase
// Factory functions for the various types of location provider to abstract
// over the platform-dependent implementations.
CONTENT_EXPORT LocationProviderBase* NewNetworkLocationProvider(
- content::AccessTokenStore* access_token_store,
+ AccessTokenStore* access_token_store,
net::URLRequestContextGetter* context,
const GURL& url,
const string16& access_token);
LocationProviderBase* NewSystemLocationProvider();
+} // namespace content
+
#endif // CONTENT_BROWSER_GEOLOCATION_LOCATION_PROVIDER_H_
diff --git a/content/browser/geolocation/location_provider_android.cc b/content/browser/geolocation/location_provider_android.cc
index a185422..eb69b17 100644
--- a/content/browser/geolocation/location_provider_android.cc
+++ b/content/browser/geolocation/location_provider_android.cc
@@ -8,6 +8,8 @@
#include "content/browser/geolocation/location_api_adapter_android.h"
#include "content/public/common/geoposition.h"
+namespace content {
+
// LocationProviderAndroid
LocationProviderAndroid::LocationProviderAndroid() {
}
@@ -17,7 +19,7 @@ LocationProviderAndroid::~LocationProviderAndroid() {
}
void LocationProviderAndroid::NotifyNewGeoposition(
- const content::Geoposition& position) {
+ const Geoposition& position) {
last_position_ = position;
UpdateListeners();
}
@@ -30,7 +32,7 @@ void LocationProviderAndroid::StopProvider() {
AndroidLocationApiAdapter::GetInstance()->Stop();
}
-void LocationProviderAndroid::GetPosition(content::Geoposition* position) {
+void LocationProviderAndroid::GetPosition(Geoposition* position) {
*position = last_position_;
}
@@ -45,3 +47,5 @@ void LocationProviderAndroid::OnPermissionGranted() {
LocationProviderBase* NewSystemLocationProvider() {
return new LocationProviderAndroid;
}
+
+} // namespace content
diff --git a/content/browser/geolocation/location_provider_android.h b/content/browser/geolocation/location_provider_android.h
index 6316296..b2f8f56 100644
--- a/content/browser/geolocation/location_provider_android.h
+++ b/content/browser/geolocation/location_provider_android.h
@@ -9,6 +9,7 @@
#include "content/browser/geolocation/location_provider.h"
#include "content/public/common/geoposition.h"
+namespace content {
class AndroidLocationApiAdapter;
struct Geoposition;
@@ -19,17 +20,19 @@ class LocationProviderAndroid : public LocationProviderBase {
virtual ~LocationProviderAndroid();
// Called by the AndroidLocationApiAdapter.
- void NotifyNewGeoposition(const content::Geoposition& position);
+ void NotifyNewGeoposition(const Geoposition& position);
// LocationProviderBase.
virtual bool StartProvider(bool high_accuracy) OVERRIDE;
virtual void StopProvider() OVERRIDE;
- virtual void GetPosition(content::Geoposition* position) OVERRIDE;
+ virtual void GetPosition(Geoposition* position) OVERRIDE;
virtual void UpdatePosition() OVERRIDE;
virtual void OnPermissionGranted() OVERRIDE;
private:
- content::Geoposition last_position_;
+ Geoposition last_position_;
};
+} // namespace content
+
#endif // CONTENT_BROWSER_GEOLOCATION_LOCATION_PROVIDER_ANDROID_H_
diff --git a/content/browser/geolocation/mock_location_provider.cc b/content/browser/geolocation/mock_location_provider.cc
index 35109ef..293a558 100644
--- a/content/browser/geolocation/mock_location_provider.cc
+++ b/content/browser/geolocation/mock_location_provider.cc
@@ -15,6 +15,7 @@
#include "base/message_loop.h"
#include "base/message_loop_proxy.h"
+namespace content {
MockLocationProvider* MockLocationProvider::instance_ = NULL;
MockLocationProvider::MockLocationProvider(MockLocationProvider** self_ref)
@@ -32,8 +33,7 @@ MockLocationProvider::~MockLocationProvider() {
*self_ref_ = NULL;
}
-void MockLocationProvider::HandlePositionChanged(
- const content::Geoposition& position) {
+void MockLocationProvider::HandlePositionChanged(const Geoposition& position) {
if (provider_loop_->BelongsToCurrentThread()) {
// The location arbitrator unit tests rely on this method running
// synchronously.
@@ -56,7 +56,7 @@ void MockLocationProvider::StopProvider() {
state_ = STOPPED;
}
-void MockLocationProvider::GetPosition(content::Geoposition* position) {
+void MockLocationProvider::GetPosition(Geoposition* position) {
*position = position_;
}
@@ -83,8 +83,7 @@ class AutoMockLocationProvider : public MockLocationProvider {
// contemporary.
position_.timestamp = base::Time::Now();
} else {
- position_.error_code =
- content::Geoposition::ERROR_CODE_POSITION_UNAVAILABLE;
+ position_.error_code = Geoposition::ERROR_CODE_POSITION_UNAVAILABLE;
}
}
virtual bool StartProvider(bool high_accuracy) {
@@ -132,3 +131,5 @@ LocationProviderBase* NewAutoFailMockLocationProvider() {
LocationProviderBase* NewAutoSuccessMockNetworkLocationProvider() {
return new AutoMockLocationProvider(true, true);
}
+
+} // namespace content
diff --git a/content/browser/geolocation/mock_location_provider.h b/content/browser/geolocation/mock_location_provider.h
index c61edf5..da70c63 100644
--- a/content/browser/geolocation/mock_location_provider.h
+++ b/content/browser/geolocation/mock_location_provider.h
@@ -12,6 +12,8 @@
#include "content/browser/geolocation/location_provider.h"
#include "content/public/common/geoposition.h"
+namespace content {
+
// Mock implementation of a location provider for testing.
class MockLocationProvider : public LocationProviderBase {
public:
@@ -21,15 +23,15 @@ class MockLocationProvider : public LocationProviderBase {
virtual ~MockLocationProvider();
// Updates listeners with the new position.
- void HandlePositionChanged(const content::Geoposition& position);
+ void HandlePositionChanged(const Geoposition& position);
// LocationProviderBase implementation.
virtual bool StartProvider(bool high_accuracy) OVERRIDE;
virtual void StopProvider() OVERRIDE;
- virtual void GetPosition(content::Geoposition* position) OVERRIDE;
+ virtual void GetPosition(Geoposition* position) OVERRIDE;
virtual void OnPermissionGranted() OVERRIDE;
- content::Geoposition position_;
+ Geoposition position_;
enum State { STOPPED, LOW_ACCURACY, HIGH_ACCURACY } state_;
bool is_permission_granted_;
MockLocationProvider** self_ref_;
@@ -60,4 +62,6 @@ LocationProviderBase* NewAutoFailMockLocationProvider();
// a permission request has been confirmed.
LocationProviderBase* NewAutoSuccessMockNetworkLocationProvider();
+} // namespace content
+
#endif // CONTENT_BROWSER_GEOLOCATION_MOCK_LOCATION_PROVIDER_H_
diff --git a/content/browser/geolocation/network_location_provider.cc b/content/browser/geolocation/network_location_provider.cc
index d6cf85b..0167fd9 100644
--- a/content/browser/geolocation/network_location_provider.cc
+++ b/content/browser/geolocation/network_location_provider.cc
@@ -9,9 +9,7 @@
#include "base/utf_string_conversions.h"
#include "content/public/browser/access_token_store.h"
-using content::AccessTokenStore;
-using content::Geoposition;
-
+namespace content {
namespace {
// The maximum period of time we'll wait for a complete set of device data
// before sending the request.
@@ -269,3 +267,5 @@ void NetworkLocationProvider::OnDeviceDataUpdated() {
bool NetworkLocationProvider::IsStarted() const {
return wifi_data_provider_ != NULL;
}
+
+} // namespace content
diff --git a/content/browser/geolocation/network_location_provider.h b/content/browser/geolocation/network_location_provider.h
index ee06e40..21023ae 100644
--- a/content/browser/geolocation/network_location_provider.h
+++ b/content/browser/geolocation/network_location_provider.h
@@ -21,7 +21,7 @@
namespace content {
class AccessTokenStore;
-}
+
class NetworkLocationProvider
: public LocationProviderBase,
@@ -43,12 +43,12 @@ class NetworkLocationProvider
// evict old entries in FIFO orderer of being added.
// Returns true on success, false otherwise.
bool CachePosition(const WifiData& wifi_data,
- const content::Geoposition& position);
+ const Geoposition& position);
// Searches for a cached position response for the current set of device
// data. Returns NULL if the position is not in the cache, or the cached
// position if available. Ownership remains with the cache.
- const content::Geoposition* FindPosition(const WifiData& wifi_data);
+ const Geoposition* FindPosition(const WifiData& wifi_data);
private:
// Makes the key for the map of cached positions, using a set of
@@ -59,13 +59,13 @@ class NetworkLocationProvider
// The cache of positions. This is stored as a map keyed on a string that
// represents a set of device data, and a list to provide
// least-recently-added eviction.
- typedef std::map<string16, content::Geoposition> CacheMap;
+ typedef std::map<string16, Geoposition> CacheMap;
CacheMap cache_;
typedef std::list<CacheMap::iterator> CacheAgeList;
CacheAgeList cache_age_list_; // Oldest first.
};
- NetworkLocationProvider(content::AccessTokenStore* access_token_store,
+ NetworkLocationProvider(AccessTokenStore* access_token_store,
net::URLRequestContextGetter* context,
const GURL& url,
const string16& access_token);
@@ -74,7 +74,7 @@ class NetworkLocationProvider
// LocationProviderBase implementation
virtual bool StartProvider(bool high_accuracy) OVERRIDE;
virtual void StopProvider() OVERRIDE;
- virtual void GetPosition(content::Geoposition *position) OVERRIDE;
+ virtual void GetPosition(Geoposition *position) OVERRIDE;
virtual void UpdatePosition() OVERRIDE;
virtual void OnPermissionGranted() OVERRIDE;
@@ -91,12 +91,12 @@ class NetworkLocationProvider
virtual void DeviceDataUpdateAvailable(WifiDataProvider* provider) OVERRIDE;
// NetworkLocationRequest::ListenerInterface implementation.
- virtual void LocationResponseAvailable(const content::Geoposition& position,
+ virtual void LocationResponseAvailable(const Geoposition& position,
bool server_error,
const string16& access_token,
const WifiData& wifi_data) OVERRIDE;
- scoped_refptr<content::AccessTokenStore> access_token_store_;
+ scoped_refptr<AccessTokenStore> access_token_store_;
// The wifi data provider, acquired via global factories.
WifiDataProvider* wifi_data_provider_;
@@ -113,7 +113,7 @@ class NetworkLocationProvider
string16 access_token_;
// The current best position estimate.
- content::Geoposition position_;
+ Geoposition position_;
// Whether permission has been granted for the provider to operate.
bool is_permission_granted_;
@@ -130,4 +130,6 @@ class NetworkLocationProvider
DISALLOW_COPY_AND_ASSIGN(NetworkLocationProvider);
};
+} // namespace content
+
#endif // CONTENT_BROWSER_GEOLOCATION_NETWORK_LOCATION_PROVIDER_H_
diff --git a/content/browser/geolocation/network_location_provider_unittest.cc b/content/browser/geolocation/network_location_provider_unittest.cc
index 4c87f20..14b2edb 100644
--- a/content/browser/geolocation/network_location_provider_unittest.cc
+++ b/content/browser/geolocation/network_location_provider_unittest.cc
@@ -17,10 +17,7 @@
#include "net/url_request/url_request_status.h"
#include "testing/gtest/include/gtest/gtest.h"
-using content::FakeAccessTokenStore;
-using content::Geoposition;
-
-namespace {
+namespace content {
// Constants used in multiple tests.
const char kTestServerUrl[] = "https://www.geolocation.test/service";
@@ -584,4 +581,4 @@ TEST_F(GeolocationNetworkProviderTest, NetworkPositionCache) {
}
}
-} // namespace
+} // namespace content
diff --git a/content/browser/geolocation/network_location_request.cc b/content/browser/geolocation/network_location_request.cc
index 9333fba..75868d8 100644
--- a/content/browser/geolocation/network_location_request.cc
+++ b/content/browser/geolocation/network_location_request.cc
@@ -21,6 +21,7 @@
#include "net/url_request/url_request_context_getter.h"
#include "net/url_request/url_request_status.h"
+namespace content {
namespace {
const size_t kMaxRequestLength = 2048;
@@ -48,7 +49,7 @@ void GetLocationFromResponse(bool http_post_result,
const std::string& response_body,
const base::Time& timestamp,
const GURL& server_url,
- content::Geoposition* position,
+ Geoposition* position,
string16* access_token);
// Parses the server response body. Returns true if parsing was successful.
@@ -56,7 +57,7 @@ void GetLocationFromResponse(bool http_post_result,
// otherwise leaves it unchanged.
bool ParseServerResponse(const std::string& response_body,
const base::Time& timestamp,
- content::Geoposition* position,
+ Geoposition* position,
string16* access_token);
void AddWifiData(const WifiData& wifi_data,
int age_milliseconds,
@@ -110,7 +111,7 @@ void NetworkLocationRequest::OnURLFetchComplete(
net::URLRequestStatus status = source->GetStatus();
int response_code = source->GetResponseCode();
- content::Geoposition position;
+ Geoposition position;
string16 access_token;
std::string data;
source->GetResponseAsString(&data);
@@ -226,9 +227,8 @@ void AddWifiData(const WifiData& wifi_data,
void FormatPositionError(const GURL& server_url,
const std::string& message,
- content::Geoposition* position) {
- position->error_code =
- content::Geoposition::ERROR_CODE_POSITION_UNAVAILABLE;
+ Geoposition* position) {
+ position->error_code = Geoposition::ERROR_CODE_POSITION_UNAVAILABLE;
position->error_message = "Network location provider at '";
position->error_message += server_url.GetOrigin().spec();
position->error_message += "' : ";
@@ -243,7 +243,7 @@ void GetLocationFromResponse(bool http_post_result,
const std::string& response_body,
const base::Time& timestamp,
const GURL& server_url,
- content::Geoposition* position,
+ Geoposition* position,
string16* access_token) {
DCHECK(position);
DCHECK(access_token);
@@ -298,11 +298,11 @@ bool GetAsDouble(const base::DictionaryValue& object,
bool ParseServerResponse(const std::string& response_body,
const base::Time& timestamp,
- content::Geoposition* position,
+ Geoposition* position,
string16* access_token) {
DCHECK(position);
DCHECK(!position->Validate());
- DCHECK(position->error_code == content::Geoposition::ERROR_CODE_NONE);
+ DCHECK(position->error_code == Geoposition::ERROR_CODE_NONE);
DCHECK(access_token);
DCHECK(!timestamp.is_null());
@@ -376,3 +376,4 @@ bool ParseServerResponse(const std::string& response_body,
} // namespace
+} // namespace content
diff --git a/content/browser/geolocation/network_location_request.h b/content/browser/geolocation/network_location_request.h
index cfb83de..49ac96c 100644
--- a/content/browser/geolocation/network_location_request.h
+++ b/content/browser/geolocation/network_location_request.h
@@ -13,15 +13,14 @@
#include "googleurl/src/gurl.h"
#include "net/url_request/url_fetcher_delegate.h"
-namespace content {
-struct Geoposition;
-}
-
namespace net {
class URLFetcher;
class URLRequestContextGetter;
}
+namespace content {
+struct Geoposition;
+
// Takes a set of device data and sends it to a server to get a position fix.
// It performs formatting of the request and interpretation of the response.
class NetworkLocationRequest : private net::URLFetcherDelegate {
@@ -34,7 +33,7 @@ class NetworkLocationRequest : private net::URLFetcherDelegate {
// Updates the listener with a new position. server_error indicates whether
// was a server or network error - either no response or a 500 error code.
virtual void LocationResponseAvailable(
- const content::Geoposition& position,
+ const Geoposition& position,
bool server_error,
const string16& access_token,
const WifiData& wifi_data) = 0;
@@ -75,4 +74,6 @@ class NetworkLocationRequest : private net::URLFetcherDelegate {
DISALLOW_COPY_AND_ASSIGN(NetworkLocationRequest);
};
+} // namespace content
+
#endif // CONTENT_BROWSER_GEOLOCATION_NETWORK_LOCATION_REQUEST_H_
diff --git a/content/browser/geolocation/wifi_data_provider_common.cc b/content/browser/geolocation/wifi_data_provider_common.cc
index e20b5ee..fd5667a 100644
--- a/content/browser/geolocation/wifi_data_provider_common.cc
+++ b/content/browser/geolocation/wifi_data_provider_common.cc
@@ -8,6 +8,8 @@
#include "base/stringprintf.h"
#include "base/utf_string_conversions.h"
+namespace content {
+
string16 MacAddressAsString16(const uint8 mac_as_int[6]) {
// mac_as_int is big-endian. Write in byte chunks.
// Format is XX-XX-XX-XX-XX-XX.
@@ -107,3 +109,5 @@ void WifiDataProviderCommon::ScheduleNextScan(int interval) {
weak_factory_.GetWeakPtr()),
base::TimeDelta::FromMilliseconds(interval));
}
+
+} // namespace content
diff --git a/content/browser/geolocation/wifi_data_provider_common.h b/content/browser/geolocation/wifi_data_provider_common.h
index c307575..7b46ce8 100644
--- a/content/browser/geolocation/wifi_data_provider_common.h
+++ b/content/browser/geolocation/wifi_data_provider_common.h
@@ -15,6 +15,8 @@
#include "content/browser/geolocation/device_data_provider.h"
#include "content/common/content_export.h"
+namespace content {
+
// Converts a MAC address stored as an array of uint8 to a string.
string16 MacAddressAsString16(const uint8 mac_as_int[6]);
@@ -123,4 +125,6 @@ class CONTENT_EXPORT WifiDataProviderCommon
DISALLOW_COPY_AND_ASSIGN(WifiDataProviderCommon);
};
+} // namespace content
+
#endif // CONTENT_BROWSER_GEOLOCATION_WIFI_DATA_PROVIDER_COMMON_H_
diff --git a/content/browser/geolocation/wifi_data_provider_common_unittest.cc b/content/browser/geolocation/wifi_data_provider_common_unittest.cc
index 664421d..ccc13cb 100644
--- a/content/browser/geolocation/wifi_data_provider_common_unittest.cc
+++ b/content/browser/geolocation/wifi_data_provider_common_unittest.cc
@@ -18,7 +18,7 @@ using testing::DoDefault;
using testing::Invoke;
using testing::Return;
-namespace {
+namespace content {
class MockWlanApi : public WifiDataProviderCommon::WlanApiInterface {
public:
@@ -230,5 +230,4 @@ TEST_F(GeolocationWifiDataProviderCommonTest,
DeviceDataProvider<WifiData>::ResetFactory();
}
-} // namespace
-
+} // namespace content
diff --git a/content/browser/geolocation/wifi_data_provider_common_win.cc b/content/browser/geolocation/wifi_data_provider_common_win.cc
index fbb0954..929903e 100644
--- a/content/browser/geolocation/wifi_data_provider_common_win.cc
+++ b/content/browser/geolocation/wifi_data_provider_common_win.cc
@@ -10,6 +10,8 @@
#include "content/browser/geolocation/device_data_provider.h"
#include "content/browser/geolocation/wifi_data_provider_common.h"
+namespace content {
+
bool ConvertToAccessPointData(const NDIS_WLAN_BSSID& data,
AccessPointData *access_point_data) {
// Currently we get only MAC address, signal strength and SSID.
@@ -50,3 +52,5 @@ int GetDataFromBssIdList(const NDIS_802_11_BSSID_LIST& bss_id_list,
}
return found;
}
+
+} // namespace content
diff --git a/content/browser/geolocation/wifi_data_provider_common_win.h b/content/browser/geolocation/wifi_data_provider_common_win.h
index cb7a0ca..f58e0c6 100644
--- a/content/browser/geolocation/wifi_data_provider_common_win.h
+++ b/content/browser/geolocation/wifi_data_provider_common_win.h
@@ -10,6 +10,8 @@
#include "content/browser/geolocation/device_data_provider.h"
+namespace content {
+
// Extracts access point data from the NDIS_802_11_BSSID_LIST structure and
// appends it to the data vector. Returns the number of access points for which
// data was extracted.
@@ -17,4 +19,6 @@ int GetDataFromBssIdList(const NDIS_802_11_BSSID_LIST& bss_id_list,
int list_size,
WifiData::AccessPointDataSet* data);
+} // namespace content
+
#endif // CONTENT_BROWSER_GEOLOCATION_WIFI_DATA_PROVIDER_COMMON_WIN_H_
diff --git a/content/browser/geolocation/wifi_data_provider_corewlan_mac.mm b/content/browser/geolocation/wifi_data_provider_corewlan_mac.mm
index a25754e..d3a179c 100644
--- a/content/browser/geolocation/wifi_data_provider_corewlan_mac.mm
+++ b/content/browser/geolocation/wifi_data_provider_corewlan_mac.mm
@@ -42,6 +42,8 @@
- (BOOL)isEqualToNetwork:(CWNetwork*)network;
@end
+namespace content {
+
class CoreWlanApi : public WifiDataProviderCommon::WlanApiInterface {
public:
CoreWlanApi() {}
@@ -160,3 +162,5 @@ WifiDataProviderCommon::WlanApiInterface* NewCoreWlanApi() {
return NULL;
}
+
+} // namespace content
diff --git a/content/browser/geolocation/wifi_data_provider_linux.cc b/content/browser/geolocation/wifi_data_provider_linux.cc
index a1f5237..6e5d54e 100644
--- a/content/browser/geolocation/wifi_data_provider_linux.cc
+++ b/content/browser/geolocation/wifi_data_provider_linux.cc
@@ -16,6 +16,7 @@
#include "dbus/object_path.h"
#include "dbus/object_proxy.h"
+namespace content {
namespace {
// The time periods between successive polls of the wifi data.
const int kDefaultPollingIntervalMilliseconds = 10 * 1000; // 10s
@@ -375,3 +376,5 @@ WifiDataProviderLinux::NewWlanApiForTesting(dbus::Bus* bus) {
return wlan_api.release();
return NULL;
}
+
+} // namespace content
diff --git a/content/browser/geolocation/wifi_data_provider_linux.h b/content/browser/geolocation/wifi_data_provider_linux.h
index c31c861..526f610 100644
--- a/content/browser/geolocation/wifi_data_provider_linux.h
+++ b/content/browser/geolocation/wifi_data_provider_linux.h
@@ -13,6 +13,8 @@ namespace dbus {
class Bus;
};
+namespace content {
+
class CONTENT_EXPORT WifiDataProviderLinux : public WifiDataProviderCommon {
public:
WifiDataProviderLinux();
@@ -32,4 +34,6 @@ class CONTENT_EXPORT WifiDataProviderLinux : public WifiDataProviderCommon {
DISALLOW_COPY_AND_ASSIGN(WifiDataProviderLinux);
};
+} // namespace content
+
#endif // CONTENT_BROWSER_GEOLOCATION_WIFI_DATA_PROVIDER_LINUX_H_
diff --git a/content/browser/geolocation/wifi_data_provider_linux_unittest.cc b/content/browser/geolocation/wifi_data_provider_linux_unittest.cc
index 94c56f2..dfc072e 100644
--- a/content/browser/geolocation/wifi_data_provider_linux_unittest.cc
+++ b/content/browser/geolocation/wifi_data_provider_linux_unittest.cc
@@ -21,6 +21,8 @@ using ::testing::Invoke;
using ::testing::Return;
using ::testing::Unused;
+namespace content {
+
class GeolocationWifiDataProviderLinuxTest : public testing::Test {
void SetUp() {
// Create a mock bus.
@@ -224,3 +226,5 @@ TEST_F(GeolocationWifiDataProviderLinuxTest, GetAccessPointData) {
EXPECT_EQ(-50, access_point_data.radio_signal_strength);
EXPECT_EQ(4, access_point_data.channel);
}
+
+} // namespace content
diff --git a/content/browser/geolocation/wifi_data_provider_mac.cc b/content/browser/geolocation/wifi_data_provider_mac.cc
index fa01bfa..561a309 100644
--- a/content/browser/geolocation/wifi_data_provider_mac.cc
+++ b/content/browser/geolocation/wifi_data_provider_mac.cc
@@ -16,6 +16,7 @@
#include "content/browser/geolocation/osx_wifi.h"
#include "content/browser/geolocation/wifi_data_provider_common.h"
+namespace content {
namespace {
// The time periods, in milliseconds, between successive polls of the wifi data.
const int kDefaultPollingInterval = 120000; // 2 mins
@@ -190,3 +191,5 @@ PollingPolicyInterface* MacWifiDataProvider::NewPollingPolicy() {
kTwoNoChangePollingInterval,
kNoWifiPollingIntervalMilliseconds>;
}
+
+} // namespace content
diff --git a/content/browser/geolocation/wifi_data_provider_mac.h b/content/browser/geolocation/wifi_data_provider_mac.h
index 1fb9ed7..e36bd8c 100644
--- a/content/browser/geolocation/wifi_data_provider_mac.h
+++ b/content/browser/geolocation/wifi_data_provider_mac.h
@@ -7,6 +7,8 @@
#include "content/browser/geolocation/wifi_data_provider_common.h"
+namespace content {
+
// Implementation of the wifi data provider for Mac OSX. Uses different API
// bindings depending on APIs detected available at runtime in order to access
// wifi scan data: Apple80211.h on OSX 10.5, CoreWLAN framework on OSX 10.6.
@@ -28,4 +30,6 @@ class MacWifiDataProvider : public WifiDataProviderCommon {
// API can not be initialized.
WifiDataProviderCommon::WlanApiInterface* NewCoreWlanApi();
+} // namespace content
+
#endif // CONTENT_BROWSER_GEOLOCATION_WIFI_DATA_PROVIDER_MAC_H_
diff --git a/content/browser/geolocation/wifi_data_provider_unittest_win.cc b/content/browser/geolocation/wifi_data_provider_unittest_win.cc
index 179ac44..e4cd77b 100644
--- a/content/browser/geolocation/wifi_data_provider_unittest_win.cc
+++ b/content/browser/geolocation/wifi_data_provider_unittest_win.cc
@@ -8,6 +8,8 @@
#include "content/browser/geolocation/wifi_data_provider_win.h"
#include "testing/gtest/include/gtest/gtest.h"
+namespace content {
+
TEST(GeolocationWin32WifiDataProviderTest, CreateDestroy) {
// WifiDataProviderCommon requires the client to have a message loop.
MessageLoop dummy_loop;
@@ -17,3 +19,5 @@ TEST(GeolocationWin32WifiDataProviderTest, CreateDestroy) {
// Can't actually call start provider on the Win32WifiDataProvider without
// it accessing hardware and so risking making the test flaky.
}
+
+} // namespace content
diff --git a/content/browser/geolocation/wifi_data_provider_win.cc b/content/browser/geolocation/wifi_data_provider_win.cc
index 8837c2ec..3140321 100644
--- a/content/browser/geolocation/wifi_data_provider_win.cc
+++ b/content/browser/geolocation/wifi_data_provider_win.cc
@@ -36,6 +36,7 @@
#define NDIS_STATUS_INVALID_LENGTH ((NDIS_STATUS)0xC0010014L)
#define NDIS_STATUS_BUFFER_TOO_SHORT ((NDIS_STATUS)0xC0010016L)
+namespace content {
namespace {
// The limits on the size of the buffer used for the OID query.
const int kInitialBufferSize = 2 << 12; // Good for about 50 APs.
@@ -605,3 +606,5 @@ bool GetSystemDirectory(string16* path) {
return true;
}
} // namespace
+
+} // namespace content
diff --git a/content/browser/geolocation/wifi_data_provider_win.h b/content/browser/geolocation/wifi_data_provider_win.h
index b03fdf2..3fbb9ce 100644
--- a/content/browser/geolocation/wifi_data_provider_win.h
+++ b/content/browser/geolocation/wifi_data_provider_win.h
@@ -8,6 +8,7 @@
#include "content/browser/geolocation/wifi_data_provider_common.h"
#include "content/common/content_export.h"
+namespace content {
class PollingPolicyInterface;
class CONTENT_EXPORT Win32WifiDataProvider : public WifiDataProviderCommon {
@@ -24,4 +25,6 @@ class CONTENT_EXPORT Win32WifiDataProvider : public WifiDataProviderCommon {
DISALLOW_COPY_AND_ASSIGN(Win32WifiDataProvider);
};
+} // namespace content
+
#endif // CONTENT_BROWSER_GEOLOCATION_WIFI_DATA_PROVIDER_WIN_H_
diff --git a/content/browser/geolocation/win7_location_api_unittest_win.cc b/content/browser/geolocation/win7_location_api_unittest_win.cc
index 1adf934..ae77fb9 100644
--- a/content/browser/geolocation/win7_location_api_unittest_win.cc
+++ b/content/browser/geolocation/win7_location_api_unittest_win.cc
@@ -24,7 +24,7 @@ using testing::Invoke;
using testing::NiceMock;
using testing::Return;
-namespace {
+namespace content {
class MockLatLongReport : public ILatLongReport {
public:
@@ -311,16 +311,16 @@ TEST_F(GeolocationApiWin7Tests, PermissionDenied) {
EXPECT_CALL(*locator_, GetReport(_, _))
.Times(AtLeast(1))
.WillRepeatedly(Return(E_ACCESSDENIED));
- content::Geoposition position;
+ Geoposition position;
api_->GetPosition(&position);
- EXPECT_EQ(content::Geoposition::ERROR_CODE_PERMISSION_DENIED,
+ EXPECT_EQ(Geoposition::ERROR_CODE_PERMISSION_DENIED,
position.error_code);
}
TEST_F(GeolocationApiWin7Tests, GetValidPosition) {
EXPECT_CALL(*locator_, GetReport(_, _))
.Times(AtLeast(1));
- content::Geoposition position;
+ Geoposition position;
api_->GetPosition(&position);
EXPECT_TRUE(position.Validate());
}
@@ -331,9 +331,9 @@ TEST_F(GeolocationApiWin7Tests, GetInvalidPosition) {
.WillRepeatedly(Return(HRESULT_FROM_WIN32(ERROR_NO_DATA)));
EXPECT_CALL(*locator_, GetReport(_, _))
.Times(AtLeast(1));
- content::Geoposition position;
+ Geoposition position;
api_->GetPosition(&position);
EXPECT_FALSE(position.Validate());
}
-} // namespace
+} // namespace content
diff --git a/content/browser/geolocation/win7_location_api_win.cc b/content/browser/geolocation/win7_location_api_win.cc
index 122ffe2..72ac44a 100644
--- a/content/browser/geolocation/win7_location_api_win.cc
+++ b/content/browser/geolocation/win7_location_api_win.cc
@@ -13,6 +13,7 @@
#include "content/public/common/content_switches.h"
#include "content/public/common/geoposition.h"
+namespace content {
namespace {
const double kKnotsToMetresPerSecondConversionFactor = 0.5144;
@@ -89,15 +90,15 @@ Win7LocationApi* Win7LocationApi::CreateForTesting(
return result;
}
-void Win7LocationApi::GetPosition(content::Geoposition* position) {
+void Win7LocationApi::GetPosition(Geoposition* position) {
DCHECK(position);
- position->error_code = content::Geoposition::ERROR_CODE_POSITION_UNAVAILABLE;
+ position->error_code = Geoposition::ERROR_CODE_POSITION_UNAVAILABLE;
if (!locator_)
return;
// Try to get a position fix
if (!GetPositionIfFixed(position))
return;
- position->error_code = content::Geoposition::ERROR_CODE_NONE;
+ position->error_code = Geoposition::ERROR_CODE_NONE;
if (!position->Validate()) {
// GetPositionIfFixed returned true, yet we've not got a valid fix.
// This shouldn't happen; something went wrong in the conversion.
@@ -105,20 +106,19 @@ void Win7LocationApi::GetPosition(content::Geoposition* position) {
<< position->latitude << "," << position->longitude
<< " accuracy " << position->accuracy << " time "
<< position->timestamp.ToDoubleT();
- position->error_code =
- content::Geoposition::ERROR_CODE_POSITION_UNAVAILABLE;
+ position->error_code = Geoposition::ERROR_CODE_POSITION_UNAVAILABLE;
position->error_message = "Bad fix from Win7 provider";
}
}
-bool Win7LocationApi::GetPositionIfFixed(content::Geoposition* position) {
+bool Win7LocationApi::GetPositionIfFixed(Geoposition* position) {
HRESULT result_type;
CComPtr<ILocationReport> location_report;
CComPtr<ILatLongReport> lat_long_report;
result_type = locator_->GetReport(IID_ILatLongReport, &location_report);
// Checks to see if location access is allowed.
if (result_type == E_ACCESSDENIED)
- position->error_code = content::Geoposition::ERROR_CODE_PERMISSION_DENIED;
+ position->error_code = Geoposition::ERROR_CODE_PERMISSION_DENIED;
// Checks for any other errors while requesting a location report.
if (!SUCCEEDED(result_type))
return false;
@@ -166,3 +166,5 @@ bool Win7LocationApi::SetHighAccuracy(bool acc) {
LOCATION_DESIRED_ACCURACY_DEFAULT);
return SUCCEEDED(result_type);
}
+
+} // namespace content
diff --git a/content/browser/geolocation/win7_location_api_win.h b/content/browser/geolocation/win7_location_api_win.h
index fc9ffc2..375f844 100644
--- a/content/browser/geolocation/win7_location_api_win.h
+++ b/content/browser/geolocation/win7_location_api_win.h
@@ -16,7 +16,6 @@
namespace content {
struct Geoposition;
-}
// PropVariantToDouble
typedef HRESULT (WINAPI* PropVariantToDoubleFunction)
@@ -34,7 +33,7 @@ class CONTENT_EXPORT Win7LocationApi {
ILocation* locator);
// Gives the best available position.
// Returns false if no valid position is available.
- virtual void GetPosition(content::Geoposition* position);
+ virtual void GetPosition(Geoposition* position);
// Changes the "accuracy" needed. Affects power levels of devices.
virtual bool SetHighAccuracy(bool acc);
@@ -49,7 +48,7 @@ class CONTENT_EXPORT Win7LocationApi {
// Provides the best position fix if one is available.
// Does this by requesting a location report and querying it to obtain
// location information.
- virtual bool GetPositionIfFixed(content::Geoposition* position);
+ virtual bool GetPositionIfFixed(Geoposition* position);
// ILocation object that lets us communicate with the Location and
// Sensors platform.
@@ -62,4 +61,6 @@ class CONTENT_EXPORT Win7LocationApi {
DISALLOW_COPY_AND_ASSIGN(Win7LocationApi);
};
+} // namespace content
+
#endif // CONTENT_BROWSER_GEOLOCATION_WIN7_LOCATION_API_WIN_H_
diff --git a/content/browser/geolocation/win7_location_provider_unittest_win.cc b/content/browser/geolocation/win7_location_provider_unittest_win.cc
index d67be50..ecb4bc3 100644
--- a/content/browser/geolocation/win7_location_provider_unittest_win.cc
+++ b/content/browser/geolocation/win7_location_provider_unittest_win.cc
@@ -15,7 +15,7 @@ using testing::DoDefault;
using testing::Invoke;
using testing::Return;
-namespace {
+namespace content {
class MockWin7LocationApi : public Win7LocationApi {
public:
@@ -26,27 +26,26 @@ class MockWin7LocationApi : public Win7LocationApi {
// Used to signal when the destructor is called.
MOCK_METHOD0(Die, void());
// Win7LocationApi
- MOCK_METHOD1(GetPosition, void(content::Geoposition*));
+ MOCK_METHOD1(GetPosition, void(Geoposition*));
MOCK_METHOD1(SetHighAccuracy, bool(bool));
virtual ~MockWin7LocationApi() {
Die();
}
- void GetPositionValid(content::Geoposition* position) {
+ void GetPositionValid(Geoposition* position) {
position->latitude = 4.5;
position->longitude = -34.1;
position->accuracy = 0.5;
position->timestamp = base::Time::FromDoubleT(200);
- position->error_code = content::Geoposition::ERROR_CODE_NONE;
+ position->error_code = Geoposition::ERROR_CODE_NONE;
}
- void GetPositionInvalid(content::Geoposition* position) {
+ void GetPositionInvalid(Geoposition* position) {
position->latitude = 4.5;
position->longitude = -340000.1;
position->accuracy = 0.5;
position->timestamp = base::Time::FromDoubleT(200);
- position->error_code =
- content::Geoposition::ERROR_CODE_POSITION_UNAVAILABLE;
+ position->error_code = Geoposition::ERROR_CODE_POSITION_UNAVAILABLE;
}
private:
@@ -119,7 +118,7 @@ TEST_F(GeolocationProviderWin7Tests, GetValidPosition) {
.WillOnce(Return(true));
EXPECT_TRUE(provider_->StartProvider(true));
main_message_loop_.Run();
- content::Geoposition position;
+ Geoposition position;
provider_->GetPosition(&position);
EXPECT_TRUE(position.Validate());
}
@@ -133,9 +132,9 @@ TEST_F(GeolocationProviderWin7Tests, GetInvalidPosition) {
.WillOnce(Return(true));
EXPECT_TRUE(provider_->StartProvider(true));
main_message_loop_.Run();
- content::Geoposition position;
+ Geoposition position;
provider_->GetPosition(&position);
EXPECT_FALSE(position.Validate());
}
-} // namespace
+} // namespace content
diff --git a/content/browser/geolocation/win7_location_provider_win.cc b/content/browser/geolocation/win7_location_provider_win.cc
index 780df8c..fa7122d 100644
--- a/content/browser/geolocation/win7_location_provider_win.cc
+++ b/content/browser/geolocation/win7_location_provider_win.cc
@@ -12,7 +12,9 @@
#include "base/logging.h"
#include "base/message_loop.h"
-namespace{
+namespace content {
+namespace {
+
const int kPollPeriodMovingMillis = 500;
// Poll less frequently whilst stationary.
const int kPollPeriodStationaryMillis = kPollPeriodMovingMillis * 3;
@@ -24,8 +26,8 @@ const int kMovementThresholdMeters = 20;
// The arbitrary delta is decreased (Gears used 100 meters); if we need to
// decrease it any further we'll likely want to do some smarter filtering to
// remove GPS location jitter noise.
-bool PositionsDifferSiginificantly(const content::Geoposition& position_1,
- const content::Geoposition& position_2) {
+bool PositionsDifferSiginificantly(const Geoposition& position_1,
+ const Geoposition& position_2) {
const bool pos_1_valid = position_1.Validate();
if (pos_1_valid != position_2.Validate())
return true;
@@ -66,7 +68,7 @@ void Win7LocationProvider::StopProvider() {
weak_factory_.InvalidateWeakPtrs();
}
-void Win7LocationProvider::GetPosition(content::Geoposition* position) {
+void Win7LocationProvider::GetPosition(Geoposition* position) {
DCHECK(position);
*position = position_;
}
@@ -76,13 +78,12 @@ void Win7LocationProvider::UpdatePosition() {
}
void Win7LocationProvider::DoPollTask() {
- content::Geoposition new_position;
+ Geoposition new_position;
api_->GetPosition(&new_position);
const bool differ = PositionsDifferSiginificantly(position_, new_position);
ScheduleNextPoll(differ ? kPollPeriodMovingMillis :
kPollPeriodStationaryMillis);
- if (differ ||
- new_position.error_code != content::Geoposition::ERROR_CODE_NONE) {
+ if (differ || new_position.error_code != Geoposition::ERROR_CODE_NONE) {
// Update if the new location is interesting or we have an error to report
position_ = new_position;
UpdateListeners();
@@ -102,3 +103,5 @@ LocationProviderBase* NewSystemLocationProvider() {
return NULL; // API not supported on this machine.
return new Win7LocationProvider(api);
}
+
+} // namespace content
diff --git a/content/browser/geolocation/win7_location_provider_win.h b/content/browser/geolocation/win7_location_provider_win.h
index ae14be7..424d432 100644
--- a/content/browser/geolocation/win7_location_provider_win.h
+++ b/content/browser/geolocation/win7_location_provider_win.h
@@ -13,6 +13,8 @@
#include "content/common/content_export.h"
#include "content/public/common/geoposition.h"
+namespace content {
+
// Location provider for Windows 7 that uses the Location and Sensors platform
// to obtain position fixes.
// TODO(allanwoj): Remove polling and let the api signal when a new location.
@@ -27,7 +29,7 @@ class CONTENT_EXPORT Win7LocationProvider : public LocationProviderBase {
// LocationProvider.
virtual bool StartProvider(bool high_accuracy) OVERRIDE;
virtual void StopProvider() OVERRIDE;
- virtual void GetPosition(content::Geoposition* position) OVERRIDE;
+ virtual void GetPosition(Geoposition* position) OVERRIDE;
virtual void UpdatePosition() OVERRIDE;
private:
@@ -37,9 +39,11 @@ class CONTENT_EXPORT Win7LocationProvider : public LocationProviderBase {
void ScheduleNextPoll(int interval);
scoped_ptr<Win7LocationApi> api_;
- content::Geoposition position_;
+ Geoposition position_;
// Holder for the tasks which run on the thread; takes care of cleanup.
base::WeakPtrFactory<Win7LocationProvider> weak_factory_;
};
+} // namespace content
+
#endif // CONTENT_BROWSER_GEOLOCATION_WIN7_LOCATION_PROVIDER_WIN_H_