]>
git.saurik.com Git - iphone-api.git/blob - WebCore/GenericWorkerTask.h
2 * Copyright (c) 2009, Google Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
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
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.
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.
31 #ifndef GenericWorkerTask_h
32 #define GenericWorkerTask_h
36 #include "WorkerMessagingProxy.h"
37 #include "ScriptExecutionContext.h"
38 #include <wtf/PassRefPtr.h>
41 class GenericWorkerTaskBase
: public ScriptExecutionContext::Task
{
43 GenericWorkerTaskBase(WorkerMessagingProxy
* messagingProxy
) : m_messagingProxy(messagingProxy
)
49 return !m_messagingProxy
->askedToTerminate();
52 WorkerMessagingProxy
* m_messagingProxy
;
55 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
>
56 class GenericWorkerTask6
: public GenericWorkerTaskBase
{
58 typedef void (*Method
)(ScriptExecutionContext
*, MP1
, MP2
, MP3
, MP4
, MP5
, MP6
);
59 typedef GenericWorkerTask6
<P1
, MP1
, P2
, MP2
, P3
, MP3
, P4
, MP4
, P5
, MP5
, P6
, MP6
> GenericWorkerTask
;
61 static PassRefPtr
<GenericWorkerTask
> create(WorkerMessagingProxy
* messagingProxy
, Method method
, const P1
& parameter1
, const P2
& parameter2
, const P3
& parameter3
, const P4
& parameter4
, const P5
& parameter5
, const P6
& parameter6
)
63 return adoptRef(new GenericWorkerTask(messagingProxy
, method
, parameter1
, parameter2
, parameter3
, parameter4
, parameter5
, parameter6
));
67 GenericWorkerTask6(WorkerMessagingProxy
* messagingProxy
, Method method
, const P1
& parameter1
, const P2
& parameter2
, const P3
& parameter3
, const P4
& parameter4
, const P5
& parameter5
, const P6
& parameter6
)
68 : GenericWorkerTaskBase(messagingProxy
)
70 , m_parameter1(parameter1
)
71 , m_parameter2(parameter2
)
72 , m_parameter3(parameter3
)
73 , m_parameter4(parameter4
)
74 , m_parameter5(parameter5
)
75 , m_parameter6(parameter6
)
79 virtual void performTask(ScriptExecutionContext
* context
)
81 if (!canPerformTask())
83 (*m_method
)(context
, m_parameter1
, m_parameter2
, m_parameter3
, m_parameter4
, m_parameter5
, m_parameter6
);
96 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
>
97 PassRefPtr
<GenericWorkerTask6
<P1
, MP1
, P2
, MP2
, P3
, MP3
, P4
, MP4
, P5
, MP5
, P6
, MP6
> > createCallbackTask(
98 WorkerMessagingProxy
* messagingProxy
,
99 void (*method
)(ScriptExecutionContext
*, MP1
, MP2
, MP3
, MP4
, MP5
, MP6
),
100 const P1
& parameter1
, const P2
& parameter2
, const P3
& parameter3
, const P4
& parameter4
, const P5
& parameter5
, const P6
& parameter6
)
102 return GenericWorkerTask6
<P1
, MP1
, P2
, MP2
, P3
, MP3
, P4
, MP4
, P5
, MP5
, P6
, MP6
>::create(messagingProxy
, method
, parameter1
, parameter2
, parameter3
, parameter4
, parameter5
, parameter6
);
105 } // namespace WebCore
107 #endif // ENABLE(WORKERS)
109 #endif // GenericWorkerTask_h