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 | |
33 | namespace IPC { |
34 | class DataReference; |
35 | } |
36 | |
37 | namespace Messages { |
38 | namespace WebSocketChannel { |
39 | |
40 | static inline IPC::StringReference messageReceiverName() |
41 | { |
42 | return IPC::StringReference("WebSocketChannel" ); |
43 | } |
44 | |
45 | class DidConnect { |
46 | public: |
47 | typedef std::tuple<> Arguments; |
48 | |
49 | static IPC::StringReference receiverName() { return messageReceiverName(); } |
50 | static IPC::StringReference name() { return IPC::StringReference("DidConnect" ); } |
51 | static const bool isSync = false; |
52 | |
53 | const Arguments& arguments() const |
54 | { |
55 | return m_arguments; |
56 | } |
57 | |
58 | private: |
59 | Arguments m_arguments; |
60 | }; |
61 | |
62 | class DidClose { |
63 | public: |
64 | typedef std::tuple<const unsigned short&, const String&> Arguments; |
65 | |
66 | static IPC::StringReference receiverName() { return messageReceiverName(); } |
67 | static IPC::StringReference name() { return IPC::StringReference("DidClose" ); } |
68 | static const bool isSync = false; |
69 | |
70 | DidClose(const unsigned short& code, const String& reason) |
71 | : m_arguments(code, reason) |
72 | { |
73 | } |
74 | |
75 | const Arguments& arguments() const |
76 | { |
77 | return m_arguments; |
78 | } |
79 | |
80 | private: |
81 | Arguments m_arguments; |
82 | }; |
83 | |
84 | class DidReceiveText { |
85 | public: |
86 | typedef std::tuple<const String&> Arguments; |
87 | |
88 | static IPC::StringReference receiverName() { return messageReceiverName(); } |
89 | static IPC::StringReference name() { return IPC::StringReference("DidReceiveText" ); } |
90 | static const bool isSync = false; |
91 | |
92 | explicit DidReceiveText(const String& message) |
93 | : m_arguments(message) |
94 | { |
95 | } |
96 | |
97 | const Arguments& arguments() const |
98 | { |
99 | return m_arguments; |
100 | } |
101 | |
102 | private: |
103 | Arguments m_arguments; |
104 | }; |
105 | |
106 | class DidReceiveBinaryData { |
107 | public: |
108 | typedef std::tuple<const IPC::DataReference&> Arguments; |
109 | |
110 | static IPC::StringReference receiverName() { return messageReceiverName(); } |
111 | static IPC::StringReference name() { return IPC::StringReference("DidReceiveBinaryData" ); } |
112 | static const bool isSync = false; |
113 | |
114 | explicit DidReceiveBinaryData(const IPC::DataReference& data) |
115 | : m_arguments(data) |
116 | { |
117 | } |
118 | |
119 | const Arguments& arguments() const |
120 | { |
121 | return m_arguments; |
122 | } |
123 | |
124 | private: |
125 | Arguments m_arguments; |
126 | }; |
127 | |
128 | } // namespace WebSocketChannel |
129 | } // namespace Messages |
130 | |