| OLD | NEW | 
|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be | 
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. | 
| 4 | 4 | 
| 5 #include "chromeos/geolocation/simple_geolocation_request.h" | 5 #include "chromeos/geolocation/simple_geolocation_request.h" | 
| 6 | 6 | 
| 7 #include <algorithm> | 7 #include <algorithm> | 
| 8 #include <string> | 8 #include <string> | 
| 9 | 9 | 
| 10 #include "base/json/json_reader.h" | 10 #include "base/json/json_reader.h" | 
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 158     PrintGeolocationError( | 158     PrintGeolocationError( | 
| 159         server_url, "Server returned empty response", position); | 159         server_url, "Server returned empty response", position); | 
| 160     RecordUmaEvent(SIMPLE_GEOLOCATION_REQUEST_EVENT_RESPONSE_EMPTY); | 160     RecordUmaEvent(SIMPLE_GEOLOCATION_REQUEST_EVENT_RESPONSE_EMPTY); | 
| 161     return false; | 161     return false; | 
| 162   } | 162   } | 
| 163   VLOG(1) << "SimpleGeolocationRequest::ParseServerResponse() : " | 163   VLOG(1) << "SimpleGeolocationRequest::ParseServerResponse() : " | 
| 164              "Parsing response '" << response_body << "'"; | 164              "Parsing response '" << response_body << "'"; | 
| 165 | 165 | 
| 166   // Parse the response, ignoring comments. | 166   // Parse the response, ignoring comments. | 
| 167   std::string error_msg; | 167   std::string error_msg; | 
| 168   scoped_ptr<base::Value> response_value( | 168   scoped_ptr<base::Value> response_value = base::JSONReader::ReadAndReturnError( | 
| 169       base::JSONReader::DeprecatedReadAndReturnError( | 169       response_body, base::JSON_PARSE_RFC, NULL, &error_msg); | 
| 170           response_body, base::JSON_PARSE_RFC, NULL, &error_msg)); |  | 
| 171   if (response_value == NULL) { | 170   if (response_value == NULL) { | 
| 172     PrintGeolocationError( | 171     PrintGeolocationError( | 
| 173         server_url, "JSONReader failed: " + error_msg, position); | 172         server_url, "JSONReader failed: " + error_msg, position); | 
| 174     RecordUmaEvent(SIMPLE_GEOLOCATION_REQUEST_EVENT_RESPONSE_MALFORMED); | 173     RecordUmaEvent(SIMPLE_GEOLOCATION_REQUEST_EVENT_RESPONSE_MALFORMED); | 
| 175     return false; | 174     return false; | 
| 176   } | 175   } | 
| 177 | 176 | 
| 178   base::DictionaryValue* response_object = NULL; | 177   base::DictionaryValue* response_object = NULL; | 
| 179   if (!response_value->GetAsDictionary(&response_object)) { | 178   if (!response_value->GetAsDictionary(&response_object)) { | 
| 180     PrintGeolocationError( | 179     PrintGeolocationError( | 
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 382            ? SIMPLE_GEOLOCATION_REQUEST_RESULT_SERVER_ERROR | 381            ? SIMPLE_GEOLOCATION_REQUEST_RESULT_SERVER_ERROR | 
| 383            : SIMPLE_GEOLOCATION_REQUEST_RESULT_FAILURE); | 382            : SIMPLE_GEOLOCATION_REQUEST_RESULT_FAILURE); | 
| 384   RecordUmaResult(result, retries_); | 383   RecordUmaResult(result, retries_); | 
| 385   position_.status = Geoposition::STATUS_TIMEOUT; | 384   position_.status = Geoposition::STATUS_TIMEOUT; | 
| 386   const base::TimeDelta elapsed = base::Time::Now() - request_started_at_; | 385   const base::TimeDelta elapsed = base::Time::Now() - request_started_at_; | 
| 387   ReplyAndDestroySelf(elapsed, true /* server_error */); | 386   ReplyAndDestroySelf(elapsed, true /* server_error */); | 
| 388   // "this" is already destroyed here. | 387   // "this" is already destroyed here. | 
| 389 } | 388 } | 
| 390 | 389 | 
| 391 }  // namespace chromeos | 390 }  // namespace chromeos | 
| OLD | NEW | 
|---|