Move android_app_version_* into an inner variables dict.
[chromium-blink-merge.git] / base / test / sequenced_worker_pool_owner.cc
blob4486323344219db6e344ebe8135bd4ae8e922e5b
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();
47 // Release the reference to the callback to prevent retain cycles.
48 will_wait_for_shutdown_callback_ = Closure();
52 void SequencedWorkerPoolOwner::OnDestruct() {
53 constructor_message_loop_->PostTask(
54 FROM_HERE,
55 constructor_message_loop_->QuitWhenIdleClosure());
58 } // namespace base