summaryrefslogtreecommitdiffstats
path: root/base/test/test_pending_task.cc
blob: cb8412c4a559689c20ab4fb4d2103e1bfd1a3b28 (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 (c) 2012 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 "base/test/test_pending_task.h"

namespace base {

TestPendingTask::TestPendingTask() : nestability(NESTABLE) {}

TestPendingTask::TestPendingTask(
    const tracked_objects::Location& location,
    const Closure& task,
    TimeTicks post_time,
    TimeDelta delay,
    TestNestability nestability)
    : location(location),
      task(task),
      post_time(post_time),
      delay(delay),
      nestability(nestability) {}

TimeTicks TestPendingTask::GetTimeToRun() const {
  return post_time + delay;
}

bool TestPendingTask::ShouldRunBefore(const TestPendingTask& other) const {
  if (nestability != other.nestability)
    return (nestability == NESTABLE);
  return GetTimeToRun() < other.GetTimeToRun();
}

TestPendingTask::~TestPendingTask() {}

}  // namespace base