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.
5 #include "base/sequence_checker_impl.h"
7 #include "base/sequenced_task_runner.h"
11 SequenceCheckerImpl::SequenceCheckerImpl(
12 const scoped_refptr
<SequencedTaskRunner
>& sequenced_task_runner
)
13 : sequenced_task_runner_(sequenced_task_runner
) {}
15 SequenceCheckerImpl::~SequenceCheckerImpl() {}
17 bool SequenceCheckerImpl::CalledOnValidSequence() const {
18 AutoLock
auto_lock(lock_
);
19 return sequenced_task_runner_
.get() ?
20 sequenced_task_runner_
->RunsTasksOnCurrentThread() :
21 thread_checker_
.CalledOnValidThread();
24 void SequenceCheckerImpl::ChangeSequence(
25 const scoped_refptr
<SequencedTaskRunner
>& sequenced_task_runner
) {
26 AutoLock
auto_lock(lock_
);
27 sequenced_task_runner_
= sequenced_task_runner
;
28 thread_checker_
.DetachFromThread();