Revert 246124 "gn: Fix clang plugin on ios."
[chromium-blink-merge.git] / base / test / sequenced_worker_pool_owner.cc
blobf6a0d013011b0b12049ab0a59b3785fc725ced60
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
3 // found in the LICENSE file.
5 #include "base/test/sequenced_worker_pool_owner.h"
7 #include "base/location.h"
8 #include "base/message_loop/message_loop.h"
10 namespace base {
12 SequencedWorkerPoolOwner::SequencedWorkerPoolOwner(
13 size_t max_threads,
14 const std::string& thread_name_prefix)
15 : constructor_message_loop_(MessageLoop::current()),
16 pool_(new SequencedWorkerPool(max_threads, thread_name_prefix, this)),
17 has_work_call_count_(0) {}
19 SequencedWorkerPoolOwner::~SequencedWorkerPoolOwner() {
20 pool_ = NULL;
21 MessageLoop::current()->Run();
24 const scoped_refptr<SequencedWorkerPool>& SequencedWorkerPoolOwner::pool() {
25 return pool_;
28 void SequencedWorkerPoolOwner::SetWillWaitForShutdownCallback(
29 const Closure& callback) {
30 will_wait_for_shutdown_callback_ = callback;
33 int SequencedWorkerPoolOwner::has_work_call_count() const {
34 AutoLock lock(has_work_lock_);
35 return has_work_call_count_;
38 void SequencedWorkerPoolOwner::OnHasWork() {
39 AutoLock lock(has_work_lock_);
40 ++has_work_call_count_;
43 void SequencedWorkerPoolOwner::WillWaitForShutdown() {
44 if (!will_wait_for_shutdown_callback_.is_null()) {
45 will_wait_for_shutdown_callback_.Run();
49 void SequencedWorkerPoolOwner::OnDestruct() {
50 constructor_message_loop_->PostTask(
51 FROM_HERE,
52 constructor_message_loop_->QuitWhenIdleClosure());
55 } // namespace base