OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 CloseEventCodeInvalidFramePayloadData = 1007, | 63 CloseEventCodeInvalidFramePayloadData = 1007, |
64 CloseEventCodePolicyViolation = 1008, | 64 CloseEventCodePolicyViolation = 1008, |
65 CloseEventCodeMessageTooBig = 1009, | 65 CloseEventCodeMessageTooBig = 1009, |
66 CloseEventCodeMandatoryExt = 1010, | 66 CloseEventCodeMandatoryExt = 1010, |
67 CloseEventCodeInternalError = 1011, | 67 CloseEventCodeInternalError = 1011, |
68 CloseEventCodeTLSHandshake = 1015, | 68 CloseEventCodeTLSHandshake = 1015, |
69 CloseEventCodeMinimumUserDefined = 3000, | 69 CloseEventCodeMinimumUserDefined = 3000, |
70 CloseEventCodeMaximumUserDefined = 4999 | 70 CloseEventCodeMaximumUserDefined = 4999 |
71 }; | 71 }; |
72 | 72 |
| 73 enum BinaryType { |
| 74 BinaryTypeBlob, |
| 75 BinaryTypeArrayBuffer, |
| 76 }; |
| 77 |
73 virtual bool connect(const KURL&, const String& protocol) = 0; | 78 virtual bool connect(const KURL&, const String& protocol) = 0; |
74 virtual void send(const CString&) = 0; | 79 virtual void send(const CString&) = 0; |
75 virtual void send(const DOMArrayBuffer&, unsigned byteOffset, unsigned byteL
ength) = 0; | 80 virtual void send(const DOMArrayBuffer&, unsigned byteOffset, unsigned byteL
ength) = 0; |
76 virtual void send(PassRefPtr<BlobDataHandle>) = 0; | 81 virtual void send(PassRefPtr<BlobDataHandle>) = 0; |
77 | 82 |
78 // For WorkerWebSocketChannel. | 83 // For WorkerWebSocketChannel. |
79 virtual void sendTextAsCharVector(PassOwnPtr<Vector<char>>) = 0; | 84 virtual void sendTextAsCharVector(PassOwnPtr<Vector<char>>) = 0; |
80 virtual void sendBinaryAsCharVector(PassOwnPtr<Vector<char>>) = 0; | 85 virtual void sendBinaryAsCharVector(PassOwnPtr<Vector<char>>) = 0; |
81 | 86 |
82 // Do not call |send| after calling this method. | 87 // Do not call |send| after calling this method. |
83 virtual void close(int code, const String& reason) = 0; | 88 virtual void close(int code, const String& reason) = 0; |
84 | 89 |
| 90 // Change binary mode. This controls whether didReceiveArrayBuffer or didRec
eiveBlob is called in responnse to a |
| 91 // binary message. The effect is not instant, so the WebSocketChannelClient
has to be prepared to receive a Blob |
| 92 // even after changing binary type to ArrayBuffer, and vice-versa. |
| 93 virtual void changeBinaryType(BinaryType) = 0; |
| 94 |
85 // Log the reason text and close the connection. Will call didClose(). | 95 // Log the reason text and close the connection. Will call didClose(). |
86 // The MessageLevel parameter will be used for the level of the message | 96 // The MessageLevel parameter will be used for the level of the message |
87 // shown at the devtool console. | 97 // shown at the devtool console. |
88 // sourceURL and lineNumber parameters may be shown with the reason text | 98 // sourceURL and lineNumber parameters may be shown with the reason text |
89 // at the devtool console. | 99 // at the devtool console. |
90 // Even if sourceURL and lineNumber are specified, they may be ignored | 100 // Even if sourceURL and lineNumber are specified, they may be ignored |
91 // and the "current" url and the line number in the sense of | 101 // and the "current" url and the line number in the sense of |
92 // JavaScript execution may be shown if this method is called in | 102 // JavaScript execution may be shown if this method is called in |
93 // a JS execution context. | 103 // a JS execution context. |
94 // You can specify String() and 0 for sourceURL and lineNumber | 104 // You can specify String() and 0 for sourceURL and lineNumber |
95 // respectively, if you can't / needn't provide the information. | 105 // respectively, if you can't / needn't provide the information. |
96 virtual void fail(const String& reason, MessageLevel, const String& sourceUR
L, unsigned lineNumber) = 0; | 106 virtual void fail(const String& reason, MessageLevel, const String& sourceUR
L, unsigned lineNumber) = 0; |
97 | 107 |
98 // Do not call any methods after calling this method. | 108 // Do not call any methods after calling this method. |
99 virtual void disconnect() = 0; // Will suppress didClose(). | 109 virtual void disconnect() = 0; // Will suppress didClose(). |
100 | 110 |
101 virtual ~WebSocketChannel() { } | 111 virtual ~WebSocketChannel() { } |
102 | 112 |
103 DEFINE_INLINE_VIRTUAL_TRACE() { } | 113 DEFINE_INLINE_VIRTUAL_TRACE() { } |
104 }; | 114 }; |
105 | 115 |
106 } // namespace blink | 116 } // namespace blink |
107 | 117 |
108 #endif // WebSocketChannel_h | 118 #endif // WebSocketChannel_h |
OLD | NEW |