Chromium Code Reviews| Index: third_party/WebKit/Source/platform/base/Bind.h |
| diff --git a/third_party/WebKit/Source/platform/base/Bind.h b/third_party/WebKit/Source/platform/base/Bind.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..2347b75ef79bfd5a4562e93beaffcf6495a488b5 |
| --- /dev/null |
| +++ b/third_party/WebKit/Source/platform/base/Bind.h |
| @@ -0,0 +1,28 @@ |
| +// Copyright 2016 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. |
| + |
| +#ifndef Bind_h |
| +#define Bind_h |
| + |
| +#include "base/bind.h" |
| + |
| +// This file provides limited access to base::Bind() function. base::Bind() |
| +// could be dangerous if it's used across threads, so we don't want to allow |
| +// general use of base::Bind(). |
| +// See also "platform/ThreadSafeFunctional.h". |
| + |
| +namespace blink { |
| + |
| +// Binds an instance of a class to its member function. Does not bind anything |
| +// else. |
| +template<typename Class, typename ReturnType, typename... Args> |
| +auto bindInstanceToMethod(ReturnType (Class::*method)(Args...), Class* instance) |
|
dcheng
2016/01/27 02:50:01
Out of curiosity, why not base::Callback<ReturnTyp
Yuki
2016/01/27 04:29:45
The return type of base::Bind is
template <typena
tzik
2016/01/27 05:17:26
The result of the complex template is just to drop
Yuki
2016/01/27 05:31:08
Ah, I see. Good to know. Thanks.
|
| + -> decltype(base::Bind(method, base::Unretained(instance))) |
| +{ |
| + return base::Bind(method, base::Unretained(instance)); |
| +} |
| + |
| +} // namespace blink |
| + |
| +#endif // Bind_h |