summaryrefslogtreecommitdiffstats
path: root/chrome/browser/geolocation/network_location_request.cc
diff options
context:
space:
mode:
authorjoth@chromium.org <joth@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-05 13:01:55 +0000
committerjoth@chromium.org <joth@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-05 13:01:55 +0000
commitfdbe105e55a422937d777e814fea4c963646cd30 (patch)
treead69c84e7332b9b51fa72cf8a53bcfea4795924a /chrome/browser/geolocation/network_location_request.cc
parenta598247f2a78fb8a394c5db79c39ae5cd2101697 (diff)
downloadchromium_src-fdbe105e55a422937d777e814fea4c963646cd30.zip
chromium_src-fdbe105e55a422937d777e814fea4c963646cd30.tar.gz
chromium_src-fdbe105e55a422937d777e814fea4c963646cd30.tar.bz2
Revert 38207 - bah. still can't work out why this passes fine on local machine & try bots.
Reattempt at http://src.chromium.org/viewvc/chrome?view=rev&revision=37989 (asserts tidy up slit out into its own change http://codereview.chromium.org/578013/show) Add tests for the geolocation network provider. Also some small tidy up a few other files. BUG=http://crbug.com/11246 TEST=unit_tests.exe gtest_filter=NetworkLocationProvider* gtest_break_on_failure Review URL: http://codereview.chromium.org/578006 TBR=joth@chromium.org Review URL: http://codereview.chromium.org/575021 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@38208 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/geolocation/network_location_request.cc')
-rw-r--r--chrome/browser/geolocation/network_location_request.cc30
1 files changed, 10 insertions, 20 deletions
diff --git a/chrome/browser/geolocation/network_location_request.cc b/chrome/browser/geolocation/network_location_request.cc
index 65e3f37..7fff715 100644
--- a/chrome/browser/geolocation/network_location_request.cc
+++ b/chrome/browser/geolocation/network_location_request.cc
@@ -66,6 +66,7 @@ NetworkLocationRequest::NetworkLocationRequest(URLRequestContextGetter* context,
ListenerInterface* listener)
: url_context_(context), timestamp_(kint64min), listener_(listener),
url_(url), host_name_(host_name) {
+// DCHECK(url_context_);
DCHECK(listener);
}
@@ -88,7 +89,7 @@ bool NetworkLocationRequest::MakeRequest(const string16& access_token,
timestamp_ = timestamp;
url_fetcher_.reset(URLFetcher::Create(
- wifi_data.access_point_data.size(), // Used for testing
+ host_name_.size(), // Used for testing
url_, URLFetcher::POST, this));
url_fetcher_->set_upload_data(kMimeApplicationJson, post_body);
url_fetcher_->set_request_context(url_context_);
@@ -311,31 +312,20 @@ bool ParseServerResponse(const std::string& response_body,
response_object->GetStringAsUTF16(kAccessTokenString, access_token);
// Get the location
- Value* location_value = NULL;
- if (!response_object->Get(kLocationString, &location_value)) {
- LOG(INFO) << "ParseServerResponse() : Missing location attribute.\n";
- return false;
- }
- 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;
+ 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);
}
- DictionaryValue* location_object =
- static_cast<DictionaryValue*>(location_value);
+ DCHECK(location_object);
// 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.