summaryrefslogtreecommitdiff
path: root/chromium/components/ntp_snippets/remote
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/components/ntp_snippets/remote')
-rw-r--r--chromium/components/ntp_snippets/remote/json_request_unittest.cc19
-rw-r--r--chromium/components/ntp_snippets/remote/remote_suggestions_fetcher_impl_unittest.cc10
-rw-r--r--chromium/components/ntp_snippets/remote/remote_suggestions_status_service_impl.cc1
-rw-r--r--chromium/components/ntp_snippets/remote/request_throttler.cc1
4 files changed, 15 insertions, 16 deletions
diff --git a/chromium/components/ntp_snippets/remote/json_request_unittest.cc b/chromium/components/ntp_snippets/remote/json_request_unittest.cc
index d6d4b77138a..85d2d1fa532 100644
--- a/chromium/components/ntp_snippets/remote/json_request_unittest.cc
+++ b/chromium/components/ntp_snippets/remote/json_request_unittest.cc
@@ -45,24 +45,21 @@ using testing::NotNull;
using testing::StrEq;
MATCHER_P(EqualsJSON, json, "equals JSON") {
- std::unique_ptr<base::Value> expected =
- base::JSONReader::ReadDeprecated(json);
+ base::Optional<base::Value> expected = base::JSONReader::Read(json);
if (!expected) {
*result_listener << "INTERNAL ERROR: couldn't parse expected JSON";
return false;
}
- std::string err_msg;
- int err_line, err_col;
- std::unique_ptr<base::Value> actual =
- base::JSONReader::ReadAndReturnErrorDeprecated(
- arg, base::JSON_PARSE_RFC, nullptr, &err_msg, &err_line, &err_col);
- if (!actual) {
- *result_listener << "input:" << err_line << ":" << err_col << ": "
- << "parse error: " << err_msg;
+ base::JSONReader::ValueWithError actual =
+ base::JSONReader::ReadAndReturnValueWithError(arg);
+ if (!actual.value) {
+ *result_listener << "input:" << actual.error_line << ":"
+ << actual.error_column << ": "
+ << "parse error: " << actual.error_message;
return false;
}
- return *expected == *actual;
+ return *expected == *actual.value;
}
} // namespace
diff --git a/chromium/components/ntp_snippets/remote/remote_suggestions_fetcher_impl_unittest.cc b/chromium/components/ntp_snippets/remote/remote_suggestions_fetcher_impl_unittest.cc
index a2193d5d03e..887545b23b6 100644
--- a/chromium/components/ntp_snippets/remote/remote_suggestions_fetcher_impl_unittest.cc
+++ b/chromium/components/ntp_snippets/remote/remote_suggestions_fetcher_impl_unittest.cc
@@ -150,12 +150,12 @@ class MockSnippetsAvailableCallback {
void ParseJson(const std::string& json,
SuccessCallback success_callback,
ErrorCallback error_callback) {
- base::JSONReader json_reader;
- base::Optional<base::Value> value = json_reader.ReadToValue(json);
- if (value) {
- std::move(success_callback).Run(std::move(*value));
+ base::JSONReader::ValueWithError parsed_json =
+ base::JSONReader::ReadAndReturnValueWithError(json);
+ if (parsed_json.value) {
+ std::move(success_callback).Run(std::move(*parsed_json.value));
} else {
- std::move(error_callback).Run(json_reader.GetErrorMessage());
+ std::move(error_callback).Run(std::move(parsed_json.error_message));
}
}
diff --git a/chromium/components/ntp_snippets/remote/remote_suggestions_status_service_impl.cc b/chromium/components/ntp_snippets/remote/remote_suggestions_status_service_impl.cc
index a13b40000db..9198c84aad2 100644
--- a/chromium/components/ntp_snippets/remote/remote_suggestions_status_service_impl.cc
+++ b/chromium/components/ntp_snippets/remote/remote_suggestions_status_service_impl.cc
@@ -8,6 +8,7 @@
#include "base/bind.h"
#include "base/feature_list.h"
+#include "base/logging.h"
#include "components/feed/core/shared_prefs/pref_names.h"
#include "components/ntp_snippets/content_suggestions_metrics.h"
#include "components/ntp_snippets/features.h"
diff --git a/chromium/components/ntp_snippets/remote/request_throttler.cc b/chromium/components/ntp_snippets/remote/request_throttler.cc
index efe56366ed9..86c2dc47051 100644
--- a/chromium/components/ntp_snippets/remote/request_throttler.cc
+++ b/chromium/components/ntp_snippets/remote/request_throttler.cc
@@ -8,6 +8,7 @@
#include <set>
#include <vector>
+#include "base/logging.h"
#include "base/metrics/histogram.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_split.h"