diff options
author | allanwoj@chromium.org <allanwoj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-23 14:31:06 +0000 |
---|---|---|
committer | allanwoj@chromium.org <allanwoj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-23 14:31:06 +0000 |
commit | b6f31f8de7f49c75238e8e0422f80f35eb5267e2 (patch) | |
tree | 380c8c56800856a029e7082092b6bc5ad057649e /chrome/browser/geolocation/network_location_request.cc | |
parent | 0ca5c104bc719dc5e7dcdc19cca1576c27391e65 (diff) | |
download | chromium_src-b6f31f8de7f49c75238e8e0422f80f35eb5267e2.zip chromium_src-b6f31f8de7f49c75238e8e0422f80f35eb5267e2.tar.gz chromium_src-b6f31f8de7f49c75238e8e0422f80f35eb5267e2.tar.bz2 |
Gateway Location Provider
Location provider using the MAC address of a router the user is connected to via Ethernet to find a position fix.
BUG=NONE
TEST=Unit test
Review URL: http://codereview.chromium.org/3153031
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@57052 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/geolocation/network_location_request.cc')
-rw-r--r-- | chrome/browser/geolocation/network_location_request.cc | 35 |
1 files changed, 32 insertions, 3 deletions
diff --git a/chrome/browser/geolocation/network_location_request.cc b/chrome/browser/geolocation/network_location_request.cc index 8081568..9700547 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 |