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

Unified Diff: base/memory/weak_ptr.cc

Issue 11564003: Make WeakPtr use SequenceChecker instead of ThreadChecker (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Sync to head Created 7 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 side-by-side diff with in-line comments
Download patch
Index: base/memory/weak_ptr.cc
diff --git a/base/memory/weak_ptr.cc b/base/memory/weak_ptr.cc
index 9dec8fd6db9c29956673a79326efa4b22af2f3ad..e4e43b1d1b21e7ae5f6a0484d0835eae26d88c12 100644
--- a/base/memory/weak_ptr.cc
+++ b/base/memory/weak_ptr.cc
@@ -3,25 +3,33 @@
// found in the LICENSE file.
#include "base/memory/weak_ptr.h"
+#include "base/single_thread_task_runner.h"
+#include "base/thread_task_runner_handle.h"
namespace base {
namespace internal {
-WeakReference::Flag::Flag() : is_valid_(true) {
+WeakReference::Flag::Flag()
+ : sequence_checker_(ThreadTaskRunnerHandle::GetIfExists()),
+ is_valid_(true) {
}
void WeakReference::Flag::Invalidate() {
// The flag being invalidated with a single ref implies that there are no
// weak pointers in existence. Allow deletion on other thread in this case.
- DCHECK(thread_checker_.CalledOnValidThread() || HasOneRef());
+ DCHECK(sequence_checker_.CalledInSequence() || HasOneRef());
jar (doing other things) 2013/02/16 02:37:27 nit: Although the semantics may be as intended (to
is_valid_ = false;
}
bool WeakReference::Flag::IsValid() const {
- DCHECK(thread_checker_.CalledOnValidThread());
+ DCHECK(sequence_checker_.CalledInSequence());
return is_valid_;
}
+void WeakReference::Flag::DetachFromThread() {
+ sequence_checker_.ChangeSequence(ThreadTaskRunnerHandle::GetIfExists());
jar (doing other things) 2013/02/16 02:37:27 nit: This "ChangeSequence" also seems confusing :-
+}
+
WeakReference::Flag::~Flag() {
}

Powered by Google App Engine
This is Rietveld 408576698