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

Side by Side Diff: base/sequence_checker_impl.h

Issue 2694813005: Revert of Remove header dependencies from sequence_checker.h to sequenced_worker_pool.h (Closed)
Patch Set: Created 3 years, 10 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
« no previous file with comments | « ash/shell.cc ('k') | base/sequence_checker_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_SEQUENCE_CHECKER_IMPL_H_ 5 #ifndef BASE_SEQUENCE_CHECKER_IMPL_H_
6 #define BASE_SEQUENCE_CHECKER_IMPL_H_ 6 #define BASE_SEQUENCE_CHECKER_IMPL_H_
7 7
8 #include <memory>
9
10 #include "base/base_export.h" 8 #include "base/base_export.h"
11 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
12 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "base/sequence_token.h"
13 #include "base/synchronization/lock.h" 12 #include "base/synchronization/lock.h"
13 #include "base/threading/sequenced_worker_pool.h"
14 #include "base/threading/thread_checker_impl.h"
14 15
15 namespace base { 16 namespace base {
16 17
17 // Real implementation of SequenceChecker for use in debug mode or for temporary 18 // Real implementation of SequenceChecker for use in debug mode or for temporary
18 // use in release mode (e.g. to CHECK on a threading issue seen only in the 19 // use in release mode (e.g. to CHECK on a threading issue seen only in the
19 // wild). 20 // wild).
20 // 21 //
21 // Note: You should almost always use the SequenceChecker class to get the right 22 // Note: You should almost always use the SequenceChecker class to get the right
22 // version for your build configuration. 23 // version for your build configuration.
23 class BASE_EXPORT SequenceCheckerImpl { 24 class BASE_EXPORT SequenceCheckerImpl {
24 public: 25 public:
25 SequenceCheckerImpl(); 26 SequenceCheckerImpl();
26 ~SequenceCheckerImpl(); 27 ~SequenceCheckerImpl();
27 28
28 // Returns true if called in sequence with previous calls to this method and 29 // Returns true if called in sequence with previous calls to this method and
29 // the constructor. 30 // the constructor.
30 bool CalledOnValidSequence() const WARN_UNUSED_RESULT; 31 bool CalledOnValidSequence() const WARN_UNUSED_RESULT;
31 32
32 // Unbinds the checker from the currently associated sequence. The checker 33 // Unbinds the checker from the currently associated sequence. The checker
33 // will be re-bound on the next call to CalledOnValidSequence(). 34 // will be re-bound on the next call to CalledOnValidSequence().
34 void DetachFromSequence(); 35 void DetachFromSequence();
35 36
36 private: 37 private:
37 class Core; 38 void EnsureSequenceTokenAssigned() const;
38 39
39 // Guards all variables below. 40 // Guards all variables below.
40 mutable Lock lock_; 41 mutable Lock lock_;
41 mutable std::unique_ptr<Core> core_; 42
43 // True when the SequenceChecker is bound to a sequence or a thread.
44 mutable bool is_assigned_ = false;
45
46 mutable SequenceToken sequence_token_;
47
48 // TODO(gab): Remove this when SequencedWorkerPool is deprecated in favor of
49 // TaskScheduler. crbug.com/622400
50 mutable SequencedWorkerPool::SequenceToken sequenced_worker_pool_token_;
51
52 // Used when |sequenced_worker_pool_token_| and |sequence_token_| are invalid.
53 ThreadCheckerImpl thread_checker_;
42 54
43 DISALLOW_COPY_AND_ASSIGN(SequenceCheckerImpl); 55 DISALLOW_COPY_AND_ASSIGN(SequenceCheckerImpl);
44 }; 56 };
45 57
46 } // namespace base 58 } // namespace base
47 59
48 #endif // BASE_SEQUENCE_CHECKER_IMPL_H_ 60 #endif // BASE_SEQUENCE_CHECKER_IMPL_H_
OLDNEW
« no previous file with comments | « ash/shell.cc ('k') | base/sequence_checker_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698