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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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. |
94 // | 94 // |
95 // If an ongoing fetch exists, it will be cancelled and a new one started, | 95 // 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 | 96 // without triggering an additional callback (i.e. not noticeable by |
97 // subscriber of SetCallback()). | 97 // subscriber of SetCallback()). |
98 // | 98 // |
99 // Fetches snippets only if the daily quota not exceeded, unless | 99 // Fetches snippets only if the daily quota not exceeded, unless |
100 // |force_request| is set to true. Use force only for user-initiated fetches. | 100 // |interactive_request| is set to true (use only for user-initiated fetches). |
101 void FetchSnippetsFromHosts(const std::set<std::string>& hosts, | 101 void FetchSnippetsFromHosts(const std::set<std::string>& hosts, |
102 const std::string& language_code, | 102 const std::string& language_code, |
103 int count, | 103 int count, |
104 bool force_request); | 104 bool interactive_request); |
105 | 105 |
106 // Debug string representing the status/result of the last fetch attempt. | 106 // Debug string representing the status/result of the last fetch attempt. |
107 const std::string& last_status() const { return last_status_; } | 107 const std::string& last_status() const { return last_status_; } |
108 | 108 |
109 // Returns the last JSON fetched from the server. | 109 // Returns the last JSON fetched from the server. |
110 const std::string& last_json() const { | 110 const std::string& last_json() const { |
111 return last_fetch_json_; | 111 return last_fetch_json_; |
112 } | 112 } |
113 | 113 |
114 // Returns the personalization setting of the fetcher. | 114 // Returns the personalization setting of the fetcher. |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
235 // When a token request gets canceled, we want to retry once. | 235 // When a token request gets canceled, we want to retry once. |
236 bool oauth_token_retried_; | 236 bool oauth_token_retried_; |
237 | 237 |
238 base::WeakPtrFactory<NTPSnippetsFetcher> weak_ptr_factory_; | 238 base::WeakPtrFactory<NTPSnippetsFetcher> weak_ptr_factory_; |
239 | 239 |
240 DISALLOW_COPY_AND_ASSIGN(NTPSnippetsFetcher); | 240 DISALLOW_COPY_AND_ASSIGN(NTPSnippetsFetcher); |
241 }; | 241 }; |
242 } // namespace ntp_snippets | 242 } // namespace ntp_snippets |
243 | 243 |
244 #endif // COMPONENTS_NTP_SNIPPETS_NTP_SNIPPETS_FETCHER_H_ | 244 #endif // COMPONENTS_NTP_SNIPPETS_NTP_SNIPPETS_FETCHER_H_ |
OLD | NEW |