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 USE(LIBWEBRTC)
28
29#include "ArgumentCoders.h"
30#include "Connection.h"
31#include "RTCNetwork.h"
32#include <wtf/Forward.h>
33#include <wtf/ThreadSafeRefCounted.h>
34
35namespace IPC {
36class DataReference;
37}
38
39namespace Messages {
40namespace WebRTCSocket {
41
42static inline IPC::StringReference messageReceiverName()
43{
44 return IPC::StringReference("WebRTCSocket");
45}
46
47class SignalReadPacket {
48public:
49 typedef std::tuple<const IPC::DataReference&, const WebKit::RTCNetwork::IPAddress&, uint16_t, int64_t> Arguments;
50
51 static IPC::StringReference receiverName() { return messageReceiverName(); }
52 static IPC::StringReference name() { return IPC::StringReference("SignalReadPacket"); }
53 static const bool isSync = false;
54
55 SignalReadPacket(const IPC::DataReference& data, const WebKit::RTCNetwork::IPAddress& address, uint16_t port, int64_t timestamp)
56 : m_arguments(data, address, port, timestamp)
57 {
58 }
59
60 const Arguments& arguments() const
61 {
62 return m_arguments;
63 }
64
65private:
66 Arguments m_arguments;
67};
68
69class SignalSentPacket {
70public:
71 typedef std::tuple<const int&, int64_t> Arguments;
72
73 static IPC::StringReference receiverName() { return messageReceiverName(); }
74 static IPC::StringReference name() { return IPC::StringReference("SignalSentPacket"); }
75 static const bool isSync = false;
76
77 SignalSentPacket(const int& packetSize, int64_t timestamp)
78 : m_arguments(packetSize, timestamp)
79 {
80 }
81
82 const Arguments& arguments() const
83 {
84 return m_arguments;
85 }
86
87private:
88 Arguments m_arguments;
89};
90
91class SignalAddressReady {
92public:
93 typedef std::tuple<const WebKit::RTCNetwork::SocketAddress&> Arguments;
94
95 static IPC::StringReference receiverName() { return messageReceiverName(); }
96 static IPC::StringReference name() { return IPC::StringReference("SignalAddressReady"); }
97 static const bool isSync = false;
98
99 explicit SignalAddressReady(const WebKit::RTCNetwork::SocketAddress& address)
100 : m_arguments(address)
101 {
102 }
103
104 const Arguments& arguments() const
105 {
106 return m_arguments;
107 }
108
109private:
110 Arguments m_arguments;
111};
112
113class SignalConnect {
114public:
115 typedef std::tuple<> Arguments;
116
117 static IPC::StringReference receiverName() { return messageReceiverName(); }
118 static IPC::StringReference name() { return IPC::StringReference("SignalConnect"); }
119 static const bool isSync = false;
120
121 const Arguments& arguments() const
122 {
123 return m_arguments;
124 }
125
126private:
127 Arguments m_arguments;
128};
129
130class SignalClose {
131public:
132 typedef std::tuple<const int&> Arguments;
133
134 static IPC::StringReference receiverName() { return messageReceiverName(); }
135 static IPC::StringReference name() { return IPC::StringReference("SignalClose"); }
136 static const bool isSync = false;
137
138 explicit SignalClose(const int& error)
139 : m_arguments(error)
140 {
141 }
142
143 const Arguments& arguments() const
144 {
145 return m_arguments;
146 }
147
148private:
149 Arguments m_arguments;
150};
151
152class SignalNewConnection {
153public:
154 typedef std::tuple<uint64_t, const WebKit::RTCNetwork::SocketAddress&> Arguments;
155
156 static IPC::StringReference receiverName() { return messageReceiverName(); }
157 static IPC::StringReference name() { return IPC::StringReference("SignalNewConnection"); }
158 static const bool isSync = false;
159
160 SignalNewConnection(uint64_t newSocketIdentifier, const WebKit::RTCNetwork::SocketAddress& remoteAddress)
161 : m_arguments(newSocketIdentifier, remoteAddress)
162 {
163 }
164
165 const Arguments& arguments() const
166 {
167 return m_arguments;
168 }
169
170private:
171 Arguments m_arguments;
172};
173
174} // namespace WebRTCSocket
175} // namespace Messages
176
177#endif // USE(LIBWEBRTC)
178