Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(56)

Side by Side Diff: components/ntp_snippets/remote/scheduling_remote_suggestions_provider.h

Issue 2702223004: [Remote suggestions] Move all decisions to fetch to the scheduler (Closed)
Patch Set: Tim's comments #2 Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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 13 matching lines...) Expand all
149 std::vector<ContentSuggestion> suggestions); 149 std::vector<ContentSuggestion> suggestions);
150 150
151 // Callback after RefetchInTheBackground is completed. 151 // Callback after RefetchInTheBackground is completed.
152 void RefetchInTheBackgroundFinished( 152 void RefetchInTheBackgroundFinished(
153 std::unique_ptr<FetchStatusCallback> callback, 153 std::unique_ptr<FetchStatusCallback> callback,
154 Status fetch_status); 154 Status fetch_status);
155 155
156 // Common function to call after a fetch of any type is finished. 156 // Common function to call after a fetch of any type is finished.
157 void OnFetchCompleted(Status fetch_status); 157 void OnFetchCompleted(Status fetch_status);
158 158
159 // Clears the time of the last fetch so that the provider is ready to make a
160 // soft fetch at any later time (upon a trigger).
161 void ClearLastFetchAttemptTime();
162
159 FetchingSchedule GetDesiredFetchingSchedule() const; 163 FetchingSchedule GetDesiredFetchingSchedule() const;
160 164
161 // Load and store |schedule_|. 165 // Load and store |schedule_|.
162 void LoadLastFetchingSchedule(); 166 void LoadLastFetchingSchedule();
163 void StoreFetchingSchedule(); 167 void StoreFetchingSchedule();
164 168
165 // Applies the persistent schedule given by |schedule_|. 169 // Applies the persistent schedule given by |schedule_|.
166 void ApplyPersistentFetchingSchedule(); 170 void ApplyPersistentFetchingSchedule();
167 171
168 // Gets enabled trigger types from the variation parameter. 172 // Gets enabled trigger types from the variation parameter.
(...skipping 12 matching lines...) Expand all
181 FetchingSchedule schedule_; 185 FetchingSchedule schedule_;
182 bool background_fetch_in_progress_; 186 bool background_fetch_in_progress_;
183 187
184 // Used to adapt the schedule based on usage activity of the user. Not owned. 188 // Used to adapt the schedule based on usage activity of the user. Not owned.
185 const UserClassifier* user_classifier_; 189 const UserClassifier* user_classifier_;
186 190
187 PrefService* pref_service_; 191 PrefService* pref_service_;
188 std::unique_ptr<base::Clock> clock_; 192 std::unique_ptr<base::Clock> clock_;
189 std::set<SchedulingRemoteSuggestionsProvider::TriggerType> enabled_triggers_; 193 std::set<SchedulingRemoteSuggestionsProvider::TriggerType> enabled_triggers_;
190 194
195 base::Time background_fetches_allowed_after_;
196
191 DISALLOW_COPY_AND_ASSIGN(SchedulingRemoteSuggestionsProvider); 197 DISALLOW_COPY_AND_ASSIGN(SchedulingRemoteSuggestionsProvider);
192 }; 198 };
193 199
194 } // namespace ntp_snippets 200 } // namespace ntp_snippets
195 201
196 #endif // COMPONENTS_NTP_SNIPPETS_REMOTE_SCHEDULING_REMOTE_SUGGESTIONS_PROVIDER _H_ 202 #endif // COMPONENTS_NTP_SNIPPETS_REMOTE_SCHEDULING_REMOTE_SUGGESTIONS_PROVIDER _H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698