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 #ifndef BASE_THREADING_SEQUENCED_WORKER_POOL_UNITTEST_H_ | 5 #ifndef BASE_THREADING_SEQUENCED_WORKER_POOL_UNITTEST_H_ |
6 #define BASE_THREADING_SEQUENCED_WORKER_POOL_UNITTEST_H_ | 6 #define BASE_THREADING_SEQUENCED_WORKER_POOL_UNITTEST_H_ |
7 | 7 |
8 #include <cstddef> | 8 #include <cstddef> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 12 matching lines...) Expand all Loading... |
23 // until the pool is actually destroyed. This is so that a | 23 // until the pool is actually destroyed. This is so that a |
24 // SequencedWorkerPool from one test doesn't outlive its test and cause | 24 // SequencedWorkerPool from one test doesn't outlive its test and cause |
25 // strange races with other tests that touch global stuff (like histograms and | 25 // strange races with other tests that touch global stuff (like histograms and |
26 // logging). However, this requires that nothing else on this thread holds a | 26 // logging). However, this requires that nothing else on this thread holds a |
27 // ref to the pool when the SequencedWorkerPoolOwner is destroyed. | 27 // ref to the pool when the SequencedWorkerPoolOwner is destroyed. |
28 class SequencedWorkerPoolOwner : public SequencedWorkerPool::TestingObserver { | 28 class SequencedWorkerPoolOwner : public SequencedWorkerPool::TestingObserver { |
29 public: | 29 public: |
30 SequencedWorkerPoolOwner(size_t max_threads, | 30 SequencedWorkerPoolOwner(size_t max_threads, |
31 const std::string& thread_name_prefix); | 31 const std::string& thread_name_prefix); |
32 | 32 |
33 virtual ~SequencedWorkerPoolOwner(); | 33 ~SequencedWorkerPoolOwner() override; |
34 | 34 |
35 // Don't change the returned pool's testing observer. | 35 // Don't change the returned pool's testing observer. |
36 const scoped_refptr<SequencedWorkerPool>& pool(); | 36 const scoped_refptr<SequencedWorkerPool>& pool(); |
37 | 37 |
38 // The given callback will be called on WillWaitForShutdown(). | 38 // The given callback will be called on WillWaitForShutdown(). |
39 void SetWillWaitForShutdownCallback(const Closure& callback); | 39 void SetWillWaitForShutdownCallback(const Closure& callback); |
40 | 40 |
41 int has_work_call_count() const; | 41 int has_work_call_count() const; |
42 | 42 |
43 private: | 43 private: |
44 // SequencedWorkerPool::TestingObserver implementation. | 44 // SequencedWorkerPool::TestingObserver implementation. |
45 virtual void OnHasWork() override; | 45 void OnHasWork() override; |
46 virtual void WillWaitForShutdown() override; | 46 void WillWaitForShutdown() override; |
47 virtual void OnDestruct() override; | 47 void OnDestruct() override; |
48 | 48 |
49 MessageLoop* const constructor_message_loop_; | 49 MessageLoop* const constructor_message_loop_; |
50 scoped_refptr<SequencedWorkerPool> pool_; | 50 scoped_refptr<SequencedWorkerPool> pool_; |
51 Closure will_wait_for_shutdown_callback_; | 51 Closure will_wait_for_shutdown_callback_; |
52 | 52 |
53 mutable Lock has_work_lock_; | 53 mutable Lock has_work_lock_; |
54 int has_work_call_count_; | 54 int has_work_call_count_; |
55 | 55 |
56 DISALLOW_COPY_AND_ASSIGN(SequencedWorkerPoolOwner); | 56 DISALLOW_COPY_AND_ASSIGN(SequencedWorkerPoolOwner); |
57 }; | 57 }; |
58 | 58 |
59 } // namespace base | 59 } // namespace base |
60 | 60 |
61 #endif // BASE_THREADING_SEQUENCED_WORKER_POOL_UNITTEST_H_ | 61 #endif // BASE_THREADING_SEQUENCED_WORKER_POOL_UNITTEST_H_ |
OLD | NEW |