diff options
author | erg@chromium.org <erg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-15 21:03:54 +0000 |
---|---|---|
committer | erg@chromium.org <erg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-15 21:03:54 +0000 |
commit | 3a3d4747769aec2954a2ca21de4812c5892994aa (patch) | |
tree | db112f2c73cc39e9d6088059eae1fc9d35b74920 /base/weak_ptr.h | |
parent | 2235b22b88260fde392b753b5d7bb7904e5efbc6 (diff) | |
download | chromium_src-3a3d4747769aec2954a2ca21de4812c5892994aa.zip chromium_src-3a3d4747769aec2954a2ca21de4812c5892994aa.tar.gz chromium_src-3a3d4747769aec2954a2ca21de4812c5892994aa.tar.bz2 |
Move implementation from header to source.
This is an effort to speed up compile and link time, and also minimizing the
size of the intermediary .o files on disk. For example, just moving the
constructor/destructor from the classes in chrome/browser/pref_member.{cc,h}
netted a 368k drop in total .o file size. In aggregate, this shrinks
libbrowser.a by 10 megabytes, and a few odd megabytes on most other chrome .a files.
A lot of this was done before I started harvesting what the most included
symbols were across all of chrome's code. Most of them are in webkit, but
there's plenty in base/ that are used everywhere to keep me busy for several
patches to come.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/3012001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@52528 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/weak_ptr.h')
-rw-r--r-- | base/weak_ptr.h | 54 |
1 files changed, 13 insertions, 41 deletions
diff --git a/base/weak_ptr.h b/base/weak_ptr.h index 1bc963e..85a26d16 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_; }; |