Commit 96a5cb26 authored by Nigel Tao's avatar Nigel Tao Committed by Commit Bot

Upgrade drive from deprecated base::JSONReader API

Bug: 1070409
Change-Id: Ib26b5d5d9a6ddf20da57c9e11be43de9cfb1d7be
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2212117Reviewed-by: default avatarStuart Langley <slangley@chromium.org>
Commit-Queue: Nigel Tao <nigeltao@chromium.org>
Cr-Commit-Position: refs/heads/master@{#771531}
parent 7246c3b4
...@@ -175,13 +175,9 @@ void CloseFile(base::File file) {} ...@@ -175,13 +175,9 @@ void CloseFile(base::File file) {}
namespace google_apis { namespace google_apis {
std::unique_ptr<base::Value> ParseJson(const std::string& json) { std::unique_ptr<base::Value> ParseJson(const std::string& json) {
int error_code = -1; base::JSONReader::ValueWithError parsed_json =
std::string error_message; base::JSONReader::ReadAndReturnValueWithError(json);
std::unique_ptr<base::Value> value = if (!parsed_json.value) {
base::JSONReader::ReadAndReturnErrorDeprecated(
json, base::JSON_PARSE_RFC, &error_code, &error_message);
if (!value.get()) {
std::string trimmed_json; std::string trimmed_json;
if (json.size() < 80) { if (json.size() < 80) {
trimmed_json = json; trimmed_json = json;
...@@ -192,10 +188,12 @@ std::unique_ptr<base::Value> ParseJson(const std::string& json) { ...@@ -192,10 +188,12 @@ std::unique_ptr<base::Value> ParseJson(const std::string& json) {
base::NumberToString(json.size() - 60).c_str(), base::NumberToString(json.size() - 60).c_str(),
json.substr(json.size() - 10).c_str()); json.substr(json.size() - 10).c_str());
} }
LOG(WARNING) << "Error while parsing entry response: " << error_message LOG(WARNING) << "Error while parsing entry response: "
<< ", code: " << error_code << ", json:\n" << trimmed_json; << parsed_json.error_message << ", json:\n"
<< trimmed_json;
return nullptr;
} }
return value; return base::Value::ToUniquePtrValue(std::move(*parsed_json.value));
} }
void GenerateMultipartBody(MultipartType multipart_type, void GenerateMultipartBody(MultipartType multipart_type,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment