Index: sync/internal_api/public/util/weak_handle.h |
diff --git a/sync/internal_api/public/util/weak_handle.h b/sync/internal_api/public/util/weak_handle.h |
index 2e499103ed1893de39d12f6c09051faa32d5d21a..6356e00df18fa3201ac10f58d1f066f1e98ea15b 100644 |
--- a/sync/internal_api/public/util/weak_handle.h |
+++ b/sync/internal_api/public/util/weak_handle.h |
@@ -114,6 +114,9 @@ class WeakHandleCoreBase { |
// May be called on any thread. |
void PostToOwnerThread(const tracked_objects::Location& from_here, |
const base::Closure& fn) const; |
+ void PostWithReplyToOwnerThread(const tracked_objects::Location& from_here, |
+ const base::Closure& fn, |
+ const base::Closure& reply) const; |
private: |
// May be used on any thread. |
@@ -195,6 +198,71 @@ class WeakHandleCore |
this, fn, a1, a2, a3, a4)); |
} |
+ // Variants that allow for a reply callback. |
+ template <typename U> |
+ void CallWithReply(const tracked_objects::Location& from_here, |
+ void (U::*fn)(void), |
+ const base::Closure& reply) const { |
+ PostWithReplyToOwnerThread( |
+ from_here, |
+ Bind(&WeakHandleCore::template DoCall0<U>, this, fn), |
+ reply); |
+ } |
+ |
+ template <typename U, typename A1> |
+ void CallWithReply(const tracked_objects::Location& from_here, |
+ void (U::*fn)(A1), |
+ typename ParamTraits<A1>::ForwardType a1, |
+ const base::Closure& reply) const { |
+ PostWithReplyToOwnerThread( |
+ from_here, |
+ Bind(&WeakHandleCore::template DoCall1<U, A1>, |
+ this, fn, a1), |
+ reply); |
+ } |
+ |
+ template <typename U, typename A1, typename A2> |
+ void CallWithReply(const tracked_objects::Location& from_here, |
+ void (U::*fn)(A1, A2), |
+ typename ParamTraits<A1>::ForwardType a1, |
+ typename ParamTraits<A2>::ForwardType a2, |
+ const base::Closure& reply) const { |
+ PostWithReplyToOwnerThread( |
+ from_here, |
+ Bind(&WeakHandleCore::template DoCall2<U, A1, A2>, |
+ this, fn, a1, a2), |
+ reply); |
+ } |
+ |
+ template <typename U, typename A1, typename A2, typename A3> |
+ void CallWithReply(const tracked_objects::Location& from_here, |
+ void (U::*fn)(A1, A2, A3), |
+ typename ParamTraits<A1>::ForwardType a1, |
+ typename ParamTraits<A2>::ForwardType a2, |
+ typename ParamTraits<A3>::ForwardType a3, |
+ const base::Closure& reply) const { |
+ PostWithReplyToOwnerThread( |
+ from_here, |
+ Bind(&WeakHandleCore::template DoCall3<U, A1, A2, A3>, |
+ this, fn, a1, a2, a3), |
+ reply); |
+ } |
+ |
+ template <typename U, typename A1, typename A2, typename A3, typename A4> |
+ void CallWithReply(const tracked_objects::Location& from_here, |
+ void (U::*fn)(A1, A2, A3, A4), |
+ typename ParamTraits<A1>::ForwardType a1, |
+ typename ParamTraits<A2>::ForwardType a2, |
+ typename ParamTraits<A3>::ForwardType a3, |
+ typename ParamTraits<A4>::ForwardType a4, |
+ const base::Closure& reply) const { |
+ PostWithReplyToOwnerThread( |
+ from_here, |
+ Bind(&WeakHandleCore::template DoCall4<U, A1, A2, A3, A4>, |
+ this, fn, a1, a2, a3, a4), |
+ reply); |
+ } |
+ |
private: |
friend class base::RefCountedThreadSafe<WeakHandleCore<T> >; |
@@ -358,6 +426,58 @@ class WeakHandle { |
core_->Call(from_here, fn, a1, a2, a3, a4); |
} |
+ // Variants that allow for a reply callback. |
+ template <typename U> |
+ void CallWithReply(const tracked_objects::Location& from_here, |
+ void (U::*fn)(void), |
+ const base::Closure& reply) const { |
+ CHECK(IsInitialized()); |
+ core_->CallWithReply(from_here, fn, reply); |
+ } |
+ |
+ template <typename U, typename A1> |
+ void CallWithReply(const tracked_objects::Location& from_here, |
+ void (U::*fn)(A1), |
+ typename internal::ParamTraits<A1>::ForwardType a1, |
+ const base::Closure& reply) const { |
+ CHECK(IsInitialized()); |
+ core_->CallWithReply(from_here, fn, a1, reply); |
+ } |
+ |
+ template <typename U, typename A1, typename A2> |
+ void CallWithReply(const tracked_objects::Location& from_here, |
+ void (U::*fn)(A1, A2), |
+ typename internal::ParamTraits<A1>::ForwardType a1, |
+ typename internal::ParamTraits<A2>::ForwardType a2, |
+ const base::Closure& reply) const { |
+ CHECK(IsInitialized()); |
+ core_->CallWithReply(from_here, fn, a1, a2, reply); |
+ } |
+ |
+ template <typename U, typename A1, typename A2, typename A3> |
+ void CallWithReply(const tracked_objects::Location& from_here, |
+ void (U::*fn)(A1, A2, A3), |
+ typename internal::ParamTraits<A1>::ForwardType a1, |
+ typename internal::ParamTraits<A2>::ForwardType a2, |
+ typename internal::ParamTraits<A3>::ForwardType a3, |
+ const base::Closure& reply) const { |
+ CHECK(IsInitialized()); |
+ core_->CallWithReply(from_here, fn, a1, a2, a3, reply); |
+ } |
+ |
+ template <typename U, typename A1, typename A2, typename A3, typename A4> |
+ void CallWithReply(const tracked_objects::Location& from_here, |
+ void (U::*fn)(A1, A2, A3, A4), |
+ typename internal::ParamTraits<A1>::ForwardType a1, |
+ typename internal::ParamTraits<A2>::ForwardType a2, |
+ typename internal::ParamTraits<A3>::ForwardType a3, |
+ typename internal::ParamTraits<A4>::ForwardType a4, |
+ const base::Closure& reply) const { |
+ CHECK(IsInitialized()); |
+ core_->CallWithReply(from_here, fn, a1, a2, a3, a4, reply); |
+ } |
+ |
+ |
private: |
FRIEND_TEST_ALL_PREFIXES(WeakHandleTest, |
TypeConversionConstructor); |