| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/deferred_sequenced_task_runner.h" | 5 #include "base/deferred_sequenced_task_runner.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/location.h" | 9 #include "base/location.h" |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| 11 #include "base/message_loop/message_loop.h" | 11 #include "base/message_loop/message_loop.h" |
| 12 #include "base/run_loop.h" | 12 #include "base/run_loop.h" |
| 13 #include "base/single_thread_task_runner.h" | 13 #include "base/single_thread_task_runner.h" |
| 14 #include "base/threading/non_thread_safe.h" | |
| 15 #include "base/threading/thread.h" | 14 #include "base/threading/thread.h" |
| 16 #include "testing/gmock/include/gmock/gmock.h" | 15 #include "testing/gmock/include/gmock/gmock.h" |
| 17 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
| 18 | 17 |
| 19 namespace { | 18 namespace { |
| 20 | 19 |
| 21 class DeferredSequencedTaskRunnerTest : public testing::Test, | 20 class DeferredSequencedTaskRunnerTest : public testing::Test { |
| 22 public base::NonThreadSafe { | |
| 23 public: | 21 public: |
| 24 class ExecuteTaskOnDestructor : | 22 class ExecuteTaskOnDestructor : |
| 25 public base::RefCounted<ExecuteTaskOnDestructor> { | 23 public base::RefCounted<ExecuteTaskOnDestructor> { |
| 26 public: | 24 public: |
| 27 ExecuteTaskOnDestructor( | 25 ExecuteTaskOnDestructor( |
| 28 DeferredSequencedTaskRunnerTest* executor, | 26 DeferredSequencedTaskRunnerTest* executor, |
| 29 int task_id) | 27 int task_id) |
| 30 : executor_(executor), | 28 : executor_(executor), |
| 31 task_id_(task_id) { | 29 task_id_(task_id) { |
| 32 } | 30 } |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 StartRunner(); | 168 StartRunner(); |
| 171 } | 169 } |
| 172 | 170 |
| 173 // All |short_lived_object| with id |2 * i| are destroyed before the task | 171 // All |short_lived_object| with id |2 * i| are destroyed before the task |
| 174 // |2 * i + 1| is executed. | 172 // |2 * i + 1| is executed. |
| 175 EXPECT_THAT(executed_task_ids_, | 173 EXPECT_THAT(executed_task_ids_, |
| 176 testing::ElementsAre(0, 1, 2, 3, 4, 5, 6, 7, 8, 9)); | 174 testing::ElementsAre(0, 1, 2, 3, 4, 5, 6, 7, 8, 9)); |
| 177 } | 175 } |
| 178 | 176 |
| 179 } // namespace | 177 } // namespace |
| OLD | NEW |