• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2009-2010 Google Inc. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions are
6  * met:
7  *
8  *     * Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  *     * Redistributions in binary form must reproduce the above
11  * copyright notice, this list of conditions and the following disclaimer
12  * in the documentation and/or other materials provided with the
13  * distribution.
14  *     * Neither the name of Google Inc. nor the names of its
15  * contributors may be used to endorse or promote products derived from
16  * this software without specific prior written permission.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29  */
30 
31 #ifndef CrossThreadTask_h
32 #define CrossThreadTask_h
33 
34 #include "CrossThreadCopier.h"
35 #include "ScriptExecutionContext.h"
36 #include <memory>
37 #include <wtf/PassOwnPtr.h>
38 #include <wtf/PassRefPtr.h>
39 #include <wtf/TypeTraits.h>
40 
41 namespace WebCore {
42 
43 // Traits for the CrossThreadTask.
44 template<typename T> struct CrossThreadTaskTraits {
45     typedef const T& ParamType;
46 };
47 
48 template<typename T> struct CrossThreadTaskTraits<T*> {
49     typedef T* ParamType;
50 };
51 
52 template<typename T> struct CrossThreadTaskTraits<PassRefPtr<T> > {
53     typedef PassRefPtr<T> ParamType;
54 };
55 
56 template<typename T> struct CrossThreadTaskTraits<PassOwnPtr<T> > {
57     typedef PassOwnPtr<T> ParamType;
58 };
59 
60 template<typename P1, typename MP1>
61 class CrossThreadTask1 : public ScriptExecutionContext::Task {
62 public:
63     typedef void (*Method)(ScriptExecutionContext*, MP1);
64     typedef CrossThreadTask1<P1, MP1> CrossThreadTask;
65     typedef typename CrossThreadTaskTraits<P1>::ParamType Param1;
66 
67     static PassOwnPtr<CrossThreadTask> create(Method method, Param1 parameter1)
68     {
69         return new CrossThreadTask(method, parameter1);
70     }
71 
72 private:
73     CrossThreadTask1(Method method, Param1 parameter1)
74         : m_method(method)
75         , m_parameter1(parameter1)
76     {
77     }
78 
79     virtual void performTask(ScriptExecutionContext* context)
80     {
81         (*m_method)(context, m_parameter1);
82     }
83 
84 private:
85     Method m_method;
86     P1 m_parameter1;
87 };
88 
89 template<typename P1, typename MP1, typename P2, typename MP2>
90 class CrossThreadTask2 : public ScriptExecutionContext::Task {
91 public:
92     typedef void (*Method)(ScriptExecutionContext*, MP1, MP2);
93     typedef CrossThreadTask2<P1, MP1, P2, MP2> CrossThreadTask;
94     typedef typename CrossThreadTaskTraits<P1>::ParamType Param1;
95     typedef typename CrossThreadTaskTraits<P2>::ParamType Param2;
96 
97     static PassOwnPtr<CrossThreadTask> create(Method method, Param1 parameter1, Param2 parameter2)
98     {
99         return new CrossThreadTask(method, parameter1, parameter2);
100     }
101 
102 private:
103     CrossThreadTask2(Method method, Param1 parameter1, Param2 parameter2)
104         : m_method(method)
105         , m_parameter1(parameter1)
106         , m_parameter2(parameter2)
107     {
108     }
109 
110     virtual void performTask(ScriptExecutionContext* context)
111     {
112         (*m_method)(context, m_parameter1, m_parameter2);
113     }
114 
115 private:
116     Method m_method;
117     P1 m_parameter1;
118     P2 m_parameter2;
119 };
120 
121 template<typename P1, typename MP1, typename P2, typename MP2, typename P3, typename MP3>
122 class CrossThreadTask3 : public ScriptExecutionContext::Task {
123 public:
124     typedef void (*Method)(ScriptExecutionContext*, MP1, MP2, MP3);
125     typedef CrossThreadTask3<P1, MP1, P2, MP2, P3, MP3> CrossThreadTask;
126     typedef typename CrossThreadTaskTraits<P1>::ParamType Param1;
127     typedef typename CrossThreadTaskTraits<P2>::ParamType Param2;
128     typedef typename CrossThreadTaskTraits<P3>::ParamType Param3;
129 
130     static PassOwnPtr<CrossThreadTask> create(Method method, Param1 parameter1, Param2 parameter2, Param3 parameter3)
131     {
132         return new CrossThreadTask(method, parameter1, parameter2, parameter3);
133     }
134 
135 private:
136     CrossThreadTask3(Method method, Param1 parameter1, Param2 parameter2, Param3 parameter3)
137         : m_method(method)
138         , m_parameter1(parameter1)
139         , m_parameter2(parameter2)
140         , m_parameter3(parameter3)
141     {
142     }
143 
144     virtual void performTask(ScriptExecutionContext* context)
145     {
146         (*m_method)(context, m_parameter1, m_parameter2, m_parameter3);
147     }
148 
149 private:
150     Method m_method;
151     P1 m_parameter1;
152     P2 m_parameter2;
153     P3 m_parameter3;
154 };
155 
156 template<typename P1, typename MP1, typename P2, typename MP2, typename P3, typename MP3, typename P4, typename MP4>
157 class CrossThreadTask4 : public ScriptExecutionContext::Task {
158 public:
159     typedef void (*Method)(ScriptExecutionContext*, MP1, MP2, MP3, MP4);
160     typedef CrossThreadTask4<P1, MP1, P2, MP2, P3, MP3, P4, MP4> CrossThreadTask;
161     typedef typename CrossThreadTaskTraits<P1>::ParamType Param1;
162     typedef typename CrossThreadTaskTraits<P2>::ParamType Param2;
163     typedef typename CrossThreadTaskTraits<P3>::ParamType Param3;
164     typedef typename CrossThreadTaskTraits<P4>::ParamType Param4;
165 
166     static PassOwnPtr<CrossThreadTask> create(Method method, Param1 parameter1, Param2 parameter2, Param3 parameter3, Param4 parameter4)
167     {
168         return new CrossThreadTask(method, parameter1, parameter2, parameter3, parameter4);
169     }
170 
171 private:
172     CrossThreadTask4(Method method, Param1 parameter1, Param2 parameter2, Param3 parameter3, Param4 parameter4)
173         : m_method(method)
174         , m_parameter1(parameter1)
175         , m_parameter2(parameter2)
176         , m_parameter3(parameter3)
177         , m_parameter4(parameter4)
178     {
179     }
180 
181     virtual void performTask(ScriptExecutionContext* context)
182     {
183         (*m_method)(context, m_parameter1, m_parameter2, m_parameter3, m_parameter4);
184     }
185 
186 private:
187     Method m_method;
188     P1 m_parameter1;
189     P2 m_parameter2;
190     P3 m_parameter3;
191     P4 m_parameter4;
192 };
193 
194 template<typename P1, typename MP1, typename P2, typename MP2, typename P3, typename MP3, typename P4, typename MP4, typename P5, typename MP5>
195 class CrossThreadTask5 : public ScriptExecutionContext::Task {
196 public:
197     typedef void (*Method)(ScriptExecutionContext*, MP1, MP2, MP3, MP4, MP5);
198     typedef CrossThreadTask5<P1, MP1, P2, MP2, P3, MP3, P4, MP4, P5, MP5> CrossThreadTask;
199     typedef typename CrossThreadTaskTraits<P1>::ParamType Param1;
200     typedef typename CrossThreadTaskTraits<P2>::ParamType Param2;
201     typedef typename CrossThreadTaskTraits<P3>::ParamType Param3;
202     typedef typename CrossThreadTaskTraits<P4>::ParamType Param4;
203     typedef typename CrossThreadTaskTraits<P5>::ParamType Param5;
204 
205     static PassOwnPtr<CrossThreadTask> create(Method method, Param1 parameter1, Param2 parameter2, Param3 parameter3, Param4 parameter4, Param5 parameter5)
206     {
207         return new CrossThreadTask(method, parameter1, parameter2, parameter3, parameter4, parameter5);
208     }
209 
210 private:
211     CrossThreadTask5(Method method, Param1 parameter1, Param2 parameter2, Param3 parameter3, Param4 parameter4, Param5 parameter5)
212         : m_method(method)
213         , m_parameter1(parameter1)
214         , m_parameter2(parameter2)
215         , m_parameter3(parameter3)
216         , m_parameter4(parameter4)
217         , m_parameter5(parameter5)
218     {
219     }
220 
221     virtual void performTask(ScriptExecutionContext* context)
222     {
223         (*m_method)(context, m_parameter1, m_parameter2, m_parameter3, m_parameter4, m_parameter5);
224     }
225 
226 private:
227     Method m_method;
228     P1 m_parameter1;
229     P2 m_parameter2;
230     P3 m_parameter3;
231     P4 m_parameter4;
232     P5 m_parameter5;
233 };
234 
235 template<typename P1, typename MP1, typename P2, typename MP2, typename P3, typename MP3, typename P4, typename MP4, typename P5, typename MP5, typename P6, typename MP6>
236 class CrossThreadTask6 : public ScriptExecutionContext::Task {
237 public:
238     typedef void (*Method)(ScriptExecutionContext*, MP1, MP2, MP3, MP4, MP5, MP6);
239     typedef CrossThreadTask6<P1, MP1, P2, MP2, P3, MP3, P4, MP4, P5, MP5, P6, MP6> CrossThreadTask;
240     typedef typename CrossThreadTaskTraits<P1>::ParamType Param1;
241     typedef typename CrossThreadTaskTraits<P2>::ParamType Param2;
242     typedef typename CrossThreadTaskTraits<P3>::ParamType Param3;
243     typedef typename CrossThreadTaskTraits<P4>::ParamType Param4;
244     typedef typename CrossThreadTaskTraits<P5>::ParamType Param5;
245     typedef typename CrossThreadTaskTraits<P6>::ParamType Param6;
246 
247     static PassOwnPtr<CrossThreadTask> create(Method method, Param1 parameter1, Param2 parameter2, Param3 parameter3, Param4 parameter4, Param5 parameter5, Param6 parameter6)
248     {
249         return new CrossThreadTask(method, parameter1, parameter2, parameter3, parameter4, parameter5, parameter6);
250     }
251 
252 private:
253     CrossThreadTask6(Method method, Param1 parameter1, Param2 parameter2, Param3 parameter3, Param4 parameter4, Param5 parameter5, Param6 parameter6)
254         : m_method(method)
255         , m_parameter1(parameter1)
256         , m_parameter2(parameter2)
257         , m_parameter3(parameter3)
258         , m_parameter4(parameter4)
259         , m_parameter5(parameter5)
260         , m_parameter6(parameter6)
261     {
262     }
263 
264     virtual void performTask(ScriptExecutionContext* context)
265     {
266         (*m_method)(context, m_parameter1, m_parameter2, m_parameter3, m_parameter4, m_parameter5, m_parameter6);
267     }
268 
269 private:
270     Method m_method;
271     P1 m_parameter1;
272     P2 m_parameter2;
273     P3 m_parameter3;
274     P4 m_parameter4;
275     P5 m_parameter5;
276     P6 m_parameter6;
277 };
278 
279 template<typename P1, typename MP1, typename P2, typename MP2, typename P3, typename MP3, typename P4, typename MP4, typename P5, typename MP5, typename P6, typename MP6, typename P7, typename MP7>
280 class CrossThreadTask7 : public ScriptExecutionContext::Task {
281 public:
282     typedef void (*Method)(ScriptExecutionContext*, MP1, MP2, MP3, MP4, MP5, MP6, MP7);
283     typedef CrossThreadTask7<P1, MP1, P2, MP2, P3, MP3, P4, MP4, P5, MP5, P6, MP6, P7, MP7> CrossThreadTask;
284     typedef typename CrossThreadTaskTraits<P1>::ParamType Param1;
285     typedef typename CrossThreadTaskTraits<P2>::ParamType Param2;
286     typedef typename CrossThreadTaskTraits<P3>::ParamType Param3;
287     typedef typename CrossThreadTaskTraits<P4>::ParamType Param4;
288     typedef typename CrossThreadTaskTraits<P5>::ParamType Param5;
289     typedef typename CrossThreadTaskTraits<P6>::ParamType Param6;
290     typedef typename CrossThreadTaskTraits<P7>::ParamType Param7;
291 
292     static PassOwnPtr<CrossThreadTask> create(Method method, Param1 parameter1, Param2 parameter2, Param3 parameter3, Param4 parameter4, Param5 parameter5, Param6 parameter6, Param7 parameter7)
293     {
294         return new CrossThreadTask(method, parameter1, parameter2, parameter3, parameter4, parameter5, parameter6, parameter7);
295     }
296 
297 private:
298     CrossThreadTask7(Method method, Param1 parameter1, Param2 parameter2, Param3 parameter3, Param4 parameter4, Param5 parameter5, Param6 parameter6, Param7 parameter7)
299         : m_method(method)
300         , m_parameter1(parameter1)
301         , m_parameter2(parameter2)
302         , m_parameter3(parameter3)
303         , m_parameter4(parameter4)
304         , m_parameter5(parameter5)
305         , m_parameter6(parameter6)
306         , m_parameter7(parameter7)
307     {
308     }
309 
310     virtual void performTask(ScriptExecutionContext* context)
311     {
312         (*m_method)(context, m_parameter1, m_parameter2, m_parameter3, m_parameter4, m_parameter5, m_parameter6, m_parameter7);
313     }
314 
315 private:
316     Method m_method;
317     P1 m_parameter1;
318     P2 m_parameter2;
319     P3 m_parameter3;
320     P4 m_parameter4;
321     P5 m_parameter5;
322     P6 m_parameter6;
323     P7 m_parameter7;
324 };
325 
326 template<typename P1, typename MP1, typename P2, typename MP2, typename P3, typename MP3, typename P4, typename MP4, typename P5, typename MP5, typename P6, typename MP6, typename P7, typename MP7, typename P8, typename MP8>
327 class CrossThreadTask8 : public ScriptExecutionContext::Task {
328 public:
329     typedef void (*Method)(ScriptExecutionContext*, MP1, MP2, MP3, MP4, MP5, MP6, MP7, MP8);
330     typedef CrossThreadTask8<P1, MP1, P2, MP2, P3, MP3, P4, MP4, P5, MP5, P6, MP6, P7, MP7, P8, MP8> CrossThreadTask;
331     typedef typename CrossThreadTaskTraits<P1>::ParamType Param1;
332     typedef typename CrossThreadTaskTraits<P2>::ParamType Param2;
333     typedef typename CrossThreadTaskTraits<P3>::ParamType Param3;
334     typedef typename CrossThreadTaskTraits<P4>::ParamType Param4;
335     typedef typename CrossThreadTaskTraits<P5>::ParamType Param5;
336     typedef typename CrossThreadTaskTraits<P6>::ParamType Param6;
337     typedef typename CrossThreadTaskTraits<P7>::ParamType Param7;
338     typedef typename CrossThreadTaskTraits<P8>::ParamType Param8;
339 
340     static PassOwnPtr<CrossThreadTask> create(Method method, Param1 parameter1, Param2 parameter2, Param3 parameter3, Param4 parameter4, Param5 parameter5, Param6 parameter6, Param7 parameter7, Param8 parameter8)
341     {
342         return new CrossThreadTask(method, parameter1, parameter2, parameter3, parameter4, parameter5, parameter6, parameter7, parameter8);
343     }
344 
345 private:
346     CrossThreadTask8(Method method, Param1 parameter1, Param2 parameter2, Param3 parameter3, Param4 parameter4, Param5 parameter5, Param6 parameter6, Param7 parameter7, Param8 parameter8)
347     : m_method(method)
348     , m_parameter1(parameter1)
349     , m_parameter2(parameter2)
350     , m_parameter3(parameter3)
351     , m_parameter4(parameter4)
352     , m_parameter5(parameter5)
353     , m_parameter6(parameter6)
354     , m_parameter7(parameter7)
355     , m_parameter8(parameter8)
356     {
357     }
358 
359     virtual void performTask(ScriptExecutionContext* context)
360     {
361         (*m_method)(context, m_parameter1, m_parameter2, m_parameter3, m_parameter4, m_parameter5, m_parameter6, m_parameter7, m_parameter8);
362     }
363 
364 private:
365     Method m_method;
366     P1 m_parameter1;
367     P2 m_parameter2;
368     P3 m_parameter3;
369     P4 m_parameter4;
370     P5 m_parameter5;
371     P6 m_parameter6;
372     P7 m_parameter7;
373     P8 m_parameter8;
374 };
375 
376 template<typename P1, typename MP1>
377 PassOwnPtr<ScriptExecutionContext::Task> createCallbackTask(
378     void (*method)(ScriptExecutionContext*, MP1),
379     const P1& parameter1)
380 {
381     return CrossThreadTask1<typename CrossThreadCopier<P1>::Type, MP1>::create(
382         method,
383         CrossThreadCopier<P1>::copy(parameter1));
384 }
385 
386 template<typename P1, typename MP1, typename P2, typename MP2>
387 PassOwnPtr<ScriptExecutionContext::Task> createCallbackTask(
388     void (*method)(ScriptExecutionContext*, MP1, MP2),
389     const P1& parameter1, const P2& parameter2)
390 {
391     return CrossThreadTask2<typename CrossThreadCopier<P1>::Type, MP1, typename CrossThreadCopier<P2>::Type, MP2>::create(
392         method,
393         CrossThreadCopier<P1>::copy(parameter1), CrossThreadCopier<P2>::copy(parameter2));
394 }
395 
396 template<typename P1, typename MP1, typename P2, typename MP2, typename P3, typename MP3>
397 PassOwnPtr<ScriptExecutionContext::Task> createCallbackTask(
398     void (*method)(ScriptExecutionContext*, MP1, MP2, MP3),
399     const P1& parameter1, const P2& parameter2, const P3& parameter3)
400 {
401     return CrossThreadTask3<typename CrossThreadCopier<P1>::Type, MP1, typename CrossThreadCopier<P2>::Type, MP2, typename CrossThreadCopier<P3>::Type, MP3>::create(
402         method,
403         CrossThreadCopier<P1>::copy(parameter1), CrossThreadCopier<P2>::copy(parameter2),
404         CrossThreadCopier<P3>::copy(parameter3));
405 }
406 
407 template<typename P1, typename MP1, typename P2, typename MP2, typename P3, typename MP3, typename P4, typename MP4>
408 PassOwnPtr<ScriptExecutionContext::Task> createCallbackTask(
409     void (*method)(ScriptExecutionContext*, MP1, MP2, MP3, MP4),
410     const P1& parameter1, const P2& parameter2, const P3& parameter3, const P4& parameter4)
411 {
412     return CrossThreadTask4<typename CrossThreadCopier<P1>::Type, MP1, typename CrossThreadCopier<P2>::Type, MP2, typename CrossThreadCopier<P3>::Type, MP3,
413         typename CrossThreadCopier<P4>::Type, MP4>::create(
414             method,
415             CrossThreadCopier<P1>::copy(parameter1), CrossThreadCopier<P2>::copy(parameter2),
416             CrossThreadCopier<P3>::copy(parameter3), CrossThreadCopier<P4>::copy(parameter4));
417 }
418 
419 template<typename P1, typename MP1, typename P2, typename MP2, typename P3, typename MP3, typename P4, typename MP4, typename P5, typename MP5>
420 PassOwnPtr<ScriptExecutionContext::Task> createCallbackTask(
421     void (*method)(ScriptExecutionContext*, MP1, MP2, MP3, MP4, MP5),
422     const P1& parameter1, const P2& parameter2, const P3& parameter3, const P4& parameter4, const P5& parameter5)
423 {
424     return CrossThreadTask5<typename CrossThreadCopier<P1>::Type, MP1, typename CrossThreadCopier<P2>::Type, MP2, typename CrossThreadCopier<P3>::Type, MP3,
425         typename CrossThreadCopier<P4>::Type, MP4, typename CrossThreadCopier<P5>::Type, MP5>::create(
426             method,
427             CrossThreadCopier<P1>::copy(parameter1), CrossThreadCopier<P2>::copy(parameter2),
428             CrossThreadCopier<P3>::copy(parameter3), CrossThreadCopier<P4>::copy(parameter4),
429             CrossThreadCopier<P5>::copy(parameter5));
430 }
431 
432 template<typename P1, typename MP1, typename P2, typename MP2, typename P3, typename MP3, typename P4, typename MP4, typename P5, typename MP5, typename P6, typename MP6>
433 PassOwnPtr<ScriptExecutionContext::Task> createCallbackTask(
434     void (*method)(ScriptExecutionContext*, MP1, MP2, MP3, MP4, MP5, MP6),
435     const P1& parameter1, const P2& parameter2, const P3& parameter3, const P4& parameter4, const P5& parameter5, const P6& parameter6)
436 {
437     return CrossThreadTask6<typename CrossThreadCopier<P1>::Type, MP1, typename CrossThreadCopier<P2>::Type, MP2, typename CrossThreadCopier<P3>::Type, MP3,
438         typename CrossThreadCopier<P4>::Type, MP4, typename CrossThreadCopier<P5>::Type, MP5, typename CrossThreadCopier<P6>::Type, MP6>::create(
439             method,
440             CrossThreadCopier<P1>::copy(parameter1), CrossThreadCopier<P2>::copy(parameter2),
441             CrossThreadCopier<P3>::copy(parameter3), CrossThreadCopier<P4>::copy(parameter4),
442             CrossThreadCopier<P5>::copy(parameter5), CrossThreadCopier<P6>::copy(parameter6));
443 }
444 
445 template<typename P1, typename MP1, typename P2, typename MP2, typename P3, typename MP3, typename P4, typename MP4, typename P5, typename MP5, typename P6, typename MP6, typename P7, typename MP7>
446 PassOwnPtr<ScriptExecutionContext::Task> createCallbackTask(
447     void (*method)(ScriptExecutionContext*, MP1, MP2, MP3, MP4, MP5, MP6, MP7),
448     const P1& parameter1, const P2& parameter2, const P3& parameter3, const P4& parameter4, const P5& parameter5, const P6& parameter6, const P7& parameter7)
449 {
450     return CrossThreadTask7<typename CrossThreadCopier<P1>::Type, MP1, typename CrossThreadCopier<P2>::Type, MP2, typename CrossThreadCopier<P3>::Type, MP3,
451         typename CrossThreadCopier<P4>::Type, MP4, typename CrossThreadCopier<P5>::Type, MP5, typename CrossThreadCopier<P6>::Type, MP6,
452         typename CrossThreadCopier<P7>::Type, MP7>::create(
453             method,
454             CrossThreadCopier<P1>::copy(parameter1), CrossThreadCopier<P2>::copy(parameter2),
455             CrossThreadCopier<P3>::copy(parameter3), CrossThreadCopier<P4>::copy(parameter4),
456             CrossThreadCopier<P5>::copy(parameter5), CrossThreadCopier<P6>::copy(parameter6),
457             CrossThreadCopier<P7>::copy(parameter7));
458 }
459 
460 template<typename P1, typename MP1, typename P2, typename MP2, typename P3, typename MP3, typename P4, typename MP4, typename P5, typename MP5, typename P6, typename MP6, typename P7, typename MP7, typename P8, typename MP8>
461 PassOwnPtr<ScriptExecutionContext::Task> createCallbackTask(
462                                                             void (*method)(ScriptExecutionContext*, MP1, MP2, MP3, MP4, MP5, MP6, MP7, MP8),
463                                                             const P1& parameter1, const P2& parameter2, const P3& parameter3, const P4& parameter4, const P5& parameter5, const P6& parameter6, const P7& parameter7, const P8& parameter8)
464 {
465     return CrossThreadTask8<typename CrossThreadCopier<P1>::Type, MP1, typename CrossThreadCopier<P2>::Type, MP2, typename CrossThreadCopier<P3>::Type, MP3,
466     typename CrossThreadCopier<P4>::Type, MP4, typename CrossThreadCopier<P5>::Type, MP5, typename CrossThreadCopier<P6>::Type, MP6,
467     typename CrossThreadCopier<P7>::Type, MP7, typename CrossThreadCopier<P8>::Type, MP8>::create(
468                                                        method,
469                                                        CrossThreadCopier<P1>::copy(parameter1), CrossThreadCopier<P2>::copy(parameter2),
470                                                        CrossThreadCopier<P3>::copy(parameter3), CrossThreadCopier<P4>::copy(parameter4),
471                                                        CrossThreadCopier<P5>::copy(parameter5), CrossThreadCopier<P6>::copy(parameter6),
472                                                        CrossThreadCopier<P7>::copy(parameter7), CrossThreadCopier<P8>::copy(parameter8));
473 }
474 
475 } // namespace WebCore
476 
477 #endif // CrossThreadTask_h
478