1/*
2 * Copyright (C) 2010-2018 Apple 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
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 *
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND
14 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
15 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
16 * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR
17 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
19 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
20 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
21 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
22 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23 */
24
25#pragma once
26
27#if ENABLE(SERVICE_WORKER)
28
29#include "ArgumentCoders.h"
30#include "Connection.h"
31#include <wtf/Forward.h>
32#include <wtf/ThreadSafeRefCounted.h>
33
34namespace IPC {
35class SharedBufferDataReference;
36class FormDataReference;
37}
38
39namespace WebCore {
40class ResourceResponse;
41class ResourceError;
42}
43
44namespace Messages {
45namespace ServiceWorkerFetchTask {
46
47static inline IPC::StringReference messageReceiverName()
48{
49 return IPC::StringReference("ServiceWorkerFetchTask");
50}
51
52class DidNotHandle {
53public:
54 typedef std::tuple<> Arguments;
55
56 static IPC::StringReference receiverName() { return messageReceiverName(); }
57 static IPC::StringReference name() { return IPC::StringReference("DidNotHandle"); }
58 static const bool isSync = false;
59
60 const Arguments& arguments() const
61 {
62 return m_arguments;
63 }
64
65private:
66 Arguments m_arguments;
67};
68
69class DidFail {
70public:
71 typedef std::tuple<const WebCore::ResourceError&> Arguments;
72
73 static IPC::StringReference receiverName() { return messageReceiverName(); }
74 static IPC::StringReference name() { return IPC::StringReference("DidFail"); }
75 static const bool isSync = false;
76
77 explicit DidFail(const WebCore::ResourceError& error)
78 : m_arguments(error)
79 {
80 }
81
82 const Arguments& arguments() const
83 {
84 return m_arguments;
85 }
86
87private:
88 Arguments m_arguments;
89};
90
91class DidReceiveRedirectResponse {
92public:
93 typedef std::tuple<const WebCore::ResourceResponse&> Arguments;
94
95 static IPC::StringReference receiverName() { return messageReceiverName(); }
96 static IPC::StringReference name() { return IPC::StringReference("DidReceiveRedirectResponse"); }
97 static const bool isSync = false;
98
99 explicit DidReceiveRedirectResponse(const WebCore::ResourceResponse& response)
100 : m_arguments(response)
101 {
102 }
103
104 const Arguments& arguments() const
105 {
106 return m_arguments;
107 }
108
109private:
110 Arguments m_arguments;
111};
112
113class DidReceiveResponse {
114public:
115 typedef std::tuple<const WebCore::ResourceResponse&, bool> Arguments;
116
117 static IPC::StringReference receiverName() { return messageReceiverName(); }
118 static IPC::StringReference name() { return IPC::StringReference("DidReceiveResponse"); }
119 static const bool isSync = false;
120
121 DidReceiveResponse(const WebCore::ResourceResponse& response, bool needsContinueDidReceiveResponseMessage)
122 : m_arguments(response, needsContinueDidReceiveResponseMessage)
123 {
124 }
125
126 const Arguments& arguments() const
127 {
128 return m_arguments;
129 }
130
131private:
132 Arguments m_arguments;
133};
134
135class DidReceiveData {
136public:
137 typedef std::tuple<const IPC::SharedBufferDataReference&, int64_t> Arguments;
138
139 static IPC::StringReference receiverName() { return messageReceiverName(); }
140 static IPC::StringReference name() { return IPC::StringReference("DidReceiveData"); }
141 static const bool isSync = false;
142
143 DidReceiveData(const IPC::SharedBufferDataReference& data, int64_t encodedDataLength)
144 : m_arguments(data, encodedDataLength)
145 {
146 }
147
148 const Arguments& arguments() const
149 {
150 return m_arguments;
151 }
152
153private:
154 Arguments m_arguments;
155};
156
157class DidReceiveFormData {
158public:
159 typedef std::tuple<const IPC::FormDataReference&> Arguments;
160
161 static IPC::StringReference receiverName() { return messageReceiverName(); }
162 static IPC::StringReference name() { return IPC::StringReference("DidReceiveFormData"); }
163 static const bool isSync = false;
164
165 explicit DidReceiveFormData(const IPC::FormDataReference& data)
166 : m_arguments(data)
167 {
168 }
169
170 const Arguments& arguments() const
171 {
172 return m_arguments;
173 }
174
175private:
176 Arguments m_arguments;
177};
178
179class DidFinish {
180public:
181 typedef std::tuple<> Arguments;
182
183 static IPC::StringReference receiverName() { return messageReceiverName(); }
184 static IPC::StringReference name() { return IPC::StringReference("DidFinish"); }
185 static const bool isSync = false;
186
187 const Arguments& arguments() const
188 {
189 return m_arguments;
190 }
191
192private:
193 Arguments m_arguments;
194};
195
196} // namespace ServiceWorkerFetchTask
197} // namespace Messages
198
199#endif // ENABLE(SERVICE_WORKER)
200