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 | #include "ArgumentCoders.h" |
28 | #include "Connection.h" |
29 | #include "ShareableResource.h" |
30 | #include <wtf/Forward.h> |
31 | #include <wtf/ThreadSafeRefCounted.h> |
32 | |
33 | namespace IPC { |
34 | class SharedBufferDataReference; |
35 | } |
36 | |
37 | namespace WebCore { |
38 | class ResourceResponse; |
39 | class ResourceError; |
40 | class ResourceRequest; |
41 | class NetworkLoadMetrics; |
42 | } |
43 | |
44 | namespace Messages { |
45 | namespace WebResourceLoader { |
46 | |
47 | static inline IPC::StringReference messageReceiverName() |
48 | { |
49 | return IPC::StringReference("WebResourceLoader" ); |
50 | } |
51 | |
52 | class WillSendRequest { |
53 | public: |
54 | typedef std::tuple<const WebCore::ResourceRequest&, const WebCore::ResourceResponse&> Arguments; |
55 | |
56 | static IPC::StringReference receiverName() { return messageReceiverName(); } |
57 | static IPC::StringReference name() { return IPC::StringReference("WillSendRequest" ); } |
58 | static const bool isSync = false; |
59 | |
60 | WillSendRequest(const WebCore::ResourceRequest& request, const WebCore::ResourceResponse& redirectResponse) |
61 | : m_arguments(request, redirectResponse) |
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 DidSendData { |
75 | public: |
76 | typedef std::tuple<uint64_t, uint64_t> Arguments; |
77 | |
78 | static IPC::StringReference receiverName() { return messageReceiverName(); } |
79 | static IPC::StringReference name() { return IPC::StringReference("DidSendData" ); } |
80 | static const bool isSync = false; |
81 | |
82 | DidSendData(uint64_t bytesSent, uint64_t totalBytesToBeSent) |
83 | : m_arguments(bytesSent, totalBytesToBeSent) |
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 DidReceiveResponse { |
97 | public: |
98 | typedef std::tuple<const WebCore::ResourceResponse&, bool> Arguments; |
99 | |
100 | static IPC::StringReference receiverName() { return messageReceiverName(); } |
101 | static IPC::StringReference name() { return IPC::StringReference("DidReceiveResponse" ); } |
102 | static const bool isSync = false; |
103 | |
104 | DidReceiveResponse(const WebCore::ResourceResponse& response, bool needsContinueDidReceiveResponseMessage) |
105 | : m_arguments(response, needsContinueDidReceiveResponseMessage) |
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 DidReceiveData { |
119 | public: |
120 | typedef std::tuple<const IPC::SharedBufferDataReference&, int64_t> Arguments; |
121 | |
122 | static IPC::StringReference receiverName() { return messageReceiverName(); } |
123 | static IPC::StringReference name() { return IPC::StringReference("DidReceiveData" ); } |
124 | static const bool isSync = false; |
125 | |
126 | DidReceiveData(const IPC::SharedBufferDataReference& data, int64_t encodedDataLength) |
127 | : m_arguments(data, encodedDataLength) |
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 DidFinishResourceLoad { |
141 | public: |
142 | typedef std::tuple<const WebCore::NetworkLoadMetrics&> Arguments; |
143 | |
144 | static IPC::StringReference receiverName() { return messageReceiverName(); } |
145 | static IPC::StringReference name() { return IPC::StringReference("DidFinishResourceLoad" ); } |
146 | static const bool isSync = false; |
147 | |
148 | explicit DidFinishResourceLoad(const WebCore::NetworkLoadMetrics& networkLoadMetrics) |
149 | : m_arguments(networkLoadMetrics) |
150 | { |
151 | } |
152 | |
153 | const Arguments& arguments() const |
154 | { |
155 | return m_arguments; |
156 | } |
157 | |
158 | private: |
159 | Arguments m_arguments; |
160 | }; |
161 | |
162 | class DidFailResourceLoad { |
163 | public: |
164 | typedef std::tuple<const WebCore::ResourceError&> Arguments; |
165 | |
166 | static IPC::StringReference receiverName() { return messageReceiverName(); } |
167 | static IPC::StringReference name() { return IPC::StringReference("DidFailResourceLoad" ); } |
168 | static const bool isSync = false; |
169 | |
170 | explicit DidFailResourceLoad(const WebCore::ResourceError& error) |
171 | : m_arguments(error) |
172 | { |
173 | } |
174 | |
175 | const Arguments& arguments() const |
176 | { |
177 | return m_arguments; |
178 | } |
179 | |
180 | private: |
181 | Arguments m_arguments; |
182 | }; |
183 | |
184 | class DidBlockAuthenticationChallenge { |
185 | public: |
186 | typedef std::tuple<> Arguments; |
187 | |
188 | static IPC::StringReference receiverName() { return messageReceiverName(); } |
189 | static IPC::StringReference name() { return IPC::StringReference("DidBlockAuthenticationChallenge" ); } |
190 | static const bool isSync = false; |
191 | |
192 | const Arguments& arguments() const |
193 | { |
194 | return m_arguments; |
195 | } |
196 | |
197 | private: |
198 | Arguments m_arguments; |
199 | }; |
200 | |
201 | class StopLoadingAfterXFrameOptionsOrContentSecurityPolicyDenied { |
202 | public: |
203 | typedef std::tuple<const WebCore::ResourceResponse&> Arguments; |
204 | |
205 | static IPC::StringReference receiverName() { return messageReceiverName(); } |
206 | static IPC::StringReference name() { return IPC::StringReference("StopLoadingAfterXFrameOptionsOrContentSecurityPolicyDenied" ); } |
207 | static const bool isSync = false; |
208 | |
209 | explicit StopLoadingAfterXFrameOptionsOrContentSecurityPolicyDenied(const WebCore::ResourceResponse& response) |
210 | : m_arguments(response) |
211 | { |
212 | } |
213 | |
214 | const Arguments& arguments() const |
215 | { |
216 | return m_arguments; |
217 | } |
218 | |
219 | private: |
220 | Arguments m_arguments; |
221 | }; |
222 | |
223 | #if ENABLE(SHAREABLE_RESOURCE) |
224 | class DidReceiveResource { |
225 | public: |
226 | typedef std::tuple<const WebKit::ShareableResource::Handle&> Arguments; |
227 | |
228 | static IPC::StringReference receiverName() { return messageReceiverName(); } |
229 | static IPC::StringReference name() { return IPC::StringReference("DidReceiveResource" ); } |
230 | static const bool isSync = false; |
231 | |
232 | explicit DidReceiveResource(const WebKit::ShareableResource::Handle& resource) |
233 | : m_arguments(resource) |
234 | { |
235 | } |
236 | |
237 | const Arguments& arguments() const |
238 | { |
239 | return m_arguments; |
240 | } |
241 | |
242 | private: |
243 | Arguments m_arguments; |
244 | }; |
245 | #endif |
246 | |
247 | } // namespace WebResourceLoader |
248 | } // namespace Messages |
249 | |