Index: base/bind_helpers.h |
diff --git a/base/bind_helpers.h b/base/bind_helpers.h |
index f3efc31953c78b349bf1b7e2d23c802129f54ac9..af6f8ac6ca312587d2f9dab3d5c02eb21748000c 100644 |
--- a/base/bind_helpers.h |
+++ b/base/bind_helpers.h |
@@ -435,45 +435,44 @@ struct UnwrapTraits<PassedWrapper<T> > { |
// Utility for handling different refcounting semantics in the Bind() |
// function. |
-template <bool is_method, typename T> |
-struct MaybeRefcount; |
+template <bool is_method, typename... T> |
+struct MaybeScopedRefPtr; |
-template <typename T> |
-struct MaybeRefcount<false, T> { |
- static void AddRef(const T&) {} |
- static void Release(const T&) {} |
+template <bool is_method> |
+struct MaybeScopedRefPtr<is_method> { |
+ MaybeScopedRefPtr() {} |
}; |
-template <typename T, size_t n> |
-struct MaybeRefcount<false, T[n]> { |
- static void AddRef(const T*) {} |
- static void Release(const T*) {} |
+template <typename T, typename... Rest> |
+struct MaybeScopedRefPtr<false, T, Rest...> { |
+ MaybeScopedRefPtr(const T&, const Rest&...) {} |
}; |
-template <typename T> |
-struct MaybeRefcount<true, T> { |
- static void AddRef(const T&) {} |
- static void Release(const T&) {} |
+template <typename T, size_t n, typename... Rest> |
+struct MaybeScopedRefPtr<false, T[n], Rest...> { |
+ MaybeScopedRefPtr(const T*, const Rest&...) {} |
}; |
-template <typename T> |
-struct MaybeRefcount<true, T*> { |
- static void AddRef(T* o) { o->AddRef(); } |
- static void Release(T* o) { o->Release(); } |
+template <typename T, typename... Rest> |
+struct MaybeScopedRefPtr<true, T, Rest...> { |
+ MaybeScopedRefPtr(const T& o, const Rest&...) {} |
}; |
-// No need to additionally AddRef() and Release() since we are storing a |
-// scoped_refptr<> inside the storage object already. |
-template <typename T> |
-struct MaybeRefcount<true, scoped_refptr<T> > { |
- static void AddRef(const scoped_refptr<T>& o) {} |
- static void Release(const scoped_refptr<T>& o) {} |
+template <typename T, typename... Rest> |
+struct MaybeScopedRefPtr<true, T*, Rest...> { |
+ MaybeScopedRefPtr(T* o, const Rest&...) : ref_(o) {} |
+ scoped_refptr<T> ref_; |
}; |
-template <typename T> |
-struct MaybeRefcount<true, const T*> { |
- static void AddRef(const T* o) { o->AddRef(); } |
- static void Release(const T* o) { o->Release(); } |
+template <typename T, typename... Rest> |
+struct MaybeScopedRefPtr<true, scoped_refptr<T>, Rest...> { |
+ MaybeScopedRefPtr(const scoped_refptr<T>&, const Rest&...) {} |
+}; |
+ |
+template <typename T, typename... Rest> |
+struct MaybeScopedRefPtr<true, const T*, Rest...> { |
+ MaybeScopedRefPtr(const T* o, const Rest&...) : ref_(o) {} |
+ scoped_refptr<const T> ref_; |
}; |
// IsWeakMethod is a helper that determine if we are binding a WeakPtr<> to a |
@@ -482,14 +481,15 @@ struct MaybeRefcount<true, const T*> { |
// the target object is invalidated. |
// |
// P1 should be the type of the object that will be received of the method. |
-template <bool IsMethod, typename P1> |
+template <bool IsMethod, typename... Args> |
struct IsWeakMethod : public false_type {}; |
-template <typename T> |
-struct IsWeakMethod<true, WeakPtr<T> > : public true_type {}; |
+template <typename T, typename... Args> |
+struct IsWeakMethod<true, WeakPtr<T>, Args...> : public true_type {}; |
-template <typename T> |
-struct IsWeakMethod<true, ConstRefWrapper<WeakPtr<T> > > : public true_type {}; |
+template <typename T, typename... Args> |
+struct IsWeakMethod<true, ConstRefWrapper<WeakPtr<T> >, Args...> |
+ : public true_type {}; |
} // namespace internal |