OLD | NEW |
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_worker_pool_owner.h" | 5 #include "base/test/sequenced_worker_pool_owner.h" |
6 | 6 |
7 #include "base/location.h" | 7 #include "base/location.h" |
8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "base/single_thread_task_runner.h" |
9 | 10 |
10 namespace base { | 11 namespace base { |
11 | 12 |
12 SequencedWorkerPoolOwner::SequencedWorkerPoolOwner( | 13 SequencedWorkerPoolOwner::SequencedWorkerPoolOwner( |
13 size_t max_threads, | 14 size_t max_threads, |
14 const std::string& thread_name_prefix) | 15 const std::string& thread_name_prefix) |
15 : constructor_message_loop_(MessageLoop::current()), | 16 : constructor_message_loop_(MessageLoop::current()), |
16 pool_(new SequencedWorkerPool(max_threads, thread_name_prefix, this)), | 17 pool_(new SequencedWorkerPool(max_threads, thread_name_prefix, this)), |
17 has_work_call_count_(0) {} | 18 has_work_call_count_(0) {} |
18 | 19 |
(...skipping 24 matching lines...) Expand all Loading... |
43 void SequencedWorkerPoolOwner::WillWaitForShutdown() { | 44 void SequencedWorkerPoolOwner::WillWaitForShutdown() { |
44 if (!will_wait_for_shutdown_callback_.is_null()) { | 45 if (!will_wait_for_shutdown_callback_.is_null()) { |
45 will_wait_for_shutdown_callback_.Run(); | 46 will_wait_for_shutdown_callback_.Run(); |
46 | 47 |
47 // Release the reference to the callback to prevent retain cycles. | 48 // Release the reference to the callback to prevent retain cycles. |
48 will_wait_for_shutdown_callback_ = Closure(); | 49 will_wait_for_shutdown_callback_ = Closure(); |
49 } | 50 } |
50 } | 51 } |
51 | 52 |
52 void SequencedWorkerPoolOwner::OnDestruct() { | 53 void SequencedWorkerPoolOwner::OnDestruct() { |
53 constructor_message_loop_->PostTask( | 54 constructor_message_loop_->task_runner()->PostTask( |
54 FROM_HERE, | 55 FROM_HERE, constructor_message_loop_->QuitWhenIdleClosure()); |
55 constructor_message_loop_->QuitWhenIdleClosure()); | |
56 } | 56 } |
57 | 57 |
58 } // namespace base | 58 } // namespace base |
OLD | NEW |