OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 public: | 66 public: |
67 // You can specify the source file and the line number information | 67 // You can specify the source file and the line number information |
68 // explicitly by passing the last parameter. | 68 // explicitly by passing the last parameter. |
69 // In the usual case, they are set automatically and you don't have to | 69 // In the usual case, they are set automatically and you don't have to |
70 // pass it. | 70 // pass it. |
71 // Specify handle explicitly only in tests. | 71 // Specify handle explicitly only in tests. |
72 static DocumentWebSocketChannel* create(ExecutionContext* context, WebSocket
ChannelClient* client, const String& sourceURL = String(), unsigned lineNumber =
0, WebSocketHandle *handle = 0) | 72 static DocumentWebSocketChannel* create(ExecutionContext* context, WebSocket
ChannelClient* client, const String& sourceURL = String(), unsigned lineNumber =
0, WebSocketHandle *handle = 0) |
73 { | 73 { |
74 return new DocumentWebSocketChannel(context, client, sourceURL, lineNumb
er, handle); | 74 return new DocumentWebSocketChannel(context, client, sourceURL, lineNumb
er, handle); |
75 } | 75 } |
76 virtual ~DocumentWebSocketChannel(); | 76 ~DocumentWebSocketChannel() override; |
77 | 77 |
78 // WebSocketChannel functions. | 78 // WebSocketChannel functions. |
79 virtual bool connect(const KURL&, const String& protocol) override; | 79 bool connect(const KURL&, const String& protocol) override; |
80 virtual void send(const CString& message) override; | 80 void send(const CString& message) override; |
81 virtual void send(const DOMArrayBuffer&, unsigned byteOffset, unsigned byteL
ength) override; | 81 void send(const DOMArrayBuffer&, unsigned byteOffset, unsigned byteLength) o
verride; |
82 virtual void send(PassRefPtr<BlobDataHandle>) override; | 82 void send(PassRefPtr<BlobDataHandle>) override; |
83 virtual void sendTextAsCharVector(PassOwnPtr<Vector<char>> data) override; | 83 void sendTextAsCharVector(PassOwnPtr<Vector<char>> data) override; |
84 virtual void sendBinaryAsCharVector(PassOwnPtr<Vector<char>> data) override; | 84 void sendBinaryAsCharVector(PassOwnPtr<Vector<char>> data) override; |
85 // Start closing handshake. Use the CloseEventCodeNotSpecified for the code | 85 // Start closing handshake. Use the CloseEventCodeNotSpecified for the code |
86 // argument to omit payload. | 86 // argument to omit payload. |
87 virtual void close(int code, const String& reason) override; | 87 void close(int code, const String& reason) override; |
88 virtual void fail(const String& reason, MessageLevel, const String&, unsigne
d lineNumber) override; | 88 void fail(const String& reason, MessageLevel, const String&, unsigned lineNu
mber) override; |
89 virtual void disconnect() override; | 89 void disconnect() override; |
90 | 90 |
91 DECLARE_VIRTUAL_TRACE(); | 91 DECLARE_VIRTUAL_TRACE(); |
92 | 92 |
93 private: | 93 private: |
94 enum MessageType { | 94 enum MessageType { |
95 MessageTypeText, | 95 MessageTypeText, |
96 MessageTypeBlob, | 96 MessageTypeBlob, |
97 MessageTypeArrayBuffer, | 97 MessageTypeArrayBuffer, |
98 MessageTypeTextAsCharVector, | 98 MessageTypeTextAsCharVector, |
99 MessageTypeBinaryAsCharVector, | 99 MessageTypeBinaryAsCharVector, |
(...skipping 29 matching lines...) Expand all Loading... |
129 DocumentWebSocketChannel(ExecutionContext*, WebSocketChannelClient*, const S
tring&, unsigned, WebSocketHandle*); | 129 DocumentWebSocketChannel(ExecutionContext*, WebSocketChannelClient*, const S
tring&, unsigned, WebSocketHandle*); |
130 void sendInternal(WebSocketHandle::MessageType, const char* data, size_t tot
alSize, uint64_t* consumedBufferedAmount); | 130 void sendInternal(WebSocketHandle::MessageType, const char* data, size_t tot
alSize, uint64_t* consumedBufferedAmount); |
131 void processSendQueue(); | 131 void processSendQueue(); |
132 void flowControlIfNecessary(); | 132 void flowControlIfNecessary(); |
133 void failAsError(const String& reason) { fail(reason, ErrorMessageLevel, m_s
ourceURLAtConstruction, m_lineNumberAtConstruction); } | 133 void failAsError(const String& reason) { fail(reason, ErrorMessageLevel, m_s
ourceURLAtConstruction, m_lineNumberAtConstruction); } |
134 void abortAsyncOperations(); | 134 void abortAsyncOperations(); |
135 void handleDidClose(bool wasClean, unsigned short code, const String& reason
); | 135 void handleDidClose(bool wasClean, unsigned short code, const String& reason
); |
136 Document* document(); // can be called only when m_identifier > 0. | 136 Document* document(); // can be called only when m_identifier > 0. |
137 | 137 |
138 // WebSocketHandleClient functions. | 138 // WebSocketHandleClient functions. |
139 virtual void didConnect(WebSocketHandle*, const WebString& selectedProtocol,
const WebString& extensions) override; | 139 void didConnect(WebSocketHandle*, const WebString& selectedProtocol, const W
ebString& extensions) override; |
140 virtual void didStartOpeningHandshake(WebSocketHandle*, const WebSocketHands
hakeRequestInfo&) override; | 140 void didStartOpeningHandshake(WebSocketHandle*, const WebSocketHandshakeRequ
estInfo&) override; |
141 virtual void didFinishOpeningHandshake(WebSocketHandle*, const WebSocketHand
shakeResponseInfo&) override; | 141 void didFinishOpeningHandshake(WebSocketHandle*, const WebSocketHandshakeRes
ponseInfo&) override; |
142 virtual void didFail(WebSocketHandle*, const WebString& message) override; | 142 void didFail(WebSocketHandle*, const WebString& message) override; |
143 virtual void didReceiveData(WebSocketHandle*, bool fin, WebSocketHandle::Mes
sageType, const char* data, size_t /* size */) override; | 143 void didReceiveData(WebSocketHandle*, bool fin, WebSocketHandle::MessageType
, const char* data, size_t /* size */) override; |
144 virtual void didClose(WebSocketHandle*, bool wasClean, unsigned short code,
const WebString& reason) override; | 144 void didClose(WebSocketHandle*, bool wasClean, unsigned short code, const We
bString& reason) override; |
145 virtual void didReceiveFlowControl(WebSocketHandle*, int64_t quota) override
; | 145 void didReceiveFlowControl(WebSocketHandle*, int64_t quota) override; |
146 virtual void didStartClosingHandshake(WebSocketHandle*) override; | 146 void didStartClosingHandshake(WebSocketHandle*) override; |
147 | 147 |
148 // Methods for BlobLoader. | 148 // Methods for BlobLoader. |
149 void didFinishLoadingBlob(PassRefPtr<DOMArrayBuffer>); | 149 void didFinishLoadingBlob(PassRefPtr<DOMArrayBuffer>); |
150 void didFailLoadingBlob(FileError::ErrorCode); | 150 void didFailLoadingBlob(FileError::ErrorCode); |
151 | 151 |
152 // m_handle is a handle of the connection. | 152 // m_handle is a handle of the connection. |
153 // m_handle == 0 means this channel is closed. | 153 // m_handle == 0 means this channel is closed. |
154 OwnPtr<WebSocketHandle> m_handle; | 154 OwnPtr<WebSocketHandle> m_handle; |
155 | 155 |
156 // m_client can be deleted while this channel is alive, but this class | 156 // m_client can be deleted while this channel is alive, but this class |
(...skipping 14 matching lines...) Expand all Loading... |
171 String m_sourceURLAtConstruction; | 171 String m_sourceURLAtConstruction; |
172 unsigned m_lineNumberAtConstruction; | 172 unsigned m_lineNumberAtConstruction; |
173 RefPtr<WebSocketHandshakeRequest> m_handshakeRequest; | 173 RefPtr<WebSocketHandshakeRequest> m_handshakeRequest; |
174 | 174 |
175 static const uint64_t receivedDataSizeForFlowControlHighWaterMark = 1 << 15; | 175 static const uint64_t receivedDataSizeForFlowControlHighWaterMark = 1 << 15; |
176 }; | 176 }; |
177 | 177 |
178 } // namespace blink | 178 } // namespace blink |
179 | 179 |
180 #endif // DocumentWebSocketChannel_h | 180 #endif // DocumentWebSocketChannel_h |
OLD | NEW |