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

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

Issue 2548343002: NTPSnippets: Set MaxRetriesOn5xx only for interactive requests. (Closed)
Patch Set: 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 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 FRIEND_TEST_ALL_PREFIXES(NTPSnippetsFetcherTest, BuildRequestAuthenticated); 175 FRIEND_TEST_ALL_PREFIXES(NTPSnippetsFetcherTest, BuildRequestAuthenticated);
176 FRIEND_TEST_ALL_PREFIXES(NTPSnippetsFetcherTest, BuildRequestUnauthenticated); 176 FRIEND_TEST_ALL_PREFIXES(NTPSnippetsFetcherTest, BuildRequestUnauthenticated);
177 FRIEND_TEST_ALL_PREFIXES(NTPSnippetsFetcherTest, BuildRequestExcludedIds); 177 FRIEND_TEST_ALL_PREFIXES(NTPSnippetsFetcherTest, BuildRequestExcludedIds);
178 FRIEND_TEST_ALL_PREFIXES(NTPSnippetsFetcherTest, BuildRequestNoUserClass); 178 FRIEND_TEST_ALL_PREFIXES(NTPSnippetsFetcherTest, BuildRequestNoUserClass);
179 FRIEND_TEST_ALL_PREFIXES(NTPSnippetsFetcherTest, 179 FRIEND_TEST_ALL_PREFIXES(NTPSnippetsFetcherTest,
180 BuildRequestWithTwoLanguages); 180 BuildRequestWithTwoLanguages);
181 FRIEND_TEST_ALL_PREFIXES(NTPSnippetsFetcherTest, 181 FRIEND_TEST_ALL_PREFIXES(NTPSnippetsFetcherTest,
182 BuildRequestWithUILanguageOnly); 182 BuildRequestWithUILanguageOnly);
183 FRIEND_TEST_ALL_PREFIXES(NTPSnippetsFetcherTest, 183 FRIEND_TEST_ALL_PREFIXES(NTPSnippetsFetcherTest,
184 BuildRequestWithOtherLanguageOnly); 184 BuildRequestWithOtherLanguageOnly);
185 FRIEND_TEST_ALL_PREFIXES(NTPSnippetsFetcherTest,
186 BuildRequestFetcherDependingOnInteractivity);
185 friend class NTPSnippetsFetcherTest; 187 friend class NTPSnippetsFetcherTest;
186 188
187 enum FetchAPI { 189 enum FetchAPI {
188 CHROME_READER_API, 190 CHROME_READER_API,
189 CHROME_CONTENT_SUGGESTIONS_API, 191 CHROME_CONTENT_SUGGESTIONS_API,
190 }; 192 };
191 193
192 class JsonRequest; 194 class JsonRequest;
193 195
194 // A class that builds authenticated and non-authenticated JsonRequests. 196 // A class that builds authenticated and non-authenticated JsonRequests.
(...skipping 21 matching lines...) Expand all
216 RequestBuilder& SetPersonalization(Personalization personalization); 218 RequestBuilder& SetPersonalization(Personalization personalization);
217 // The tick_clock borrowed from the fetcher will be injected into the 219 // The tick_clock borrowed from the fetcher will be injected into the
218 // request. It will be used at build time and after the fetch returned. 220 // request. It will be used at build time and after the fetch returned.
219 // It has to be alive until the request is destroyed. 221 // It has to be alive until the request is destroyed.
220 RequestBuilder& SetTickClock(base::TickClock* tick_clock); 222 RequestBuilder& SetTickClock(base::TickClock* tick_clock);
221 RequestBuilder& SetUrl(const GURL& url); 223 RequestBuilder& SetUrl(const GURL& url);
222 RequestBuilder& SetUrlRequestContextGetter( 224 RequestBuilder& SetUrlRequestContextGetter(
223 const scoped_refptr<net::URLRequestContextGetter>& context_getter); 225 const scoped_refptr<net::URLRequestContextGetter>& context_getter);
224 RequestBuilder& SetUserClassifier(const UserClassifier& user_classifier); 226 RequestBuilder& SetUserClassifier(const UserClassifier& user_classifier);
225 227
226 std::string PreviewRequestBodyForTesting() { return BuildBody(); } 228 std::string PreviewRequestBodyForTesting() const { return BuildBody(); }
tschumann 2016/12/05 17:26:33 hmm... this has a smell and doesn't seem to scale
fhorschig 2016/12/06 14:31:40 Reverted changes made here and added a TODO. In or
227 std::string PreviewRequestHeadersForTesting() { return BuildHeaders(); } 229 std::string PreviewRequestHeadersForTesting() const {
230 return BuildHeaders();
231 }
232 // Creates a valid net::URLFetcher that has no request and can therefore not
233 // fetch and trigger a delegate. Body and Header are empty.
234 std::unique_ptr<net::URLFetcher> PreviewURLFetcherForTesting() const;
228 RequestBuilder& SetUserClassForTesting(const std::string& user_class) { 235 RequestBuilder& SetUserClassForTesting(const std::string& user_class) {
229 user_class_ = user_class; 236 user_class_ = user_class;
230 return *this; 237 return *this;
231 } 238 }
232 239
233 protected: 240 protected:
234 // TODO(fhorschig): As soon as crbug.com/crbug.com/645447 is resolved, 241 // TODO(fhorschig): As soon as crbug.com/crbug.com/645447 is resolved,
235 // make these an implementation detail in the body and remove the mock. 242 // make these an implementation detail in the body and remove the mock.
236 virtual bool IsSendingTopLanguagesEnabled() const; 243 virtual bool IsSendingTopLanguagesEnabled() const;
237 virtual bool IsSendingUserClassEnabled() const; 244 virtual bool IsSendingUserClassEnabled() const;
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 std::string last_status_; 364 std::string last_status_;
358 std::string last_fetch_json_; 365 std::string last_fetch_json_;
359 366
360 base::WeakPtrFactory<NTPSnippetsFetcher> weak_ptr_factory_; 367 base::WeakPtrFactory<NTPSnippetsFetcher> weak_ptr_factory_;
361 368
362 DISALLOW_COPY_AND_ASSIGN(NTPSnippetsFetcher); 369 DISALLOW_COPY_AND_ASSIGN(NTPSnippetsFetcher);
363 }; 370 };
364 } // namespace ntp_snippets 371 } // namespace ntp_snippets
365 372
366 #endif // COMPONENTS_NTP_SNIPPETS_REMOTE_NTP_SNIPPETS_FETCHER_H_ 373 #endif // COMPONENTS_NTP_SNIPPETS_REMOTE_NTP_SNIPPETS_FETCHER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698