OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "components/scheduler/base/task_queue_manager.h" | 5 #include "components/scheduler/base/task_queue_manager.h" |
6 | 6 |
7 #include "base/location.h" | 7 #include "base/location.h" |
8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
9 #include "base/single_thread_task_runner.h" | 9 #include "base/single_thread_task_runner.h" |
10 #include "base/test/simple_test_tick_clock.h" | 10 #include "base/test/simple_test_tick_clock.h" |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 } | 64 } |
65 | 65 |
66 void Initialize(size_t num_queues) { | 66 void Initialize(size_t num_queues) { |
67 now_src_.reset(new base::SimpleTestTickClock()); | 67 now_src_.reset(new base::SimpleTestTickClock()); |
68 now_src_->Advance(base::TimeDelta::FromMicroseconds(1000)); | 68 now_src_->Advance(base::TimeDelta::FromMicroseconds(1000)); |
69 InitializeWithClock(num_queues, | 69 InitializeWithClock(num_queues, |
70 make_scoped_ptr(new TestTimeSource(now_src_.get()))); | 70 make_scoped_ptr(new TestTimeSource(now_src_.get()))); |
71 } | 71 } |
72 | 72 |
73 void InitializeWithRealMessageLoop(size_t num_queues) { | 73 void InitializeWithRealMessageLoop(size_t num_queues) { |
| 74 now_src_.reset(new base::SimpleTestTickClock()); |
74 message_loop_.reset(new base::MessageLoop()); | 75 message_loop_.reset(new base::MessageLoop()); |
75 manager_ = make_scoped_ptr(new TaskQueueManager( | 76 manager_ = make_scoped_ptr(new TaskQueueManager( |
76 MessageLoopTaskRunner::Create( | 77 MessageLoopTaskRunner::Create( |
77 make_scoped_ptr(new TestTimeSource(now_src_.get()))), | 78 make_scoped_ptr(new TestTimeSource(now_src_.get()))), |
78 "test.scheduler", "test.scheduler", "test.scheduler.debug")); | 79 "test.scheduler", "test.scheduler", "test.scheduler.debug")); |
79 | 80 |
80 for (size_t i = 0; i < num_queues; i++) | 81 for (size_t i = 0; i < num_queues; i++) |
81 runners_.push_back(manager_->NewTaskQueue(TaskQueue::Spec("test_queue"))); | 82 runners_.push_back(manager_->NewTaskQueue(TaskQueue::Spec("test_queue"))); |
82 } | 83 } |
83 | 84 |
(...skipping 1286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1370 // release its reference, and checks that it has. | 1371 // release its reference, and checks that it has. |
1371 runners_[0]->PostTask(FROM_HERE, | 1372 runners_[0]->PostTask(FROM_HERE, |
1372 base::Bind(&HasOneRefTask, base::Unretained(&log), | 1373 base::Bind(&HasOneRefTask, base::Unretained(&log), |
1373 base::Unretained(task_queue.get()))); | 1374 base::Unretained(task_queue.get()))); |
1374 message_loop_->RunUntilIdle(); | 1375 message_loop_->RunUntilIdle(); |
1375 | 1376 |
1376 EXPECT_THAT(log, ElementsAre(false, false, true)); | 1377 EXPECT_THAT(log, ElementsAre(false, false, true)); |
1377 } | 1378 } |
1378 | 1379 |
1379 } // namespace scheduler | 1380 } // namespace scheduler |
OLD | NEW |