blob: cdabb3ae4f2813bfb3a04a0bd303ae01e036e75e (
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
36
37
38
39
40
41
42
43
44
45
46
47
48
|
// Copyright (c) 2013 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.
#include "chrome/browser/metrics/variations/variations_request_scheduler.h"
namespace chrome_variations {
namespace {
// Time between seed fetches, in hours.
const int kSeedFetchPeriodHours = 5;
} // namespace
VariationsRequestScheduler::VariationsRequestScheduler(
const base::Closure& task) : task_(task) {
}
VariationsRequestScheduler::~VariationsRequestScheduler() {
}
void VariationsRequestScheduler::Start() {
// Call the task and repeat it periodically.
task_.Run();
timer_.Start(FROM_HERE, base::TimeDelta::FromHours(kSeedFetchPeriodHours),
task_);
}
void VariationsRequestScheduler::Reset() {
if (timer_.IsRunning())
timer_.Reset();
}
base::Closure VariationsRequestScheduler::task() const {
return task_;
}
#if !defined(OS_ANDROID)
// static
VariationsRequestScheduler* VariationsRequestScheduler::Create(
const base::Closure& task,
PrefService* local_state) {
return new VariationsRequestScheduler(task);
}
#endif // !defined(OS_ANDROID)
} // namespace chrome_variations
|