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

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

Issue 2699613002: [remote suggestions] Add separte fetch interval for NTP open trigger (Closed)
Patch Set: ' 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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 // Abstract description of the fetching schedule. 107 // Abstract description of the fetching schedule.
108 struct FetchingSchedule { 108 struct FetchingSchedule {
109 static FetchingSchedule Empty(); 109 static FetchingSchedule Empty();
110 bool operator==(const FetchingSchedule& other) const; 110 bool operator==(const FetchingSchedule& other) const;
111 bool operator!=(const FetchingSchedule& other) const; 111 bool operator!=(const FetchingSchedule& other) const;
112 bool is_empty() const; 112 bool is_empty() const;
113 113
114 base::TimeDelta interval_persistent_wifi; 114 base::TimeDelta interval_persistent_wifi;
115 base::TimeDelta interval_persistent_fallback; 115 base::TimeDelta interval_persistent_fallback;
116 base::TimeDelta interval_soft_on_usage_event; 116 base::TimeDelta interval_soft_on_usage_event;
117 base::TimeDelta interval_ntp_open;
jkrcal 2017/02/15 16:35:34 nit: can it be soft_on_ntp_opened? (opened to mak
markusheintz_ 2017/02/15 21:19:29 soft_on_ntp_opened SGTM. Name updated.
117 }; 118 };
118 119
119 enum class TriggerType; 120 enum class TriggerType;
120 121
121 // Callback that is notified whenever the status of |provider_| changes. 122 // Callback that is notified whenever the status of |provider_| changes.
122 void OnProviderStatusChanged( 123 void OnProviderStatusChanged(
123 RemoteSuggestionsProvider::ProviderStatus status); 124 RemoteSuggestionsProvider::ProviderStatus status);
124 125
125 // 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
126 // run any time later without impacting the current schedule. 127 // run any time later without impacting the current schedule.
127 // If you want to enforce rescheduling, call Unschedule() and then Schedule(). 128 // If you want to enforce rescheduling, call Unschedule() and then Schedule().
128 void StartScheduling(); 129 void StartScheduling();
129 130
130 // 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().
131 // Idempotent, can be run any time later without impacting the current 132 // Idempotent, can be run any time later without impacting the current
132 // schedule. 133 // schedule.
133 void StopScheduling(); 134 void StopScheduling();
134 135
135 // Trigger a background refetch for the given |trigger| if enabled. 136 // Trigger a background refetch for the given |trigger| if enabled.
136 void RefetchInTheBackgroundIfEnabled(TriggerType trigger); 137 void RefetchInTheBackgroundIfEnabled(TriggerType trigger);
137 138
138 // Checks whether it is time to perform a soft background fetch, according to 139 // Checks whether it is time to perform a soft background fetch, according to
139 // |schedule|. 140 // |schedule|.
140 bool ShouldRefetchInTheBackgroundNow(); 141 bool ShouldRefetchInTheBackgroundNow(TriggerType trigger);
141 142
142 // Returns whether background fetching (for the given |trigger|) is disabled. 143 // Returns whether background fetching (for the given |trigger|) is disabled.
143 bool BackgroundFetchesDisabled(TriggerType trigger) const; 144 bool BackgroundFetchesDisabled(TriggerType trigger) const;
144 145
145 // Callback after Fetch is completed. 146 // Callback after Fetch is completed.
146 void FetchFinished(const FetchDoneCallback& callback, 147 void FetchFinished(const FetchDoneCallback& callback,
147 Status fetch_status, 148 Status fetch_status,
148 std::vector<ContentSuggestion> suggestions); 149 std::vector<ContentSuggestion> suggestions);
149 150
150 // Callback after RefetchInTheBackground is completed. 151 // Callback after RefetchInTheBackground is completed.
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 PrefService* pref_service_; 187 PrefService* pref_service_;
187 std::unique_ptr<base::Clock> clock_; 188 std::unique_ptr<base::Clock> clock_;
188 std::set<SchedulingRemoteSuggestionsProvider::TriggerType> enabled_triggers_; 189 std::set<SchedulingRemoteSuggestionsProvider::TriggerType> enabled_triggers_;
189 190
190 DISALLOW_COPY_AND_ASSIGN(SchedulingRemoteSuggestionsProvider); 191 DISALLOW_COPY_AND_ASSIGN(SchedulingRemoteSuggestionsProvider);
191 }; 192 };
192 193
193 } // namespace ntp_snippets 194 } // namespace ntp_snippets
194 195
195 #endif // COMPONENTS_NTP_SNIPPETS_REMOTE_SCHEDULING_REMOTE_SUGGESTIONS_PROVIDER _H_ 196 #endif // COMPONENTS_NTP_SNIPPETS_REMOTE_SCHEDULING_REMOTE_SUGGESTIONS_PROVIDER _H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698