[M108 Migration][VD] Support set time and time zone offset
[platform/framework/web/chromium-efl.git] / base / pending_task.cc
1 // Copyright 2011 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "base/pending_task.h"
6
7
8 namespace base {
9
10 PendingTask::PendingTask() = default;
11
12 PendingTask::PendingTask(const Location& posted_from,
13                          OnceClosure task,
14                          TimeTicks queue_time,
15                          TimeTicks delayed_run_time,
16                          TimeDelta leeway,
17                          subtle::DelayPolicy delay_policy)
18     : task(std::move(task)),
19       posted_from(posted_from),
20       queue_time(queue_time),
21       delayed_run_time(delayed_run_time),
22       leeway(leeway),
23       delay_policy(delay_policy) {}
24
25 PendingTask::PendingTask(PendingTask&& other) = default;
26
27 PendingTask::~PendingTask() = default;
28
29 PendingTask& PendingTask::operator=(PendingTask&& other) = default;
30
31 TimeTicks PendingTask::GetDesiredExecutionTime() const {
32   if (!delayed_run_time.is_null())
33     return delayed_run_time;
34   return queue_time;
35 }
36
37 TimeTicks PendingTask::earliest_delayed_run_time() const {
38   DCHECK(!delayed_run_time.is_null());
39   if (delay_policy == subtle::DelayPolicy::kFlexiblePreferEarly)
40     return delayed_run_time - leeway;
41   return delayed_run_time;
42 }
43
44 TimeTicks PendingTask::latest_delayed_run_time() const {
45   DCHECK(!delayed_run_time.is_null());
46   if (delay_policy == subtle::DelayPolicy::kFlexibleNoSooner)
47     return delayed_run_time + leeway;
48   return delayed_run_time;
49 }
50
51 }  // namespace base