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