| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 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 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 338 updateBufferedAmountAfterClose(arrayBufferView->byteLength()); | 338 updateBufferedAmountAfterClose(arrayBufferView->byteLength()); |
| 339 return; | 339 return; |
| 340 } | 340 } |
| 341 ASSERT(m_channel); | 341 ASSERT(m_channel); |
| 342 RefPtr<ArrayBuffer> arrayBuffer(arrayBufferView->buffer()); | 342 RefPtr<ArrayBuffer> arrayBuffer(arrayBufferView->buffer()); |
| 343 handleSendResult(m_channel->send(*arrayBuffer, arrayBufferView->byteOffset()
, arrayBufferView->byteLength()), es); | 343 handleSendResult(m_channel->send(*arrayBuffer, arrayBufferView->byteOffset()
, arrayBufferView->byteLength()), es); |
| 344 } | 344 } |
| 345 | 345 |
| 346 void WebSocket::send(Blob* binaryData, ExceptionState& es) | 346 void WebSocket::send(Blob* binaryData, ExceptionState& es) |
| 347 { | 347 { |
| 348 LOG(Network, "WebSocket %p send() Sending Blob '%s'", this, binaryData->url(
).elidedString().utf8().data()); | 348 LOG(Network, "WebSocket %p send() Sending Blob '%s'", this, binaryData->uuid
().utf8().data()); |
| 349 ASSERT(binaryData); | 349 ASSERT(binaryData); |
| 350 if (m_state == CONNECTING) { | 350 if (m_state == CONNECTING) { |
| 351 es.throwDOMException(InvalidStateError, ExceptionMessages::failedToExecu
te("send", "WebSocket", "already in CONNECTING state.")); | 351 es.throwDOMException(InvalidStateError, ExceptionMessages::failedToExecu
te("send", "WebSocket", "already in CONNECTING state.")); |
| 352 return; | 352 return; |
| 353 } | 353 } |
| 354 if (m_state == CLOSING || m_state == CLOSED) { | 354 if (m_state == CLOSING || m_state == CLOSED) { |
| 355 updateBufferedAmountAfterClose(static_cast<unsigned long>(binaryData->si
ze())); | 355 updateBufferedAmountAfterClose(static_cast<unsigned long>(binaryData->si
ze())); |
| 356 return; | 356 return; |
| 357 } | 357 } |
| 358 ASSERT(m_channel); | 358 ASSERT(m_channel); |
| 359 handleSendResult(m_channel->send(*binaryData), es); | 359 handleSendResult(m_channel->send(binaryData->blobDataHandle()), es); |
| 360 } | 360 } |
| 361 | 361 |
| 362 void WebSocket::close(unsigned short code, const String& reason, ExceptionState&
es) | 362 void WebSocket::close(unsigned short code, const String& reason, ExceptionState&
es) |
| 363 { | 363 { |
| 364 closeInternal(code, reason, es); | 364 closeInternal(code, reason, es); |
| 365 } | 365 } |
| 366 | 366 |
| 367 void WebSocket::close(ExceptionState& es) | 367 void WebSocket::close(ExceptionState& es) |
| 368 { | 368 { |
| 369 closeInternal(WebSocketChannel::CloseEventCodeNotSpecified, String(), es); | 369 closeInternal(WebSocketChannel::CloseEventCodeNotSpecified, String(), es); |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 529 void WebSocket::didReceiveBinaryData(PassOwnPtr<Vector<char> > binaryData) | 529 void WebSocket::didReceiveBinaryData(PassOwnPtr<Vector<char> > binaryData) |
| 530 { | 530 { |
| 531 LOG(Network, "WebSocket %p didReceiveBinaryData() %lu byte binary message",
this, static_cast<unsigned long>(binaryData->size())); | 531 LOG(Network, "WebSocket %p didReceiveBinaryData() %lu byte binary message",
this, static_cast<unsigned long>(binaryData->size())); |
| 532 switch (m_binaryType) { | 532 switch (m_binaryType) { |
| 533 case BinaryTypeBlob: { | 533 case BinaryTypeBlob: { |
| 534 size_t size = binaryData->size(); | 534 size_t size = binaryData->size(); |
| 535 RefPtr<RawData> rawData = RawData::create(); | 535 RefPtr<RawData> rawData = RawData::create(); |
| 536 binaryData->swap(*rawData->mutableData()); | 536 binaryData->swap(*rawData->mutableData()); |
| 537 OwnPtr<BlobData> blobData = BlobData::create(); | 537 OwnPtr<BlobData> blobData = BlobData::create(); |
| 538 blobData->appendData(rawData.release(), 0, BlobDataItem::toEndOfFile); | 538 blobData->appendData(rawData.release(), 0, BlobDataItem::toEndOfFile); |
| 539 RefPtr<Blob> blob = Blob::create(blobData.release(), size); | 539 RefPtr<Blob> blob = Blob::create(BlobDataHandle::create(blobData.release
(), size)); |
| 540 dispatchEvent(MessageEvent::create(blob.release(), SecurityOrigin::creat
e(m_url)->toString())); | 540 dispatchEvent(MessageEvent::create(blob.release(), SecurityOrigin::creat
e(m_url)->toString())); |
| 541 break; | 541 break; |
| 542 } | 542 } |
| 543 | 543 |
| 544 case BinaryTypeArrayBuffer: | 544 case BinaryTypeArrayBuffer: |
| 545 dispatchEvent(MessageEvent::create(ArrayBuffer::create(binaryData->data(
), binaryData->size()), SecurityOrigin::create(m_url)->toString())); | 545 dispatchEvent(MessageEvent::create(ArrayBuffer::create(binaryData->data(
), binaryData->size()), SecurityOrigin::create(m_url)->toString())); |
| 546 break; | 546 break; |
| 547 } | 547 } |
| 548 } | 548 } |
| 549 | 549 |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 605 static const size_t minimumPayloadSizeWithEightByteExtendedPayloadLength = 0
x10000; | 605 static const size_t minimumPayloadSizeWithEightByteExtendedPayloadLength = 0
x10000; |
| 606 size_t overhead = hybiBaseFramingOverhead + hybiMaskingKeyLength; | 606 size_t overhead = hybiBaseFramingOverhead + hybiMaskingKeyLength; |
| 607 if (payloadSize >= minimumPayloadSizeWithEightByteExtendedPayloadLength) | 607 if (payloadSize >= minimumPayloadSizeWithEightByteExtendedPayloadLength) |
| 608 overhead += 8; | 608 overhead += 8; |
| 609 else if (payloadSize >= minimumPayloadSizeWithTwoByteExtendedPayloadLength) | 609 else if (payloadSize >= minimumPayloadSizeWithTwoByteExtendedPayloadLength) |
| 610 overhead += 2; | 610 overhead += 2; |
| 611 return overhead; | 611 return overhead; |
| 612 } | 612 } |
| 613 | 613 |
| 614 } // namespace WebCore | 614 } // namespace WebCore |
| OLD | NEW |