Index: tools/clang/base_bind_rewriters/tests/test-expected.cc |
diff --git a/tools/clang/base_bind_rewriters/tests/test-expected.cc b/tools/clang/base_bind_rewriters/tests/test-expected.cc |
index 59a3b1c464de0034b55301a603bb95b54d98ff7b..92e175283f4f88b62591f0490a2998dd0748f434 100644 |
--- a/tools/clang/base_bind_rewriters/tests/test-expected.cc |
+++ b/tools/clang/base_bind_rewriters/tests/test-expected.cc |
@@ -1,35 +1,82 @@ |
-// Copyright 2016 The Chromium Authors. All rights reserved. |
+// Copyright 2017 The Chromium Authors. All rights reserved. |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
-template <typename> |
-class scoped_refptr { |
+#include <utility> |
+ |
+namespace base { |
+namespace internal { |
+ |
+enum class CopyMode { MoveOnly, Copyable }; |
+enum class RepeatMode { Once, Repeating }; |
+ |
+} // namespace internal |
+ |
+template <typename Signature, |
+ internal::CopyMode copy_mode = internal::CopyMode::Copyable, |
+ internal::RepeatMode repeat_mode = internal::RepeatMode::Repeating> |
+class Callback; |
+ |
+template <typename Signature> |
+using OnceCallback = Callback<Signature, |
+ internal::CopyMode::MoveOnly, |
+ internal::RepeatMode::Once>; |
+template <typename Signature> |
+using RepeatingCallback = Callback<Signature, |
+ internal::CopyMode::Copyable, |
+ internal::RepeatMode::Repeating>; |
+ |
+using Closure = Callback<void()>; |
+using OnceClosure = OnceCallback<void()>; |
+using RepeatingClosure = RepeatingCallback<void()>; |
+ |
+namespace internal { |
+ |
+template <typename From, typename To> |
+struct IsCallbackConvertible : std::false_type {}; |
+ |
+template <typename Signature> |
+struct IsCallbackConvertible<RepeatingCallback<Signature>, |
+ OnceCallback<Signature>> : std::true_type {}; |
+ |
+} // namespace internal |
+ |
+template <typename Signature, internal::CopyMode, internal::RepeatMode> |
+class Callback { |
public: |
- void* get() { return 0; } |
+ Callback() {} |
+ Callback(const Callback&) {} |
+ Callback(Callback&&) {} |
+ |
+ template <typename OtherCallback, |
+ typename = typename std::enable_if< |
+ internal::IsCallbackConvertible<OtherCallback, |
+ Callback>::value>::type> |
+ Callback(OtherCallback other) {} |
}; |
-namespace base { |
+template <typename Functor, typename... Args> |
+Callback<void()> Bind(Functor, Args&&...) { |
+ return Callback<void()>(); |
+} |
template <typename Functor, typename... Args> |
-void Bind(Functor&&, Args&&...) {} |
+OnceCallback<void()> BindOnce(Functor, Args&&...) { |
+ return Callback<void()>(); |
+} |
} // namespace base |
-struct Foo { |
- void Bar(); |
- static void Baz(); |
-}; |
+void foo(base::OnceClosure) {} |
dcheng
2017/04/05 16:57:37
Super minor nit: Uppercase foo() to follow Google
tzik
2017/04/11 07:35:13
Done.
|
void Test() { |
- using base::Bind; |
- scoped_refptr<int> foo; |
- base::Bind(&Foo::Bar, foo); |
- Bind(&Foo::Bar, foo); |
- base::Bind(&Foo::Bar, (&foo)); |
- base::Bind(&Foo::Bar, foo); |
- base::Bind(&Foo::Bar, foo); |
- base::Bind(&Foo::Bar, foo, foo.get()); |
- base::Bind(&Foo::Baz, foo.get()); |
- base::Bind(&Foo::Bar, foo); |
- base::Bind(&Foo::Bar, (&foo)); |
+ base::OnceClosure cb = base::BindOnce([] {}); |
+ foo(base::BindOnce([] {})); |
+ |
+ using namespace base; |
+ |
+ OnceClosure cb2 = BindOnce([] {}); |
+ foo(BindOnce([] {})); |
+ |
+ Closure cb3 = base::Bind([] {}); |
} |