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

Side by Side Diff: components/ntp_snippets/remote/ntp_snippets_fetcher.h

Issue 2549163002: RemoteContentSuggestions: Stores the time of the last successful background fetch in a pref (Closed)
Patch Set: Add a comment for the new pref Created 4 years 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 #ifndef COMPONENTS_NTP_SNIPPETS_REMOTE_NTP_SNIPPETS_FETCHER_H_ 5 #ifndef COMPONENTS_NTP_SNIPPETS_REMOTE_NTP_SNIPPETS_FETCHER_H_
6 #define COMPONENTS_NTP_SNIPPETS_REMOTE_NTP_SNIPPETS_FETCHER_H_ 6 #define COMPONENTS_NTP_SNIPPETS_REMOTE_NTP_SNIPPETS_FETCHER_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <queue> 9 #include <queue>
10 #include <set> 10 #include <set>
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 NTPSnippet::PtrVector snippets; 73 NTPSnippet::PtrVector snippets;
74 74
75 FetchedCategory(Category c, CategoryInfo&& info); 75 FetchedCategory(Category c, CategoryInfo&& info);
76 FetchedCategory(FetchedCategory&&); // = default, in .cc 76 FetchedCategory(FetchedCategory&&); // = default, in .cc
77 ~FetchedCategory(); // = default, in .cc 77 ~FetchedCategory(); // = default, in .cc
78 FetchedCategory& operator=(FetchedCategory&&); // = default, in .cc 78 FetchedCategory& operator=(FetchedCategory&&); // = default, in .cc
79 }; 79 };
80 using FetchedCategoriesVector = std::vector<FetchedCategory>; 80 using FetchedCategoriesVector = std::vector<FetchedCategory>;
81 using OptionalFetchedCategories = base::Optional<FetchedCategoriesVector>; 81 using OptionalFetchedCategories = base::Optional<FetchedCategoriesVector>;
82 82
83 // |snippets| contains parsed snippets if a fetch succeeded. If problems
84 // occur, |snippets| contains no value (no actual vector in base::Optional).
85 // Error details can be retrieved using last_status().
86 using SnippetsAvailableCallback =
87 base::OnceCallback<void(OptionalFetchedCategories fetched_categories)>;
88
89 // Enumeration listing all possible outcomes for fetch attempts. Used for UMA 83 // Enumeration listing all possible outcomes for fetch attempts. Used for UMA
90 // histograms, so do not change existing values. Insert new values at the end, 84 // histograms, so do not change existing values. Insert new values at the end,
91 // and update the histogram definition. 85 // and update the histogram definition.
92 enum class FetchResult { 86 enum class FetchResult {
93 SUCCESS, 87 SUCCESS,
94 DEPRECATED_EMPTY_HOSTS, 88 DEPRECATED_EMPTY_HOSTS,
95 URL_REQUEST_STATUS_ERROR, 89 URL_REQUEST_STATUS_ERROR,
96 HTTP_ERROR, 90 HTTP_ERROR,
97 JSON_PARSE_ERROR, 91 JSON_PARSE_ERROR,
98 INVALID_SNIPPET_CONTENT_ERROR, 92 INVALID_SNIPPET_CONTENT_ERROR,
99 OAUTH_TOKEN_ERROR, 93 OAUTH_TOKEN_ERROR,
100 INTERACTIVE_QUOTA_ERROR, 94 INTERACTIVE_QUOTA_ERROR,
101 NON_INTERACTIVE_QUOTA_ERROR, 95 NON_INTERACTIVE_QUOTA_ERROR,
102 RESULT_MAX 96 RESULT_MAX
103 }; 97 };
98 // |snippets| contains parsed snippets if a fetch succeeded. If problems
Marc Treib 2016/12/07 14:42:13 nit: Empty line before.
markusheintz_ 2016/12/08 09:47:41 Done.
99 // occur, |snippets| contains no value (no actual vector in base::Optional).
100 // Error details can be retrieved using last_status().
101 using SnippetsAvailableCallback =
102 base::OnceCallback<void(OptionalFetchedCategories fetched_categories,
103 FetchResult fetch_result)>;
Marc Treib 2016/12/07 14:42:13 nit: I'd find it a bit more natural to have the Fe
markusheintz_ 2016/12/08 09:47:41 I have absolutely no hard feeling on this. But I g
Marc Treib 2016/12/08 10:33:48 I think if we are gonna change the order at all, t
markusheintz_ 2016/12/08 11:37:18 Since Christmas is close here is my present for yo
Marc Treib 2016/12/08 12:15:40 Woohoo! :D
104 104
105 // Enumeration listing all possible variants of dealing with personalization. 105 // Enumeration listing all possible variants of dealing with personalization.
106 enum class Personalization { kPersonal, kNonPersonal, kBoth }; 106 enum class Personalization { kPersonal, kNonPersonal, kBoth };
107 107
108 // Contains all the parameters for one fetch. 108 // Contains all the parameters for one fetch.
109 struct Params { 109 struct Params {
110 Params(); 110 Params();
111 Params(const Params&); 111 Params(const Params&);
112 ~Params(); 112 ~Params();
113 113
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 std::string last_status_; 357 std::string last_status_;
358 std::string last_fetch_json_; 358 std::string last_fetch_json_;
359 359
360 base::WeakPtrFactory<NTPSnippetsFetcher> weak_ptr_factory_; 360 base::WeakPtrFactory<NTPSnippetsFetcher> weak_ptr_factory_;
361 361
362 DISALLOW_COPY_AND_ASSIGN(NTPSnippetsFetcher); 362 DISALLOW_COPY_AND_ASSIGN(NTPSnippetsFetcher);
363 }; 363 };
364 } // namespace ntp_snippets 364 } // namespace ntp_snippets
365 365
366 #endif // COMPONENTS_NTP_SNIPPETS_REMOTE_NTP_SNIPPETS_FETCHER_H_ 366 #endif // COMPONENTS_NTP_SNIPPETS_REMOTE_NTP_SNIPPETS_FETCHER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698