Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(523)

Side by Side Diff: base/test/task_runner_test_template.cc

Issue 1647803004: Move base to DEPS (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « base/test/task_runner_test_template.h ('k') | base/test/test_discardable_memory_allocator.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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.
4
5 #include "base/test/task_runner_test_template.h"
6
7 namespace base {
8
9 namespace internal {
10
11 TaskTracker::TaskTracker() : task_runs_(0), task_runs_cv_(&lock_) {}
12
13 TaskTracker::~TaskTracker() {}
14
15 Closure TaskTracker::WrapTask(const Closure& task, int i) {
16 return Bind(&TaskTracker::RunTask, this, task, i);
17 }
18
19 void TaskTracker::RunTask(const Closure& task, int i) {
20 AutoLock lock(lock_);
21 if (!task.is_null()) {
22 task.Run();
23 }
24 ++task_run_counts_[i];
25 ++task_runs_;
26 task_runs_cv_.Signal();
27 }
28
29 std::map<int, int> TaskTracker::GetTaskRunCounts() const {
30 AutoLock lock(lock_);
31 return task_run_counts_;
32 }
33
34 void TaskTracker::WaitForCompletedTasks(int count) {
35 AutoLock lock(lock_);
36 while (task_runs_ < count)
37 task_runs_cv_.Wait();
38 }
39
40 void ExpectRunsTasksOnCurrentThread(
41 bool expected_value,
42 const scoped_refptr<TaskRunner>& task_runner) {
43 EXPECT_EQ(expected_value, task_runner->RunsTasksOnCurrentThread());
44 }
45
46 } // namespace internal
47
48 } // namespace base
OLDNEW
« no previous file with comments | « base/test/task_runner_test_template.h ('k') | base/test/test_discardable_memory_allocator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698