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

Unified Diff: third_party/WebKit/Source/wtf/Functional.h

Issue 2122133002: Make Function's constructor and bindInternal() private Base URL: https://chromium.googlesource.com/chromium/src.git@TRV_WTFCrossThreadBind
Patch Set: Rebase Created 4 years, 5 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/wtf/Functional.h
diff --git a/third_party/WebKit/Source/wtf/Functional.h b/third_party/WebKit/Source/wtf/Functional.h
index bdcff7c12602e8cfd6f35a9fb937b235663cc1e4..d4f6c45f6ac7dbdd26645207f2bdde2cbbf36344 100644
--- a/third_party/WebKit/Source/wtf/Functional.h
+++ b/third_party/WebKit/Source/wtf/Functional.h
@@ -239,9 +239,6 @@ class Function<R(Args...), threadAffinity> {
USING_FAST_MALLOC(Function);
WTF_MAKE_NONCOPYABLE(Function);
public:
- Function(base::Callback<R(Args...)> callback)
- : m_callback(std::move(callback)) { }
-
~Function()
{
DCHECK(m_threadChecker.CalledOnValidThread());
@@ -259,6 +256,22 @@ public:
}
private:
+ Function(base::Callback<R(Args...)> callback)
+ : m_callback(std::move(callback)) { }
+
+ template <typename FunctionType, typename... BoundParameters>
+ static std::unique_ptr<Function<base::MakeUnboundRunType<FunctionType, BoundParameters...>, threadAffinity>> bindInternal(FunctionType function, BoundParameters&&... boundParameters)
+ {
+ using UnboundRunType = base::MakeUnboundRunType<FunctionType, BoundParameters...>;
+ return wrapUnique(new Function<UnboundRunType, threadAffinity>(base::Bind(function, typename ParamStorageTraits<typename std::decay<BoundParameters>::type>::StorageType(std::forward<BoundParameters>(boundParameters))...)));
+ }
+
+ template <typename FunctionType, typename... BoundParameters>
+ friend std::unique_ptr<Function<base::MakeUnboundRunType<FunctionType, BoundParameters...>, SameThreadAffinity>> bind(FunctionType, BoundParameters&&...);
+
+ template <typename FunctionType, typename... BoundParameters>
+ friend std::unique_ptr<Function<base::MakeUnboundRunType<FunctionType, BoundParameters...>, CrossThreadAffinity>> crossThreadBind(FunctionType, BoundParameters&&...);
+
using MaybeThreadChecker = typename std::conditional<
threadAffinity == SameThreadAffinity,
base::ThreadChecker,
@@ -267,23 +280,16 @@ private:
base::Callback<R(Args...)> m_callback;
};
-template <FunctionThreadAffinity threadAffinity, typename FunctionType, typename... BoundParameters>
-std::unique_ptr<Function<base::MakeUnboundRunType<FunctionType, BoundParameters...>, threadAffinity>> bindInternal(FunctionType function, BoundParameters&&... boundParameters)
-{
- using UnboundRunType = base::MakeUnboundRunType<FunctionType, BoundParameters...>;
- return wrapUnique(new Function<UnboundRunType, threadAffinity>(base::Bind(function, typename ParamStorageTraits<typename std::decay<BoundParameters>::type>::StorageType(std::forward<BoundParameters>(boundParameters))...)));
-}
-
template <typename FunctionType, typename... BoundParameters>
std::unique_ptr<Function<base::MakeUnboundRunType<FunctionType, BoundParameters...>, SameThreadAffinity>> bind(FunctionType function, BoundParameters&&... boundParameters)
{
- return bindInternal<SameThreadAffinity>(function, std::forward<BoundParameters>(boundParameters)...);
+ return Function<base::MakeUnboundRunType<FunctionType, BoundParameters...>, SameThreadAffinity>::bindInternal(function, std::forward<BoundParameters>(boundParameters)...);
}
template <typename FunctionType, typename... BoundParameters>
std::unique_ptr<Function<base::MakeUnboundRunType<FunctionType, BoundParameters...>, CrossThreadAffinity>> crossThreadBind(FunctionType function, BoundParameters&&... boundParameters)
{
- return bindInternal<CrossThreadAffinity>(function, CrossThreadCopier<typename std::decay<BoundParameters>::type>::copy(std::forward<BoundParameters>(boundParameters))...);
+ return Function<base::MakeUnboundRunType<FunctionType, BoundParameters...>, CrossThreadAffinity>::bindInternal(function, CrossThreadCopier<typename std::decay<BoundParameters>::type>::copy(std::forward<BoundParameters>(boundParameters))...);
}
typedef Function<void(), SameThreadAffinity> Closure;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698