summaryrefslogtreecommitdiffstats
path: root/base/memory/weak_ptr.h
Commit message (Collapse)AuthorAgeFilesLines
* Update WeakPtr documentation for SequencedTaskRunner support.davidben2014-10-221-9/+10
| | | | | | | | | | | | WeakPtr supported SequencedTaskRunner in https://codereview.chromium.org/20754006, but the documentation was not updated to match. BUG=none Review URL: https://codereview.chromium.org/323153002 Cr-Commit-Position: refs/heads/master@{#300717}
* dllexport base::internal::WeakReference::Flaghans@chromium.org2014-06-111-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | Flag's methods can end up getting called across a dll boundary due to inlining. For example, Flag's destructor ends up being called from gpu.dll when the following call chain gets inlined: gpu::gles2::ContextGroup::HaveContexts() -> std::vector<WeakPtr<gles2::GLES2Decoder>>::remove_if() -> WeakPtr copy assignment -> WeakReference copy assignment -> scoped_refptr<Flag> copy assignment -> RefCountedThreadSafe<Flag>::Release -> ~Flag. (Note that dllimport/export isn't inherited by nested classes, but the visibility attribute that we use on other platforms is.) BUG=82385 TEST=build gpu.dll with Clang in a shared_library Release build R=mark@chromium.org Review URL: https://codereview.chromium.org/321983002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@276220 0039d316-1c4b-4281-b951-d872f2087c98
* Remove obsolete WeakPtr hack.sievers@chromium.org2013-08-031-17/+0
| | | | | | | | BUG=234964 Review URL: https://chromiumcodereview.appspot.com/20777008 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@215470 0039d316-1c4b-4281-b951-d872f2087c98
* base: Re-re-apply WeakPtr support for SequencedWorkerPoolstommycli@chromium.org2013-07-301-3/+3
| | | | | | | | | | | | | | | | | | This is a continuation of https://codereview.chromium.org/20163004/#ps55001 and identical to Patchset 4. I'm adding back some death test threadsafe flags that got dropped from the re-apply. In other words, this CL is: https://codereview.chromium.org/20163004/#ps55001 + https://codereview.chromium.org/19617002/ Feel free to revert if it causes issues again. TBR=akalin,darin,dewittj,rnk BUG=165590 Review URL: https://codereview.chromium.org/20754006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@214411 0039d316-1c4b-4281-b951-d872f2087c98
* Revert 213906 "base: Re-apply WeakPtr support for SequencedWorke..."dewittj@chromium.org2013-07-261-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | Speculative due to base_unittests failures. > base: Re-apply WeakPtr support for SequencedWorkerPools, fixing deadlock > > This reverts the revert found here: https://codereview.chromium.org/19882002 > > It also fixes the deadlock that caused the revert, reported here: > http://crbug.com/261448 > > Patchset 1 is simply what was originally committed (and reverted). Subsequent patchsets show the fix of the deadlock problem. > > BUG=165590 > TBR=darin > > Review URL: https://chromiumcodereview.appspot.com/20163004 TBR=tommycli@chromium.org Review URL: https://codereview.chromium.org/20771002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@213943 0039d316-1c4b-4281-b951-d872f2087c98
* base: Re-apply WeakPtr support for SequencedWorkerPools, fixing deadlocktommycli@chromium.org2013-07-261-3/+3
| | | | | | | | | | | | | | | | This reverts the revert found here: https://codereview.chromium.org/19882002 It also fixes the deadlock that caused the revert, reported here: http://crbug.com/261448 Patchset 1 is simply what was originally committed (and reverted). Subsequent patchsets show the fix of the deadlock problem. BUG=165590 TBR=darin Review URL: https://chromiumcodereview.appspot.com/20163004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@213906 0039d316-1c4b-4281-b951-d872f2087c98
* Revert 211956 "base: Change WeakPtr to use SequenceChecker inste..." vandebo@chromium.org2013-07-201-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | As well as revert 212725 "base: Make SequenceChecker death tests multi-threads work correctly." See http://crbug.com/261448 > base: Change WeakPtr to use SequenceChecker instead of ThreadChecker. > > This will enable WeakPtr to be used in SequencedWorkerPool, et al. with a sequence token. > > This is a continuation of issue: https://chromiumcodereview.appspot.com/18231002/ > > The original issue got messed up by a rietveld bug, so refer there for history and comments. > > BUG=165590 > > Review URL: https://chromiumcodereview.appspot.com/18501008 TBR=tommycli@chromium.org Review URL: https://chromiumcodereview.appspot.com/19695005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@212780 0039d316-1c4b-4281-b951-d872f2087c98
* base: Change WeakPtr to use SequenceChecker instead of ThreadChecker.tommycli@chromium.org2013-07-171-3/+3
| | | | | | | | | | | | | | This will enable WeakPtr to be used in SequencedWorkerPool, et al. with a sequence token. This is a continuation of issue: https://chromiumcodereview.appspot.com/18231002/ The original issue got messed up by a rietveld bug, so refer there for history and comments. BUG=165590 Review URL: https://chromiumcodereview.appspot.com/18501008 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@211956 0039d316-1c4b-4281-b951-d872f2087c98
* Make expressions like "if (weak_ptr)" workakalin@chromium.org2013-06-061-0/+18
| | | | | | | | | | | | | | Use the same trick as scoped_ptr<T>. Add comments regarding == and != operators and their relation to the bool trick. BUG=245942 R=darin@chromium.org, rsleevi@chromium.org Review URL: https://codereview.chromium.org/15721007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@204438 0039d316-1c4b-4281-b951-d872f2087c98
* Remove WeakPtr<T>'s operator T*()akalin@chromium.org2013-06-061-1/+0
| | | | | | | | | | | BUG=245942 R=darin@chromium.org Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=204293 Review URL: https://chromiumcodereview.appspot.com/16267003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@204379 0039d316-1c4b-4281-b951-d872f2087c98
* Revert 204293 "Remove WeakPtr<T>'s operator T*()"kkania@chromium.org2013-06-051-0/+1
| | | | | | | | | | | | | | | | | | | | | broke linux chromeos compile: chromeos-chrome-29.0.1530.0_alpha-r1: content/common/gpu/media/exynos_video_decode_accelerator.cc: In member function 'void content::ExynosVideoDecodeAccelerator::NotifyError(media::VideoDecodeAccelerator::Error)': chromeos-chrome-29.0.1530.0_alpha-r1: content/common/gpu/media/exynos_video_decode_accelerator.cc:1894:14: error: could not convert '((content::ExynosVideoDecodeAccelerator*)this)->content::ExynosVideoDecodeAccelerator::client_' from 'base::WeakPtr<media::VideoDecodeAccelerator::Client>' to 'bool' ...more errors > Remove WeakPtr<T>'s operator T*() > > BUG=245942 > R=darin@chromium.org > > Review URL: https://codereview.chromium.org/16267003 TBR=akalin@chromium.org Review URL: https://codereview.chromium.org/16229012 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@204315 0039d316-1c4b-4281-b951-d872f2087c98
* Remove WeakPtr<T>'s operator T*()akalin@chromium.org2013-06-051-1/+0
| | | | | | | | | BUG=245942 R=darin@chromium.org Review URL: https://codereview.chromium.org/16267003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@204293 0039d316-1c4b-4281-b951-d872f2087c98
* Update base/ to use scoped_refptr<T>::get() rather than implicit "operator T*"rsleevi@chromium.org2013-05-311-1/+2
| | | | | | | | | | | Linux fixes BUG=110610 TBR=darin Review URL: https://chromiumcodereview.appspot.com/16160015 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@203483 0039d316-1c4b-4281-b951-d872f2087c98
* Remove all but one use of WeakPtrFactory::DetachFromThread. wez@chromium.org2013-05-291-28/+27
| | | | | | | | | | | | | | | | | | | | | | | This is a re-land of issue 14299011, which broke GLSurfaceGLX, in turn breaking Chrome Linux/Aura. This CL changes WeakPtr in the following ways: * Changes thread-bindings semantics so that WeakPtrs only become bound when the first one is dereferenced, or the owning factory invalidates them. * Removes WeakPtrFactory::DetachFromThread. * Renames SupportsWeakPtr::DetachFromThread to DetachFromThreadHack. Calling code changes to allow this: * Unnecessary use of SupportsWeakPtr removed from SGIVideoSyncProviderThreadShim. * Unnecessary DetachFromThread() calls removed from PluginInfoMessageFilter, DhcpProxyScript[Adapter]FetcherWin and (Chromoting's) PolicyWatcherLinux. * DetachFromThread() calls rendered unnecessary by change in binding semantics removed from IOThread, SearchProviderInstallData, RuleRegistryWithCache and GLSurfaceGlx. WebGraphicsContext3DInProcessCommandBufferImpl uses the re-named DetachFromThreadHack() - bug 234964 tracks work to remove that use. TBR=darin,awong BUG=232143, 234964, 243914 Review URL: https://chromiumcodereview.appspot.com/16007009 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@202811 0039d316-1c4b-4281-b951-d872f2087c98
* Revert 202038 "Remove all but one use of WeakPtrFactory::DetachF..."erg@chromium.org2013-05-241-27/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | | Caused local failures in linux_aura builds. Unsure why this isn't showing up on the bots. > Remove all but one use of WeakPtrFactory::DetachFromThread. > > This CL changes WeakPtr in the following ways: > * Changes thread-bindings semantics so that WeakPtrs only become bound when the first one is dereferenced, or the owning factory invalidates them. > * Removes WeakPtrFactory::DetachFromThread. > * Renames SupportsWeakPtr::DetachFromThread to DetachFromThreadHack. > > Calling code changes to allow this: > * Unnecessary DetachFromThread() calls removed from PluginInfoMessageFilter, DhcpProxyScript[Adapter]FetcherWin and (Chromoting's) PolicyWatcherLinux. > * DetachFromThread() calls rendered unnecessary by change in binding semantics removed from IOThread, SearchProviderInstallData, RuleRegistryWithCache and GLSurfaceGlx. > > WebGraphicsContext3DInProcessCommandBufferImpl uses the re-named DetachFromThreadHack() - bug 234964 tracks work to remove that use. > > Review URL: https://chromiumcodereview.appspot.com/14299011 BUG=232143, 234964, 243914 TBR=wez@chromium.org Review URL: https://codereview.chromium.org/15819004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@202193 0039d316-1c4b-4281-b951-d872f2087c98
* Remove all but one use of WeakPtrFactory::DetachFromThread.wez@chromium.org2013-05-241-28/+27
| | | | | | | | | | | | | | | | | | | This CL changes WeakPtr in the following ways: * Changes thread-bindings semantics so that WeakPtrs only become bound when the first one is dereferenced, or the owning factory invalidates them. * Removes WeakPtrFactory::DetachFromThread. * Renames SupportsWeakPtr::DetachFromThread to DetachFromThreadHack. Calling code changes to allow this: * Unnecessary DetachFromThread() calls removed from PluginInfoMessageFilter, DhcpProxyScript[Adapter]FetcherWin and (Chromoting's) PolicyWatcherLinux. * DetachFromThread() calls rendered unnecessary by change in binding semantics removed from IOThread, SearchProviderInstallData, RuleRegistryWithCache and GLSurfaceGlx. WebGraphicsContext3DInProcessCommandBufferImpl uses the re-named DetachFromThreadHack() - bug 234964 tracks work to remove that use. BUG=232143, 234964 Review URL: https://chromiumcodereview.appspot.com/14299011 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@202038 0039d316-1c4b-4281-b951-d872f2087c98
* Overhaul comments on WeakPtr to emphasize WeakPtrFactory over SupportsWeakPtr.wez@chromium.org2013-04-251-88/+81
| | | | | | Review URL: https://chromiumcodereview.appspot.com/13556005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@196488 0039d316-1c4b-4281-b951-d872f2087c98
* Fix WeakPtr's generalized copy constructor to work on non-owner threadsakalin@chromium.org2013-03-021-2/+4
| | | | | | | | BUG=179544 Review URL: https://codereview.chromium.org/12387056 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@185666 0039d316-1c4b-4281-b951-d872f2087c98
* Second try of http://codereview.chromium.org/10698063/kaiwang@chromium.org2012-07-111-10/+23
| | | | | | | | Rename/re-comment tests and added new death tests for WeakPtr. Review URL: https://chromiumcodereview.appspot.com/10690080 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@146212 0039d316-1c4b-4281-b951-d872f2087c98
* Remove the rest of #pragma once in one big CL.ajwong@chromium.org2012-07-111-1/+0
| | | | | | | | | For context see this thread: https://groups.google.com/a/chromium.org/forum/?fromgroups#!topic/chromium-dev/RMcVNGjB4II TBR=thakis,pkasting,jam git-svn-id: svn://svn.chromium.org/chrome/trunk/src@146163 0039d316-1c4b-4281-b951-d872f2087c98
* Revert 145402 - Rename/re-comment tests and 2 new death tests for WeakPtrraymes@google.com2012-07-041-12/+8
| | | | | | | | | Review URL: https://chromiumcodereview.appspot.com/10698063 TBR=kaiwang@chromium.org Review URL: https://chromiumcodereview.appspot.com/10704094 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@145409 0039d316-1c4b-4281-b951-d872f2087c98
* Rename/re-comment tests and 2 new death tests for WeakPtrkaiwang@chromium.org2012-07-041-8/+12
| | | | | | Review URL: https://chromiumcodereview.appspot.com/10698063 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@145402 0039d316-1c4b-4281-b951-d872f2087c98
* RefCounted types should not have public destructors, base/ editionrsleevi@chromium.org2012-06-261-0/+3
| | | | | | | | | | BUG=123295 TEST=it compiles Review URL: https://chromiumcodereview.appspot.com/10332269 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@144130 0039d316-1c4b-4281-b951-d872f2087c98
* Add weak pointer static casting.gavinp@chromium.org2012-06-151-3/+61
| | | | | | | | | | | | This allows classes to more naturally extend classes using WeakPtr. TEST=None BUG= Review URL: https://chromiumcodereview.appspot.com/10537127 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@142404 0039d316-1c4b-4281-b951-d872f2087c98
* Let WeakPtrFactory operations fail once its dtor is calledoshima@chromium.org2012-05-181-0/+8
| | | | | | | | | | | | | | | | | We had a weird bug (crbug.com/127534) where the task was posted and executed even after WeakPtrFactory has been deleted. It turns out that someone was posting a task AFTER its detor was called while executing destructor, and bots (including valgrind) couldn't catch this because the memory stays valid until the hosting object is deleted. This CL is to catch such case early by resetting the ptr_. BUG=none TEST=none Review URL: https://chromiumcodereview.appspot.com/10387063 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@137963 0039d316-1c4b-4281-b951-d872f2087c98
* Make WeakPtr::operator* return reference instead of pointerhashimoto@chromium.org2012-02-291-2/+2
| | | | | | | | | | | | | Reference is more suitable type for operator*'s return values. Add test code for operator->. BUG=None TEST=base_unittests --gtest_filter="WeakPtrTest.Dereference" Review URL: http://codereview.chromium.org/9455086 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@124141 0039d316-1c4b-4281-b951-d872f2087c98
* Fix weak_ptr's operator* implementation.mnaganov@chromium.org2012-02-241-2/+2
| | | | | | | | | | | | | This looks like a typo. Seems that nobody has tried to use this operator before. BUG=none TEST=WeakPtrTest.Dereference R=darin@chromium.org Review URL: https://chromiumcodereview.appspot.com/9452021 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@123456 0039d316-1c4b-4281-b951-d872f2087c98
* Make WeakPtr thread-safe, i.e. allow cross-thread copying of WeakPtrsievers@chromium.org2011-08-261-8/+15
| | | | | | | | | | | | | | | | | | | | | | | | | and destruction on a thread other than the one where the original reference was created. The problem with the current implementation is modifying the flag pointer from WeakPtr::~WeakPtr which might happen on a different thread (potentially racing with somebody invalidating the flag on the original thread). For compatibility reasons, creating the initial reference attaches to the thread and governs the thread-safety checking logic with respect to checking a reference to be valid and invalidating it, which should both only be done on the same thread. BUG=82509 TEST=added unit tests Added memleak suppression: http://crbug.com/94345 TBR=timurrrr@chromium.org Review URL: http://codereview.chromium.org/7677028 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@98443 0039d316-1c4b-4281-b951-d872f2087c98
* Revert 97808 - Make WeakPtr thread-safe, i.e. allow cross-thread copying of ↵cbentzel@chromium.org2011-08-231-15/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | WeakPtr and destruction on a thread other than the one where the original reference was created. The problem with the current implementation is modifying the flag pointer from WeakPtr::~WeakPtr which might happen on a different thread (potentially racing with somebody invalidating the flag on the original thread). For compatibility reasons, creating the initial reference attaches to the thread and governs the thread-safety checking logic with respect to checking a reference to be valid and invalidating it, which should both only be done on the same thread. BUG=82509 TEST=added unit tests Review URL: http://codereview.chromium.org/7677028 TBR=sievers@chromium.org Review URL: http://codereview.chromium.org/7685054 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@97846 0039d316-1c4b-4281-b951-d872f2087c98
* Make WeakPtr thread-safe, i.e. allow cross-thread copying of WeakPtrsievers@chromium.org2011-08-231-8/+15
| | | | | | | | | | | | | | | | | | | | | and destruction on a thread other than the one where the original reference was created. The problem with the current implementation is modifying the flag pointer from WeakPtr::~WeakPtr which might happen on a different thread (potentially racing with somebody invalidating the flag on the original thread). For compatibility reasons, creating the initial reference attaches to the thread and governs the thread-safety checking logic with respect to checking a reference to be valid and invalidating it, which should both only be done on the same thread. BUG=82509 TEST=added unit tests Review URL: http://codereview.chromium.org/7677028 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@97808 0039d316-1c4b-4281-b951-d872f2087c98
* Rename BASE_API to BASE_EXPORT.darin@chromium.org2011-08-051-4/+4
| | | | | | | R=rvargas Review URL: http://codereview.chromium.org/7461141 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@95618 0039d316-1c4b-4281-b951-d872f2087c98
* Fix base::internal::WeakReference::Flag to be RefCountedThreadSafe.willchan@chromium.org2011-04-111-7/+16
| | | | | | | | | | | | | This allows a base::WeakPtr to be deleted on a different thread, which will modify the refcount on Flag. BUG=none TEST=none Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=81142 Review URL: http://codereview.chromium.org/6826034 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@81148 0039d316-1c4b-4281-b951-d872f2087c98
* Revert 81142 - Fix base::internal::WeakReference::Flag to be ↵erg@google.com2011-04-111-16/+7
| | | | | | | | | RefCountedThreadSafe.This allows a base::WeakPtr to be deleted on a different thread, which will modify the refcount on Flag.BUG=noneTEST=noneReview URL: http://codereview.chromium.org/6826034 TBR=willchan@chromium.org Review URL: http://codereview.chromium.org/6821053 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@81144 0039d316-1c4b-4281-b951-d872f2087c98
* Fix base::internal::WeakReference::Flag to be RefCountedThreadSafe.willchan@chromium.org2011-04-111-7/+16
| | | | | | | | | | | | This allows a base::WeakPtr to be deleted on a different thread, which will modify the refcount on Flag. BUG=none TEST=none Review URL: http://codereview.chromium.org/6826034 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@81142 0039d316-1c4b-4281-b951-d872f2087c98
* Move some files from base to base/memory.levin@chromium.org2011-03-281-0/+246
raw_scoped_refptr_mismatch_checker.h ref_counted.cc ref_counted.h ref_counted_memory.cc ref_counted_memory.h ref_counted_unittest.cc scoped_callback_factory.h scoped_comptr_win.h scoped_handle.h scoped_native_library.cc scoped_native_library.h scoped_native_library_unittest.cc scoped_nsobject.h scoped_open_process.h scoped_ptr.h scoped_ptr_unittest.cc scoped_temp_dir.cc scoped_temp_dir.h scoped_temp_dir_unittest.cc scoped_vector.h singleton.h singleton_objc.h singleton_unittest.cc linked_ptr.h linked_ptr_unittest.cc weak_ptr.cc weak_ptr.h weak_ptr_unittest.cc BUG=None TEST=Compile Review URL: http://codereview.chromium.org/6714032 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@79524 0039d316-1c4b-4281-b951-d872f2087c98