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_REMOTE_SUGGESTIONS_FETCHER_H_ | 5 #ifndef COMPONENTS_NTP_SNIPPETS_REMOTE_REMOTE_SUGGESTIONS_FETCHER_H_ |
6 #define COMPONENTS_NTP_SNIPPETS_REMOTE_REMOTE_SUGGESTIONS_FETCHER_H_ | 6 #define COMPONENTS_NTP_SNIPPETS_REMOTE_REMOTE_SUGGESTIONS_FETCHER_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include <queue> | 9 #include <queue> |
10 #include <string> | 10 #include <string> |
(...skipping 18 matching lines...) Expand all Loading... | |
29 class SigninManagerBase; | 29 class SigninManagerBase; |
30 | 30 |
31 namespace base { | 31 namespace base { |
32 class Value; | 32 class Value; |
33 } // namespace base | 33 } // namespace base |
34 | 34 |
35 namespace ntp_snippets { | 35 namespace ntp_snippets { |
36 | 36 |
37 class UserClassifier; | 37 class UserClassifier; |
38 | 38 |
39 // Returns the appropriate API endpoint for the fetcher, in consideration of | |
40 // the channel and variation parameters. | |
41 std::string GetFetchEndpoint(bool is_stable_or_beta_channel); | |
42 | |
39 // TODO(tschumann): BuildArticleCategoryInfo() and BuildRemoteCategoryInfo() | 43 // TODO(tschumann): BuildArticleCategoryInfo() and BuildRemoteCategoryInfo() |
40 // don't really belong into this library. However, as the fetcher is | 44 // don't really belong into this library. However, as the fetcher is |
41 // providing this data for server-defined remote sections it's a good starting | 45 // providing this data for server-defined remote sections it's a good starting |
42 // point. Candiates to add to such a library would be persisting categories | 46 // point. Candiates to add to such a library would be persisting categories |
43 // (have all category managment in one place) or turning parsed JSON into | 47 // (have all category managment in one place) or turning parsed JSON into |
44 // FetchedCategory objects (all domain-specific logic in one place). | 48 // FetchedCategory objects (all domain-specific logic in one place). |
45 | 49 |
46 // Provides the CategoryInfo data for article suggestions. If |title| is | 50 // Provides the CategoryInfo data for article suggestions. If |title| is |
47 // nullopt, then the default, hard-coded title will be used. | 51 // nullopt, then the default, hard-coded title will be used. |
48 CategoryInfo BuildArticleCategoryInfo( | 52 CategoryInfo BuildArticleCategoryInfo( |
(...skipping 27 matching lines...) Expand all Loading... | |
76 base::OnceCallback<void(Status status, | 80 base::OnceCallback<void(Status status, |
77 OptionalFetchedCategories fetched_categories)>; | 81 OptionalFetchedCategories fetched_categories)>; |
78 | 82 |
79 RemoteSuggestionsFetcher( | 83 RemoteSuggestionsFetcher( |
80 SigninManagerBase* signin_manager, | 84 SigninManagerBase* signin_manager, |
81 OAuth2TokenService* token_service, | 85 OAuth2TokenService* token_service, |
82 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter, | 86 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter, |
83 PrefService* pref_service, | 87 PrefService* pref_service, |
84 translate::LanguageModel* language_model, | 88 translate::LanguageModel* language_model, |
85 const ParseJSONCallback& parse_json_callback, | 89 const ParseJSONCallback& parse_json_callback, |
90 const std::string& api_endpoint, | |
Marc Treib
2017/02/23 13:57:14
Should this be a GURL?
sfiera
2017/02/23 14:48:10
Sure.
| |
86 const std::string& api_key, | 91 const std::string& api_key, |
87 const UserClassifier* user_classifier); | 92 const UserClassifier* user_classifier); |
88 ~RemoteSuggestionsFetcher() override; | 93 ~RemoteSuggestionsFetcher() override; |
89 | 94 |
90 // Initiates a fetch from the server. When done (successfully or not), calls | 95 // Initiates a fetch from the server. When done (successfully or not), calls |
91 // the callback. | 96 // the callback. |
92 // | 97 // |
93 // If an ongoing fetch exists, both fetches won't influence each other (i.e. | 98 // If an ongoing fetch exists, both fetches won't influence each other (i.e. |
94 // every callback will be called exactly once). | 99 // every callback will be called exactly once). |
95 void FetchSnippets(const RequestParams& params, | 100 void FetchSnippets(const RequestParams& params, |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
207 // Info on the last finished fetch. | 212 // Info on the last finished fetch. |
208 std::string last_status_; | 213 std::string last_status_; |
209 std::string last_fetch_json_; | 214 std::string last_fetch_json_; |
210 | 215 |
211 DISALLOW_COPY_AND_ASSIGN(RemoteSuggestionsFetcher); | 216 DISALLOW_COPY_AND_ASSIGN(RemoteSuggestionsFetcher); |
212 }; | 217 }; |
213 | 218 |
214 } // namespace ntp_snippets | 219 } // namespace ntp_snippets |
215 | 220 |
216 #endif // COMPONENTS_NTP_SNIPPETS_REMOTE_REMOTE_SUGGESTIONS_FETCHER_H_ | 221 #endif // COMPONENTS_NTP_SNIPPETS_REMOTE_REMOTE_SUGGESTIONS_FETCHER_H_ |
OLD | NEW |