Chromium Code Reviews| 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_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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 77 kBoth | 77 kBoth |
| 78 }; | 78 }; |
| 79 | 79 |
| 80 NTPSnippetsFetcher( | 80 NTPSnippetsFetcher( |
| 81 SigninManagerBase* signin_manager, | 81 SigninManagerBase* signin_manager, |
| 82 OAuth2TokenService* oauth2_token_service, | 82 OAuth2TokenService* oauth2_token_service, |
| 83 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter, | 83 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter, |
| 84 PrefService* pref_service, | 84 PrefService* pref_service, |
| 85 CategoryFactory* category_factory, | 85 CategoryFactory* category_factory, |
| 86 const ParseJSONCallback& parse_json_callback, | 86 const ParseJSONCallback& parse_json_callback, |
| 87 bool is_stable_channel); | 87 const std::string& api_key); |
| 88 ~NTPSnippetsFetcher() override; | 88 ~NTPSnippetsFetcher() override; |
| 89 | 89 |
| 90 // Set a callback that is called when a new set of snippets are downloaded, | 90 // Set a callback that is called when a new set of snippets are downloaded, |
| 91 // overriding any previously set callback. | 91 // overriding any previously set callback. |
| 92 void SetCallback(const SnippetsAvailableCallback& callback); | 92 void SetCallback(const SnippetsAvailableCallback& callback); |
| 93 | 93 |
| 94 // Fetches snippets from the server. |hosts| restricts the results to a set of | 94 // Fetches snippets from the server. |hosts| restricts the results to a set of |
| 95 // hosts, e.g. "www.google.com". If host restrictions are enabled, an empty | 95 // hosts, e.g. "www.google.com". If host restrictions are enabled, an empty |
| 96 // host set produces an error without issuing a fetch. | 96 // host set produces an error without issuing a fetch. |
| 97 // | 97 // |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 224 const GURL fetch_url_; | 224 const GURL fetch_url_; |
| 225 // Which API to use | 225 // Which API to use |
| 226 const FetchAPI fetch_api_; | 226 const FetchAPI fetch_api_; |
| 227 | 227 |
| 228 // The fetcher for downloading the snippets. | 228 // The fetcher for downloading the snippets. |
| 229 std::unique_ptr<net::URLFetcher> url_fetcher_; | 229 std::unique_ptr<net::URLFetcher> url_fetcher_; |
| 230 | 230 |
| 231 // The callback to notify when new snippets get fetched. | 231 // The callback to notify when new snippets get fetched. |
| 232 SnippetsAvailableCallback snippets_available_callback_; | 232 SnippetsAvailableCallback snippets_available_callback_; |
| 233 | 233 |
| 234 // Flag for picking the right (stable/non-stable) API key for Chrome Reader. | 234 // Flag for picking the right (stable/non-stable) API key for Chrome Reader. |
|
Marc Treib
2016/08/31 09:26:16
Please update the comment
sfiera
2016/08/31 10:09:16
Done.
| |
| 235 bool is_stable_channel_; | 235 const std::string api_key_; |
| 236 | 236 |
| 237 // The variant of the fetching to use, loaded from variation parameters. | 237 // The variant of the fetching to use, loaded from variation parameters. |
| 238 Personalization personalization_; | 238 Personalization personalization_; |
| 239 // Should we apply host restriction? It is loaded from variation parameters. | 239 // Should we apply host restriction? It is loaded from variation parameters. |
| 240 bool use_host_restriction_; | 240 bool use_host_restriction_; |
| 241 | 241 |
| 242 // Is the request user initiated? | 242 // Is the request user initiated? |
| 243 bool interactive_request_; | 243 bool interactive_request_; |
| 244 | 244 |
| 245 // Allow for an injectable tick clock for testing. | 245 // Allow for an injectable tick clock for testing. |
| 246 std::unique_ptr<base::TickClock> tick_clock_; | 246 std::unique_ptr<base::TickClock> tick_clock_; |
| 247 | 247 |
| 248 // Request throttler for limiting requests. | 248 // Request throttler for limiting requests. |
| 249 RequestThrottler request_throttler_; | 249 RequestThrottler request_throttler_; |
| 250 | 250 |
| 251 // When a token request gets canceled, we want to retry once. | 251 // When a token request gets canceled, we want to retry once. |
| 252 bool oauth_token_retried_; | 252 bool oauth_token_retried_; |
| 253 | 253 |
| 254 base::WeakPtrFactory<NTPSnippetsFetcher> weak_ptr_factory_; | 254 base::WeakPtrFactory<NTPSnippetsFetcher> weak_ptr_factory_; |
| 255 | 255 |
| 256 DISALLOW_COPY_AND_ASSIGN(NTPSnippetsFetcher); | 256 DISALLOW_COPY_AND_ASSIGN(NTPSnippetsFetcher); |
| 257 }; | 257 }; |
| 258 } // namespace ntp_snippets | 258 } // namespace ntp_snippets |
| 259 | 259 |
| 260 #endif // COMPONENTS_NTP_SNIPPETS_NTP_SNIPPETS_FETCHER_H_ | 260 #endif // COMPONENTS_NTP_SNIPPETS_NTP_SNIPPETS_FETCHER_H_ |
| OLD | NEW |