Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(160)

Unified Diff: mojo/public/cpp/bindings/lib/callback_internal.h

Issue 294833002: Mojo: more idiomatic C++ bindings (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix windows bustage Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: mojo/public/cpp/bindings/lib/callback_internal.h
diff --git a/mojo/public/cpp/bindings/lib/callback_internal.h b/mojo/public/cpp/bindings/lib/callback_internal.h
index 4802e437f2b6be2a4bec41ca7a27398175b1dcf2..d43ca2a58bd6fa193f3ad29471515474013cff41 100644
--- a/mojo/public/cpp/bindings/lib/callback_internal.h
+++ b/mojo/public/cpp/bindings/lib/callback_internal.h
@@ -6,49 +6,31 @@
#define MOJO_PUBLIC_CPP_BINDINGS_LIB_CALLBACK_INTERNAL_H_
#include "mojo/public/cpp/bindings/lib/bindings_internal.h"
+#include "mojo/public/cpp/bindings/lib/template_util.h"
namespace mojo {
+class String;
+
namespace internal {
-template <typename T, bool is_object_type = TypeTraits<T>::kIsObject>
+template <typename T, bool is_move_only = IsMoveOnlyType<T>::value>
yzshen1 2014/05/27 22:16:59 It seems we don't need the second template paramet
struct Callback_ParamTraits {};
template <typename T>
struct Callback_ParamTraits<T, true> {
- typedef const T& ForwardType;
- static const bool kIsScopedHandle = false;
+ typedef T ForwardType;
};
template <typename T>
struct Callback_ParamTraits<T, false> {
typedef T ForwardType;
- static const bool kIsScopedHandle = false;
};
-template <typename H>
-struct Callback_ParamTraits<ScopedHandleBase<H>, true> {
- typedef ScopedHandleBase<H> ForwardType;
- static const bool kIsScopedHandle = true;
+template <>
+struct Callback_ParamTraits<String, false> {
+ typedef const String& ForwardType;
};
-template<bool B, typename T = void>
-struct EnableIf {};
-
-template<typename T>
-struct EnableIf<true, T> { typedef T type; };
-
-template <typename T>
-typename EnableIf<!Callback_ParamTraits<T>::kIsScopedHandle, T>::type&
- Callback_Forward(T& t) {
- return t;
-}
-
-template <typename T>
-typename EnableIf<Callback_ParamTraits<T>::kIsScopedHandle, T>::type
- Callback_Forward(T& t) {
- return t.Pass();
-}
-
} // namespace internal
} // namespace mojo

Powered by Google App Engine
This is Rietveld 408576698