| 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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 | 93 |
| 94 void DocumentWebSocketChannel::BlobLoader::cancel() | 94 void DocumentWebSocketChannel::BlobLoader::cancel() |
| 95 { | 95 { |
| 96 m_loader.cancel(); | 96 m_loader.cancel(); |
| 97 // didFail will be called immediately. | 97 // didFail will be called immediately. |
| 98 // |this| is deleted here. | 98 // |this| is deleted here. |
| 99 } | 99 } |
| 100 | 100 |
| 101 void DocumentWebSocketChannel::BlobLoader::didFinishLoading() | 101 void DocumentWebSocketChannel::BlobLoader::didFinishLoading() |
| 102 { | 102 { |
| 103 m_channel->didFinishLoadingBlob(m_loader.arrayBufferResult()); | 103 RefPtr<DOMArrayBuffer> result = m_loader.arrayBufferResultOrNull(); |
| 104 // FIXME(crbug.com/536816): |
| 105 // Is there a better way to handle an allocation failure instead |
| 106 // of crashing? Would it be okay to fail silently by passing a nullptr? |
| 107 // Should we call didFailLoadingBlob? If so, with which ErrorCode? |
| 108 // Spec may need to be ammended for this. |
| 109 RELEASE_ASSERT(result); // This is essentially an out-of-memory crash |
| 110 m_channel->didFinishLoadingBlob(result.release()); |
| 104 // |this| is deleted here. | 111 // |this| is deleted here. |
| 105 } | 112 } |
| 106 | 113 |
| 107 void DocumentWebSocketChannel::BlobLoader::didFail(FileError::ErrorCode errorCod
e) | 114 void DocumentWebSocketChannel::BlobLoader::didFail(FileError::ErrorCode errorCod
e) |
| 108 { | 115 { |
| 109 m_channel->didFailLoadingBlob(errorCode); | 116 m_channel->didFailLoadingBlob(errorCode); |
| 110 // |this| is deleted here. | 117 // |this| is deleted here. |
| 111 } | 118 } |
| 112 | 119 |
| 113 DocumentWebSocketChannel::DocumentWebSocketChannel(Document* document, WebSocket
ChannelClient* client, const String& sourceURL, unsigned lineNumber, WebSocketHa
ndle *handle) | 120 DocumentWebSocketChannel::DocumentWebSocketChannel(Document* document, WebSocket
ChannelClient* client, const String& sourceURL, unsigned lineNumber, WebSocketHa
ndle *handle) |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 | 199 |
| 193 void DocumentWebSocketChannel::send(const DOMArrayBuffer& buffer, unsigned byteO
ffset, unsigned byteLength) | 200 void DocumentWebSocketChannel::send(const DOMArrayBuffer& buffer, unsigned byteO
ffset, unsigned byteLength) |
| 194 { | 201 { |
| 195 WTF_LOG(Network, "DocumentWebSocketChannel %p sendArrayBuffer(%p, %u, %u)",
this, buffer.data(), byteOffset, byteLength); | 202 WTF_LOG(Network, "DocumentWebSocketChannel %p sendArrayBuffer(%p, %u, %u)",
this, buffer.data(), byteOffset, byteLength); |
| 196 // FIXME: Change the inspector API to show the entire message instead | 203 // FIXME: Change the inspector API to show the entire message instead |
| 197 // of individual frames. | 204 // of individual frames. |
| 198 InspectorInstrumentation::didSendWebSocketFrame(document(), m_identifier, We
bSocketFrame::OpCodeBinary, true, static_cast<const char*>(buffer.data()) + byte
Offset, byteLength); | 205 InspectorInstrumentation::didSendWebSocketFrame(document(), m_identifier, We
bSocketFrame::OpCodeBinary, true, static_cast<const char*>(buffer.data()) + byte
Offset, byteLength); |
| 199 // buffer.slice copies its contents. | 206 // buffer.slice copies its contents. |
| 200 // FIXME: Reduce copy by sending the data immediately when we don't need to | 207 // FIXME: Reduce copy by sending the data immediately when we don't need to |
| 201 // queue the data. | 208 // queue the data. |
| 202 m_messages.append(adoptPtr(new Message(buffer.slice(byteOffset, byteOffset +
byteLength)))); | 209 RefPtr<DOMArrayBuffer> slice = buffer.sliceOrNull(byteOffset, byteOffset + b
yteLength); |
| 210 // FIXME: Could we propagate a RangeError exception from here instead the fo
llowing assert? |
| 211 RELEASE_ASSERT(slice); // This is an out-of-memory condition. |
| 212 m_messages.append(adoptPtr(new Message(slice.release()))); |
| 203 processSendQueue(); | 213 processSendQueue(); |
| 204 } | 214 } |
| 205 | 215 |
| 206 void DocumentWebSocketChannel::sendTextAsCharVector(PassOwnPtr<Vector<char>> dat
a) | 216 void DocumentWebSocketChannel::sendTextAsCharVector(PassOwnPtr<Vector<char>> dat
a) |
| 207 { | 217 { |
| 208 WTF_LOG(Network, "DocumentWebSocketChannel %p sendTextAsCharVector(%p, %llu)
", this, data.get(), static_cast<unsigned long long>(data->size())); | 218 WTF_LOG(Network, "DocumentWebSocketChannel %p sendTextAsCharVector(%p, %llu)
", this, data.get(), static_cast<unsigned long long>(data->size())); |
| 209 // FIXME: Change the inspector API to show the entire message instead | 219 // FIXME: Change the inspector API to show the entire message instead |
| 210 // of individual frames. | 220 // of individual frames. |
| 211 InspectorInstrumentation::didSendWebSocketFrame(document(), m_identifier, We
bSocketFrame::OpCodeText, true, data->data(), data->size()); | 221 InspectorInstrumentation::didSendWebSocketFrame(document(), m_identifier, We
bSocketFrame::OpCodeText, true, data->data(), data->size()); |
| 212 m_messages.append(adoptPtr(new Message(data, MessageTypeTextAsCharVector))); | 222 m_messages.append(adoptPtr(new Message(data, MessageTypeTextAsCharVector))); |
| (...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 555 | 565 |
| 556 DEFINE_TRACE(DocumentWebSocketChannel) | 566 DEFINE_TRACE(DocumentWebSocketChannel) |
| 557 { | 567 { |
| 558 visitor->trace(m_blobLoader); | 568 visitor->trace(m_blobLoader); |
| 559 visitor->trace(m_client); | 569 visitor->trace(m_client); |
| 560 WebSocketChannel::trace(visitor); | 570 WebSocketChannel::trace(visitor); |
| 561 ContextLifecycleObserver::trace(visitor); | 571 ContextLifecycleObserver::trace(visitor); |
| 562 } | 572 } |
| 563 | 573 |
| 564 } // namespace blink | 574 } // namespace blink |
| OLD | NEW |