Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(532)

Side by Side Diff: base/threading/sequenced_worker_pool_unittest.h

Issue 9663075: Implementation of SequencedTaskRunner based on SequencedWorkerPool. (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
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.
4
5 #ifndef BASE_THREADING_SEQUENCED_WORKER_POOL_UNITTEST_H_
6 #define BASE_THREADING_SEQUENCED_WORKER_POOL_UNITTEST_H_
7
8 #include "base/callback.h"
9 #include "base/threading/sequenced_worker_pool.h"
10
11 class MessageLoop;
12
13 namespace base {
14
15 // Wrapper around SequencedWorkerPool that blocks destruction until
16 // the pool is actually destroyed. This is so that a
17 // SequencedWorkerPool from one test doesn't outlive its test and
18 // cause strange races with other tests that touch global stuff (like
19 // histograms and logging). However, this requires that nothing else
20 // on this thread holds a ref to the pool when the
21 // SequencedWorkerPoolOwner is destroyed.
22 class SequencedWorkerPoolOwner : public SequencedWorkerPool::TestingObserver {
23 public:
24 SequencedWorkerPoolOwner(size_t max_threads,
25 const std::string& thread_name_prefix);
26
27 virtual ~SequencedWorkerPoolOwner();
28
29 // Don't change the return pool's testing observer.
30 const scoped_refptr<SequencedWorkerPool>& pool();
31
32 // The given callback will be called on WillWaitForShutdown().
33 void SetWillWaitForShutdownCallback(const Closure& callback);
34
35 private:
36 // SequencedWorkerPool::TestingObserver implementation.
37 virtual void WillWaitForShutdown() OVERRIDE;
38 virtual void OnDestruct() OVERRIDE;
39
40 MessageLoop* const constructor_message_loop_;
41 scoped_refptr<SequencedWorkerPool> pool_;
42 // TODO(francoisk777@gmail.com) Make this a scoped_ptr and forward-declare?
43 // Perhaps not worth the trouble as this header will only be included in a
44 // few places.
45 Closure will_wait_for_shutdown_callback_;
46
47 DISALLOW_COPY_AND_ASSIGN(SequencedWorkerPoolOwner);
48 };
49
50 } // namespace base
51
52 #endif // BASE_THREADING_SEQUENCED_WORKER_POOL_UNITTEST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698