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

Unified Diff: base/memory/weak_ptr.cc

Issue 1647803004: Move base to DEPS (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 4 years, 11 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
« no previous file with comments | « base/memory/weak_ptr.h ('k') | base/memory/weak_ptr_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/memory/weak_ptr.cc
diff --git a/base/memory/weak_ptr.cc b/base/memory/weak_ptr.cc
deleted file mode 100644
index d9ce86ad18901a0719255c031fae1a1357ad1f2f..0000000000000000000000000000000000000000
--- a/base/memory/weak_ptr.cc
+++ /dev/null
@@ -1,77 +0,0 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "base/memory/weak_ptr.h"
-
-namespace base {
-namespace internal {
-
-WeakReference::Flag::Flag() : is_valid_(true) {
- // Flags only become bound when checked for validity, or invalidated,
- // so that we can check that later validity/invalidation operations on
- // the same Flag take place on the same sequenced thread.
- sequence_checker_.DetachFromSequence();
-}
-
-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(sequence_checker_.CalledOnValidSequencedThread() || HasOneRef())
- << "WeakPtrs must be invalidated on the same sequenced thread.";
- is_valid_ = false;
-}
-
-bool WeakReference::Flag::IsValid() const {
- DCHECK(sequence_checker_.CalledOnValidSequencedThread())
- << "WeakPtrs must be checked on the same sequenced thread.";
- return is_valid_;
-}
-
-WeakReference::Flag::~Flag() {
-}
-
-WeakReference::WeakReference() {
-}
-
-WeakReference::WeakReference(const Flag* flag) : flag_(flag) {
-}
-
-WeakReference::~WeakReference() {
-}
-
-bool WeakReference::is_valid() const { return flag_.get() && flag_->IsValid(); }
-
-WeakReferenceOwner::WeakReferenceOwner() {
-}
-
-WeakReferenceOwner::~WeakReferenceOwner() {
- Invalidate();
-}
-
-WeakReference WeakReferenceOwner::GetRef() const {
- // If we hold the last reference to the Flag then create a new one.
- if (!HasRefs())
- flag_ = new WeakReference::Flag();
-
- return WeakReference(flag_.get());
-}
-
-void WeakReferenceOwner::Invalidate() {
- if (flag_.get()) {
- flag_->Invalidate();
- flag_ = NULL;
- }
-}
-
-WeakPtrBase::WeakPtrBase() {
-}
-
-WeakPtrBase::~WeakPtrBase() {
-}
-
-WeakPtrBase::WeakPtrBase(const WeakReference& ref) : ref_(ref) {
-}
-
-} // namespace internal
-} // namespace base
« no previous file with comments | « base/memory/weak_ptr.h ('k') | base/memory/weak_ptr_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698