summaryrefslogtreecommitdiffstats
path: root/base/callback_internal.h
Commit message (Collapse)AuthorAgeFilesLines
* Permit .Pass()ing scoped_ptr_malloc<>'s that have custom FreeProcs.rsleevi@chromium.org2012-05-091-6/+6
| | | | | | | | | | BUG=126008 TEST=TaskRunnerHelpersTest.PostTaskAndReplyWithResultPassed R=willchan Review URL: https://chromiumcodereview.appspot.com/10384021 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@135955 0039d316-1c4b-4281-b951-d872f2087c98
* When using PostTaskAndReplyWithResults, if the ResultType is a passed type ↵rsleevi@chromium.org2012-05-031-0/+5
| | | | | | | | | | | | | | (eg: scoped_ptr and friends), .Pass() the result to the reply. Because the temporary storage of the result is an implementation detail of PostTaskAndReplyWithResults, its safe to always assume that passed types should be passed. BUG=126008 TEST=TaskRunnerHelpersTest.PostTaskAndReplyWithResultPassed Review URL: http://codereview.chromium.org/10344012 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@135228 0039d316-1c4b-4281-b951-d872f2087c98
* Fix ScopedVector<T> passing via base::Bind()willchan@chromium.org2012-03-231-3/+17
| | | | | | | | | | | | | | | The original implementation neglected to define the necessary CallbackParamTraits and CallbackForward implementations for ScopedVector. Fix scoped_ptr_malloc and scoped_array while I'm at it. Awesome. BUG=NONE TEST=scoped_vector_unittest.cc Review URL: http://codereview.chromium.org/9827003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@128350 0039d316-1c4b-4281-b951-d872f2087c98
* Redo r113722 - Add Pass(), which implements move semantics, to scoped_ptr, ↵ajwong@chromium.org2011-12-221-0/+59
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-59/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-0/+59
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Retry 114494 - Remove BindStateHolder and have Bind() return a Callback<> ↵ajwong@chromium.org2011-12-201-25/+5
| | | | | | | | | | | | | | | object directly." This removes some complexity and also fixes a bug where if you call Bind() with the result of Bind(), the resulting Callback would only be valid during the first call. Ouch. Also makes the static type checking a bit more strict when assigning into a Callback<>. BUG=none TEST=new unittests Review URL: http://codereview.chromium.org/8915024 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@115045 0039d316-1c4b-4281-b951-d872f2087c98
* Revert 114494 - Remove BindStateHolder and have Bind() return a Callback<> ↵sail@chromium.org2011-12-141-5/+25
| | | | | | | | | | | | | | | | | object directly. This removes some complexity and also fixes a bug where if you call Bind() with the result of Bind(), the resulting Callback would only be valid during the first call. Ouch. BUG=none TEST=new unittests Review URL: http://codereview.chromium.org/8738001 TBR=ajwong@chromium.org Review URL: http://codereview.chromium.org/8914022 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@114495 0039d316-1c4b-4281-b951-d872f2087c98
* Remove BindStateHolder and have Bind() return a Callback<> object directly.ajwong@chromium.org2011-12-141-25/+5
| | | | | | | | | | | | This removes some complexity and also fixes a bug where if you call Bind() with the result of Bind(), the resulting Callback would only be valid during the first call. Ouch. BUG=none TEST=new unittests Review URL: http://codereview.chromium.org/8738001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@114494 0039d316-1c4b-4281-b951-d872f2087c98
* Revert of "Redo r113722 - Add Pass(), which implements move semantics, to ↵ajwong@chromium.org2011-12-131-59/+0
| | | | | | | | | | | | | | | | | 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-0/+59
| | | | | | | | | | | | | | 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-59/+0
| | | | | | | | | | | | | | | | 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-0/+59
| | | | | | | | | | | | | | | | | | | | | | | 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-59/+0
| | | | | | | | | | | | | | | | | | | | | | 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-0/+59
| | | | | | | | | | | | | | | | | | | 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-19/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* base::Bind: Convert CloudPrintProxyService.jhawkins@chromium.org2011-10-251-4/+5
| | | | | | | | | BUG=none TEST=none Review URL: http://codereview.chromium.org/8368014 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@107235 0039d316-1c4b-4281-b951-d872f2087c98
* Make Callback.Equals() only work when comparing against the same type.ajwong@chromium.org2011-09-101-1/+1
| | | | | | | | | | | Previously, we were using the base class's comparator to check equality, which allows us to make comparisons across callbacks of different types. This disallows such a thing. BUG=none TEST=New no-compile test. Review URL: http://codereview.chromium.org/7780016 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@100565 0039d316-1c4b-4281-b951-d872f2087c98
* Rename BASE_API to BASE_EXPORT.darin@chromium.org2011-08-051-2/+2
| | | | | | | 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
* iwyu: Cleanup in the following files:jhawkins@chromium.org2011-04-041-0/+2
| | | | | | | | | | | | | | | | | | | | | * at_exit.cc * atomicops.h * base_paths.h * bzip2_error_handler.cc * callback_internal.h * command_line.cc * cpu.cc * environment.h * event_recorder.cc * file_descriptor_shuffle.cc * file_path.cc BUG=none TEST=none Review URL: http://codereview.chromium.org/6759017 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@80340 0039d316-1c4b-4281-b951-d872f2087c98
* Move some files from base to base/memory.levin@chromium.org2011-03-281-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Base: A few more files using BASE_API (for base.dll)rvargas@google.com2011-03-241-1/+2
| | | | | | | | BUG=76996 TEST=none Review URL: http://codereview.chromium.org/6729002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@79303 0039d316-1c4b-4281-b951-d872f2087c98
* Callback support for unbound reference and array arguments.ajwong@chromium.org2011-03-241-0/+46
| | | | | | | | | | | 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
* Callback: De-inline CallbackBase, and move to callback_helpers -> ↵ajwong@chromium.org2011-02-181-0/+86
| | | | | | | | | | | | | | | callback_internal.h We can re-inline later if it starts being an issue. BUG=none TEST=unit-tests Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=75443 Review URL: http://codereview.chromium.org/6542026 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@75464 0039d316-1c4b-4281-b951-d872f2087c98
* Revert "Callback: De-inline CallbackBase, and move to callback_helpers -> ↵ajwong@chromium.org2011-02-181-86/+0
| | | | | | | | | | callback_internal.h" This reverts commit r75443. TBR=akalin git-svn-id: svn://svn.chromium.org/chrome/trunk/src@75445 0039d316-1c4b-4281-b951-d872f2087c98
* Callback: De-inline CallbackBase, and move to callback_helpers -> ↵ajwong@chromium.org2011-02-181-0/+86
callback_internal.h We can re-inline later if it starts being an issue. BUG=none TEST=unit-tests Review URL: http://codereview.chromium.org/6542026 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@75443 0039d316-1c4b-4281-b951-d872f2087c98