summaryrefslogtreecommitdiffstats
path: root/base/sequence_checker_impl.h
diff options
context:
space:
mode:
authorvandebo@chromium.org <vandebo@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-07-20 11:51:28 +0000
committervandebo@chromium.org <vandebo@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-07-20 11:51:28 +0000
commit87738f7d5cdb54e524520144f28baa78e38098e2 (patch)
tree3c1db8b038a88450c85a4703b5f399ad9e23f942 /base/sequence_checker_impl.h
parenta077da7b45007de882a8d843ad084ff2eba14c2f (diff)
downloadchromium_src-87738f7d5cdb54e524520144f28baa78e38098e2.zip
chromium_src-87738f7d5cdb54e524520144f28baa78e38098e2.tar.gz
chromium_src-87738f7d5cdb54e524520144f28baa78e38098e2.tar.bz2
Revert 211956 "base: Change WeakPtr to use SequenceChecker inste..."
As well as revert 212725 "base: Make SequenceChecker death tests multi-threads work correctly." See http://crbug.com/261448 > base: Change WeakPtr to use SequenceChecker instead of ThreadChecker. > > This will enable WeakPtr to be used in SequencedWorkerPool, et al. with a sequence token. > > This is a continuation of issue: https://chromiumcodereview.appspot.com/18231002/ > > The original issue got messed up by a rietveld bug, so refer there for history and comments. > > BUG=165590 > > Review URL: https://chromiumcodereview.appspot.com/18501008 TBR=tommycli@chromium.org Review URL: https://chromiumcodereview.appspot.com/19695005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@212780 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/sequence_checker_impl.h')
-rw-r--r--base/sequence_checker_impl.h42
1 files changed, 24 insertions, 18 deletions
diff --git a/base/sequence_checker_impl.h b/base/sequence_checker_impl.h
index 741aafe..ccd1198 100644
--- a/base/sequence_checker_impl.h
+++ b/base/sequence_checker_impl.h
@@ -7,42 +7,48 @@
#include "base/base_export.h"
#include "base/basictypes.h"
+#include "base/memory/ref_counted.h"
#include "base/synchronization/lock.h"
-#include "base/threading/sequenced_worker_pool.h"
#include "base/threading/thread_checker_impl.h"
namespace base {
+class SequencedTaskRunner;
+
// SequenceCheckerImpl is used to help verify that some methods of a
// class are called in sequence -- that is, called from the same
// SequencedTaskRunner. It is a generalization of ThreadChecker; in
-// particular, it behaves exactly like ThreadChecker if constructed
-// on a thread that is not part of a SequencedWorkerPool.
+// particular, it behaves exactly like ThreadChecker if its passed a
+// NULL SequencedTaskRunner.
class BASE_EXPORT SequenceCheckerImpl {
public:
- SequenceCheckerImpl();
+ // |sequenced_task_runner| can be NULL. In that case, this object
+ // behaves exactly like a ThreadChecker bound to the current thread,
+ // i.e. CalledOnValidSequence() behaves like CalledOnValidThread().
+ explicit SequenceCheckerImpl(
+ const scoped_refptr<SequencedTaskRunner>& sequenced_task_runner);
~SequenceCheckerImpl();
- // Returns whether the we are being called on the same sequence token
- // as previous calls. If there is no associated sequence, then returns
- // whether we are being called on the underlying ThreadChecker's thread.
- bool CalledOnValidSequencedThread() const;
+ // Returns whether the we are being called on the underyling
+ // SequencedTaskRunner. If we're not bound to a
+ // |sequenced_task_runner|, returns whether we are being called on
+ // the underlying ThreadChecker's thread.
+ bool CalledOnValidSequence() const;
- // Unbinds the checker from the currently associated sequence. The
- // checker will be re-bound on the next call to CalledOnValidSequence().
- void DetachFromSequence();
+ // Changes the underyling SequencedTaskRunner.
+ // |sequenced_task_runner| can be NULL. In that case, this object
+ // behaves exactly like a ThreadChecker that has been detached from
+ // its thread, i.e. we will be bound to the thread on which we next
+ // call CalledOnValidSequence().
+ void ChangeSequence(
+ const scoped_refptr<SequencedTaskRunner>& sequenced_task_runner);
private:
- void EnsureSequenceTokenAssigned() const;
-
// Guards all variables below.
mutable Lock lock_;
-
- // Used if |sequence_token_| is not valid.
+ scoped_refptr<SequencedTaskRunner> sequenced_task_runner_;
+ // Used if |sequenced_task_runner_| is NULL.
ThreadCheckerImpl thread_checker_;
- mutable bool sequence_token_assigned_;
-
- mutable SequencedWorkerPool::SequenceToken sequence_token_;
DISALLOW_COPY_AND_ASSIGN(SequenceCheckerImpl);
};