summaryrefslogtreecommitdiffstats
path: root/base/revocable_store.cc
diff options
context:
space:
mode:
authordarin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-25 23:34:34 +0000
committerdarin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-25 23:34:34 +0000
commit59326aacf6020c3cfa8978a334c36b2dcc1a99bb (patch)
tree698940cee180d498131c98b9efbb2de30b642161 /base/revocable_store.cc
parent754f7e974507e71f6ac40eec66bcb73f13d868c6 (diff)
downloadchromium_src-59326aacf6020c3cfa8978a334c36b2dcc1a99bb.zip
chromium_src-59326aacf6020c3cfa8978a334c36b2dcc1a99bb.tar.gz
chromium_src-59326aacf6020c3cfa8978a334c36b2dcc1a99bb.tar.bz2
Implement ScopedRunnableMethodFactory using WeakPtr.
This required some changes to WeakPtr to support the addition of WeakPtrFactory::HasWeakPtrs(), which is used to implement ScopedRunnableMethodFactory::empty(). Now, the WeakReferenceOwner just holds a pointer to the Flag class, and the Flag holds a back-pointer that it can use to clear the WeakReferenceOwner's pointer when the Flag is destroyed. I use the null'ness of this back-pointer in place of the bool member that was previously used to indicate if the WeakReference is valid. It was also necessary to expose a HasOneRef method on RefCounted. I included one on RefCountedThreadSafe for completeness. Finally, I switched HttpCache over to using WeakPtr instead of RevocableStore so that I could delete RevocableStore. (I'm making this change to consolidate similar functionality.) R=abarth BUG=none TEST=none Review URL: http://codereview.chromium.org/235027 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@27287 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/revocable_store.cc')
-rw-r--r--base/revocable_store.cc47
1 files changed, 0 insertions, 47 deletions
diff --git a/base/revocable_store.cc b/base/revocable_store.cc
deleted file mode 100644
index 400b2dd..0000000
--- a/base/revocable_store.cc
+++ /dev/null
@@ -1,47 +0,0 @@
-// Copyright (c) 2006-2008 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/revocable_store.h"
-
-#include "base/logging.h"
-
-RevocableStore::Revocable::Revocable(RevocableStore* store)
- : store_reference_(store->owning_reference_) {
- // We AddRef() the owning reference.
- DCHECK(store_reference_->store());
- store_reference_->store()->Add(this);
-}
-
-RevocableStore::Revocable::~Revocable() {
- if (!revoked()) {
- // Notify the store of our destruction.
- --(store_reference_->store()->count_);
- }
-}
-
-RevocableStore::RevocableStore() : count_(0) {
- // Create a new owning reference.
- owning_reference_ = new StoreRef(this);
-}
-
-RevocableStore::~RevocableStore() {
- // Revoke all the items in the store.
- owning_reference_->set_store(NULL);
-}
-
-void RevocableStore::Add(Revocable* item) {
- DCHECK(!item->revoked());
- ++count_;
-}
-
-void RevocableStore::RevokeAll() {
- // We revoke all the existing items in the store and reset our count.
- owning_reference_->set_store(NULL);
- count_ = 0;
-
- // Then we create a new owning reference for new items that get added.
- // This Release()s the old owning reference, allowing it to be freed after
- // all the items that were in the store are eventually destroyed.
- owning_reference_ = new StoreRef(this);
-}