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 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 m_client->didReceiveMessage(WebString(payload)); | 165 m_client->didReceiveMessage(WebString(payload)); |
166 } | 166 } |
167 | 167 |
168 void WebSocketImpl::didReceiveBinaryMessage(PassOwnPtr<Vector<char>> payload) | 168 void WebSocketImpl::didReceiveBinaryMessage(PassOwnPtr<Vector<char>> payload) |
169 { | 169 { |
170 switch (m_binaryType) { | 170 switch (m_binaryType) { |
171 case BinaryTypeBlob: | 171 case BinaryTypeBlob: |
172 // FIXME: Handle Blob after supporting WebBlob. | 172 // FIXME: Handle Blob after supporting WebBlob. |
173 break; | 173 break; |
174 case BinaryTypeArrayBuffer: | 174 case BinaryTypeArrayBuffer: |
175 m_client->didReceiveArrayBuffer(WebArrayBuffer(DOMArrayBuffer::create(pa
yload->data(), payload->size()))); | 175 RefPtr<DOMArrayBuffer> buffer = DOMArrayBuffer::createOrNull(payload->da
ta(), payload->size()); |
| 176 if (buffer) |
| 177 m_client->didReceiveArrayBuffer(WebArrayBuffer(buffer.release())); |
176 break; | 178 break; |
177 } | 179 } |
178 } | 180 } |
179 | 181 |
180 void WebSocketImpl::didError() | 182 void WebSocketImpl::didError() |
181 { | 183 { |
182 m_client->didReceiveMessageError(); | 184 m_client->didReceiveMessageError(); |
183 } | 185 } |
184 | 186 |
185 void WebSocketImpl::didConsumeBufferedAmount(unsigned long consumed) | 187 void WebSocketImpl::didConsumeBufferedAmount(unsigned long consumed) |
(...skipping 13 matching lines...) Expand all Loading... |
199 void WebSocketImpl::didClose(WebSocketChannelClient::ClosingHandshakeCompletionS
tatus status, unsigned short code, const String& reason) | 201 void WebSocketImpl::didClose(WebSocketChannelClient::ClosingHandshakeCompletionS
tatus status, unsigned short code, const String& reason) |
200 { | 202 { |
201 m_isClosingOrClosed = true; | 203 m_isClosingOrClosed = true; |
202 m_client->didClose(static_cast<WebSocketClient::ClosingHandshakeCompletionSt
atus>(status), code, WebString(reason)); | 204 m_client->didClose(static_cast<WebSocketClient::ClosingHandshakeCompletionSt
atus>(status), code, WebString(reason)); |
203 | 205 |
204 // FIXME: Deprecate this call. | 206 // FIXME: Deprecate this call. |
205 m_client->didClose(m_bufferedAmount - m_bufferedAmountAfterClose, static_cas
t<WebSocketClient::ClosingHandshakeCompletionStatus>(status), code, WebString(re
ason)); | 207 m_client->didClose(m_bufferedAmount - m_bufferedAmountAfterClose, static_cas
t<WebSocketClient::ClosingHandshakeCompletionStatus>(status), code, WebString(re
ason)); |
206 } | 208 } |
207 | 209 |
208 } // namespace blink | 210 } // namespace blink |
OLD | NEW |