summaryrefslogtreecommitdiffstats
path: root/components/ntp_snippets/ntp_snippets_scheduler.h
blob: c374409c0b0b96b47d566caa38536b358e464e85 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef COMPONENTS_NTP_SNIPPETS_NTP_SNIPPETS_SCHEDULER_H_
#define COMPONENTS_NTP_SNIPPETS_NTP_SNIPPETS_SCHEDULER_H_

#include "base/macros.h"
#include "base/time/time.h"

namespace ntp_snippets {

// Interface to schedule the periodic fetching of snippets.
class NTPSnippetsScheduler {
 public:
  // Schedule periodic fetching of snippets, with different period depending on
  // network and charging state. The concrete implementation should call
  // NTPSnippetsService::FetchSnippets once per period.
  virtual bool Schedule(base::TimeDelta period_wifi_charging,
                        base::TimeDelta period_wifi,
                        base::TimeDelta period_fallback) = 0;

  // Cancel the scheduled fetching task, if any.
  virtual bool Unschedule() = 0;

 protected:
  NTPSnippetsScheduler() = default;

 private:
  DISALLOW_COPY_AND_ASSIGN(NTPSnippetsScheduler);
};

}  // namespace ntp_snippets

#endif  // COMPONENTS_NTP_SNIPPETS_NTP_SNIPPETS_SCHEDULER_H_