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 // TODO(junov): crbug.com/536816 |
| 176 // Avoid crashing when out of memory by calling createOrNull. Requires |
| 177 // determining appropriate alternate behavior for dealing with allocatio
n |
| 178 // failures. Should the notification be droped? Should we just pass null |
| 179 // data? Should we signal an error somehow? |
| 180 RefPtr<DOMArrayBuffer> buffer = DOMArrayBuffer::deprecatedCreateOrCrash(
payload->data(), payload->size()); |
| 181 m_client->didReceiveArrayBuffer(WebArrayBuffer(buffer.release())); |
176 break; | 182 break; |
177 } | 183 } |
178 } | 184 } |
179 | 185 |
180 void WebSocketImpl::didError() | 186 void WebSocketImpl::didError() |
181 { | 187 { |
182 m_client->didReceiveMessageError(); | 188 m_client->didReceiveMessageError(); |
183 } | 189 } |
184 | 190 |
185 void WebSocketImpl::didConsumeBufferedAmount(unsigned long consumed) | 191 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) | 205 void WebSocketImpl::didClose(WebSocketChannelClient::ClosingHandshakeCompletionS
tatus status, unsigned short code, const String& reason) |
200 { | 206 { |
201 m_isClosingOrClosed = true; | 207 m_isClosingOrClosed = true; |
202 m_client->didClose(static_cast<WebSocketClient::ClosingHandshakeCompletionSt
atus>(status), code, WebString(reason)); | 208 m_client->didClose(static_cast<WebSocketClient::ClosingHandshakeCompletionSt
atus>(status), code, WebString(reason)); |
203 | 209 |
204 // FIXME: Deprecate this call. | 210 // FIXME: Deprecate this call. |
205 m_client->didClose(m_bufferedAmount - m_bufferedAmountAfterClose, static_cas
t<WebSocketClient::ClosingHandshakeCompletionStatus>(status), code, WebString(re
ason)); | 211 m_client->didClose(m_bufferedAmount - m_bufferedAmountAfterClose, static_cas
t<WebSocketClient::ClosingHandshakeCompletionStatus>(status), code, WebString(re
ason)); |
206 } | 212 } |
207 | 213 |
208 } // namespace blink | 214 } // namespace blink |
OLD | NEW |