Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(22)

Unified Diff: components/ntp_tiles/popular_sites.cc

Issue 2192783002: Parse PopularSites JSON by callback. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@json
Patch Set: Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/ntp_tiles/popular_sites.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/ntp_tiles/popular_sites.cc
diff --git a/components/ntp_tiles/popular_sites.cc b/components/ntp_tiles/popular_sites.cc
index 90363341ea3d3eee9a99d9c17947633ad333b7de..912622fae08513f91ef74bca3241af9f29cdd14c 100644
--- a/components/ntp_tiles/popular_sites.cc
+++ b/components/ntp_tiles/popular_sites.cc
@@ -25,7 +25,6 @@
#include "components/ntp_tiles/switches.h"
#include "components/pref_registry/pref_registry_syncable.h"
#include "components/prefs/pref_service.h"
-#include "components/safe_json/safe_json_parser.h"
#include "components/search_engines/search_engine_type.h"
#include "components/search_engines/template_url_service.h"
#include "components/variations/service/variations_service.h"
@@ -176,7 +175,8 @@ PopularSites::PopularSites(
const TemplateURLService* template_url_service,
VariationsService* variations_service,
net::URLRequestContextGetter* download_context,
- const base::FilePath& directory)
+ const base::FilePath& directory,
+ ParseJSONCallback parse_json)
: blocking_runner_(blocking_pool->GetTaskRunnerWithShutdownBehavior(
base::SequencedWorkerPool::CONTINUE_ON_SHUTDOWN)),
prefs_(prefs),
@@ -186,6 +186,7 @@ PopularSites::PopularSites(
local_path_(directory.empty()
? base::FilePath()
: directory.AppendASCII(kPopularSitesLocalFilename)),
+ parse_json_(std::move(parse_json)),
is_fallback_(false),
weak_ptr_factory_(this) {}
@@ -296,7 +297,7 @@ void PopularSites::OnURLFetchComplete(const net::URLFetcher* source) {
return;
}
- safe_json::SafeJsonParser::Parse(
+ parse_json_.Run(
json_string,
base::Bind(&PopularSites::OnJsonParsed, weak_ptr_factory_.GetWeakPtr()),
base::Bind(&PopularSites::OnJsonParseFailed,
« no previous file with comments | « components/ntp_tiles/popular_sites.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698