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