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

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

Issue 2810053004: [Remote suggestions] Report time distribution of triggers (Closed)
Patch Set: Created 3 years, 8 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_REMOTE_SUGGESTIONS_SCHEDULER_IMPL_H_ 5 #ifndef COMPONENTS_NTP_SNIPPETS_REMOTE_REMOTE_SUGGESTIONS_SCHEDULER_IMPL_H_
6 #define COMPONENTS_NTP_SNIPPETS_REMOTE_REMOTE_SUGGESTIONS_SCHEDULER_IMPL_H_ 6 #define COMPONENTS_NTP_SNIPPETS_REMOTE_REMOTE_SUGGESTIONS_SCHEDULER_IMPL_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 // Idempotent, can be run any time later without impacting the current 86 // Idempotent, can be run any time later without impacting the current
87 // schedule. 87 // schedule.
88 void StopScheduling(); 88 void StopScheduling();
89 89
90 // Trigger a background refetch for the given |trigger| if enabled and if the 90 // Trigger a background refetch for the given |trigger| if enabled and if the
91 // timing is appropriate for another fetch. 91 // timing is appropriate for another fetch.
92 void RefetchInTheBackgroundIfAppropriate(TriggerType trigger); 92 void RefetchInTheBackgroundIfAppropriate(TriggerType trigger);
93 93
94 // Checks whether it is time to perform a soft background fetch, according to 94 // Checks whether it is time to perform a soft background fetch, according to
95 // |schedule|. 95 // |schedule|.
96 bool ShouldRefetchInTheBackgroundNow(); 96 bool ShouldRefetchInTheBackgroundNow(
97 const base::Time& last_fetch_attempt_time);
Marc Treib 2017/04/12 12:48:31 nit: Time is essentially an int64, so it's fine to
jkrcal 2017/04/12 13:26:44 Done.
97 98
98 // Returns whether background fetching (for the given |trigger|) is disabled. 99 // Returns whether background fetching (for the given |trigger|) is disabled.
99 bool BackgroundFetchesDisabled(TriggerType trigger) const; 100 bool BackgroundFetchesDisabled(TriggerType trigger) const;
100 101
101 // Returns true if quota is available for another request. 102 // Returns true if quota is available for another request.
102 bool AcquireQuota(bool interactive_request); 103 bool AcquireQuota(bool interactive_request);
103 104
104 // Callback after RefetchInTheBackground is completed. 105 // Callback after RefetchInTheBackground is completed.
105 void RefetchInTheBackgroundFinished(Status fetch_status); 106 void RefetchInTheBackgroundFinished(Status fetch_status);
106 107
(...skipping 30 matching lines...) Expand all
137 bool background_fetch_in_progress_; 138 bool background_fetch_in_progress_;
138 139
139 // Used to adapt the schedule based on usage activity of the user. Not owned. 140 // Used to adapt the schedule based on usage activity of the user. Not owned.
140 const UserClassifier* user_classifier_; 141 const UserClassifier* user_classifier_;
141 142
142 // Request throttlers for limiting requests for different classes of users. 143 // Request throttlers for limiting requests for different classes of users.
143 RequestThrottler request_throttler_rare_ntp_user_; 144 RequestThrottler request_throttler_rare_ntp_user_;
144 RequestThrottler request_throttler_active_ntp_user_; 145 RequestThrottler request_throttler_active_ntp_user_;
145 RequestThrottler request_throttler_active_suggestions_consumer_; 146 RequestThrottler request_throttler_active_suggestions_consumer_;
146 147
148 // To make sure we only report the first trigger to UMA.
149 bool time_until_first_trigger_reported_;
150
147 // We should not fetch in background before EULA gets accepted. 151 // We should not fetch in background before EULA gets accepted.
148 std::unique_ptr<EulaState> eula_state_; 152 std::unique_ptr<EulaState> eula_state_;
149 153
150 PrefService* profile_prefs_; 154 PrefService* profile_prefs_;
151 std::unique_ptr<base::Clock> clock_; 155 std::unique_ptr<base::Clock> clock_;
152 std::set<TriggerType> enabled_triggers_; 156 std::set<TriggerType> enabled_triggers_;
153 157
154 base::Time background_fetches_allowed_after_; 158 base::Time background_fetches_allowed_after_;
155 159
156 DISALLOW_COPY_AND_ASSIGN(RemoteSuggestionsSchedulerImpl); 160 DISALLOW_COPY_AND_ASSIGN(RemoteSuggestionsSchedulerImpl);
157 }; 161 };
158 162
159 } // namespace ntp_snippets 163 } // namespace ntp_snippets
160 164
161 #endif // COMPONENTS_NTP_SNIPPETS_REMOTE_REMOTE_SUGGESTIONS_SCHEDULER_IMPL_H_ 165 #endif // COMPONENTS_NTP_SNIPPETS_REMOTE_REMOTE_SUGGESTIONS_SCHEDULER_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698