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

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

Issue 578006: Re-attempt at http://src.chromium.org/viewvc/chrome?view=rev&revision=37989 ... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 10 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_provider_unittest.cc ('k') | chrome/chrome_tests.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/geolocation/network_location_request.cc
===================================================================
--- chrome/browser/geolocation/network_location_request.cc (revision 38111)
+++ chrome/browser/geolocation/network_location_request.cc (working copy)
@@ -66,7 +66,6 @@
ListenerInterface* listener)
: url_context_(context), timestamp_(kint64min), listener_(listener),
url_(url), host_name_(host_name) {
-// DCHECK(url_context_);
DCHECK(listener);
}
@@ -89,7 +88,7 @@
timestamp_ = timestamp;
url_fetcher_.reset(URLFetcher::Create(
- host_name_.size(), // Used for testing
+ wifi_data.access_point_data.size(), // Used for testing
url_, URLFetcher::POST, this));
url_fetcher_->set_upload_data(kMimeApplicationJson, post_body);
url_fetcher_->set_request_context(url_context_);
@@ -312,20 +311,31 @@
response_object->GetStringAsUTF16(kAccessTokenString, access_token);
// Get the location
- DictionaryValue* location_object;
- if (!response_object->GetDictionary(kLocationString, &location_object)) {
- Value* value = NULL;
- // If the network provider was unable to provide a position fix, it should
- // return a 200 with location == null. Otherwise it's an error.
- return response_object->Get(kLocationString, &value)
- && value && value->IsType(Value::TYPE_NULL);
+ Value* location_value = NULL;
+ if (!response_object->Get(kLocationString, &location_value)) {
+ LOG(INFO) << "ParseServerResponse() : Missing location attribute.\n";
+ return false;
}
- DCHECK(location_object);
+ DCHECK(location_value);
+ if (!location_value->IsType(Value::TYPE_DICTIONARY)) {
+ if (!location_value->IsType(Value::TYPE_NULL)) {
+ LOG(INFO) << "ParseServerResponse() : Unexpected location type"
+ << location_value->GetType() << ".\n";
+ // If the network provider was unable to provide a position fix, it should
+ // return a HTTP 200, with "location" : null. Otherwise it's an error.
+ return false;
+ }
+ return true; // Successfully parsed response containing no fix.
+ }
+ DictionaryValue* location_object =
+ static_cast<DictionaryValue*>(location_value);
+
// latitude and longitude fields are always required.
double latitude, longitude;
if (!GetAsDouble(*location_object, kLatitudeString, &latitude) ||
!GetAsDouble(*location_object, kLongitudeString, &longitude)) {
+ LOG(INFO) << "ParseServerResponse() : location lacks lat and/or long.\n";
return false;
}
// All error paths covered: now start actually modifying postion.
« no previous file with comments | « chrome/browser/geolocation/network_location_provider_unittest.cc ('k') | chrome/chrome_tests.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698