summaryrefslogtreecommitdiffstats
path: root/base/bind_helpers.h
Commit message (Collapse)AuthorAgeFilesLines
* Remove task.h and finish base::Bind() migration.ajwong@chromium.org2012-01-061-1/+42
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Over 341 CLs, in ~3 months, touching 3251 unique files! Top 5 most CLs: (121) jhawkins ( 45) dcheng ( 24) achuith ( 23) csilv ( 12) tfarina ( 12) groby ~1000 files touched: (918) jhawkins 100+ files touched: (486) ajwong (385) willchan (372) dcheng (126) csilv (123) fischman (112) sergeyu 49+ files touched: (65) tfarina (57) acolwell (52) adamk (49) tzik BUG=35223 TEST=existing Review URL: http://codereview.chromium.org/9114020 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@116748 0039d316-1c4b-4281-b951-d872f2087c98
* Change over IgnoreReturn to IgnoreResult. remove IgnoreReturn.ajwong@chromium.org2012-01-061-12/+0
| | | | | | | | | BUG=98919 TEST=existing Review URL: http://codereview.chromium.org/9111032 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@116631 0039d316-1c4b-4281-b951-d872f2087c98
* Redo r113722 - Add Pass(), which implements move semantics, to scoped_ptr, ↵ajwong@chromium.org2011-12-221-31/+121
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | scoped_array.... -- This time for sure. -- Add Pass(), which implements move semantics, to scoped_ptr, scoped_array, and scoped_ptr_malloc. This modification to the scopers implements the "moveable but not copyable" semantics that were introduced in C++11's unique_ptr<>. With this, is now possible to use scopers as an argument type or a return type. This signifies, in the type system, transfer of ownership into a function or out of a function respectively. Calling, or returning such a function MUST use the temporary resulting from a function or explicit cast. This distinction makes it possible to avoid the implicit ownership transfer issues of auto_ptr, but still allow us to have compiler enforced ownership transfer. Also adds a Passed() helper that allows using a scoper with Bind(). Original Review URL: http://codereview.chromium.org/8774032 BUG=96118 TEST=new unittests Review URL: http://codereview.chromium.org/9018037 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@115607 0039d316-1c4b-4281-b951-d872f2087c98
* Revert 115441 - Redo r113722 - Add Pass(), which implements move semantics, ↵jeremya@chromium.org2011-12-211-121/+31
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | to scoped_ptr, scoped_array.... (This undoes the revert in r114247. Win canaries still can't link, but this change has been deemed safe). Add Pass(), which implements move semantics, to scoped_ptr, scoped_array, and scoped_ptr_malloc. This modification to the scopers implements the "moveable but not copyable" semantics that were introduced in C++11's unique_ptr<>. With this, is now possible to use scopers as an argument type or a return type. This signifies, in the type system, transfer of ownership into a function or out of a function respectively. Calling, or returning such a function MUST use the temporary resulting from a function or explicit cast. This distinction makes it possible to avoid the implicit ownership transfer issues of auto_ptr, but still allow us to have compiler enforced ownership transfer. Also adds a Passed() helper that allows using a scoper with Bind(). BUG=96118 TEST=new unittests Review URL: http://codereview.chromium.org/9021032 TBR=ajwong@chromium.org Review URL: http://codereview.chromium.org/8949057 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@115444 0039d316-1c4b-4281-b951-d872f2087c98
* Redo r113722 - Add Pass(), which implements move semantics, to scoped_ptr, ↵ajwong@chromium.org2011-12-211-31/+121
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | scoped_array.... (This undoes the revert in r114247. Win canaries still can't link, but this change has been deemed safe). Add Pass(), which implements move semantics, to scoped_ptr, scoped_array, and scoped_ptr_malloc. This modification to the scopers implements the "moveable but not copyable" semantics that were introduced in C++11's unique_ptr<>. With this, is now possible to use scopers as an argument type or a return type. This signifies, in the type system, transfer of ownership into a function or out of a function respectively. Calling, or returning such a function MUST use the temporary resulting from a function or explicit cast. This distinction makes it possible to avoid the implicit ownership transfer issues of auto_ptr, but still allow us to have compiler enforced ownership transfer. Also adds a Passed() helper that allows using a scoper with Bind(). BUG=96118 TEST=new unittests Review URL: http://codereview.chromium.org/9021032 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@115441 0039d316-1c4b-4281-b951-d872f2087c98
* Revert of "Redo r113722 - Add Pass(), which implements move semantics, to ↵ajwong@chromium.org2011-12-131-121/+31
| | | | | | | | | | | | | | | | | scoped_ptr, scoped_ar..." This reverts commit r113922. Win Canary has been failing to link due to OOM since the weekend. While this was not the original cause, it might be making things worse. Speculatively remove for now. Also changes render_widge_host_view to use Owned() instead of Passed(). BUG=none TEST=existing. Review URL: http://codereview.chromium.org/8931008 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@114247 0039d316-1c4b-4281-b951-d872f2087c98
* Revert of "Revert of "Redo r113722 - Add Pass(), which implements move ↵ajwong@chromium.org2011-12-131-31/+121
| | | | | | | | | | | | | | semantics, to scoped_ptr..." This reverts commit r114228. BUG=none TEST=none TBR=acolwell Review URL: http://codereview.chromium.org/8929008 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@114230 0039d316-1c4b-4281-b951-d872f2087c98
* Revert "Redo r113722 - Add Pass(), which implements move semantics, to ↵ajwong@chromium.org2011-12-131-121/+31
| | | | | | | | | | | | | | | | scoped_ptr, scoped_array...." This reverts commit r113922. Win Canary has been failing to link due to OOM since the weekend. While this was not the original cause, it might be making things worse. Speculatively remove for now. BUG=none TEST=none TBR=kareng Review URL: http://codereview.chromium.org/8932006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@114228 0039d316-1c4b-4281-b951-d872f2087c98
* Redo r113722 - Add Pass(), which implements move semantics, to scoped_ptr, ↵ajwong@chromium.org2011-12-101-31/+121
| | | | | | | | | | | | | | | | | | | | | | | scoped_array.... Add Pass(), which implements move semantics, to scoped_ptr, scoped_array, and scoped_ptr_malloc. This modification to the scopers implements the "moveable but not copyable" semantics that were introduced in C++11's unique_ptr<>. With this, is now possible to use scopers as an argument type or a return type. This signifies, in the type system, transfer of ownership into a function or out of a function respectively. Calling, or returning such a function MUST use the temporary resultin This distinction makes it possible to avoid the implicit ownership transfer issues of auto_ptr, but still allow us to have compiler enforced ownership transfer. Also adds a Passed() helper that allows using a scoper with Bind(). BUG=96118 TEST=new unittests Original review URL: http://codereview.chromium.org/8774032 Review URL: http://codereview.chromium.org/8897005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@113922 0039d316-1c4b-4281-b951-d872f2087c98
* Revert 113722 - Add Pass(), which implements move semantics, to scoped_ptr, ↵sergeyu@chromium.org2011-12-091-121/+31
| | | | | | | | | | | | | | | | | | | | | | scoped_array, and scoped_ptr_malloc. This modification to the scopers implements the "moveable but not copyable" semantics that were introduced in C++11's unique_ptr<>. With this, is now possible to use scopers as an argument type or a return type. This signifies, in the type system, transfer of ownership into a function or out of a function respectively. Calling, or returning such a function MUST use the temporary resulting from the scoper's Pass() function. You CANNOT just pass the scoper by copy as there is still no copy constructor or assignment operator; trying to do so will yield a compilation error. This distinction makes it possible to avoid the implicit ownership transfer issues of auto_ptr, but still allow us to have compiler enforced ownership transfer. Also adds a Passed() helper that allows using a scoper with Bind(). BUG=96118 TEST=new unittests Review URL: http://codereview.chromium.org/8774032 TBR=ajwong@chromium.org Review URL: http://codereview.chromium.org/8890060 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@113738 0039d316-1c4b-4281-b951-d872f2087c98
* Add Pass(), which implements move semantics, to scoped_ptr, scoped_array, ↵ajwong@chromium.org2011-12-091-31/+121
| | | | | | | | | | | | | | | | | | | and scoped_ptr_malloc. This modification to the scopers implements the "moveable but not copyable" semantics that were introduced in C++11's unique_ptr<>. With this, is now possible to use scopers as an argument type or a return type. This signifies, in the type system, transfer of ownership into a function or out of a function respectively. Calling, or returning such a function MUST use the temporary resulting from the scoper's Pass() function. You CANNOT just pass the scoper by copy as there is still no copy constructor or assignment operator; trying to do so will yield a compilation error. This distinction makes it possible to avoid the implicit ownership transfer issues of auto_ptr, but still allow us to have compiler enforced ownership transfer. Also adds a Passed() helper that allows using a scoper with Bind(). BUG=96118 TEST=new unittests Review URL: http://codereview.chromium.org/8774032 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@113722 0039d316-1c4b-4281-b951-d872f2087c98
* Callback API Change: Reimplement Bind(); support IgnoreResult, full ↵ajwong@chromium.org2011-11-211-25/+98
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | currying, and use less types. The main API change IgnoreResult() and fully currying. See unittest for what the new API looks like. The rest of the changes are done to support that. Previously, IgnoreReturn could not be used with WeakPtr<> Bind()s as it was applied after the fact to the Callback object. Now, IgnoreResult() wraps the function like Unretained(). As an incidental benefit, the new implementation gave us fully currying for free. Also, the new implementation scales better when supporting higher arities of functions. The new type growth is: (n^2 + 20n) / 2 as opposed to (3n^2 + 17n) / 2 where n == arity. For n = 6 and n=10, the new implementation has 81 and 155 templates respectively. The old implementation had 105 and 235 templates respectively. BUG=35233,98919,98542 TEST=existing unittests Review URL: http://codereview.chromium.org/8483003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@110975 0039d316-1c4b-4281-b951-d872f2087c98
* Add in an Owned() wrapper to base::Bind().ajwong@chromium.org2011-10-151-13/+75
| | | | | | | | | | | This allows expression of ownership of a pointer by a callback. It's basically a "scoped_ptr<>" for Callback where the scope tied to the callback object. BUG=96118 TEST=new unittests. Review URL: http://codereview.chromium.org/8209001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@105622 0039d316-1c4b-4281-b951-d872f2087c98
* Support scoped_refptr<> as the object for a method call in base::Bind(). ↵ajwong@chromium.org2011-10-071-0/+13
| | | | | | | | | | | | | | | Reduce useless copies. Patch up an API hole where you can't do base::Bind(&Foo::method, ptr), if ptr is a scoped_refptr. Also modify Unwrap() to remove a couple of unecessary copies for scoped_refptrs, and WeakPtrs<>. BUG=none TEST=none Review URL: http://codereview.chromium.org/8171013 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@104399 0039d316-1c4b-4281-b951-d872f2087c98
* Add new helper that can adapt Callbacks with return values for Closures.ajwong@chromium.org2011-09-281-3/+27
| | | | | | | | | | | This is helpful for reducing manually written static functions that just effectively just invoke the function and ignore the return value. BUG=87287 TEST=new unittest Review URL: http://codereview.chromium.org/8048008 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@103060 0039d316-1c4b-4281-b951-d872f2087c98
* Support binding WeakPtr<> to methods with void return types.ajwong@chromium.org2011-05-161-1/+8
| | | | | | | | | | | | | | | This should give functionality similar to ScopedRunnableMethodFactory. Note that binding a WeakPtr only make sense with methods with void return types. If the return type is not void, then it is unclear what the function should return when the pointer is invalidated. This code adds a compile time assert to check the return type. BUG=35223 TEST=unittests Review URL: http://codereview.chromium.org/7015064 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@85549 0039d316-1c4b-4281-b951-d872f2087c98
* Make the Pepper proxy support in-process font rendering.brettw@chromium.org2011-05-101-3/+5
| | | | | | | | | | | | | This implements a WebKit thread in the PPAPI plugin process so we can do the font calls without IPC. The existing font support was refactored into a virtual class (to prevent PPAPI from depending on WebKit and creating a circular GYP dependency). This moves the renderer sandbox support into content/common so that it can be used by the PPAPI process. Review URL: http://codereview.chromium.org/6981001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@84856 0039d316-1c4b-4281-b951-d872f2087c98
* Add support for base::Closure in the MessageLoop, and reimplement the whole ↵ajwong@chromium.org2011-04-201-1/+1
| | | | | | | | | | | sucker on top of base::Closure. After this, all Task objects that are posted will be wrapped in a closure prior to dispatch. BUG=35223 TEST=unittests. Review URL: http://codereview.chromium.org/6463013 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@82300 0039d316-1c4b-4281-b951-d872f2087c98
* MSVC warns when you try to use Base if T has a private destructor,ajwong@chromium.org2011-04-131-0/+9
| | | | | | | | | | | | | The common pattern for refcounted types. It does this even though no attempt to instantiate Base is made. We disable the warning for this portion of code. BUG=none TEST=try bots. Review URL: http://codereview.chromium.org/6833006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@81499 0039d316-1c4b-4281-b951-d872f2087c98
* Callback support for unbound reference and array arguments.ajwong@chromium.org2011-03-241-38/+5
| | | | | | | | | | | Because the callback object uses const An& for the type of the Run() function in argument forwarding, the code breaks for An=T& or An=T[]. This CL adds in code to modify the parameter type to remove duplicate references, and other fun. BUG=35223 TEST=new unittests Review URL: http://codereview.chromium.org/6718021 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@79239 0039d316-1c4b-4281-b951-d872f2087c98
* Unified callback system based on tr1::function/tr1::bind and Google's ↵ajwong@chromium.org2011-02-151-0/+287
internal callback code. This callback system allows for creation of functors for normal functions, methods, and const methods. It is a superset of the functionality of NewRunnableMethod, NewRunnableFunction, NewCallback, and CreateFunctor. We support partial binding of function arguments, and also specification of refcounting semantics by wrapping a target object in a wrapper object. BUG=35223 TEST=none Review URL: http://codereview.chromium.org/6109007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@74904 0039d316-1c4b-4281-b951-d872f2087c98