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

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: Ilya's comments 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
« no previous file with comments | « no previous file | components/ntp_snippets/remote/remote_suggestions_scheduler_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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(base::Time last_fetch_attempt_time);
97 97
98 // Returns whether background fetching (for the given |trigger|) is disabled. 98 // Returns whether background fetching (for the given |trigger|) is disabled.
99 bool BackgroundFetchesDisabled(TriggerType trigger) const; 99 bool BackgroundFetchesDisabled(TriggerType trigger) const;
100 100
101 // Returns true if quota is available for another request. 101 // Returns true if quota is available for another request.
102 bool AcquireQuota(bool interactive_request); 102 bool AcquireQuota(bool interactive_request);
103 103
104 // Callback after RefetchInTheBackground is completed. 104 // Callback after RefetchInTheBackground is completed.
105 void RefetchInTheBackgroundFinished(Status fetch_status); 105 void RefetchInTheBackgroundFinished(Status fetch_status);
106 106
(...skipping 30 matching lines...) Expand all
137 bool background_fetch_in_progress_; 137 bool background_fetch_in_progress_;
138 138
139 // Used to adapt the schedule based on usage activity of the user. Not owned. 139 // Used to adapt the schedule based on usage activity of the user. Not owned.
140 const UserClassifier* user_classifier_; 140 const UserClassifier* user_classifier_;
141 141
142 // Request throttlers for limiting requests for different classes of users. 142 // Request throttlers for limiting requests for different classes of users.
143 RequestThrottler request_throttler_rare_ntp_user_; 143 RequestThrottler request_throttler_rare_ntp_user_;
144 RequestThrottler request_throttler_active_ntp_user_; 144 RequestThrottler request_throttler_active_ntp_user_;
145 RequestThrottler request_throttler_active_suggestions_consumer_; 145 RequestThrottler request_throttler_active_suggestions_consumer_;
146 146
147 // To make sure we only report the first trigger to UMA.
148 bool time_until_first_trigger_reported_;
149
147 // We should not fetch in background before EULA gets accepted. 150 // We should not fetch in background before EULA gets accepted.
148 std::unique_ptr<EulaState> eula_state_; 151 std::unique_ptr<EulaState> eula_state_;
149 152
150 PrefService* profile_prefs_; 153 PrefService* profile_prefs_;
151 std::unique_ptr<base::Clock> clock_; 154 std::unique_ptr<base::Clock> clock_;
152 std::set<TriggerType> enabled_triggers_; 155 std::set<TriggerType> enabled_triggers_;
153 156
154 base::Time background_fetches_allowed_after_; 157 base::Time background_fetches_allowed_after_;
155 158
156 DISALLOW_COPY_AND_ASSIGN(RemoteSuggestionsSchedulerImpl); 159 DISALLOW_COPY_AND_ASSIGN(RemoteSuggestionsSchedulerImpl);
157 }; 160 };
158 161
159 } // namespace ntp_snippets 162 } // namespace ntp_snippets
160 163
161 #endif // COMPONENTS_NTP_SNIPPETS_REMOTE_REMOTE_SUGGESTIONS_SCHEDULER_IMPL_H_ 164 #endif // COMPONENTS_NTP_SNIPPETS_REMOTE_REMOTE_SUGGESTIONS_SCHEDULER_IMPL_H_
OLDNEW
« no previous file with comments | « no previous file | components/ntp_snippets/remote/remote_suggestions_scheduler_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698