summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormvanouwerkerk <mvanouwerkerk@chromium.org>2016-02-17 07:45:10 -0800
committerCommit bot <commit-bot@chromium.org>2016-02-17 15:46:28 +0000
commit7316bb86443c21f42e98de7595f2ffcaa00c7311 (patch)
treee34a86e18bffef16694edac08b9435457a352bc4
parent0a8b0305c8449bb57066e2733e6307b8f18d5e40 (diff)
downloadchromium_src-7316bb86443c21f42e98de7595f2ffcaa00c7311.zip
chromium_src-7316bb86443c21f42e98de7595f2ffcaa00c7311.tar.gz
chromium_src-7316bb86443c21f42e98de7595f2ffcaa00c7311.tar.bz2
Clarify naming of the timestamp passed around in geolocation.
If it's not on a position, it is the wifi data timestamp. Review URL: https://codereview.chromium.org/1698043004 Cr-Commit-Position: refs/heads/master@{#375892}
-rw-r--r--content/browser/geolocation/network_location_provider.cc11
-rw-r--r--content/browser/geolocation/network_location_provider.h2
-rw-r--r--content/browser/geolocation/network_location_request.cc37
-rw-r--r--content/browser/geolocation/network_location_request.h4
4 files changed, 25 insertions, 29 deletions
diff --git a/content/browser/geolocation/network_location_provider.cc b/content/browser/geolocation/network_location_provider.cc
index cb972fe..0174861 100644
--- a/content/browser/geolocation/network_location_provider.cc
+++ b/content/browser/geolocation/network_location_provider.cc
@@ -212,7 +212,7 @@ bool NetworkLocationProvider::StartProvider(bool high_accuracy) {
void NetworkLocationProvider::OnWifiDataUpdated() {
DCHECK(CalledOnValidThread());
- wifi_data_updated_timestamp_ = base::Time::Now();
+ wifi_timestamp_ = base::Time::Now();
is_new_data_available_ = is_wifi_data_complete_;
RequestRefresh();
@@ -235,8 +235,8 @@ void NetworkLocationProvider::RequestPosition() {
const Geoposition* cached_position =
position_cache_->FindPosition(wifi_data_);
- DCHECK(!wifi_data_updated_timestamp_.is_null()) <<
- "Timestamp must be set before looking up position";
+ DCHECK(!wifi_timestamp_.is_null())
+ << "Timestamp must be set before looking up position";
if (cached_position) {
DCHECK(cached_position->Validate());
// Record the position and update its timestamp.
@@ -244,7 +244,7 @@ void NetworkLocationProvider::RequestPosition() {
// The timestamp of a position fix is determined by the timestamp
// of the source data update. (The value of position_.timestamp from
// the cache could be from weeks ago!)
- position_.timestamp = wifi_data_updated_timestamp_;
+ position_.timestamp = wifi_timestamp_;
is_new_data_available_ = false;
// Let listeners know that we now have a position available.
NotifyCallback(position_);
@@ -264,8 +264,7 @@ void NetworkLocationProvider::RequestPosition() {
"with new data. Wifi APs: "
<< wifi_data_.access_point_data.size();
}
- request_->MakeRequest(access_token_, wifi_data_,
- wifi_data_updated_timestamp_);
+ request_->MakeRequest(access_token_, wifi_data_, wifi_timestamp_);
}
bool NetworkLocationProvider::IsStarted() const {
diff --git a/content/browser/geolocation/network_location_provider.h b/content/browser/geolocation/network_location_provider.h
index 69d891f..6c37a8c 100644
--- a/content/browser/geolocation/network_location_provider.h
+++ b/content/browser/geolocation/network_location_provider.h
@@ -109,7 +109,7 @@ class NetworkLocationProvider
bool is_wifi_data_complete_;
// The timestamp for the latest wifi data update.
- base::Time wifi_data_updated_timestamp_;
+ base::Time wifi_timestamp_;
// Cached value loaded from the token store or set by a previous server
// response, and sent in each subsequent network request.
diff --git a/content/browser/geolocation/network_location_request.cc b/content/browser/geolocation/network_location_request.cc
index 81ef4da..7471c17 100644
--- a/content/browser/geolocation/network_location_request.cc
+++ b/content/browser/geolocation/network_location_request.cc
@@ -74,7 +74,7 @@ void RecordUmaAccessPoints(int count) {
GURL FormRequestURL(const GURL& url);
void FormUploadData(const WifiData& wifi_data,
- const base::Time& timestamp,
+ const base::Time& wifi_timestamp,
const base::string16& access_token,
std::string* upload_data);
@@ -83,7 +83,7 @@ void FormUploadData(const WifiData& wifi_data,
void GetLocationFromResponse(bool http_post_result,
int status_code,
const std::string& response_body,
- const base::Time& timestamp,
+ const base::Time& wifi_timestamp,
const GURL& server_url,
Geoposition* position,
base::string16* access_token);
@@ -92,7 +92,7 @@ void GetLocationFromResponse(bool http_post_result,
// Sets |*position| to the parsed location if a valid fix was received,
// otherwise leaves it unchanged.
bool ParseServerResponse(const std::string& response_body,
- const base::Time& timestamp,
+ const base::Time& wifi_timestamp,
Geoposition* position,
base::string16* access_token);
void AddWifiData(const WifiData& wifi_data,
@@ -114,7 +114,7 @@ NetworkLocationRequest::~NetworkLocationRequest() {
bool NetworkLocationRequest::MakeRequest(const base::string16& access_token,
const WifiData& wifi_data,
- const base::Time& timestamp) {
+ const base::Time& wifi_timestamp) {
RecordUmaEvent(NETWORK_LOCATION_REQUEST_EVENT_REQUEST_START);
RecordUmaAccessPoints(wifi_data.access_point_data.size());
if (url_fetcher_ != NULL) {
@@ -123,14 +123,14 @@ bool NetworkLocationRequest::MakeRequest(const base::string16& access_token,
url_fetcher_.reset();
}
wifi_data_ = wifi_data;
- wifi_data_timestamp_ = timestamp;
+ wifi_timestamp_ = wifi_timestamp;
GURL request_url = FormRequestURL(url_);
url_fetcher_ = net::URLFetcher::Create(url_fetcher_id_for_tests, request_url,
net::URLFetcher::POST, this);
url_fetcher_->SetRequestContext(url_context_.get());
std::string upload_data;
- FormUploadData(wifi_data, timestamp, access_token, &upload_data);
+ FormUploadData(wifi_data, wifi_timestamp, access_token, &upload_data);
url_fetcher_->SetUploadData("application/json", upload_data);
url_fetcher_->SetLoadFlags(
net::LOAD_BYPASS_CACHE | net::LOAD_DISABLE_CACHE |
@@ -154,12 +154,8 @@ void NetworkLocationRequest::OnURLFetchComplete(
base::string16 access_token;
std::string data;
source->GetResponseAsString(&data);
- GetLocationFromResponse(status.is_success(),
- response_code,
- data,
- wifi_data_timestamp_,
- source->GetURL(),
- &position,
+ GetLocationFromResponse(status.is_success(), response_code, data,
+ wifi_timestamp_, source->GetURL(), &position,
&access_token);
const bool server_error =
!status.is_success() || (response_code >= 500 && response_code < 600);
@@ -209,14 +205,14 @@ GURL FormRequestURL(const GURL& url) {
}
void FormUploadData(const WifiData& wifi_data,
- const base::Time& timestamp,
+ const base::Time& wifi_timestamp,
const base::string16& access_token,
std::string* upload_data) {
int age = std::numeric_limits<int32_t>::min(); // Invalid so AddInteger()
// will ignore.
- if (!timestamp.is_null()) {
+ if (!wifi_timestamp.is_null()) {
// Convert absolute timestamps into a relative age.
- int64_t delta_ms = (base::Time::Now() - timestamp).InMilliseconds();
+ int64_t delta_ms = (base::Time::Now() - wifi_timestamp).InMilliseconds();
if (delta_ms >= 0 && delta_ms < std::numeric_limits<int32_t>::max())
age = static_cast<int>(delta_ms);
}
@@ -285,7 +281,7 @@ void FormatPositionError(const GURL& server_url,
void GetLocationFromResponse(bool http_post_result,
int status_code,
const std::string& response_body,
- const base::Time& timestamp,
+ const base::Time& wifi_timestamp,
const GURL& server_url,
Geoposition* position,
base::string16* access_token) {
@@ -308,7 +304,8 @@ void GetLocationFromResponse(bool http_post_result,
}
// We use the timestamp from the wifi data that was used to generate
// this position fix.
- if (!ParseServerResponse(response_body, timestamp, position, access_token)) {
+ if (!ParseServerResponse(response_body, wifi_timestamp, position,
+ access_token)) {
// We failed to parse the repsonse.
FormatPositionError(server_url, "Response was malformed", position);
RecordUmaEvent(NETWORK_LOCATION_REQUEST_EVENT_RESPONSE_MALFORMED);
@@ -346,14 +343,14 @@ bool GetAsDouble(const base::DictionaryValue& object,
}
bool ParseServerResponse(const std::string& response_body,
- const base::Time& timestamp,
+ const base::Time& wifi_timestamp,
Geoposition* position,
base::string16* access_token) {
DCHECK(position);
DCHECK(!position->Validate());
DCHECK(position->error_code == Geoposition::ERROR_CODE_NONE);
DCHECK(access_token);
- DCHECK(!timestamp.is_null());
+ DCHECK(!wifi_timestamp.is_null());
if (response_body.empty()) {
LOG(WARNING) << "ParseServerResponse() : Response was empty.";
@@ -416,7 +413,7 @@ bool ParseServerResponse(const std::string& response_body,
// All error paths covered: now start actually modifying postion.
position->latitude = latitude;
position->longitude = longitude;
- position->timestamp = timestamp;
+ position->timestamp = wifi_timestamp;
// Other fields are optional.
GetAsDouble(*response_object, kAccuracyString, &position->accuracy);
diff --git a/content/browser/geolocation/network_location_request.h b/content/browser/geolocation/network_location_request.h
index fe15b72..d87b373 100644
--- a/content/browser/geolocation/network_location_request.h
+++ b/content/browser/geolocation/network_location_request.h
@@ -47,7 +47,7 @@ class NetworkLocationRequest : private net::URLFetcherDelegate {
// started. In all cases, any currently pending request will be canceled.
bool MakeRequest(const base::string16& access_token,
const WifiData& wifi_data,
- const base::Time& timestamp);
+ const base::Time& wifi_timestamp);
bool is_request_pending() const { return url_fetcher_ != NULL; }
const GURL& url() const { return url_; }
@@ -64,7 +64,7 @@ class NetworkLocationRequest : private net::URLFetcherDelegate {
// 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 wifi_data_timestamp_;
+ base::Time wifi_timestamp_;
// The start time for the request.
base::TimeTicks request_start_time_;