| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/location.h" | 10 #include "base/location.h" |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 make_scoped_ptr(new TestTimeSource(now_src_.get()))); | 65 make_scoped_ptr(new TestTimeSource(now_src_.get()))); |
| 66 manager_ = make_scoped_ptr(new TaskQueueManager( | 66 manager_ = make_scoped_ptr(new TaskQueueManager( |
| 67 main_task_runner_, "test.scheduler", "test.scheduler", | 67 main_task_runner_, "test.scheduler", "test.scheduler", |
| 68 "test.scheduler.debug")); | 68 "test.scheduler.debug")); |
| 69 | 69 |
| 70 for (size_t i = 0; i < num_queues; i++) | 70 for (size_t i = 0; i < num_queues; i++) |
| 71 runners_.push_back(manager_->NewTaskQueue(TaskQueue::Spec("test_queue"))); | 71 runners_.push_back(manager_->NewTaskQueue(TaskQueue::Spec("test_queue"))); |
| 72 } | 72 } |
| 73 | 73 |
| 74 void Initialize(size_t num_queues) { | 74 void Initialize(size_t num_queues) { |
| 75 now_src_.reset(new base::SimpleTestTickClock()); | 75 now_src_.reset(new base::SimpleTestTickClock( |
| 76 now_src_->Advance(base::TimeDelta::FromMicroseconds(1000)); | 76 base::TimeTicks() + base::TimeDelta::FromMicroseconds(1000))); |
| 77 InitializeWithClock(num_queues, | 77 InitializeWithClock(num_queues, |
| 78 make_scoped_ptr(new TestTimeSource(now_src_.get()))); | 78 make_scoped_ptr(new TestTimeSource(now_src_.get()))); |
| 79 } | 79 } |
| 80 | 80 |
| 81 void InitializeWithRealMessageLoop(size_t num_queues) { | 81 void InitializeWithRealMessageLoop(size_t num_queues) { |
| 82 now_src_.reset(new base::SimpleTestTickClock()); | 82 now_src_.reset(new base::SimpleTestTickClock(base::TimeTicks())); |
| 83 message_loop_.reset(new base::MessageLoop()); | 83 message_loop_.reset(new base::MessageLoop()); |
| 84 manager_ = make_scoped_ptr(new TaskQueueManager( | 84 manager_ = make_scoped_ptr(new TaskQueueManager( |
| 85 MessageLoopTaskRunner::Create( | 85 MessageLoopTaskRunner::Create( |
| 86 make_scoped_ptr(new TestTimeSource(now_src_.get()))), | 86 make_scoped_ptr(new TestTimeSource(now_src_.get()))), |
| 87 "test.scheduler", "test.scheduler", "test.scheduler.debug")); | 87 "test.scheduler", "test.scheduler", "test.scheduler.debug")); |
| 88 | 88 |
| 89 for (size_t i = 0; i < num_queues; i++) | 89 for (size_t i = 0; i < num_queues; i++) |
| 90 runners_.push_back(manager_->NewTaskQueue(TaskQueue::Spec("test_queue"))); | 90 runners_.push_back(manager_->NewTaskQueue(TaskQueue::Spec("test_queue"))); |
| 91 } | 91 } |
| 92 | 92 |
| (...skipping 1606 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1699 double ratio = static_cast<double>(linear_delayed_task.count()) / | 1699 double ratio = static_cast<double>(linear_delayed_task.count()) / |
| 1700 static_cast<double>(quadratic_immediate_task.count()); | 1700 static_cast<double>(quadratic_immediate_task.count()); |
| 1701 | 1701 |
| 1702 // This is by design, we want to enforce a strict ordering in task execution | 1702 // This is by design, we want to enforce a strict ordering in task execution |
| 1703 // where by delayed tasks can not skip ahead of non-delayed work. | 1703 // where by delayed tasks can not skip ahead of non-delayed work. |
| 1704 EXPECT_GT(ratio, 0.0); | 1704 EXPECT_GT(ratio, 0.0); |
| 1705 EXPECT_LT(ratio, 0.1); | 1705 EXPECT_LT(ratio, 0.1); |
| 1706 } | 1706 } |
| 1707 | 1707 |
| 1708 } // namespace scheduler | 1708 } // namespace scheduler |
| OLD | NEW |