summaryrefslogtreecommitdiffstats
path: root/base/weak_ptr.h
Commit message (Collapse)AuthorAgeFilesLines
* Implement ScopedRunnableMethodFactory using WeakPtr.darin@chromium.org2009-09-251-33/+47
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Make WeakPtr harder to misuse.phajdan.jr@chromium.org2009-09-171-2/+20
| | | | | | | | | | | | Well, I managed to misuse it (issue caught in review), and these DCHECKS will catch it. TEST=none BUG=none Review URL: http://codereview.chromium.org/207005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@26422 0039d316-1c4b-4281-b951-d872f2087c98
* Eliminate remaining WebCore dependencies from webplugin_impl.ccdarin@chromium.org2009-09-021-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Introduces WebPluginPageDelegate to hold the methods that only existed on WebViewDelegate to allow WebPluginImpl to talk to the RenderView. This enables us to eliminate those methods from WebViewDelegate, which eliminates the last dependency on gfx/ native_widget_types.h in our WebKit interface! WebViewDelegate grows a CreatePlugin method that returns a WebKit::WebPlugin. It loses its CreatePluginDelegate method, which now lives on WebPluginPageDelegate. This change makes RenderView use WeakPtr when it hands itself to each WebPluginDelegateProxy and WebPluginImpl instance. This makes the memory management simpler. This change also moves various WebPlugin* interfaces defined in webkit/glue into the webkit_glue namespace. This was to help reduce confusion with similarly named types in the WebKit namespace. WebKit::WebPluginParams is added to contain the set of parameters used to construct a plugin. WebPluginContainer gets a couple more methods to allow us to avoid WebCore dependencies in WebPluginImpl. R=jam BUG=10036 TEST=none Review URL: http://codereview.chromium.org/181014 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@25184 0039d316-1c4b-4281-b951-d872f2087c98
* Add a WeakPtr<T> class.darin@chromium.org2009-09-011-0/+221
This allows a class to hand out weak pointers to itself that will be nulled out automatically when the class instance is destroyed. I have provided two ways for a class to implement weak pointers. It can either subclass SupportsWeakPtr (like subclassing RefCounted) or it can be composed of WeakPtrFactory (like having a ScopedRunnableMethodFactory member). Eventually, I'd like to make it possible to pass a WeakPtr<T> as the first parameter to NewRunnableMethod. This will make ScopedRunnableMethodFactory obsolete and should help cleanup some code. One feature that makes the implementation here a bit more complicated is that it is possible to pass a WeakPtr<U> to a method that takes a WeakPtr<T> provided U "is a" T. This proved useful in RenderView, which can then give out weak references to both itself as well as to an interface it implements. This informed the design of WeakPtr, causing it to have a T* ptr_ member instead of stashing that pointer within the ref counted WeakReference object. R=brettw BUG=none TEST=weak_ptr_unittest.cc Review URL: http://codereview.chromium.org/183026 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@25087 0039d316-1c4b-4281-b951-d872f2087c98