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

Unified Diff: chrome/browser/geolocation/network_location_request.cc

Issue 3153031: Gateway Location Provider (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: Land patch Created 10 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/geolocation/network_location_request.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/geolocation/network_location_request.cc
diff --git a/chrome/browser/geolocation/network_location_request.cc b/chrome/browser/geolocation/network_location_request.cc
index 8081568fe8389fa379182be8441cfb92183b207c..97005470756008a10491c25152afd1f8a5aae0ae 100644
--- a/chrome/browser/geolocation/network_location_request.cc
+++ b/chrome/browser/geolocation/network_location_request.cc
@@ -32,6 +32,7 @@ const char kAltitudeAccuracyString[] = "altitude_accuracy";
// Creates the request payload to send to the server.
void FormRequestBody(const std::string& host_name,
const string16& access_token,
+ const GatewayData& gateway_data,
const RadioData& radio_data,
const WifiData& wifi_data,
const base::Time& timestamp,
@@ -61,6 +62,9 @@ bool ParseServerResponse(const std::string& response_body,
const base::Time& timestamp,
Geoposition* position,
string16* access_token);
+void AddGatewayData(const GatewayData& gateway_data,
+ int age_milliseconds,
+ DictionaryValue* body_object);
void AddRadioData(const RadioData& radio_data,
int age_milliseconds,
DictionaryValue* body_object);
@@ -84,6 +88,7 @@ NetworkLocationRequest::~NetworkLocationRequest() {
bool NetworkLocationRequest::MakeRequest(const std::string& host_name,
const string16& access_token,
+ const GatewayData& gateway_data,
const RadioData& radio_data,
const WifiData& wifi_data,
const base::Time& timestamp) {
@@ -91,12 +96,13 @@ bool NetworkLocationRequest::MakeRequest(const std::string& host_name,
DLOG(INFO) << "NetworkLocationRequest : Cancelling pending request";
url_fetcher_.reset();
}
+ gateway_data_ = gateway_data;
radio_data_ = radio_data;
wifi_data_ = wifi_data;
timestamp_ = timestamp;
std::string post_body;
- FormRequestBody(host_name, access_token, radio_data_, wifi_data_,
- timestamp_, &post_body);
+ FormRequestBody(host_name, access_token, gateway_data, radio_data_,
+ wifi_data_, timestamp_, &post_body);
url_fetcher_.reset(URLFetcher::Create(
url_fetcher_id_for_tests, url_, URLFetcher::POST, this));
@@ -131,7 +137,7 @@ void NetworkLocationRequest::OnURLFetchComplete(const URLFetcher* source,
DLOG(INFO) << "NetworkLocationRequest::Run() : "
"Calling listener with position.\n";
listener_->LocationResponseAvailable(position, server_error, access_token,
- radio_data_, wifi_data_);
+ gateway_data_, radio_data_, wifi_data_);
}
// Local functions.
@@ -139,6 +145,7 @@ namespace {
void FormRequestBody(const std::string& host_name,
const string16& access_token,
+ const GatewayData& gateway_data,
const RadioData& radio_data,
const WifiData& wifi_data,
const base::Time& timestamp,
@@ -166,6 +173,7 @@ void FormRequestBody(const std::string& host_name,
}
AddRadioData(radio_data, age, &body_object);
AddWifiData(wifi_data, age, &body_object);
+ AddGatewayData(gateway_data, age, &body_object);
base::JSONWriter::Write(&body_object, false, data);
DLOG(INFO) << "NetworkLocationRequest::FormRequestBody(): Formed body "
@@ -421,4 +429,25 @@ void AddWifiData(const WifiData& wifi_data,
}
body_object->Set("wifi_towers", wifi_towers);
}
+
+void AddGatewayData(const GatewayData& gateway_data,
+ int age_milliseconds,
+ DictionaryValue* body_object) {
+ DCHECK(body_object);
+
+ if (gateway_data.router_data.empty()) {
+ return;
+ }
+
+ ListValue* gateways = new ListValue;
+ for (GatewayData::RouterDataSet::const_iterator iter =
+ gateway_data.router_data.begin();
+ iter != gateway_data.router_data.end();
+ iter++) {
+ DictionaryValue* gateway = new DictionaryValue;
+ AddString("mac_address", iter->mac_address, gateway);
+ gateways->Append(gateway);
+ }
+ body_object->Set("gateways", gateways);
+}
} // namespace
« no previous file with comments | « chrome/browser/geolocation/network_location_request.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698