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

Unified Diff: components/ntp_snippets/ntp_snippets_fetcher.h

Issue 2276383002: Support server-provided category names. (Closed) Base URL: https://chromium.googlesource.com/chromium/src@master
Patch Set: Move "ignored" comment. Created 4 years, 4 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
Index: components/ntp_snippets/ntp_snippets_fetcher.h
diff --git a/components/ntp_snippets/ntp_snippets_fetcher.h b/components/ntp_snippets/ntp_snippets_fetcher.h
index eafc462999e8e27da69395fd94145ad2ef58d5a6..2892abace8c1921ad106e4e5c66934397544869f 100644
--- a/components/ntp_snippets/ntp_snippets_fetcher.h
+++ b/components/ntp_snippets/ntp_snippets_fetcher.h
@@ -47,7 +47,19 @@ class NTPSnippetsFetcher : public OAuth2TokenService::Consumer,
using ParseJSONCallback = base::Callback<
void(const std::string&, const SuccessCallback&, const ErrorCallback&)>;
- using OptionalSnippets = base::Optional<NTPSnippet::CategoryMap>;
+ struct FetchedCategory {
+ Category category;
+ base::string16 localized_title; // Ignored for non-server categories.
+ NTPSnippet::PtrVector snippets;
+
+ FetchedCategory(Category c);
+ FetchedCategory(FetchedCategory&&); // = default, in .cc
+ ~FetchedCategory(); // = default, in .cc
+ FetchedCategory& operator=(FetchedCategory&&); // = default, in .cc
+ };
+ using FetchedCategoriesVector = std::vector<FetchedCategory>;
+ using OptionalSnippets = base::Optional<FetchedCategoriesVector>;
+
// |snippets| contains parsed snippets if a fetch succeeded. If problems
// occur, |snippets| contains no value (no actual vector in base::Optional).
// Error details can be retrieved using last_status().
@@ -183,7 +195,7 @@ class NTPSnippetsFetcher : public OAuth2TokenService::Consumer,
void OnURLFetchComplete(const net::URLFetcher* source) override;
bool JsonToSnippets(const base::Value& parsed,
- NTPSnippet::CategoryMap* snippets);
+ FetchedCategoriesVector* categories);
void OnJsonParsed(std::unique_ptr<base::Value> parsed);
void OnJsonError(const std::string& error);
void FetchFinished(OptionalSnippets snippets,

Powered by Google App Engine
This is Rietveld 408576698