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

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

Issue 2759943002: [Remote suggestions] Do not fetch before EULA accepted (Closed)
Patch Set: Fix compilation 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_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>
11 #include <utility> 11 #include <utility>
12 #include <vector> 12 #include <vector>
13 13
14 #include "base/macros.h" 14 #include "base/macros.h"
15 #include "base/time/time.h" 15 #include "base/time/time.h"
16 #include "components/ntp_snippets/content_suggestions_provider.h" 16 #include "components/ntp_snippets/content_suggestions_provider.h"
17 #include "components/ntp_snippets/remote/persistent_scheduler.h" 17 #include "components/ntp_snippets/remote/persistent_scheduler.h"
18 #include "components/ntp_snippets/remote/remote_suggestions_provider.h" 18 #include "components/ntp_snippets/remote/remote_suggestions_provider.h"
19 #include "components/ntp_snippets/remote/remote_suggestions_scheduler.h" 19 #include "components/ntp_snippets/remote/remote_suggestions_scheduler.h"
20 #include "components/ntp_snippets/remote/request_throttler.h" 20 #include "components/ntp_snippets/remote/request_throttler.h"
21 #include "components/web_resource/eula_accepted_notifier.h"
21 22
22 class PrefRegistrySimple; 23 class PrefRegistrySimple;
23 class PrefService; 24 class PrefService;
24 25
25 namespace base { 26 namespace base {
26 class Clock; 27 class Clock;
27 } 28 }
28 29
29 namespace ntp_snippets { 30 namespace ntp_snippets {
30 31
31 struct Status; 32 struct Status;
33 class EulaState;
32 class UserClassifier; 34 class UserClassifier;
33 35
34 // A wrapper around RemoteSuggestionsProvider that introduces periodic fetching. 36 // A wrapper around RemoteSuggestionsProvider that introduces periodic fetching.
35 // 37 //
36 // The class initiates fetches on its own in these situations: 38 // The class initiates fetches on its own in these situations:
37 // - initial fetch when the provider is constructed and we have no suggestions; 39 // - initial fetch when the provider is constructed and we have no suggestions;
38 // - regular fetches according to its schedule. 40 // - regular fetches according to its schedule.
39 // TODO(jkrcal): After soft fetch on Chrome startup is introduced, remove 41 // TODO(jkrcal): After soft fetch on Chrome startup is introduced, remove
40 // the initial fetch completely. 42 // the initial fetch completely.
41 // 43 //
(...skipping 15 matching lines...) Expand all
57 // Scheduler interface. crbug.com/695447 59 // Scheduler interface. crbug.com/695447
58 class SchedulingRemoteSuggestionsProvider final 60 class SchedulingRemoteSuggestionsProvider final
59 : public RemoteSuggestionsProvider, 61 : public RemoteSuggestionsProvider,
60 public RemoteSuggestionsScheduler { 62 public RemoteSuggestionsScheduler {
61 public: 63 public:
62 SchedulingRemoteSuggestionsProvider( 64 SchedulingRemoteSuggestionsProvider(
63 Observer* observer, 65 Observer* observer,
64 std::unique_ptr<RemoteSuggestionsProvider> provider, 66 std::unique_ptr<RemoteSuggestionsProvider> provider,
65 PersistentScheduler* persistent_scheduler, 67 PersistentScheduler* persistent_scheduler,
66 const UserClassifier* user_classifier, 68 const UserClassifier* user_classifier,
67 PrefService* pref_service, 69 PrefService* profile_prefs,
70 PrefService* local_state_prefs,
68 std::unique_ptr<base::Clock> clock); 71 std::unique_ptr<base::Clock> clock);
69 72
70 ~SchedulingRemoteSuggestionsProvider() override; 73 ~SchedulingRemoteSuggestionsProvider() override;
71 74
72 static void RegisterProfilePrefs(PrefRegistrySimple* registry); 75 static void RegisterProfilePrefs(PrefRegistrySimple* registry);
73 76
74 // RemoteSuggestionsScheduler implementation. 77 // RemoteSuggestionsScheduler implementation.
75 void OnProviderActivated() override; 78 void OnProviderActivated() override;
76 void OnProviderDeactivated() override; 79 void OnProviderDeactivated() override;
77 void OnSuggestionsCleared() override; 80 void OnSuggestionsCleared() override;
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 bool background_fetch_in_progress_; 194 bool background_fetch_in_progress_;
192 195
193 // Used to adapt the schedule based on usage activity of the user. Not owned. 196 // Used to adapt the schedule based on usage activity of the user. Not owned.
194 const UserClassifier* user_classifier_; 197 const UserClassifier* user_classifier_;
195 198
196 // Request throttlers for limiting requests for different classes of users. 199 // Request throttlers for limiting requests for different classes of users.
197 RequestThrottler request_throttler_rare_ntp_user_; 200 RequestThrottler request_throttler_rare_ntp_user_;
198 RequestThrottler request_throttler_active_ntp_user_; 201 RequestThrottler request_throttler_active_ntp_user_;
199 RequestThrottler request_throttler_active_suggestions_consumer_; 202 RequestThrottler request_throttler_active_suggestions_consumer_;
200 203
201 PrefService* pref_service_; 204 // We should not fetch in background before EULA gets accepted.
205 std::unique_ptr<EulaState> eula_state_;
206
207 PrefService* profile_prefs_;
202 std::unique_ptr<base::Clock> clock_; 208 std::unique_ptr<base::Clock> clock_;
203 std::set<SchedulingRemoteSuggestionsProvider::TriggerType> enabled_triggers_; 209 std::set<SchedulingRemoteSuggestionsProvider::TriggerType> enabled_triggers_;
204 210
205 base::Time background_fetches_allowed_after_; 211 base::Time background_fetches_allowed_after_;
206 212
207 DISALLOW_COPY_AND_ASSIGN(SchedulingRemoteSuggestionsProvider); 213 DISALLOW_COPY_AND_ASSIGN(SchedulingRemoteSuggestionsProvider);
208 }; 214 };
209 215
210 } // namespace ntp_snippets 216 } // namespace ntp_snippets
211 217
212 #endif // COMPONENTS_NTP_SNIPPETS_REMOTE_SCHEDULING_REMOTE_SUGGESTIONS_PROVIDER _H_ 218 #endif // COMPONENTS_NTP_SNIPPETS_REMOTE_SCHEDULING_REMOTE_SUGGESTIONS_PROVIDER _H_
OLDNEW
« no previous file with comments | « components/ntp_snippets/DEPS ('k') | components/ntp_snippets/remote/scheduling_remote_suggestions_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698