| 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/timezone/timezone_request.h" | 5 #include "chromeos/timezone/timezone_request.h" | 
| 6 | 6 | 
| 7 #include <string> | 7 #include <string> | 
| 8 | 8 | 
| 9 #include "base/json/json_reader.h" | 9 #include "base/json/json_reader.h" | 
| 10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" | 
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 168   if (response_body.empty()) { | 168   if (response_body.empty()) { | 
| 169     PrintTimeZoneError(server_url, "Server returned empty response", timezone); | 169     PrintTimeZoneError(server_url, "Server returned empty response", timezone); | 
| 170     RecordUmaEvent(TIMEZONE_REQUEST_EVENT_RESPONSE_EMPTY); | 170     RecordUmaEvent(TIMEZONE_REQUEST_EVENT_RESPONSE_EMPTY); | 
| 171     return false; | 171     return false; | 
| 172   } | 172   } | 
| 173   VLOG(1) << "TimeZoneRequest::ParseServerResponse() : Parsing response " | 173   VLOG(1) << "TimeZoneRequest::ParseServerResponse() : Parsing response " | 
| 174           << response_body; | 174           << response_body; | 
| 175 | 175 | 
| 176   // Parse the response, ignoring comments. | 176   // Parse the response, ignoring comments. | 
| 177   std::string error_msg; | 177   std::string error_msg; | 
| 178   scoped_ptr<base::Value> response_value( | 178   scoped_ptr<base::Value> response_value = base::JSONReader::ReadAndReturnError( | 
| 179       base::JSONReader::DeprecatedReadAndReturnError( | 179       response_body, base::JSON_PARSE_RFC, NULL, &error_msg); | 
| 180           response_body, base::JSON_PARSE_RFC, NULL, &error_msg)); |  | 
| 181   if (response_value == NULL) { | 180   if (response_value == NULL) { | 
| 182     PrintTimeZoneError(server_url, "JSONReader failed: " + error_msg, timezone); | 181     PrintTimeZoneError(server_url, "JSONReader failed: " + error_msg, timezone); | 
| 183     RecordUmaEvent(TIMEZONE_REQUEST_EVENT_RESPONSE_MALFORMED); | 182     RecordUmaEvent(TIMEZONE_REQUEST_EVENT_RESPONSE_MALFORMED); | 
| 184     return false; | 183     return false; | 
| 185   } | 184   } | 
| 186 | 185 | 
| 187   const base::DictionaryValue* response_object = NULL; | 186   const base::DictionaryValue* response_object = NULL; | 
| 188   if (!response_value->GetAsDictionary(&response_object)) { | 187   if (!response_value->GetAsDictionary(&response_object)) { | 
| 189     PrintTimeZoneError(server_url, | 188     PrintTimeZoneError(server_url, | 
| 190                        "Unexpected response type : " + | 189                        "Unexpected response type : " + | 
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 420       dstOffset, | 419       dstOffset, | 
| 421       rawOffset, | 420       rawOffset, | 
| 422       timeZoneId.c_str(), | 421       timeZoneId.c_str(), | 
| 423       timeZoneName.c_str(), | 422       timeZoneName.c_str(), | 
| 424       error_message.c_str(), | 423       error_message.c_str(), | 
| 425       (unsigned)status, | 424       (unsigned)status, | 
| 426       (status < arraysize(status2string) ? status2string[status] : "unknown")); | 425       (status < arraysize(status2string) ? status2string[status] : "unknown")); | 
| 427 } | 426 } | 
| 428 | 427 | 
| 429 }  // namespace chromeos | 428 }  // namespace chromeos | 
| OLD | NEW | 
|---|