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
33namespace IPC {
34class SharedBufferDataReference;
35}
36
37namespace WebCore {
38class ResourceResponse;
39class ResourceError;
40class ResourceRequest;
41class NetworkLoadMetrics;
42}
43
44namespace Messages {
45namespace WebResourceLoader {
46
47static inline IPC::StringReference messageReceiverName()
48{
49 return IPC::StringReference("WebResourceLoader");
50}
51
52class WillSendRequest {
53public:
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
70private:
71 Arguments m_arguments;
72};
73
74class DidSendData {
75public:
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
92private:
93 Arguments m_arguments;
94};
95
96class DidReceiveResponse {
97public:
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
114private:
115 Arguments m_arguments;
116};
117
118class DidReceiveData {
119public:
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
136private:
137 Arguments m_arguments;
138};
139
140class DidFinishResourceLoad {
141public:
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
158private:
159 Arguments m_arguments;
160};
161
162class DidFailResourceLoad {
163public:
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
180private:
181 Arguments m_arguments;
182};
183
184class DidBlockAuthenticationChallenge {
185public:
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
197private:
198 Arguments m_arguments;
199};
200
201class StopLoadingAfterXFrameOptionsOrContentSecurityPolicyDenied {
202public:
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
219private:
220 Arguments m_arguments;
221};
222
223#if ENABLE(SHAREABLE_RESOURCE)
224class DidReceiveResource {
225public:
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
242private:
243 Arguments m_arguments;
244};
245#endif
246
247} // namespace WebResourceLoader
248} // namespace Messages
249