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

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

Issue 2557363002: [NTP Snippets] Refactor background scheduling for remote suggestions (Closed)
Patch Set: Rebase 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.
14 // These persistent fetches must get triggered according to their schedule
15 // independent of whether Chrome is running at that moment.
16 class PersistentScheduler {
17 public:
18 // Interface to access from platform dependend persistent scheduling code.
19 class Listener {
tschumann 2016/12/15 14:12:11 this feels like the wrong place to implement this
jkrcal 2016/12/19 09:40:24 Done.
20 public:
21 // Fetches content suggestions.
22 virtual void OnFetchDue() = 0;
23
24 // Forces rescheduling of fetching.
25 virtual void RescheduleFetching() = 0;
26 };
27
28 // Schedule periodic fetching of remote suggestions, with different periods
29 // depending on network state. Once per period, the concrete implementation
30 // should call PersitentScheduler::Listener::OnFetchDue() where the listener
31 // is obtained from ContentSuggestionsService. Any of the periods can be zero
32 // to indicate that the corresponding task should not be scheduled.
33 virtual bool Schedule(base::TimeDelta period_wifi,
34 base::TimeDelta period_fallback) = 0;
35
36 // Cancel any scheduled tasks. Equivalent to Schedule(0, 0).
37 virtual bool Unschedule() = 0;
38
39 protected:
40 PersistentScheduler() = default;
41
42 private:
43 DISALLOW_COPY_AND_ASSIGN(PersistentScheduler);
44 };
45
46 } // namespace ntp_snippets
47
48 #endif // COMPONENTS_NTP_SNIPPETS_REMOTE_PERSISTENT_SCHEDULER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698