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 <wtf/Forward.h>
30#include <wtf/ThreadSafeRefCounted.h>
31#include <wtf/text/WTFString.h>
32
33namespace IPC {
34class DataReference;
35}
36
37namespace WebCore {
38class ResourceResponse;
39class AuthenticationChallenge;
40class ResourceRequest;
41class ResourceError;
42}
43
44namespace WebKit {
45class DownloadID;
46}
47
48namespace Messages {
49namespace DownloadProxy {
50
51static inline IPC::StringReference messageReceiverName()
52{
53 return IPC::StringReference("DownloadProxy");
54}
55
56class DidStart {
57public:
58 typedef std::tuple<const WebCore::ResourceRequest&, const AtomString&> Arguments;
59
60 static IPC::StringReference receiverName() { return messageReceiverName(); }
61 static IPC::StringReference name() { return IPC::StringReference("DidStart"); }
62 static const bool isSync = false;
63
64 DidStart(const WebCore::ResourceRequest& request, const AtomString& suggestedFilename)
65 : m_arguments(request, suggestedFilename)
66 {
67 }
68
69 const Arguments& arguments() const
70 {
71 return m_arguments;
72 }
73
74private:
75 Arguments m_arguments;
76};
77
78class DidReceiveAuthenticationChallenge {
79public:
80 typedef std::tuple<const WebCore::AuthenticationChallenge&, uint64_t> Arguments;
81
82 static IPC::StringReference receiverName() { return messageReceiverName(); }
83 static IPC::StringReference name() { return IPC::StringReference("DidReceiveAuthenticationChallenge"); }
84 static const bool isSync = false;
85
86 DidReceiveAuthenticationChallenge(const WebCore::AuthenticationChallenge& challenge, uint64_t challengeID)
87 : m_arguments(challenge, challengeID)
88 {
89 }
90
91 const Arguments& arguments() const
92 {
93 return m_arguments;
94 }
95
96private:
97 Arguments m_arguments;
98};
99
100class WillSendRequest {
101public:
102 typedef std::tuple<const WebCore::ResourceRequest&, const WebCore::ResourceResponse&> Arguments;
103
104 static IPC::StringReference receiverName() { return messageReceiverName(); }
105 static IPC::StringReference name() { return IPC::StringReference("WillSendRequest"); }
106 static const bool isSync = false;
107
108 WillSendRequest(const WebCore::ResourceRequest& redirectRequest, const WebCore::ResourceResponse& redirectResponse)
109 : m_arguments(redirectRequest, redirectResponse)
110 {
111 }
112
113 const Arguments& arguments() const
114 {
115 return m_arguments;
116 }
117
118private:
119 Arguments m_arguments;
120};
121
122class DecideDestinationWithSuggestedFilenameAsync {
123public:
124 typedef std::tuple<const WebKit::DownloadID&, const String&> Arguments;
125
126 static IPC::StringReference receiverName() { return messageReceiverName(); }
127 static IPC::StringReference name() { return IPC::StringReference("DecideDestinationWithSuggestedFilenameAsync"); }
128 static const bool isSync = false;
129
130 DecideDestinationWithSuggestedFilenameAsync(const WebKit::DownloadID& downloadID, const String& suggestedFilename)
131 : m_arguments(downloadID, suggestedFilename)
132 {
133 }
134
135 const Arguments& arguments() const
136 {
137 return m_arguments;
138 }
139
140private:
141 Arguments m_arguments;
142};
143
144class DidReceiveResponse {
145public:
146 typedef std::tuple<const WebCore::ResourceResponse&> Arguments;
147
148 static IPC::StringReference receiverName() { return messageReceiverName(); }
149 static IPC::StringReference name() { return IPC::StringReference("DidReceiveResponse"); }
150 static const bool isSync = false;
151
152 explicit DidReceiveResponse(const WebCore::ResourceResponse& response)
153 : m_arguments(response)
154 {
155 }
156
157 const Arguments& arguments() const
158 {
159 return m_arguments;
160 }
161
162private:
163 Arguments m_arguments;
164};
165
166class DidReceiveData {
167public:
168 typedef std::tuple<uint64_t> Arguments;
169
170 static IPC::StringReference receiverName() { return messageReceiverName(); }
171 static IPC::StringReference name() { return IPC::StringReference("DidReceiveData"); }
172 static const bool isSync = false;
173
174 explicit DidReceiveData(uint64_t length)
175 : m_arguments(length)
176 {
177 }
178
179 const Arguments& arguments() const
180 {
181 return m_arguments;
182 }
183
184private:
185 Arguments m_arguments;
186};
187
188class DidCreateDestination {
189public:
190 typedef std::tuple<const String&> Arguments;
191
192 static IPC::StringReference receiverName() { return messageReceiverName(); }
193 static IPC::StringReference name() { return IPC::StringReference("DidCreateDestination"); }
194 static const bool isSync = false;
195
196 explicit DidCreateDestination(const String& path)
197 : m_arguments(path)
198 {
199 }
200
201 const Arguments& arguments() const
202 {
203 return m_arguments;
204 }
205
206private:
207 Arguments m_arguments;
208};
209
210class DidFinish {
211public:
212 typedef std::tuple<> Arguments;
213
214 static IPC::StringReference receiverName() { return messageReceiverName(); }
215 static IPC::StringReference name() { return IPC::StringReference("DidFinish"); }
216 static const bool isSync = false;
217
218 const Arguments& arguments() const
219 {
220 return m_arguments;
221 }
222
223private:
224 Arguments m_arguments;
225};
226
227class DidFail {
228public:
229 typedef std::tuple<const WebCore::ResourceError&, const IPC::DataReference&> Arguments;
230
231 static IPC::StringReference receiverName() { return messageReceiverName(); }
232 static IPC::StringReference name() { return IPC::StringReference("DidFail"); }
233 static const bool isSync = false;
234
235 DidFail(const WebCore::ResourceError& error, const IPC::DataReference& resumeData)
236 : m_arguments(error, resumeData)
237 {
238 }
239
240 const Arguments& arguments() const
241 {
242 return m_arguments;
243 }
244
245private:
246 Arguments m_arguments;
247};
248
249class DidCancel {
250public:
251 typedef std::tuple<const IPC::DataReference&> Arguments;
252
253 static IPC::StringReference receiverName() { return messageReceiverName(); }
254 static IPC::StringReference name() { return IPC::StringReference("DidCancel"); }
255 static const bool isSync = false;
256
257 explicit DidCancel(const IPC::DataReference& resumeData)
258 : m_arguments(resumeData)
259 {
260 }
261
262 const Arguments& arguments() const
263 {
264 return m_arguments;
265 }
266
267private:
268 Arguments m_arguments;
269};
270
271} // namespace DownloadProxy
272} // namespace Messages
273