1 // Copyright (c) 2012 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.
5 #include "base/test/task_runner_test_template.h"
11 TaskTracker::TaskTracker() : task_runs_(0), task_runs_cv_(&lock_
) {}
13 TaskTracker::~TaskTracker() {}
15 Closure
TaskTracker::WrapTask(const Closure
& task
, int i
) {
16 return Bind(&TaskTracker::RunTask
, this, task
, i
);
19 void TaskTracker::RunTask(const Closure
& task
, int i
) {
21 if (!task
.is_null()) {
24 ++task_run_counts_
[i
];
26 task_runs_cv_
.Signal();
29 std::map
<int, int> TaskTracker::GetTaskRunCounts() const {
31 return task_run_counts_
;
34 void TaskTracker::WaitForCompletedTasks(int count
) {
36 while (task_runs_
< count
)
40 void ExpectRunsTasksOnCurrentThread(
42 const scoped_refptr
<TaskRunner
>& task_runner
) {
43 EXPECT_EQ(expected_value
, task_runner
->RunsTasksOnCurrentThread());
46 } // namespace internal