| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2011, 2012 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 10 matching lines...) Expand all Loading... |
| 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 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. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #ifndef WebSocket_h | 31 #ifndef WebPepperSocket_h |
| 32 #define WebSocket_h | 32 #define WebPepperSocket_h |
| 33 | 33 |
| 34 #include "../platform/WebCommon.h" | 34 #include "../platform/WebCommon.h" |
| 35 #include "../platform/WebPrivatePtr.h" | 35 #include "../platform/WebPrivatePtr.h" |
| 36 #include "../platform/WebString.h" | 36 #include "../platform/WebString.h" |
| 37 | 37 |
| 38 namespace blink { | 38 namespace blink { |
| 39 | 39 |
| 40 class WebArrayBuffer; | 40 class WebArrayBuffer; |
| 41 class WebDocument; | 41 class WebDocument; |
| 42 class WebPepperSocketClient; |
| 42 class WebURL; | 43 class WebURL; |
| 43 class WebSocketClient; | |
| 44 | 44 |
| 45 class WebSocket { | 45 class WebPepperSocket { |
| 46 public: | 46 public: |
| 47 enum CloseEventCode { | 47 enum CloseEventCode { |
| 48 CloseEventCodeNotSpecified = -1, | 48 CloseEventCodeNotSpecified = -1, |
| 49 CloseEventCodeNormalClosure = 1000, | 49 CloseEventCodeNormalClosure = 1000, |
| 50 CloseEventCodeGoingAway = 1001, | 50 CloseEventCodeGoingAway = 1001, |
| 51 CloseEventCodeProtocolError = 1002, | 51 CloseEventCodeProtocolError = 1002, |
| 52 CloseEventCodeUnsupportedData = 1003, | 52 CloseEventCodeUnsupportedData = 1003, |
| 53 CloseEventCodeFrameTooLarge = 1004, | 53 CloseEventCodeFrameTooLarge = 1004, |
| 54 CloseEventCodeNoStatusRcvd = 1005, | 54 CloseEventCodeNoStatusRcvd = 1005, |
| 55 CloseEventCodeAbnormalClosure = 1006, | 55 CloseEventCodeAbnormalClosure = 1006, |
| 56 CloseEventCodeInvalidFramePayloadData = 1007, | 56 CloseEventCodeInvalidFramePayloadData = 1007, |
| 57 CloseEventCodePolicyViolation = 1008, | 57 CloseEventCodePolicyViolation = 1008, |
| 58 CloseEventCodeMessageTooBig = 1009, | 58 CloseEventCodeMessageTooBig = 1009, |
| 59 CloseEventCodeMandatoryExt = 1010, | 59 CloseEventCodeMandatoryExt = 1010, |
| 60 CloseEventCodeInternalError = 1011, | 60 CloseEventCodeInternalError = 1011, |
| 61 CloseEventCodeTLSHandshake = 1015, | 61 CloseEventCodeTLSHandshake = 1015, |
| 62 CloseEventCodeMinimumUserDefined = 3000, | 62 CloseEventCodeMinimumUserDefined = 3000, |
| 63 CloseEventCodeMaximumUserDefined = 4999 | 63 CloseEventCodeMaximumUserDefined = 4999 |
| 64 }; | 64 }; |
| 65 | 65 |
| 66 enum BinaryType { | 66 enum BinaryType { |
| 67 BinaryTypeBlob = 0, | 67 BinaryTypeBlob = 0, |
| 68 BinaryTypeArrayBuffer = 1 | 68 BinaryTypeArrayBuffer = 1 |
| 69 }; | 69 }; |
| 70 | 70 |
| 71 BLINK_EXPORT static WebSocket* create(const WebDocument&, WebSocketClient*); | 71 BLINK_EXPORT static WebPepperSocket* create(const WebDocument&, WebPepperSoc
ketClient*); |
| 72 virtual ~WebSocket() { } | 72 virtual ~WebPepperSocket() { } |
| 73 | 73 |
| 74 // These functions come from binaryType attribute of the WebSocket API | 74 // These functions come from binaryType attribute of the WebSocket API |
| 75 // specification. It specifies binary object type for receiving binary | 75 // specification. It specifies binary object type for receiving binary |
| 76 // frames representation. Receiving text frames are always mapped to | 76 // frames representation. Receiving text frames are always mapped to |
| 77 // WebString type regardless of this attribute. | 77 // WebString type regardless of this attribute. |
| 78 // Default type is BinaryTypeBlob. But currently it is not supported. | 78 // Default type is BinaryTypeBlob. But currently it is not supported. |
| 79 // Set BinaryTypeArrayBuffer here ahead of using binary communication. | 79 // Set BinaryTypeArrayBuffer here ahead of using binary communication. |
| 80 // See also, The WebSocket API - http://www.w3.org/TR/websockets/ . | 80 // See also, The WebSocket API - http://www.w3.org/TR/websockets/ . |
| 81 virtual BinaryType binaryType() const = 0; | 81 virtual BinaryType binaryType() const = 0; |
| 82 virtual bool setBinaryType(BinaryType) = 0; | 82 virtual bool setBinaryType(BinaryType) = 0; |
| 83 | 83 |
| 84 virtual void connect(const WebURL&, const WebString& protocol) = 0; | 84 virtual void connect(const WebURL&, const WebString& protocol) = 0; |
| 85 virtual WebString subprotocol() { return WebString(); } | 85 virtual WebString subprotocol() { return WebString(); } |
| 86 virtual WebString extensions() { return WebString(); } | 86 virtual WebString extensions() { return WebString(); } |
| 87 virtual bool sendText(const WebString&) = 0; | 87 virtual bool sendText(const WebString&) = 0; |
| 88 virtual bool sendArrayBuffer(const WebArrayBuffer&) = 0; | 88 virtual bool sendArrayBuffer(const WebArrayBuffer&) = 0; |
| 89 virtual unsigned long bufferedAmount() const { return 0; } | 89 virtual unsigned long bufferedAmount() const { return 0; } |
| 90 virtual void close(int code, const WebString& reason) = 0; | 90 virtual void close(int code, const WebString& reason) = 0; |
| 91 virtual void fail(const WebString& reason) = 0; | 91 virtual void fail(const WebString& reason) = 0; |
| 92 virtual void disconnect() = 0; | 92 virtual void disconnect() = 0; |
| 93 }; | 93 }; |
| 94 | 94 |
| 95 } // namespace blink | 95 } // namespace blink |
| 96 | 96 |
| 97 #endif // WebSocket_h | 97 #endif // WebPepperSocket_h |
| OLD | NEW |