| 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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 NTPSnippet::PtrVector snippets; | 73 NTPSnippet::PtrVector snippets; |
| 74 | 74 |
| 75 FetchedCategory(Category c, CategoryInfo&& info); | 75 FetchedCategory(Category c, CategoryInfo&& info); |
| 76 FetchedCategory(FetchedCategory&&); // = default, in .cc | 76 FetchedCategory(FetchedCategory&&); // = default, in .cc |
| 77 ~FetchedCategory(); // = default, in .cc | 77 ~FetchedCategory(); // = default, in .cc |
| 78 FetchedCategory& operator=(FetchedCategory&&); // = default, in .cc | 78 FetchedCategory& operator=(FetchedCategory&&); // = default, in .cc |
| 79 }; | 79 }; |
| 80 using FetchedCategoriesVector = std::vector<FetchedCategory>; | 80 using FetchedCategoriesVector = std::vector<FetchedCategory>; |
| 81 using OptionalFetchedCategories = base::Optional<FetchedCategoriesVector>; | 81 using OptionalFetchedCategories = base::Optional<FetchedCategoriesVector>; |
| 82 | 82 |
| 83 // |snippets| contains parsed snippets if a fetch succeeded. If problems | |
| 84 // occur, |snippets| contains no value (no actual vector in base::Optional). | |
| 85 // Error details can be retrieved using last_status(). | |
| 86 using SnippetsAvailableCallback = | |
| 87 base::OnceCallback<void(OptionalFetchedCategories fetched_categories)>; | |
| 88 | |
| 89 // Enumeration listing all possible outcomes for fetch attempts. Used for UMA | 83 // Enumeration listing all possible outcomes for fetch attempts. Used for UMA |
| 90 // histograms, so do not change existing values. Insert new values at the end, | 84 // histograms, so do not change existing values. Insert new values at the end, |
| 91 // and update the histogram definition. | 85 // and update the histogram definition. |
| 92 enum class FetchResult { | 86 enum class FetchResult { |
| 93 SUCCESS, | 87 SUCCESS, |
| 94 DEPRECATED_EMPTY_HOSTS, | 88 DEPRECATED_EMPTY_HOSTS, |
| 95 URL_REQUEST_STATUS_ERROR, | 89 URL_REQUEST_STATUS_ERROR, |
| 96 HTTP_ERROR, | 90 HTTP_ERROR, |
| 97 JSON_PARSE_ERROR, | 91 JSON_PARSE_ERROR, |
| 98 INVALID_SNIPPET_CONTENT_ERROR, | 92 INVALID_SNIPPET_CONTENT_ERROR, |
| 99 OAUTH_TOKEN_ERROR, | 93 OAUTH_TOKEN_ERROR, |
| 100 INTERACTIVE_QUOTA_ERROR, | 94 INTERACTIVE_QUOTA_ERROR, |
| 101 NON_INTERACTIVE_QUOTA_ERROR, | 95 NON_INTERACTIVE_QUOTA_ERROR, |
| 102 RESULT_MAX | 96 RESULT_MAX |
| 103 }; | 97 }; |
| 104 | 98 |
| 99 // |snippets| contains parsed snippets if a fetch succeeded. If problems |
| 100 // occur, |snippets| contains no value (no actual vector in base::Optional). |
| 101 // Error details can be retrieved using last_status(). |
| 102 using SnippetsAvailableCallback = |
| 103 base::OnceCallback<void(FetchResult fetch_result, |
| 104 OptionalFetchedCategories fetched_categories)>; |
| 105 |
| 105 // Enumeration listing all possible variants of dealing with personalization. | 106 // Enumeration listing all possible variants of dealing with personalization. |
| 106 enum class Personalization { kPersonal, kNonPersonal, kBoth }; | 107 enum class Personalization { kPersonal, kNonPersonal, kBoth }; |
| 107 | 108 |
| 108 // Contains all the parameters for one fetch. | 109 // Contains all the parameters for one fetch. |
| 109 struct Params { | 110 struct Params { |
| 110 Params(); | 111 Params(); |
| 111 Params(const Params&); | 112 Params(const Params&); |
| 112 ~Params(); | 113 ~Params(); |
| 113 | 114 |
| 114 // If non-empty, restricts the result to the given set of hosts. | 115 // If non-empty, restricts the result to the given set of hosts. |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 357 std::string last_status_; | 358 std::string last_status_; |
| 358 std::string last_fetch_json_; | 359 std::string last_fetch_json_; |
| 359 | 360 |
| 360 base::WeakPtrFactory<NTPSnippetsFetcher> weak_ptr_factory_; | 361 base::WeakPtrFactory<NTPSnippetsFetcher> weak_ptr_factory_; |
| 361 | 362 |
| 362 DISALLOW_COPY_AND_ASSIGN(NTPSnippetsFetcher); | 363 DISALLOW_COPY_AND_ASSIGN(NTPSnippetsFetcher); |
| 363 }; | 364 }; |
| 364 } // namespace ntp_snippets | 365 } // namespace ntp_snippets |
| 365 | 366 |
| 366 #endif // COMPONENTS_NTP_SNIPPETS_REMOTE_NTP_SNIPPETS_FETCHER_H_ | 367 #endif // COMPONENTS_NTP_SNIPPETS_REMOTE_NTP_SNIPPETS_FETCHER_H_ |
| OLD | NEW |