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

Side by Side Diff: base/sequence_checker_impl.cc

Issue 1647803004: Move base to DEPS (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 4 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 | « base/sequence_checker_impl.h ('k') | base/sequence_checker_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "base/sequence_checker_impl.h"
6
7 namespace base {
8
9 SequenceCheckerImpl::SequenceCheckerImpl()
10 : sequence_token_assigned_(false) {
11 AutoLock auto_lock(lock_);
12 EnsureSequenceTokenAssigned();
13 }
14
15 SequenceCheckerImpl::~SequenceCheckerImpl() {}
16
17 bool SequenceCheckerImpl::CalledOnValidSequencedThread() const {
18 AutoLock auto_lock(lock_);
19 EnsureSequenceTokenAssigned();
20
21 // If this thread is not associated with a SequencedWorkerPool,
22 // SequenceChecker behaves as a ThreadChecker. See header for details.
23 if (!sequence_token_.IsValid())
24 return thread_checker_.CalledOnValidThread();
25
26 return sequence_token_.Equals(
27 SequencedWorkerPool::GetSequenceTokenForCurrentThread());
28 }
29
30 void SequenceCheckerImpl::DetachFromSequence() {
31 AutoLock auto_lock(lock_);
32 thread_checker_.DetachFromThread();
33 sequence_token_assigned_ = false;
34 sequence_token_ = SequencedWorkerPool::SequenceToken();
35 }
36
37 void SequenceCheckerImpl::EnsureSequenceTokenAssigned() const {
38 lock_.AssertAcquired();
39 if (sequence_token_assigned_)
40 return;
41
42 sequence_token_assigned_ = true;
43 sequence_token_ = SequencedWorkerPool::GetSequenceTokenForCurrentThread();
44 }
45
46 } // namespace base
OLDNEW
« no previous file with comments | « base/sequence_checker_impl.h ('k') | base/sequence_checker_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698