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

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

Issue 2557363002: [NTP Snippets] Refactor background scheduling for remote suggestions (Closed)
Patch Set: Tim's comments and splitting RemoteSuggestionsProvider and RemoteSuggestionsProviderImpl Created 4 years 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef COMPONENTS_NTP_SNIPPETS_REMOTE_PERSISTENT_SCHEDULER_H_
6 #define COMPONENTS_NTP_SNIPPETS_REMOTE_PERSISTENT_SCHEDULER_H_
7
8 #include "base/macros.h"
9 #include "base/time/time.h"
10
11 namespace ntp_snippets {
12
13 // Interface to schedule persistent periodic fetches for remote suggestions, OS-
14 // dependent. These persistent fetches must get triggered according to their
15 // schedule independent of whether Chrome is running at that moment.
16 //
17 // Once per period, the concrete implementation should call
18 // RemoteSuggestionsScheduler::OnFetchDue() where the scheduler object is
19 // obtained from ContentSuggestionsService.
20 //
21 // The implementation may also call
22 // RemoteSuggestionsScheduler::RescheduleFetching() when its own current
23 // schedule got corrupted for whatever reason and needs to be applied again
24 // (in turn, this will result in calling Schedule() on the implementation).
25 class PersistentScheduler {
26 public:
27 // Schedule periodic fetching of remote suggestions, with different periods
28 // depending on network state. Any of the periods can be zero to indicate that
29 // the corresponding task should not be scheduled.
30 virtual bool Schedule(base::TimeDelta period_wifi,
31 base::TimeDelta period_fallback) = 0;
32
33 // Cancel any scheduled tasks. Equivalent to Schedule(0, 0).
Marc Treib 2016/12/19 12:59:23 Hm, we could just get rid of Unschedule. WDYT?
jkrcal 2016/12/20 16:39:46 We could. I prefer them being split, though. It ma
34 virtual bool Unschedule() = 0;
35
36 protected:
37 PersistentScheduler() = default;
38
39 private:
40 DISALLOW_COPY_AND_ASSIGN(PersistentScheduler);
41 };
42
43 } // namespace ntp_snippets
44
45 #endif // COMPONENTS_NTP_SNIPPETS_REMOTE_PERSISTENT_SCHEDULER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698