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

Side by Side Diff: base/sequence_checker_impl.cc

Issue 2788613004: Fix method naming in SequenceCheckerImpl::Core to match SequenceCheckerImpl::CalledOnValidSequence() (Closed)
Patch Set: Created 3 years, 8 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 | « no previous file | no next file » | 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 #include "base/sequence_checker_impl.h" 5 #include "base/sequence_checker_impl.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/memory/ptr_util.h" 8 #include "base/memory/ptr_util.h"
9 #include "base/sequence_token.h" 9 #include "base/sequence_token.h"
10 #include "base/threading/sequenced_worker_pool.h" 10 #include "base/threading/sequenced_worker_pool.h"
11 #include "base/threading/thread_checker_impl.h" 11 #include "base/threading/thread_checker_impl.h"
12 12
13 namespace base { 13 namespace base {
14 14
15 class SequenceCheckerImpl::Core { 15 class SequenceCheckerImpl::Core {
16 public: 16 public:
17 Core() 17 Core()
18 : sequence_token_(SequenceToken::GetForCurrentThread()), 18 : sequence_token_(SequenceToken::GetForCurrentThread()),
19 sequenced_worker_pool_token_( 19 sequenced_worker_pool_token_(
20 SequencedWorkerPool::GetSequenceTokenForCurrentThread()) { 20 SequencedWorkerPool::GetSequenceTokenForCurrentThread()) {
21 // SequencedWorkerPool doesn't use SequenceToken and code outside of 21 // SequencedWorkerPool doesn't use SequenceToken and code outside of
22 // SequenceWorkerPool doesn't set a SequencedWorkerPool token. 22 // SequenceWorkerPool doesn't set a SequencedWorkerPool token.
23 DCHECK(!sequence_token_.IsValid() || 23 DCHECK(!sequence_token_.IsValid() ||
24 !sequenced_worker_pool_token_.IsValid()); 24 !sequenced_worker_pool_token_.IsValid());
25 } 25 }
26 26
27 ~Core() = default; 27 ~Core() = default;
28 28
29 bool CalledOnValidThread() const { 29 bool CalledOnValidSequence() const {
30 if (sequence_token_.IsValid()) 30 if (sequence_token_.IsValid())
31 return sequence_token_ == SequenceToken::GetForCurrentThread(); 31 return sequence_token_ == SequenceToken::GetForCurrentThread();
32 32
33 if (sequenced_worker_pool_token_.IsValid()) { 33 if (sequenced_worker_pool_token_.IsValid()) {
34 return sequenced_worker_pool_token_.Equals( 34 return sequenced_worker_pool_token_.Equals(
35 SequencedWorkerPool::GetSequenceTokenForCurrentThread()); 35 SequencedWorkerPool::GetSequenceTokenForCurrentThread());
36 } 36 }
37 37
38 // SequenceChecker behaves as a ThreadChecker when it is not bound to a 38 // SequenceChecker behaves as a ThreadChecker when it is not bound to a
39 // valid sequence token. 39 // valid sequence token.
(...skipping 11 matching lines...) Expand all
51 ThreadCheckerImpl thread_checker_; 51 ThreadCheckerImpl thread_checker_;
52 }; 52 };
53 53
54 SequenceCheckerImpl::SequenceCheckerImpl() : core_(MakeUnique<Core>()) {} 54 SequenceCheckerImpl::SequenceCheckerImpl() : core_(MakeUnique<Core>()) {}
55 SequenceCheckerImpl::~SequenceCheckerImpl() = default; 55 SequenceCheckerImpl::~SequenceCheckerImpl() = default;
56 56
57 bool SequenceCheckerImpl::CalledOnValidSequence() const { 57 bool SequenceCheckerImpl::CalledOnValidSequence() const {
58 AutoLock auto_lock(lock_); 58 AutoLock auto_lock(lock_);
59 if (!core_) 59 if (!core_)
60 core_ = MakeUnique<Core>(); 60 core_ = MakeUnique<Core>();
61 return core_->CalledOnValidThread(); 61 return core_->CalledOnValidSequence();
62 } 62 }
63 63
64 void SequenceCheckerImpl::DetachFromSequence() { 64 void SequenceCheckerImpl::DetachFromSequence() {
65 AutoLock auto_lock(lock_); 65 AutoLock auto_lock(lock_);
66 core_.reset(); 66 core_.reset();
67 } 67 }
68 68
69 } // namespace base 69 } // namespace base
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698