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

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

Issue 1800743003: base: Remove some unnecessary const scoped_refptr<>&. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/test/sequenced_task_runner_test_template.h" 5 #include "base/test/sequenced_task_runner_test_template.h"
6 6
7 #include <ostream> 7 #include <ostream>
8 8
9 #include "base/location.h" 9 #include "base/location.h"
10 10
11 namespace base { 11 namespace base {
12 12
13 namespace internal { 13 namespace internal {
14 14
15 TaskEvent::TaskEvent(int i, Type type) 15 TaskEvent::TaskEvent(int i, Type type)
16 : i(i), type(type) { 16 : i(i), type(type) {
17 } 17 }
18 18
19 SequencedTaskTracker::SequencedTaskTracker() 19 SequencedTaskTracker::SequencedTaskTracker()
20 : next_post_i_(0), 20 : next_post_i_(0),
21 task_end_count_(0), 21 task_end_count_(0),
22 task_end_cv_(&lock_) { 22 task_end_cv_(&lock_) {
23 } 23 }
24 24
25 void SequencedTaskTracker::PostWrappedNonNestableTask( 25 void SequencedTaskTracker::PostWrappedNonNestableTask(
26 const scoped_refptr<SequencedTaskRunner>& task_runner, 26 SequencedTaskRunner* task_runner,
27 const Closure& task) { 27 const Closure& task) {
28 AutoLock event_lock(lock_); 28 AutoLock event_lock(lock_);
29 const int post_i = next_post_i_++; 29 const int post_i = next_post_i_++;
30 Closure wrapped_task = Bind(&SequencedTaskTracker::RunTask, this, 30 Closure wrapped_task = Bind(&SequencedTaskTracker::RunTask, this,
31 task, post_i); 31 task, post_i);
32 task_runner->PostNonNestableTask(FROM_HERE, wrapped_task); 32 task_runner->PostNonNestableTask(FROM_HERE, wrapped_task);
33 TaskPosted(post_i); 33 TaskPosted(post_i);
34 } 34 }
35 35
36 void SequencedTaskTracker::PostWrappedNestableTask( 36 void SequencedTaskTracker::PostWrappedNestableTask(
37 const scoped_refptr<SequencedTaskRunner>& task_runner, 37 SequencedTaskRunner* task_runner,
38 const Closure& task) { 38 const Closure& task) {
39 AutoLock event_lock(lock_); 39 AutoLock event_lock(lock_);
40 const int post_i = next_post_i_++; 40 const int post_i = next_post_i_++;
41 Closure wrapped_task = Bind(&SequencedTaskTracker::RunTask, this, 41 Closure wrapped_task = Bind(&SequencedTaskTracker::RunTask, this,
42 task, post_i); 42 task, post_i);
43 task_runner->PostTask(FROM_HERE, wrapped_task); 43 task_runner->PostTask(FROM_HERE, wrapped_task);
44 TaskPosted(post_i); 44 TaskPosted(post_i);
45 } 45 }
46 46
47 void SequencedTaskTracker::PostWrappedDelayedNonNestableTask( 47 void SequencedTaskTracker::PostWrappedDelayedNonNestableTask(
48 const scoped_refptr<SequencedTaskRunner>& task_runner, 48 SequencedTaskRunner* task_runner,
49 const Closure& task, 49 const Closure& task,
50 TimeDelta delay) { 50 TimeDelta delay) {
51 AutoLock event_lock(lock_); 51 AutoLock event_lock(lock_);
52 const int post_i = next_post_i_++; 52 const int post_i = next_post_i_++;
53 Closure wrapped_task = Bind(&SequencedTaskTracker::RunTask, this, 53 Closure wrapped_task = Bind(&SequencedTaskTracker::RunTask, this,
54 task, post_i); 54 task, post_i);
55 task_runner->PostNonNestableDelayedTask(FROM_HERE, wrapped_task, delay); 55 task_runner->PostNonNestableDelayedTask(FROM_HERE, wrapped_task, delay);
56 TaskPosted(post_i); 56 TaskPosted(post_i);
57 } 57 }
58 58
59 void SequencedTaskTracker::PostNonNestableTasks( 59 void SequencedTaskTracker::PostNonNestableTasks(
60 const scoped_refptr<SequencedTaskRunner>& task_runner, 60 SequencedTaskRunner* task_runner,
61 int task_count) { 61 int task_count) {
62 for (int i = 0; i < task_count; ++i) { 62 for (int i = 0; i < task_count; ++i) {
63 PostWrappedNonNestableTask(task_runner, Closure()); 63 PostWrappedNonNestableTask(task_runner, Closure());
64 } 64 }
65 } 65 }
66 66
67 void SequencedTaskTracker::RunTask(const Closure& task, int task_i) { 67 void SequencedTaskTracker::RunTask(const Closure& task, int task_i) {
68 TaskStarted(task_i); 68 TaskStarted(task_i);
69 if (!task.is_null()) 69 if (!task.is_null())
70 task.Run(); 70 task.Run();
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 CheckEventOrdersForEachTask(events, task_count); 261 CheckEventOrdersForEachTask(events, task_count);
262 if (!result) 262 if (!result)
263 return result; 263 return result;
264 264
265 return CheckNoTaskRunsOverlap(events); 265 return CheckNoTaskRunsOverlap(events);
266 } 266 }
267 267
268 } // namespace internal 268 } // namespace internal
269 269
270 } // namespace base 270 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698