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

Unified Diff: base/weak_ptr.h

Issue 3012001: Move implementation from header to source. (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: blank line Created 10 years, 5 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
« base/tracked.h ('K') | « base/values.cc ('k') | base/weak_ptr.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/weak_ptr.h
diff --git a/base/weak_ptr.h b/base/weak_ptr.h
index 1bc963e7ef65e19514191e727646c59fd945bcad..85a26d162c80003a7bc6bd588eafe05bd9fb588d 100644
--- a/base/weak_ptr.h
+++ b/base/weak_ptr.h
@@ -65,24 +65,11 @@ class WeakReference {
public:
class Flag : public RefCounted<Flag>, public NonThreadSafe {
public:
- Flag(Flag** handle) : handle_(handle) {
- }
-
- ~Flag() {
- if (handle_)
- *handle_ = NULL;
- }
-
- void AddRef() {
- DCHECK(CalledOnValidThread());
- RefCounted<Flag>::AddRef();
- }
-
- void Release() {
- DCHECK(CalledOnValidThread());
- RefCounted<Flag>::Release();
- }
+ Flag(Flag** handle);
+ ~Flag();
+ void AddRef();
+ void Release();
void Invalidate() { handle_ = NULL; }
bool is_valid() const { return handle_ != NULL; }
@@ -90,10 +77,10 @@ class WeakReference {
Flag** handle_;
};
- WeakReference() {}
- WeakReference(Flag* flag) : flag_(flag) {}
+ WeakReference();
+ WeakReference(Flag* flag);
- bool is_valid() const { return flag_ && flag_->is_valid(); }
+ bool is_valid() const;
private:
scoped_refptr<Flag> flag_;
@@ -101,29 +88,16 @@ class WeakReference {
class WeakReferenceOwner {
public:
- WeakReferenceOwner() : flag_(NULL) {
- }
-
- ~WeakReferenceOwner() {
- Invalidate();
- }
+ WeakReferenceOwner();
+ ~WeakReferenceOwner();
- WeakReference GetRef() const {
- if (!flag_)
- flag_ = new WeakReference::Flag(&flag_);
- return WeakReference(flag_);
- }
+ WeakReference GetRef() const;
bool HasRefs() const {
return flag_ != NULL;
}
- void Invalidate() {
- if (flag_) {
- flag_->Invalidate();
- flag_ = NULL;
- }
- }
+ void Invalidate();
private:
mutable WeakReference::Flag* flag_;
@@ -135,12 +109,10 @@ class WeakReferenceOwner {
// base class gives us a way to access ref_ in a protected fashion.
class WeakPtrBase {
public:
- WeakPtrBase() {
- }
+ WeakPtrBase();
protected:
- WeakPtrBase(const WeakReference& ref) : ref_(ref) {
- }
+ WeakPtrBase(const WeakReference& ref);
WeakReference ref_;
};
« base/tracked.h ('K') | « base/values.cc ('k') | base/weak_ptr.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698