Commit c44f810c authored by tzik's avatar tzik Committed by Commit Bot

Support Microsoft::WRL::ComPtr as a receiver of base::Bind{Once,Repeating}

After this CL, we can use ComPtr as the |this| pointer of base::BindOnce
and base::BindRepeating.

ComPtr doesn't have `operator*` nor `operator->*` that are needed to run
a method pointer. So we need a special handling for it to use it as a
receiver on base::Bind.

We currently use scoped_refptr to store COM instance on base::Bind, which
happens to work, but that looks fragile. This CL is a preparation to
convert these scoped_refptr to ComPtr.

Change-Id: I1fe31e23ac627050860fe2c81ead6807a17bb939
Reviewed-on: https://chromium-review.googlesource.com/1145153
Commit-Queue: Taiju Tsuiki <tzik@chromium.org>
Reviewed-by: default avatarJan Wilken Dörrie <jdoerrie@chromium.org>
Reviewed-by: default avatarRobert Liao <robliao@chromium.org>
Reviewed-by: default avatarDaniel Cheng <dcheng@chromium.org>
Cr-Commit-Position: refs/heads/master@{#577470}
parent 49874bf7
......@@ -46,6 +46,15 @@
// BindState<> -- Stores the curried parameters, and is the main entry point
// into the Bind() system.
#if defined(OS_WIN)
namespace Microsoft {
namespace WRL {
template <typename>
class ComPtr;
} // namespace WRL
} // namespace Microsoft
#endif
namespace base {
template <typename T>
......@@ -910,6 +919,13 @@ struct BindUnwrapTraits<internal::PassedWrapper<T>> {
static T Unwrap(const internal::PassedWrapper<T>& o) { return o.Take(); }
};
#if defined(OS_WIN)
template <typename T>
struct BindUnwrapTraits<Microsoft::WRL::ComPtr<T>> {
static T* Unwrap(const Microsoft::WRL::ComPtr<T>& ptr) { return ptr.Get(); }
};
#endif
// CallbackCancellationTraits allows customization of Callback's cancellation
// semantics. By default, callbacks are not cancellable. A specialization should
// set is_cancellable = true and implement an IsCancelled() that returns if the
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment