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
parent 24e4f0a9
......@@ -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,14 +116,13 @@ 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,
void LocationArbitratorImpl::OnLocationUpdate(const LocationProvider* provider,
const Geoposition& new_position) {
DCHECK(new_position.Validate() ||
new_position.error_code != Geoposition::ERROR_CODE_NONE);
......@@ -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() {
......
......@@ -70,8 +70,8 @@ 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,
// 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|.
......@@ -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_|
......
......@@ -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,
......
......@@ -82,15 +82,15 @@ 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,
void OnLocationResponse(const Geoposition& position,
bool server_error,
const base::string16& access_token,
const WifiData& wifi_data);
......
......@@ -35,7 +35,7 @@ class MessageLoopQuitListener {
CHECK(client_message_loop_);
}
void LocationUpdateAvailable(const LocationProvider* provider,
void OnLocationUpdate(const LocationProvider* provider,
const Geoposition& position) {
EXPECT_EQ(client_message_loop_, base::MessageLoop::current());
updated_provider_ = provider;
......@@ -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())
......
......@@ -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.
......
......@@ -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);
};
......
......@@ -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();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment