OLD | NEW |
| (Empty) |
1 /* | |
2 * Copyright (C) 2011, 2012 Google 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 are | |
6 * met: | |
7 * | |
8 * * Redistributions of source code must retain the above copyright | |
9 * notice, this list of conditions and the following disclaimer. | |
10 * * Redistributions in binary form must reproduce the above | |
11 * copyright notice, this list of conditions and the following disclaimer | |
12 * in the documentation and/or other materials provided with the | |
13 * distribution. | |
14 * * Neither the name of Google Inc. nor the names of its | |
15 * contributors may be used to endorse or promote products derived from | |
16 * this software without specific prior written permission. | |
17 * | |
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
29 */ | |
30 | |
31 #ifndef WebSocket_h | |
32 #define WebSocket_h | |
33 | |
34 #include "../platform/WebCommon.h" | |
35 #include "../platform/WebPrivatePtr.h" | |
36 | |
37 namespace WebCore { class WebSocketChannel; } | |
38 | |
39 namespace WebKit { | |
40 | |
41 class WebArrayBuffer; | |
42 class WebDocument; | |
43 class WebString; | |
44 class WebURL; | |
45 class WebSocketClient; | |
46 | |
47 class WebSocket { | |
48 public: | |
49 enum CloseEventCode { | |
50 CloseEventCodeNotSpecified = -1, | |
51 CloseEventCodeNormalClosure = 1000, | |
52 CloseEventCodeGoingAway = 1001, | |
53 CloseEventCodeProtocolError = 1002, | |
54 CloseEventCodeUnsupportedData = 1003, | |
55 CloseEventCodeFrameTooLarge = 1004, | |
56 CloseEventCodeNoStatusRcvd = 1005, | |
57 CloseEventCodeAbnormalClosure = 1006, | |
58 CloseEventCodeInvalidFramePayloadData = 1007, | |
59 CloseEventCodePolicyViolation = 1008, | |
60 CloseEventCodeMessageTooBig = 1009, | |
61 CloseEventCodeMandatoryExt = 1010, | |
62 CloseEventCodeInternalError = 1011, | |
63 CloseEventCodeTLSHandshake = 1015, | |
64 CloseEventCodeMinimumUserDefined = 3000, | |
65 CloseEventCodeMaximumUserDefined = 4999 | |
66 }; | |
67 | |
68 enum BinaryType { | |
69 BinaryTypeBlob = 0, | |
70 BinaryTypeArrayBuffer = 1 | |
71 }; | |
72 | |
73 WEBKIT_EXPORT static WebSocket* create(const WebDocument&, WebSocketClient*)
; | |
74 virtual ~WebSocket() { } | |
75 | |
76 // These functions come from binaryType attribute of the WebSocket API | |
77 // specification. It specifies binary object type for receiving binary | |
78 // frames representation. Receiving text frames are always mapped to | |
79 // WebString type regardless of this attribute. | |
80 // Default type is BinaryTypeBlob. But currently it is not supported. | |
81 // Set BinaryTypeArrayBuffer here ahead of using binary communication. | |
82 // See also, The WebSocket API - http://www.w3.org/TR/websockets/ . | |
83 virtual BinaryType binaryType() const = 0; | |
84 virtual bool setBinaryType(BinaryType) = 0; | |
85 | |
86 virtual void connect(const WebURL&, const WebString& protocol) = 0; | |
87 virtual WebString subprotocol() = 0; | |
88 virtual WebString extensions() = 0; | |
89 virtual bool sendText(const WebString&) = 0; | |
90 virtual bool sendArrayBuffer(const WebArrayBuffer&) = 0; | |
91 virtual unsigned long bufferedAmount() const = 0; | |
92 virtual void close(int code, const WebString& reason) = 0; | |
93 virtual void fail(const WebString& reason) = 0; | |
94 virtual void disconnect() = 0; | |
95 }; | |
96 | |
97 } // namespace WebKit | |
98 | |
99 #endif // WebSocket_h | |
OLD | NEW |