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_SCHEDULING_REMOTE_SUGGESTIONS_PROVIDER_H_ | 5 #ifndef COMPONENTS_NTP_SNIPPETS_REMOTE_SCHEDULING_REMOTE_SUGGESTIONS_PROVIDER_H_ |
6 #define COMPONENTS_NTP_SNIPPETS_REMOTE_SCHEDULING_REMOTE_SUGGESTIONS_PROVIDER_H_ | 6 #define COMPONENTS_NTP_SNIPPETS_REMOTE_SCHEDULING_REMOTE_SUGGESTIONS_PROVIDER_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 PersistentScheduler* persistent_scheduler, | 61 PersistentScheduler* persistent_scheduler, |
62 const UserClassifier* user_classifier, | 62 const UserClassifier* user_classifier, |
63 PrefService* pref_service, | 63 PrefService* pref_service, |
64 std::unique_ptr<base::Clock> clock); | 64 std::unique_ptr<base::Clock> clock); |
65 | 65 |
66 ~SchedulingRemoteSuggestionsProvider() override; | 66 ~SchedulingRemoteSuggestionsProvider() override; |
67 | 67 |
68 static void RegisterProfilePrefs(PrefRegistrySimple* registry); | 68 static void RegisterProfilePrefs(PrefRegistrySimple* registry); |
69 | 69 |
70 // RemoteSuggestionsScheduler implementation. | 70 // RemoteSuggestionsScheduler implementation. |
| 71 void OnProviderActivated() override; |
| 72 void OnProviderInactivated() override; |
| 73 void OnSuggestionsCleared() override; |
| 74 void OnHistoryCleared() override; |
71 void RescheduleFetching() override; | 75 void RescheduleFetching() override; |
72 void OnPersistentSchedulerWakeUp() override; | 76 void OnPersistentSchedulerWakeUp() override; |
73 void OnBrowserForegrounded() override; | 77 void OnBrowserForegrounded() override; |
74 void OnBrowserColdStart() override; | 78 void OnBrowserColdStart() override; |
75 void OnNTPOpened() override; | 79 void OnNTPOpened() override; |
76 | 80 |
77 // RemoteSuggestionsProvider implementation. | 81 // RemoteSuggestionsProvider implementation. |
78 void SetProviderStatusCallback( | 82 void SetRemoteSuggestionsScheduler( |
79 std::unique_ptr<ProviderStatusCallback> callback) override; | 83 RemoteSuggestionsScheduler* scheduler) override; |
80 void RefetchInTheBackground( | 84 void RefetchInTheBackground( |
81 std::unique_ptr<FetchStatusCallback> callback) override; | 85 std::unique_ptr<FetchStatusCallback> callback) override; |
82 const RemoteSuggestionsFetcher* suggestions_fetcher_for_debugging() | 86 const RemoteSuggestionsFetcher* suggestions_fetcher_for_debugging() |
83 const override; | 87 const override; |
84 | 88 |
85 // ContentSuggestionsProvider implementation. | 89 // ContentSuggestionsProvider implementation. |
86 CategoryStatus GetCategoryStatus(Category category) override; | 90 CategoryStatus GetCategoryStatus(Category category) override; |
87 CategoryInfo GetCategoryInfo(Category category) override; | 91 CategoryInfo GetCategoryInfo(Category category) override; |
88 void DismissSuggestion(const ContentSuggestion::ID& suggestion_id) override; | 92 void DismissSuggestion(const ContentSuggestion::ID& suggestion_id) override; |
89 void FetchSuggestionImage(const ContentSuggestion::ID& suggestion_id, | 93 void FetchSuggestionImage(const ContentSuggestion::ID& suggestion_id, |
(...skipping 22 matching lines...) Expand all Loading... |
112 bool is_empty() const; | 116 bool is_empty() const; |
113 | 117 |
114 base::TimeDelta interval_persistent_wifi; | 118 base::TimeDelta interval_persistent_wifi; |
115 base::TimeDelta interval_persistent_fallback; | 119 base::TimeDelta interval_persistent_fallback; |
116 base::TimeDelta interval_soft_on_usage_event; | 120 base::TimeDelta interval_soft_on_usage_event; |
117 base::TimeDelta interval_soft_on_ntp_opened; | 121 base::TimeDelta interval_soft_on_ntp_opened; |
118 }; | 122 }; |
119 | 123 |
120 enum class TriggerType; | 124 enum class TriggerType; |
121 | 125 |
122 // Callback that is notified whenever the status of |provider_| changes. | |
123 void OnProviderStatusChanged( | |
124 RemoteSuggestionsProvider::ProviderStatus status); | |
125 | |
126 // After the call, updates will be scheduled in the future. Idempotent, can be | 126 // After the call, updates will be scheduled in the future. Idempotent, can be |
127 // run any time later without impacting the current schedule. | 127 // run any time later without impacting the current schedule. |
128 // If you want to enforce rescheduling, call Unschedule() and then Schedule(). | 128 // If you want to enforce rescheduling, call Unschedule() and then Schedule(). |
129 void StartScheduling(); | 129 void StartScheduling(); |
130 | 130 |
131 // After the call, no updates will happen before another call to Schedule(). | 131 // After the call, no updates will happen before another call to Schedule(). |
132 // Idempotent, can be run any time later without impacting the current | 132 // Idempotent, can be run any time later without impacting the current |
133 // schedule. | 133 // schedule. |
134 void StopScheduling(); | 134 void StopScheduling(); |
135 | 135 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 FetchingSchedule schedule_; | 181 FetchingSchedule schedule_; |
182 bool background_fetch_in_progress_; | 182 bool background_fetch_in_progress_; |
183 | 183 |
184 // Used to adapt the schedule based on usage activity of the user. Not owned. | 184 // Used to adapt the schedule based on usage activity of the user. Not owned. |
185 const UserClassifier* user_classifier_; | 185 const UserClassifier* user_classifier_; |
186 | 186 |
187 PrefService* pref_service_; | 187 PrefService* pref_service_; |
188 std::unique_ptr<base::Clock> clock_; | 188 std::unique_ptr<base::Clock> clock_; |
189 std::set<SchedulingRemoteSuggestionsProvider::TriggerType> enabled_triggers_; | 189 std::set<SchedulingRemoteSuggestionsProvider::TriggerType> enabled_triggers_; |
190 | 190 |
| 191 base::Time background_fetches_allowed_after_; |
| 192 |
191 DISALLOW_COPY_AND_ASSIGN(SchedulingRemoteSuggestionsProvider); | 193 DISALLOW_COPY_AND_ASSIGN(SchedulingRemoteSuggestionsProvider); |
192 }; | 194 }; |
193 | 195 |
194 } // namespace ntp_snippets | 196 } // namespace ntp_snippets |
195 | 197 |
196 #endif // COMPONENTS_NTP_SNIPPETS_REMOTE_SCHEDULING_REMOTE_SUGGESTIONS_PROVIDER
_H_ | 198 #endif // COMPONENTS_NTP_SNIPPETS_REMOTE_SCHEDULING_REMOTE_SUGGESTIONS_PROVIDER
_H_ |
OLD | NEW |