diff options
author | mvanouwerkerk@chromium.org <mvanouwerkerk@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-08-14 19:47:17 +0000 |
---|---|---|
committer | mvanouwerkerk@chromium.org <mvanouwerkerk@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-08-14 19:49:49 +0000 |
commit | 86493cdf8af35fdd99e7034d0e34705e595576d4 (patch) | |
tree | 8b77c7f35938b6f49a1cf4606a192c557cc0a500 | |
parent | 24e4f0a94526ca90f862974e1437fa83139b4c19 (diff) | |
download | chromium_src-86493cdf8af35fdd99e7034d0e34705e595576d4.zip chromium_src-86493cdf8af35fdd99e7034d0e34705e595576d4.tar.gz chromium_src-86493cdf8af35fdd99e7034d0e34705e595576d4.tar.bz2 |
Rename various Geolocation bits for clarity and consistency.
Review URL: https://codereview.chromium.org/477633002
Cr-Commit-Position: refs/heads/master@{#289678}
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@289678 0039d316-1c4b-4281-b951-d872f2087c98
8 files changed, 44 insertions, 46 deletions
diff --git a/content/browser/geolocation/location_arbitrator_impl.cc b/content/browser/geolocation/location_arbitrator_impl.cc index b8ed8c4..ef20a0c 100644 --- a/content/browser/geolocation/location_arbitrator_impl.cc +++ b/content/browser/geolocation/location_arbitrator_impl.cc @@ -28,9 +28,9 @@ const int64 LocationArbitratorImpl::kFixStaleTimeoutMilliseconds = LocationArbitratorImpl::LocationArbitratorImpl( const LocationUpdateCallback& callback) - : callback_(callback), - provider_callback_( - base::Bind(&LocationArbitratorImpl::LocationUpdateAvailable, + : arbitrator_update_callback_(callback), + provider_update_callback_( + base::Bind(&LocationArbitratorImpl::OnLocationUpdate, base::Unretained(this))), position_provider_(NULL), is_permission_granted_(false), @@ -116,15 +116,14 @@ void LocationArbitratorImpl::RegisterProvider( LocationProvider* provider) { if (!provider) return; - provider->SetUpdateCallback(provider_callback_); + provider->SetUpdateCallback(provider_update_callback_); if (is_permission_granted_) provider->OnPermissionGranted(); providers_.push_back(provider); } -void LocationArbitratorImpl::LocationUpdateAvailable( - const LocationProvider* provider, - const Geoposition& new_position) { +void LocationArbitratorImpl::OnLocationUpdate(const LocationProvider* provider, + const Geoposition& new_position) { DCHECK(new_position.Validate() || new_position.error_code != Geoposition::ERROR_CODE_NONE); if (!IsNewPositionBetter(position_, new_position, @@ -132,7 +131,7 @@ void LocationArbitratorImpl::LocationUpdateAvailable( return; position_provider_ = provider; position_ = new_position; - callback_.Run(position_); + arbitrator_update_callback_.Run(position_); } AccessTokenStore* LocationArbitratorImpl::NewAccessTokenStore() { diff --git a/content/browser/geolocation/location_arbitrator_impl.h b/content/browser/geolocation/location_arbitrator_impl.h index da20e7b..21ba90e 100644 --- a/content/browser/geolocation/location_arbitrator_impl.h +++ b/content/browser/geolocation/location_arbitrator_impl.h @@ -70,9 +70,9 @@ class CONTENT_EXPORT LocationArbitratorImpl : public LocationArbitrator { net::URLRequestContextGetter* context_getter); void DoStartProviders(); - // The providers call this function when a new position is available. - void LocationUpdateAvailable(const LocationProvider* provider, - const Geoposition& new_position); + // Gets called when a provider has a new position. + void OnLocationUpdate(const LocationProvider* provider, + const Geoposition& new_position); // 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 @@ -82,8 +82,8 @@ class CONTENT_EXPORT LocationArbitratorImpl : public LocationArbitrator { bool from_same_provider) const; scoped_refptr<AccessTokenStore> access_token_store_; - LocationUpdateCallback callback_; - LocationProvider::LocationProviderUpdateCallback provider_callback_; + LocationUpdateCallback arbitrator_update_callback_; + LocationProvider::LocationProviderUpdateCallback provider_update_callback_; ScopedVector<LocationProvider> providers_; bool use_high_accuracy_; // The provider which supplied the current |position_| diff --git a/content/browser/geolocation/network_location_provider.cc b/content/browser/geolocation/network_location_provider.cc index 2a9d7c8..0cc7f8f 100644 --- a/content/browser/geolocation/network_location_provider.cc +++ b/content/browser/geolocation/network_location_provider.cc @@ -110,7 +110,7 @@ NetworkLocationProvider::NetworkLocationProvider( : access_token_store_(access_token_store), wifi_data_provider_(NULL), wifi_data_update_callback_( - base::Bind(&NetworkLocationProvider::WifiDataUpdateAvailable, + base::Bind(&NetworkLocationProvider::OnWifiDataUpdate, base::Unretained(this))), is_wifi_data_complete_(false), access_token_(access_token), @@ -120,10 +120,11 @@ NetworkLocationProvider::NetworkLocationProvider( // Create the position cache. position_cache_.reset(new PositionCache()); - NetworkLocationRequest::LocationResponseCallback callback = - base::Bind(&NetworkLocationProvider::LocationResponseAvailable, - base::Unretained(this)); - request_.reset(new NetworkLocationRequest(url_context_getter, url, callback)); + request_.reset(new NetworkLocationRequest( + url_context_getter, + url, + base::Bind(&NetworkLocationProvider::OnLocationResponse, + base::Unretained(this)))); } NetworkLocationProvider::~NetworkLocationProvider() { @@ -153,14 +154,13 @@ void NetworkLocationProvider::OnPermissionGranted() { } } -void NetworkLocationProvider::WifiDataUpdateAvailable( - WifiDataProvider* provider) { +void NetworkLocationProvider::OnWifiDataUpdate(WifiDataProvider* provider) { DCHECK(provider == wifi_data_provider_); is_wifi_data_complete_ = wifi_data_provider_->GetData(&wifi_data_); OnWifiDataUpdated(); } -void NetworkLocationProvider::LocationResponseAvailable( +void NetworkLocationProvider::OnLocationResponse( const Geoposition& position, bool server_error, const base::string16& access_token, diff --git a/content/browser/geolocation/network_location_provider.h b/content/browser/geolocation/network_location_provider.h index 710fd3f..daf0c8b 100644 --- a/content/browser/geolocation/network_location_provider.h +++ b/content/browser/geolocation/network_location_provider.h @@ -82,18 +82,18 @@ class NetworkLocationProvider // Satisfies a position request from cache or network. void RequestPosition(); - // Called from a callback when new wifi data is available. - void WifiDataUpdateAvailable(WifiDataProvider* provider); + // Gets called when new wifi data is available. + void OnWifiDataUpdate(WifiDataProvider* provider); - // Internal helper used by WifiDataUpdateAvailable. + // Internal helper used by OnWifiDataUpdate. void OnWifiDataUpdated(); bool IsStarted() const; - void LocationResponseAvailable(const Geoposition& position, - bool server_error, - const base::string16& access_token, - const WifiData& wifi_data); + void OnLocationResponse(const Geoposition& position, + bool server_error, + const base::string16& access_token, + const WifiData& wifi_data); scoped_refptr<AccessTokenStore> access_token_store_; diff --git a/content/browser/geolocation/network_location_provider_unittest.cc b/content/browser/geolocation/network_location_provider_unittest.cc index c574b7a..23bb754 100644 --- a/content/browser/geolocation/network_location_provider_unittest.cc +++ b/content/browser/geolocation/network_location_provider_unittest.cc @@ -35,8 +35,8 @@ class MessageLoopQuitListener { CHECK(client_message_loop_); } - void LocationUpdateAvailable(const LocationProvider* provider, - const Geoposition& position) { + void OnLocationUpdate(const LocationProvider* provider, + const Geoposition& position) { EXPECT_EQ(client_message_loop_, base::MessageLoop::current()); updated_provider_ = provider; client_message_loop_->Quit(); @@ -473,9 +473,8 @@ TEST_F(GeolocationNetworkProviderTest, NoRequestOnStartupUntilWifiData) { scoped_ptr<LocationProvider> provider(CreateProvider(true)); EXPECT_TRUE(provider->StartProvider(false)); - provider->SetUpdateCallback( - base::Bind(&MessageLoopQuitListener::LocationUpdateAvailable, - base::Unretained(&listener))); + provider->SetUpdateCallback(base::Bind( + &MessageLoopQuitListener::OnLocationUpdate, base::Unretained(&listener))); main_message_loop_.RunUntilIdle(); EXPECT_FALSE(get_url_fetcher_and_advance_id()) diff --git a/content/browser/geolocation/network_location_request.cc b/content/browser/geolocation/network_location_request.cc index 75c7c84..84ba5b0 100644 --- a/content/browser/geolocation/network_location_request.cc +++ b/content/browser/geolocation/network_location_request.cc @@ -103,9 +103,7 @@ NetworkLocationRequest::NetworkLocationRequest( net::URLRequestContextGetter* context, const GURL& url, LocationResponseCallback callback) - : url_context_(context), - callback_(callback), - url_(url) { + : url_context_(context), location_response_callback_(callback), url_(url) { } NetworkLocationRequest::~NetworkLocationRequest() { @@ -122,7 +120,7 @@ bool NetworkLocationRequest::MakeRequest(const base::string16& access_token, url_fetcher_.reset(); } wifi_data_ = wifi_data; - timestamp_ = timestamp; + wifi_data_timestamp_ = timestamp; GURL request_url = FormRequestURL(url_); url_fetcher_.reset(net::URLFetcher::Create( @@ -136,7 +134,7 @@ bool NetworkLocationRequest::MakeRequest(const base::string16& access_token, net::LOAD_DO_NOT_SAVE_COOKIES | net::LOAD_DO_NOT_SEND_COOKIES | net::LOAD_DO_NOT_SEND_AUTH_DATA); - start_time_ = base::TimeTicks::Now(); + request_start_time_ = base::TimeTicks::Now(); url_fetcher_->Start(); return true; } @@ -156,7 +154,7 @@ void NetworkLocationRequest::OnURLFetchComplete( GetLocationFromResponse(status.is_success(), response_code, data, - timestamp_, + wifi_data_timestamp_, source->GetURL(), &position, &access_token); @@ -165,7 +163,8 @@ void NetworkLocationRequest::OnURLFetchComplete( url_fetcher_.reset(); if (!server_error) { - const base::TimeDelta request_time = base::TimeTicks::Now() - start_time_; + const base::TimeDelta request_time = + base::TimeTicks::Now() - request_start_time_; UMA_HISTOGRAM_CUSTOM_TIMES( "Net.Wifi.LbsLatency", @@ -176,7 +175,8 @@ void NetworkLocationRequest::OnURLFetchComplete( } DVLOG(1) << "NetworkLocationRequest::OnURLFetchComplete() : run callback."; - callback_.Run(position, server_error, access_token, wifi_data_); + location_response_callback_.Run( + position, server_error, access_token, wifi_data_); } // Local functions. diff --git a/content/browser/geolocation/network_location_request.h b/content/browser/geolocation/network_location_request.h index 6fea08b..23bffb9 100644 --- a/content/browser/geolocation/network_location_request.h +++ b/content/browser/geolocation/network_location_request.h @@ -57,17 +57,17 @@ class NetworkLocationRequest : private net::URLFetcherDelegate { virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE; scoped_refptr<net::URLRequestContextGetter> url_context_; - LocationResponseCallback callback_; + LocationResponseCallback location_response_callback_; const GURL url_; scoped_ptr<net::URLFetcher> url_fetcher_; // Keep a copy of the data sent in the request, so we can refer back to it // when the response arrives. WifiData wifi_data_; - base::Time timestamp_; // Timestamp of the above data, not of the request. + base::Time wifi_data_timestamp_; // The start time for the request. - base::TimeTicks start_time_; + base::TimeTicks request_start_time_; DISALLOW_COPY_AND_ASSIGN(NetworkLocationRequest); }; diff --git a/content/browser/geolocation/wifi_data_provider_common_unittest.cc b/content/browser/geolocation/wifi_data_provider_common_unittest.cc index 9c55dfd..7b583f2 100644 --- a/content/browser/geolocation/wifi_data_provider_common_unittest.cc +++ b/content/browser/geolocation/wifi_data_provider_common_unittest.cc @@ -62,12 +62,12 @@ class MessageLoopQuitter { public: explicit MessageLoopQuitter(base::MessageLoop* message_loop) : message_loop_to_quit_(message_loop), - callback_(base::Bind(&MessageLoopQuitter::WifiDataUpdateAvailable, + callback_(base::Bind(&MessageLoopQuitter::OnWifiDataUpdate, base::Unretained(this))) { CHECK(message_loop_to_quit_ != NULL); } - void WifiDataUpdateAvailable(WifiDataProvider* provider) { + void OnWifiDataUpdate(WifiDataProvider* provider) { // Provider should call back on client's thread. EXPECT_EQ(base::MessageLoop::current(), message_loop_to_quit_); message_loop_to_quit_->QuitNow(); |