mirror of
				https://bitbucket.org/chromiumembedded/cef
				synced 2025-06-05 21:39:12 +02:00 
			
		
		
		
	Remove deprecated base::Bind APIs (see issue #3140)
This CL removes the following deprecated APIs: - base::Bind() - base::Callback - base::Closure - base::CancelableCallback - base::CancelableClosure The behavior that these APIs provided is still available using the *Repeating* variants. However, consider strongly whether using these variants is actually necessary in your case or whether the *Once* variants will suffice: unless your callback *objects* (note: not variables!) need to be called multiple times, they most likely can and should be the Once variants. This applies the same changes as https://crrev.com/6cc94b5339.
This commit is contained in:
		| @@ -54,9 +54,6 @@ | |||||||
| //   auto cb = base::BindOnce(&C::F, instance); | //   auto cb = base::BindOnce(&C::F, instance); | ||||||
| //   std::move(cb).Run();  // Identical to instance->F() | //   std::move(cb).Run();  // Identical to instance->F() | ||||||
| // | // | ||||||
| // base::Bind is currently a type alias for base::BindRepeating(). In the |  | ||||||
| // future, we expect to flip this to default to base::BindOnce(). |  | ||||||
| // |  | ||||||
| // See //docs/callback.md for the full documentation. | // See //docs/callback.md for the full documentation. | ||||||
| // | // | ||||||
| // ----------------------------------------------------------------------------- | // ----------------------------------------------------------------------------- | ||||||
| @@ -126,17 +123,6 @@ BindRepeating(Functor&& functor, Args&&... args) { | |||||||
|                                                std::forward<Args>(args)...); |                                                std::forward<Args>(args)...); | ||||||
| } | } | ||||||
|  |  | ||||||
| // Unannotated Bind. |  | ||||||
| // TODO(tzik): Deprecate this and migrate to OnceCallback and |  | ||||||
| // RepeatingCallback, once they get ready. |  | ||||||
| template <typename Functor, typename... Args> |  | ||||||
| inline Callback<internal::MakeUnboundRunType<Functor, Args...>> Bind( |  | ||||||
|     Functor&& functor, |  | ||||||
|     Args&&... args) { |  | ||||||
|   return base::BindRepeating(std::forward<Functor>(functor), |  | ||||||
|                              std::forward<Args>(args)...); |  | ||||||
| } |  | ||||||
|  |  | ||||||
| // Special cases for binding to a base::Callback without extra bound arguments. | // Special cases for binding to a base::Callback without extra bound arguments. | ||||||
| // We CHECK() the validity of callback to guard against null pointers | // We CHECK() the validity of callback to guard against null pointers | ||||||
| // accidentally ending up in posted tasks, causing hard-to-debug crashes. | // accidentally ending up in posted tasks, causing hard-to-debug crashes. | ||||||
| @@ -159,12 +145,6 @@ RepeatingCallback<Signature> BindRepeating( | |||||||
|   return callback; |   return callback; | ||||||
| } | } | ||||||
|  |  | ||||||
| template <typename Signature> |  | ||||||
| Callback<Signature> Bind(Callback<Signature> callback) { |  | ||||||
|   CHECK(callback); |  | ||||||
|   return callback; |  | ||||||
| } |  | ||||||
|  |  | ||||||
| // Unretained() allows binding a non-refcounted class, and to disable | // Unretained() allows binding a non-refcounted class, and to disable | ||||||
| // refcounting on arguments that are refcounted objects. | // refcounting on arguments that are refcounted objects. | ||||||
| // | // | ||||||
|   | |||||||
| @@ -60,9 +60,6 @@ | |||||||
| // will be a no-op. Note that |IsCancelled()| and |is_null()| are distinct: | // will be a no-op. Note that |IsCancelled()| and |is_null()| are distinct: | ||||||
| // simply cancelling a callback will not also make it null. | // simply cancelling a callback will not also make it null. | ||||||
| // | // | ||||||
| // base::Callback is currently a type alias for base::RepeatingCallback. In the |  | ||||||
| // future, we expect to flip this to default to base::OnceCallback. |  | ||||||
| // |  | ||||||
| // See https://chromium.googlesource.com/chromium/src/+/HEAD/docs/callback.md | // See https://chromium.googlesource.com/chromium/src/+/HEAD/docs/callback.md | ||||||
| // for the full documentation. | // for the full documentation. | ||||||
|  |  | ||||||
| @@ -115,7 +112,7 @@ class OnceCallback<R(Args...)> : public internal::CallbackBase { | |||||||
|     return *this; |     return *this; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   R Run(Args... args) const & { |   R Run(Args... args) const& { | ||||||
|     static_assert(!sizeof(*this), |     static_assert(!sizeof(*this), | ||||||
|                   "OnceCallback::Run() may only be invoked on a non-const " |                   "OnceCallback::Run() may only be invoked on a non-const " | ||||||
|                   "rvalue, i.e. std::move(callback).Run()."); |                   "rvalue, i.e. std::move(callback).Run()."); | ||||||
| @@ -195,7 +192,7 @@ class RepeatingCallback<R(Args...)> : public internal::CallbackBaseCopyable { | |||||||
|     return !operator==(other); |     return !operator==(other); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   R Run(Args... args) const & { |   R Run(Args... args) const& { | ||||||
|     PolymorphicInvoke f = |     PolymorphicInvoke f = | ||||||
|         reinterpret_cast<PolymorphicInvoke>(this->polymorphic_invoke()); |         reinterpret_cast<PolymorphicInvoke>(this->polymorphic_invoke()); | ||||||
|     return f(this->bind_state_.get(), std::forward<Args>(args)...); |     return f(this->bind_state_.get(), std::forward<Args>(args)...); | ||||||
|   | |||||||
| @@ -48,15 +48,11 @@ class OnceCallback; | |||||||
| template <typename Signature> | template <typename Signature> | ||||||
| class RepeatingCallback; | class RepeatingCallback; | ||||||
|  |  | ||||||
| template <typename Signature> |  | ||||||
| using Callback = RepeatingCallback<Signature>; |  | ||||||
|  |  | ||||||
| // Syntactic sugar to make OnceClosure<void()> and RepeatingClosure<void()> | // Syntactic sugar to make OnceClosure<void()> and RepeatingClosure<void()> | ||||||
| // easier to declare since they will be used in a lot of APIs with delayed | // easier to declare since they will be used in a lot of APIs with delayed | ||||||
| // execution. | // execution. | ||||||
| using OnceClosure = OnceCallback<void()>; | using OnceClosure = OnceCallback<void()>; | ||||||
| using RepeatingClosure = RepeatingCallback<void()>; | using RepeatingClosure = RepeatingCallback<void()>; | ||||||
| using Closure = Callback<void()>; |  | ||||||
|  |  | ||||||
| }  // namespace base | }  // namespace base | ||||||
|  |  | ||||||
|   | |||||||
| @@ -83,10 +83,10 @@ | |||||||
|  |  | ||||||
| #include "include/base/cef_bind.h" | #include "include/base/cef_bind.h" | ||||||
| #include "include/base/cef_callback.h" | #include "include/base/cef_callback.h" | ||||||
| #include "include/base/internal/cef_callback_internal.h" |  | ||||||
| #include "include/base/cef_logging.h" |  | ||||||
| #include "include/base/cef_compiler_specific.h" | #include "include/base/cef_compiler_specific.h" | ||||||
|  | #include "include/base/cef_logging.h" | ||||||
| #include "include/base/cef_weak_ptr.h" | #include "include/base/cef_weak_ptr.h" | ||||||
|  | #include "include/base/internal/cef_callback_internal.h" | ||||||
|  |  | ||||||
| namespace base { | namespace base { | ||||||
| namespace internal { | namespace internal { | ||||||
| @@ -113,9 +113,7 @@ class CancelableCallbackImpl { | |||||||
|   } |   } | ||||||
|  |  | ||||||
|   // Returns true if the wrapped callback has been cancelled. |   // Returns true if the wrapped callback has been cancelled. | ||||||
|   bool IsCancelled() const { |   bool IsCancelled() const { return callback_.is_null(); } | ||||||
|     return callback_.is_null(); |  | ||||||
|   } |  | ||||||
|  |  | ||||||
|   // Sets |callback| as the closure that may be cancelled. |callback| may not |   // Sets |callback| as the closure that may be cancelled. |callback| may not | ||||||
|   // be null. Outstanding and any previously wrapped callbacks are cancelled. |   // be null. Outstanding and any previously wrapped callbacks are cancelled. | ||||||
| @@ -180,10 +178,6 @@ using CancelableRepeatingCallback = | |||||||
|     internal::CancelableCallbackImpl<RepeatingCallback<Signature>>; |     internal::CancelableCallbackImpl<RepeatingCallback<Signature>>; | ||||||
| using CancelableRepeatingClosure = CancelableRepeatingCallback<void()>; | using CancelableRepeatingClosure = CancelableRepeatingCallback<void()>; | ||||||
|  |  | ||||||
| template <typename Signature> |  | ||||||
| using CancelableCallback = CancelableRepeatingCallback<Signature>; |  | ||||||
| using CancelableClosure = CancelableCallback<void()>; |  | ||||||
|  |  | ||||||
| }  // namespace base | }  // namespace base | ||||||
|  |  | ||||||
| #endif  // !USING_CHROMIUM_INCLUDES | #endif  // !USING_CHROMIUM_INCLUDES | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user