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

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

Issue 2568033005: [NTP::SectionOrder] Replace CategoryFactory with a category ranker. (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 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 131
132 // If set, only return results for this category. 132 // If set, only return results for this category.
133 base::Optional<Category> exclusive_category; 133 base::Optional<Category> exclusive_category;
134 }; 134 };
135 135
136 NTPSnippetsFetcher( 136 NTPSnippetsFetcher(
137 SigninManagerBase* signin_manager, 137 SigninManagerBase* signin_manager,
138 OAuth2TokenService* token_service, 138 OAuth2TokenService* token_service,
139 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter, 139 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter,
140 PrefService* pref_service, 140 PrefService* pref_service,
141 CategoryFactory* category_factory,
142 translate::LanguageModel* language_model, 141 translate::LanguageModel* language_model,
143 const ParseJSONCallback& parse_json_callback, 142 const ParseJSONCallback& parse_json_callback,
144 const std::string& api_key, 143 const std::string& api_key,
145 const UserClassifier* user_classifier); 144 const UserClassifier* user_classifier);
146 ~NTPSnippetsFetcher() override; 145 ~NTPSnippetsFetcher() override;
147 146
148 // Initiates a fetch from the server. When done (successfully or not), calls 147 // Initiates a fetch from the server. When done (successfully or not), calls
149 // the subscriber of SetCallback(). 148 // the subscriber of SetCallback().
150 // 149 //
151 // If an ongoing fetch exists, it will be silently abandoned and a new one 150 // If an ongoing fetch exists, it will be silently abandoned and a new one
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 // When a token request gets canceled, we want to retry once. 322 // When a token request gets canceled, we want to retry once.
324 bool oauth_token_retried_ = false; 323 bool oauth_token_retried_ = false;
325 324
326 // Holds the URL request context. 325 // Holds the URL request context.
327 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter_; 326 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter_;
328 327
329 // Stores requests that wait for an access token. 328 // Stores requests that wait for an access token.
330 std::queue<std::pair<RequestBuilder, SnippetsAvailableCallback>> 329 std::queue<std::pair<RequestBuilder, SnippetsAvailableCallback>>
331 pending_requests_; 330 pending_requests_;
332 331
333 // Weak references, not owned. 332 // Weak reference, not owned.
334 CategoryFactory* const category_factory_;
335 translate::LanguageModel* const language_model_; 333 translate::LanguageModel* const language_model_;
336 334
337 const ParseJSONCallback parse_json_callback_; 335 const ParseJSONCallback parse_json_callback_;
338 336
339 // API endpoint for fetching snippets. 337 // API endpoint for fetching snippets.
340 const GURL fetch_url_; 338 const GURL fetch_url_;
341 // Which API to use 339 // Which API to use
342 const FetchAPI fetch_api_; 340 const FetchAPI fetch_api_;
343 341
344 // API key to use for non-authenticated requests. 342 // API key to use for non-authenticated requests.
(...skipping 17 matching lines...) Expand all
362 std::string last_status_; 360 std::string last_status_;
363 std::string last_fetch_json_; 361 std::string last_fetch_json_;
364 362
365 base::WeakPtrFactory<NTPSnippetsFetcher> weak_ptr_factory_; 363 base::WeakPtrFactory<NTPSnippetsFetcher> weak_ptr_factory_;
366 364
367 DISALLOW_COPY_AND_ASSIGN(NTPSnippetsFetcher); 365 DISALLOW_COPY_AND_ASSIGN(NTPSnippetsFetcher);
368 }; 366 };
369 } // namespace ntp_snippets 367 } // namespace ntp_snippets
370 368
371 #endif // COMPONENTS_NTP_SNIPPETS_REMOTE_NTP_SNIPPETS_FETCHER_H_ 369 #endif // COMPONENTS_NTP_SNIPPETS_REMOTE_NTP_SNIPPETS_FETCHER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698