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 | |
34 | namespace IPC { |
35 | class DataReference; |
36 | class FormDataReference; |
37 | } |
38 | |
39 | namespace WebCore { |
40 | class ResourceResponse; |
41 | class ResourceError; |
42 | } |
43 | |
44 | namespace Messages { |
45 | namespace ServiceWorkerClientFetch { |
46 | |
47 | static inline IPC::StringReference messageReceiverName() |
48 | { |
49 | return IPC::StringReference("ServiceWorkerClientFetch" ); |
50 | } |
51 | |
52 | class DidReceiveResponse { |
53 | public: |
54 | typedef std::tuple<const WebCore::ResourceResponse&, bool> Arguments; |
55 | |
56 | static IPC::StringReference receiverName() { return messageReceiverName(); } |
57 | static IPC::StringReference name() { return IPC::StringReference("DidReceiveResponse" ); } |
58 | static const bool isSync = false; |
59 | |
60 | DidReceiveResponse(const WebCore::ResourceResponse& response, bool needsContinueDidReceiveResponseMessage) |
61 | : m_arguments(response, needsContinueDidReceiveResponseMessage) |
62 | { |
63 | } |
64 | |
65 | const Arguments& arguments() const |
66 | { |
67 | return m_arguments; |
68 | } |
69 | |
70 | private: |
71 | Arguments m_arguments; |
72 | }; |
73 | |
74 | class DidReceiveRedirectResponse { |
75 | public: |
76 | typedef std::tuple<const WebCore::ResourceResponse&> Arguments; |
77 | |
78 | static IPC::StringReference receiverName() { return messageReceiverName(); } |
79 | static IPC::StringReference name() { return IPC::StringReference("DidReceiveRedirectResponse" ); } |
80 | static const bool isSync = false; |
81 | |
82 | explicit DidReceiveRedirectResponse(const WebCore::ResourceResponse& response) |
83 | : m_arguments(response) |
84 | { |
85 | } |
86 | |
87 | const Arguments& arguments() const |
88 | { |
89 | return m_arguments; |
90 | } |
91 | |
92 | private: |
93 | Arguments m_arguments; |
94 | }; |
95 | |
96 | class DidReceiveData { |
97 | public: |
98 | typedef std::tuple<const IPC::DataReference&, int64_t> Arguments; |
99 | |
100 | static IPC::StringReference receiverName() { return messageReceiverName(); } |
101 | static IPC::StringReference name() { return IPC::StringReference("DidReceiveData" ); } |
102 | static const bool isSync = false; |
103 | |
104 | DidReceiveData(const IPC::DataReference& data, int64_t encodedDataLength) |
105 | : m_arguments(data, encodedDataLength) |
106 | { |
107 | } |
108 | |
109 | const Arguments& arguments() const |
110 | { |
111 | return m_arguments; |
112 | } |
113 | |
114 | private: |
115 | Arguments m_arguments; |
116 | }; |
117 | |
118 | class DidReceiveFormData { |
119 | public: |
120 | typedef std::tuple<const IPC::FormDataReference&> Arguments; |
121 | |
122 | static IPC::StringReference receiverName() { return messageReceiverName(); } |
123 | static IPC::StringReference name() { return IPC::StringReference("DidReceiveFormData" ); } |
124 | static const bool isSync = false; |
125 | |
126 | explicit DidReceiveFormData(const IPC::FormDataReference& data) |
127 | : m_arguments(data) |
128 | { |
129 | } |
130 | |
131 | const Arguments& arguments() const |
132 | { |
133 | return m_arguments; |
134 | } |
135 | |
136 | private: |
137 | Arguments m_arguments; |
138 | }; |
139 | |
140 | class DidFinish { |
141 | public: |
142 | typedef std::tuple<> Arguments; |
143 | |
144 | static IPC::StringReference receiverName() { return messageReceiverName(); } |
145 | static IPC::StringReference name() { return IPC::StringReference("DidFinish" ); } |
146 | static const bool isSync = false; |
147 | |
148 | const Arguments& arguments() const |
149 | { |
150 | return m_arguments; |
151 | } |
152 | |
153 | private: |
154 | Arguments m_arguments; |
155 | }; |
156 | |
157 | class DidFail { |
158 | public: |
159 | typedef std::tuple<const WebCore::ResourceError&> Arguments; |
160 | |
161 | static IPC::StringReference receiverName() { return messageReceiverName(); } |
162 | static IPC::StringReference name() { return IPC::StringReference("DidFail" ); } |
163 | static const bool isSync = false; |
164 | |
165 | explicit DidFail(const WebCore::ResourceError& error) |
166 | : m_arguments(error) |
167 | { |
168 | } |
169 | |
170 | const Arguments& arguments() const |
171 | { |
172 | return m_arguments; |
173 | } |
174 | |
175 | private: |
176 | Arguments m_arguments; |
177 | }; |
178 | |
179 | class DidNotHandle { |
180 | public: |
181 | typedef std::tuple<> Arguments; |
182 | |
183 | static IPC::StringReference receiverName() { return messageReceiverName(); } |
184 | static IPC::StringReference name() { return IPC::StringReference("DidNotHandle" ); } |
185 | static const bool isSync = false; |
186 | |
187 | const Arguments& arguments() const |
188 | { |
189 | return m_arguments; |
190 | } |
191 | |
192 | private: |
193 | Arguments m_arguments; |
194 | }; |
195 | |
196 | } // namespace ServiceWorkerClientFetch |
197 | } // namespace Messages |
198 | |
199 | #endif // ENABLE(SERVICE_WORKER) |
200 | |