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

Side by Side Diff: third_party/WebKit/Source/platform/CrossThreadFunctional.h

Issue 2125003002: Move CrossThreadCopier from platform/ to wtf/ Base URL: https://chromium.googlesource.com/chromium/src.git@TRV_RemoveTupleInBind
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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CrossThreadFunctional_h 5 #ifndef CrossThreadFunctional_h
6 #define CrossThreadFunctional_h 6 #define CrossThreadFunctional_h
7 7
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "platform/CrossThreadCopier.h" 9 #include "wtf/CrossThreadCopier.h"
sof 2016/07/06 14:13:34 Do you plan to move CrossThreadFunctional.h in a f
10 #include "wtf/Functional.h" 10 #include "wtf/Functional.h"
11 #include <type_traits> 11 #include <type_traits>
12 12
13 namespace blink { 13 namespace blink {
14 14
15 // crossThreadBind() is bind() for cross-thread task posting. 15 // crossThreadBind() is bind() for cross-thread task posting.
16 // crossThreadBind() applies CrossThreadCopier to the arguments. 16 // crossThreadBind() applies CrossThreadCopier to the arguments.
17 // 17 //
18 // Example: 18 // Example:
19 // void func1(int, const String&); 19 // void func1(int, const String&);
20 // f = crossThreadBind(func1, 42, str); 20 // f = crossThreadBind(func1, 42, str);
21 // func1(42, str2) will be called when |f()| is executed, 21 // func1(42, str2) will be called when |f()| is executed,
22 // where |str2| is a deep copy of |str| (created by str.isolatedCopy()). 22 // where |str2| is a deep copy of |str| (created by str.isolatedCopy()).
23 // 23 //
24 // crossThreadBind(str) is similar to bind(str.isolatedCopy()), but the latter 24 // crossThreadBind(str) is similar to bind(str.isolatedCopy()), but the latter
25 // is NOT thread-safe due to temporary objects (https://crbug.com/390851). 25 // is NOT thread-safe due to temporary objects (https://crbug.com/390851).
26 // 26 //
27 // Don't (if you pass the task across threads): 27 // Don't (if you pass the task across threads):
28 // bind(func1, 42, str); 28 // bind(func1, 42, str);
29 // bind(func1, 42, str.isolatedCopy()); 29 // bind(func1, 42, str.isolatedCopy());
30 30
31 template<typename FunctionType, typename... Ps> 31 template<typename FunctionType, typename... Ps>
32 std::unique_ptr<Function<base::MakeUnboundRunType<FunctionType, Ps...>, WTF::Cro ssThreadAffinity>> crossThreadBind( 32 std::unique_ptr<Function<base::MakeUnboundRunType<FunctionType, Ps...>, WTF::Cro ssThreadAffinity>> crossThreadBind(
33 FunctionType function, 33 FunctionType function,
34 Ps&&... parameters) 34 Ps&&... parameters)
35 { 35 {
36 return WTF::bindInternal<WTF::CrossThreadAffinity>( 36 return WTF::bindInternal<WTF::CrossThreadAffinity>(
37 function, 37 function,
38 CrossThreadCopier<typename std::decay<Ps>::type>::copy(std::forward<Ps>( parameters))...); 38 WTF::CrossThreadCopier<typename std::decay<Ps>::type>::copy(std::forward <Ps>(parameters))...);
39 } 39 }
40 40
41 } // namespace blink 41 } // namespace blink
42 42
43 #endif // CrossThreadFunctional_h 43 #endif // CrossThreadFunctional_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698