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

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

Issue 2558743003: Add generic functions for getting typed variation parameter values (Closed)
Patch Set: Alexei's comments 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_REMOTE_SUGGESTIONS_SCHEDULER_H_
6 #define COMPONENTS_NTP_SNIPPETS_REMOTE_REMOTE_SUGGESTIONS_SCHEDULER_H_
7
8 #include "base/macros.h"
9 #include "base/time/time.h"
10
11 namespace ntp_snippets {
12
13 // Class to take care of scheduling of periodic updates of snippets. There are
14 // two types of scheduled updates:
15 // - "hard" ones that should outlive current running instance of Chrome. These
16 // should get triggered according to their schedule even if Chrome is not
17 // running at the given moment. This is OS-dependent, may be unavilable on
18 // some platforms.
19 // - "soft" ones that get triggered only if Chrome stays running until the
20 // scheduled point.
21 class RemoteSuggestionsScheduler {
22 public:
23 // Interface to perform the scheduled update.
24 class Updater {
25 virtual void HardUpdate();
26 virtual void SoftUpdate();
27 };
28
29 // The passed in |updater| is called when an update is due according to the
30 // schedule. Note that hard fetches get access to the |updater| via the keyed
31 // ContentSuggestionService because the concrete instance passed to
32 // RemoteSuggestionsScheduler when the hard fetch was scheduled may not exist
33 // any more when the hard update is due.
34 explicit RemoteSuggestionsScheduler(Updater* updater);
35
36 // Schedules both "soft" and "hard" fetches. First removes existing schedule
37 // before scheduling new updates.
38 void Schedule();
39
40 // Removes any existing schedule.
41 void Unschedule();
42
43 // Schedule periodic fetching of snippets, with different periods depending on
44 // network state. Once per period, the concrete implementation should call
45 // RemoteSuggestionsUpdater::HardUpdate where RemoteSuggestionsUpdater is
46 // obtained from ContentSuggestionsService.
47 // Any of the periods can be zero to indicate that the corresponding task
48 // should not be scheduled.
49 virtual bool Schedule(base::TimeDelta period_wifi,
50 base::TimeDelta period_fallback) = 0;
51
52 // Cancel any scheduled tasks.
53 virtual bool Unschedule() = 0;
54
55 private:
56 DISALLOW_COPY_AND_ASSIGN(RemoteSuggestionsHardScheduler);
57 };
58
59 } // namespace ntp_snippets
60
61 #endif // COMPONENTS_NTP_SNIPPETS_REMOTE_REMOTE_SUGGESTIONS_HARD_SCHEDULER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698