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

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

Issue 2274953002: Inform server of dismissed articles. (Closed) Base URL: https://chromium.googlesource.com/chromium/src@master
Patch Set: Created 4 years, 3 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 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_NTP_SNIPPETS_FETCHER_H_ 5 #ifndef COMPONENTS_NTP_SNIPPETS_NTP_SNIPPETS_FETCHER_H_
6 #define COMPONENTS_NTP_SNIPPETS_NTP_SNIPPETS_FETCHER_H_ 6 #define COMPONENTS_NTP_SNIPPETS_NTP_SNIPPETS_FETCHER_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 CategoryFactory* category_factory, 83 CategoryFactory* category_factory,
84 const ParseJSONCallback& parse_json_callback, 84 const ParseJSONCallback& parse_json_callback,
85 bool is_stable_channel); 85 bool is_stable_channel);
86 ~NTPSnippetsFetcher() override; 86 ~NTPSnippetsFetcher() override;
87 87
88 // Set a callback that is called when a new set of snippets are downloaded, 88 // Set a callback that is called when a new set of snippets are downloaded,
89 // overriding any previously set callback. 89 // overriding any previously set callback.
90 void SetCallback(const SnippetsAvailableCallback& callback); 90 void SetCallback(const SnippetsAvailableCallback& callback);
91 91
92 // Fetches snippets from the server. |hosts| restricts the results to a set of 92 // Fetches snippets from the server. |hosts| restricts the results to a set of
93 // hosts, e.g. "www.google.com". An empty host set produces an error. 93 // hosts, e.g. "www.google.com". An empty host set produces an error.
Marc Treib 2016/08/25 09:01:41 Not your doing, but: Do you mind updating this com
sfiera 2016/08/25 10:39:56 Done.
94 // Suggestions in |excluded_ids| will not be returned.
94 // 95 //
95 // If an ongoing fetch exists, it will be cancelled and a new one started, 96 // If an ongoing fetch exists, it will be cancelled and a new one started,
96 // without triggering an additional callback (i.e. not noticeable by 97 // without triggering an additional callback (i.e. not noticeable by
97 // subscriber of SetCallback()). 98 // subscriber of SetCallback()).
98 // 99 //
99 // Fetches snippets only if the daily quota not exceeded, unless 100 // Fetches snippets only if the daily quota not exceeded, unless
100 // |interactive_request| is set to true (use only for user-initiated fetches). 101 // |interactive_request| is set to true (use only for user-initiated fetches).
101 void FetchSnippetsFromHosts(const std::set<std::string>& hosts, 102 void FetchSnippetsFromHosts(const std::set<std::string>& hosts,
102 const std::string& language_code, 103 const std::string& language_code,
104 const std::set<std::string>& excluded_ids,
103 int count, 105 int count,
104 bool interactive_request); 106 bool interactive_request);
105 107
106 // Debug string representing the status/result of the last fetch attempt. 108 // Debug string representing the status/result of the last fetch attempt.
107 const std::string& last_status() const { return last_status_; } 109 const std::string& last_status() const { return last_status_; }
108 110
109 // Returns the last JSON fetched from the server. 111 // Returns the last JSON fetched from the server.
110 const std::string& last_json() const { 112 const std::string& last_json() const {
111 return last_fetch_json_; 113 return last_fetch_json_;
112 } 114 }
(...skipping 26 matching lines...) Expand all
139 CHROME_READER_API, 141 CHROME_READER_API,
140 CHROME_CONTENT_SUGGESTIONS_API, 142 CHROME_CONTENT_SUGGESTIONS_API,
141 }; 143 };
142 144
143 struct RequestParams { 145 struct RequestParams {
144 FetchAPI fetch_api; 146 FetchAPI fetch_api;
145 std::string obfuscated_gaia_id; 147 std::string obfuscated_gaia_id;
146 bool only_return_personalized_results; 148 bool only_return_personalized_results;
147 std::string user_locale; 149 std::string user_locale;
148 std::set<std::string> host_restricts; 150 std::set<std::string> host_restricts;
151 std::set<std::string> excluded_ids;
149 int count_to_fetch; 152 int count_to_fetch;
150 153
151 RequestParams(); 154 RequestParams();
152 ~RequestParams(); 155 ~RequestParams();
153 156
154 std::string BuildRequest(); 157 std::string BuildRequest();
155 }; 158 };
156 159
157 void FetchSnippetsImpl(const GURL& url, 160 void FetchSnippetsImpl(const GURL& url,
158 const std::string& auth_header, 161 const std::string& auth_header,
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 197
195 CategoryFactory* const category_factory_; 198 CategoryFactory* const category_factory_;
196 const ParseJSONCallback parse_json_callback_; 199 const ParseJSONCallback parse_json_callback_;
197 base::TimeTicks fetch_start_time_; 200 base::TimeTicks fetch_start_time_;
198 std::string last_status_; 201 std::string last_status_;
199 std::string last_fetch_json_; 202 std::string last_fetch_json_;
200 203
201 // Hosts to restrict the snippets to. 204 // Hosts to restrict the snippets to.
202 std::set<std::string> hosts_; 205 std::set<std::string> hosts_;
203 206
207 // Snippets to exclude from the results.
208 std::set<std::string> excluded_ids_;
209
204 // Count of snippets to fetch. 210 // Count of snippets to fetch.
205 int count_to_fetch_; 211 int count_to_fetch_;
206 212
207 // Language code to restrict to for personalized results. 213 // Language code to restrict to for personalized results.
208 std::string locale_; 214 std::string locale_;
209 215
210 // API endpoint for fetching snippets. 216 // API endpoint for fetching snippets.
211 const GURL fetch_url_; 217 const GURL fetch_url_;
212 // Which API to use 218 // Which API to use
213 const FetchAPI fetch_api_; 219 const FetchAPI fetch_api_;
(...skipping 21 matching lines...) Expand all
235 // When a token request gets canceled, we want to retry once. 241 // When a token request gets canceled, we want to retry once.
236 bool oauth_token_retried_; 242 bool oauth_token_retried_;
237 243
238 base::WeakPtrFactory<NTPSnippetsFetcher> weak_ptr_factory_; 244 base::WeakPtrFactory<NTPSnippetsFetcher> weak_ptr_factory_;
239 245
240 DISALLOW_COPY_AND_ASSIGN(NTPSnippetsFetcher); 246 DISALLOW_COPY_AND_ASSIGN(NTPSnippetsFetcher);
241 }; 247 };
242 } // namespace ntp_snippets 248 } // namespace ntp_snippets
243 249
244 #endif // COMPONENTS_NTP_SNIPPETS_NTP_SNIPPETS_FETCHER_H_ 250 #endif // COMPONENTS_NTP_SNIPPETS_NTP_SNIPPETS_FETCHER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698