summaryrefslogtreecommitdiffstats
path: root/base/bind_internal.h.pump
Commit message (Collapse)AuthorAgeFilesLines
* Add DCHECK to avoid binding values to null callbackshashimoto@chromium.org2012-11-201-0/+1
| | | | | | | | | | BUG=161714 TEST=base_unittests Review URL: https://chromiumcodereview.appspot.com/11419061 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@168764 0039d316-1c4b-4281-b951-d872f2087c98
* Add quick reference for bind/callback usage.brettw@chromium.org2012-07-121-0/+3
| | | | | | Review URL: https://chromiumcodereview.appspot.com/10692147 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@146425 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
* Redo r113722 - Add Pass(), which implements move semantics, to scoped_ptr, ↵ajwong@chromium.org2011-12-221-8/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-7/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-8/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-7/+8
| | | | | | | | | | | | | | | | | 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-8/+7
| | | | | | | | | | | | | | 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-7/+8
| | | | | | | | | | | | | | | | 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-8/+7
| | | | | | | | | | | | | | | | | | | | | | | 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-7/+8
| | | | | | | | | | | | | | | | | | | | | | 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-8/+7
| | | | | | | | | | | | | | | | | | | 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
* Increase Bind/Callback Arity from 6 -> 7.ajwong@chromium.org2011-11-281-7/+2
| | | | | | | | | | | | | | A few functions need this and the expected compile-speed impact is low. We should be careful when raising this number higher. If you're binding a function that has more parameters than this supports, consider refactoring your API to use a parameter struct or something. Template equation: (n^2 + 26n) / 2 Template growth: 96 -> 116 types. BUG=98542 TEST=try bots Review URL: http://codereview.chromium.org/8728010 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@111788 0039d316-1c4b-4281-b951-d872f2087c98
* Revert "Increase Bind/Callback Arity from 6 -> 11: These go to eleven."ajwong@chromium.org2011-11-241-1/+1
| | | | | | | | | | | | | | | This reverts r111410. Doing this increased Win builder cycle time by about 10s on incrementals (eyeballed from stats dashboard). Alas, 11 proved to be too high for us. BUG=98542 TEST=none Review URL: http://codereview.chromium.org/8682030 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@111463 0039d316-1c4b-4281-b951-d872f2087c98
* Increase Bind/Callback Arity from 6 -> 11: These go to eleven.ajwong@chromium.org2011-11-231-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | This is only for a build time stress test only. I will revert back to 6 after getting the data. 11 allows for binding of 11 arguments to a function, and 10 arguments to a method. 10 seemed like a nice round number to try (MSVC's tr1::bind() only supports 10). Template Growth rate (n == arity): bind.h: n bind_internal.h: (n^2 + 20n)/2 bind_internal_win.h: n callback.h: n Template growth equation: (n^2 + 26n) / 2 Template growth: 96 -> 203 types BUG=98542 TEST=try bots. Then we get to watch the bot cycle times. Review URL: http://codereview.chromium.org/8682015 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@111410 0039d316-1c4b-4281-b951-d872f2087c98
* Callback API Change: Reimplement Bind(); support IgnoreResult, full ↵ajwong@chromium.org2011-11-211-266/+365
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Reverting as an experiment to determine if this caused increased Win buildjhawkins@chromium.org2011-10-191-8/+8
| | | | | | | | | | | | | | | | | | | | | | | | times. Revert 105754 - base::Bind: Increase the arity to 7. This is required by a CL I have in the works. Stats from builds of Release Chrome target with -j12: Build time: -0.2%, within the noise. Size: No change in size of chrome binary. BUG=98542 TEST=none R=ajwong@chromium.org,akalin@chromium.org,willchan@chromium.org Review URL: http://codereview.chromium.org/8306008 TBR=jhawkins@chromium.org Review URL: http://codereview.chromium.org/8344065 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@106386 0039d316-1c4b-4281-b951-d872f2087c98
* base::Bind: Increase the arity to 7.jhawkins@chromium.org2011-10-161-8/+8
| | | | | | | | | | | | | | | | | This is required by a CL I have in the works. Stats from builds of Release Chrome target with -j12: Build time: -0.2%, within the noise. Size: No change in size of chrome binary. BUG=98542 TEST=none R=ajwong@chromium.org,akalin@chromium.org,willchan@chromium.org Review URL: http://codereview.chromium.org/8306008 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@105754 0039d316-1c4b-4281-b951-d872f2087c98
* Use NeedsScopedRefptrButGetsRawPtr instead of UnsafeBindtoRefCountedArg.ajwong@chromium.org2011-10-011-3/+6
| | | | | | | | | | | | | | | | | | Will's implementation of NeedsScopedRefptrButGetsRawPtr checks for refcounting by testing for converability of the pointer values to base::RefCounted and base::RefCountedThreadsafe. This happens to tolerate incomplete types in a sane way on linux where the check is enabled. UnsafeBindtoRefCountedArg's impelmentation relies on introspecting the type for the existence of a member function. Though this will catch refcounted objects with a refcount API that are not derived from base::RefCounted and base::RefCountedThreadsafe it requires complete types which places too strong of a constraint on what kinds of arguments can be bound. Since the majority (all?) refcounted types in Chromium are derived from base::RefCounted and base::RefCountedThreadsafe, this should be just as good of a guarantee. Bug filed to see if there's a way to adapt UnsafeBindtoRefCountedArg. BUG=94995,98732 TEST=new unittest. Review URL: http://codereview.chromium.org/8101008 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@103627 0039d316-1c4b-4281-b951-d872f2087c98
* Allow Bind() to take a Callback<> and bind all its free parameters.ajwong@chromium.org2011-09-301-0/+17
| | | | | | | | | | | | | | | | Basically, turns base::Callback<void(...)> to base::Closure. It turns out there are a number of use caess where an API takes a callback, and then wants to invoke the Callback on another thread. This piece of syntactic sugar removes the need for custom helper functions. This isn't quite full currying, however it is much simpler to implement. BUG=87287 TEST=none Review URL: http://codereview.chromium.org/8073012 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@103446 0039d316-1c4b-4281-b951-d872f2087c98
* Add COMPILE_ASSERT to ensure the result of Bind matches the Callback's type.ajwong@chromium.org2011-06-261-0/+15
| | | | | | | | | | | | | | Required because we abstract the storage of the funciton pointer out using a reinterpret_cast to reduce template bloat. This effectively readds the failure that would have happened had we stored the function pointer directly in the template class. BUG=86008 TEST=new unittests. Review URL: http://codereview.chromium.org/7241015 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@90525 0039d316-1c4b-4281-b951-d872f2087c98
* Support binding WeakPtr<> to methods with void return types.ajwong@chromium.org2011-05-161-5/+58
| | | | | | | | | | | | | | | 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
* Callback support for unbound reference and array arguments.ajwong@chromium.org2011-03-241-20/+47
| | | | | | | | | | | 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 support for __fastcall and __stdcall functions.ajwong@chromium.org2011-02-271-3/+8
| | | | | | | | | | | | | | Create FunctionTraits specializations that can unwrap function pointers that are delcared with __fastcall and __stdcall on windows. Only include these in the Windows build. BUG=35223 TEST=new unittests Review URL: http://codereview.chromium.org/6561004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@76174 0039d316-1c4b-4281-b951-d872f2087c98
* Callbacks: Replumb the type-inference.ajwong@chromium.org2011-02-191-52/+96
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In preparation for attempting to support __stdcall, __fastcall, etc., break apart the templates so that instead of having one set of InvokerNs per type of function pointer, only have one per syntactic method of invocation. This lets the number of template specializations scale better. Previously, for each type of function pointer, we needed sum(1...arity) InvokerN specializations. There were 3 types (function, method, const method). The Windows calling conventions would have added another 2. in this method, we have 2 sets of InvokerN templates, and 1 set of FunctionTraits templates for each type. We only need (arity) number of FunctionTraits templates, so this is a net win. For our 6-arity system, it should go from 5 types * (1+2+3+4+5+6) InvokerNs = 105 specializations to 5 types * 6 FunctionTraits + 2 calling_syntaxes * (1+2+3+4+5+6) InvokerNs = 72 specializations This puts a bit more work on the compiler, but...hey, better it than the reader of the code. BUG=35223 TEST=none Review URL: http://codereview.chromium.org/6538045 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@75482 0039d316-1c4b-4281-b951-d872f2087c98
* Callback: De-inline CallbackBase, and move to callback_helpers -> ↵ajwong@chromium.org2011-02-181-1/+1
| | | | | | | | | | | | | | | 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-1/+1
| | | | | | | | | | 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-1/+1
| | | | | | | | | | | | | 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
* Unified callback system based on tr1::function/tr1::bind and Google's ↵ajwong@chromium.org2011-02-151-0/+237
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