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

Side by Side Diff: Source/core/dom/ExecutionContextTask.h

Issue 374583002: Replace CallClosureTask::create(bind()) with createCrossThreadTask() (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Move createCallClosureTask to CrossThreadTask.h Created 6 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 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Neither the name of Google Inc. nor the names of its 10 * * Neither the name of Google Inc. nor the names of its
(...skipping 13 matching lines...) Expand all
24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */ 25 */
26 26
27 #ifndef ExecutionContextTask_h 27 #ifndef ExecutionContextTask_h
28 #define ExecutionContextTask_h 28 #define ExecutionContextTask_h
29 29
30 #include "wtf/FastAllocBase.h" 30 #include "wtf/FastAllocBase.h"
31 #include "wtf/Functional.h" 31 #include "wtf/Functional.h"
32 #include "wtf/Noncopyable.h" 32 #include "wtf/Noncopyable.h"
33 #include "wtf/PassOwnPtr.h" 33 #include "wtf/PassOwnPtr.h"
34 #include "wtf/WeakPtr.h"
34 35
35 namespace WebCore { 36 namespace WebCore {
36 37
37 class ExecutionContext; 38 class ExecutionContext;
38 39
39 class ExecutionContextTask { 40 class ExecutionContextTask {
40 WTF_MAKE_NONCOPYABLE(ExecutionContextTask); 41 WTF_MAKE_NONCOPYABLE(ExecutionContextTask);
41 WTF_MAKE_FAST_ALLOCATED; 42 WTF_MAKE_FAST_ALLOCATED;
42 public: 43 public:
43 ExecutionContextTask() { } 44 ExecutionContextTask() { }
44 virtual ~ExecutionContextTask() { } 45 virtual ~ExecutionContextTask() { }
45 virtual void performTask(ExecutionContext*) = 0; 46 virtual void performTask(ExecutionContext*) = 0;
46 // Certain tasks get marked specially so that they aren't discarded, and are executed, when the context is shutting down its message queue. 47 // Certain tasks get marked specially so that they aren't discarded, and are executed, when the context is shutting down its message queue.
47 virtual bool isCleanupTask() const { return false; } 48 virtual bool isCleanupTask() const { return false; }
48 }; 49 };
49 50
50 class CallClosureTask FINAL : public ExecutionContextTask { 51 class CallClosureTask FINAL : public ExecutionContextTask {
51 public: 52 public:
53 virtual void performTask(ExecutionContext*) OVERRIDE { m_closure(); }
54
55 private:
56 // Do not use create other than in createCallClosureTask. http://crbug.com/3 90851
yhirano 2014/07/10 04:55:42 "Do not use |create| ..." or "Do not use create()
hiroshige 2014/07/10 07:16:32 Done.
52 static PassOwnPtr<CallClosureTask> create(const Closure& closure) 57 static PassOwnPtr<CallClosureTask> create(const Closure& closure)
53 { 58 {
54 return adoptPtr(new CallClosureTask(closure)); 59 return adoptPtr(new CallClosureTask(closure));
55 } 60 }
56 virtual void performTask(ExecutionContext*) OVERRIDE { m_closure(); }
57
58 private:
59 explicit CallClosureTask(const Closure& closure) : m_closure(closure) { } 61 explicit CallClosureTask(const Closure& closure) : m_closure(closure) { }
60 Closure m_closure; 62 Closure m_closure;
63
64 // Templates for member function of class C + raw pointer (C*)
65 // which do not use CrossThreadCopier for the raw pointer
66 template<typename R, typename C>
67 friend PassOwnPtr<ExecutionContextTask> createCallClosureTask(R (C::*)(), C* );
tkent 2014/07/10 03:36:14 These |friend|s are ugly and overkill. Keeping th
hiroshige 2014/07/10 07:16:32 Done.
68 template<typename R, typename C, typename P2, typename A2>
69 friend PassOwnPtr<ExecutionContextTask> createCallClosureTask(R (C::*)(P2), C*, const A2&);
70 template<typename R, typename C, typename P2, typename A2, typename P3, type name A3>
71 friend PassOwnPtr<ExecutionContextTask> createCallClosureTask(R (C::*)(P2, P 3), C*, const A2&, const A3&);
72 template<typename R, typename C, typename P2, typename A2, typename P3, type name A3, typename P4, typename A4>
73 friend PassOwnPtr<ExecutionContextTask> createCallClosureTask(R (C::*)(P2, P 3, P4), C*, const A2&, const A3&, const A4&);
74 template<typename R, typename C, typename P2, typename A2, typename P3, type name A3, typename P4, typename A4, typename P5, typename A5>
75 friend PassOwnPtr<ExecutionContextTask> createCallClosureTask(R (C::*)(P2, P 3, P4, P5), C*, const A2&, const A3&, const A4&, const A5&);
76 template<typename R, typename C, typename P2, typename A2, typename P3, type name A3, typename P4, typename A4, typename P5, typename A5, typename P6, typena me A6>
77 friend PassOwnPtr<ExecutionContextTask> createCallClosureTask(R (C::*)(P2, P 3, P4, P5, P6), C*, const A2&, const A3&, const A4&, const A5&, const A6&);
78 // Templates for member function of class C + weak pointer (const WeakPtr<C> &)
79 // which do not use CrossThreadCopier for the weak pointer
80 template<typename R, typename C>
81 friend PassOwnPtr<ExecutionContextTask> createCallClosureTask(R (C::*)(), co nst WeakPtr<C>&);
82 template<typename R, typename C, typename P2, typename A2>
83 friend PassOwnPtr<ExecutionContextTask> createCallClosureTask(R (C::*)(P2), const WeakPtr<C>&, const A2&);
84 template<typename R, typename C, typename P2, typename A2, typename P3, type name A3>
85 friend PassOwnPtr<ExecutionContextTask> createCallClosureTask(R (C::*)(P2, P 3), const WeakPtr<C>&, const A2&, const A3&);
86 template<typename R, typename C, typename P2, typename A2, typename P3, type name A3, typename P4, typename A4>
87 friend PassOwnPtr<ExecutionContextTask> createCallClosureTask(R (C::*)(P2, P 3, P4), const WeakPtr<C>&, const A2&, const A3&, const A4&);
88 template<typename R, typename C, typename P2, typename A2, typename P3, type name A3, typename P4, typename A4, typename P5, typename A5>
89 friend PassOwnPtr<ExecutionContextTask> createCallClosureTask(R (C::*)(P2, P 3, P4, P5), const WeakPtr<C>&, const A2&, const A3&, const A4&, const A5&);
90 template<typename R, typename C, typename P2, typename A2, typename P3, type name A3, typename P4, typename A4, typename P5, typename A5, typename P6, typena me A6>
91 friend PassOwnPtr<ExecutionContextTask> createCallClosureTask(R (C::*)(P2, P 3, P4, P5, P6), const WeakPtr<C>&, const A2&, const A3&, const A4&, const A5&, c onst A6&);
92 // Other cases; use CrossThreadCopier for all arguments
93 template<typename FunctionType>
94 friend PassOwnPtr<ExecutionContextTask> createCallClosureTask(FunctionType);
95 template<typename FunctionType, typename A1>
96 friend PassOwnPtr<ExecutionContextTask> createCallClosureTask(FunctionType, const A1&);
97 template<typename FunctionType, typename A1, typename A2>
98 friend PassOwnPtr<ExecutionContextTask> createCallClosureTask(FunctionType, const A1&, const A2&);
99 template<typename FunctionType, typename A1, typename A2, typename A3>
100 friend PassOwnPtr<ExecutionContextTask> createCallClosureTask(FunctionType, const A1&, const A2&, const A3&);
101 template<typename FunctionType, typename A1, typename A2, typename A3, typen ame A4>
102 friend PassOwnPtr<ExecutionContextTask> createCallClosureTask(FunctionType, const A1&, const A2&, const A3&, const A4&);
103 template<typename FunctionType, typename A1, typename A2, typename A3, typen ame A4, typename A5>
104 friend PassOwnPtr<ExecutionContextTask> createCallClosureTask(FunctionType, const A1&, const A2&, const A3&, const A4&, const A5&);
105 template<typename FunctionType, typename A1, typename A2, typename A3, typen ame A4, typename A5, typename A6>
106 friend PassOwnPtr<ExecutionContextTask> createCallClosureTask(FunctionType, const A1&, const A2&, const A3&, const A4&, const A5&, const A6&);
61 }; 107 };
62 108
63 } // namespace 109 } // namespace
64 110
65 #endif 111 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698