| 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 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 331 updateBufferedAmountAfterClose(arrayBufferView->byteLength()); | 331 updateBufferedAmountAfterClose(arrayBufferView->byteLength()); |
| 332 return; | 332 return; |
| 333 } | 333 } |
| 334 ASSERT(m_channel); | 334 ASSERT(m_channel); |
| 335 RefPtr<ArrayBuffer> arrayBuffer(arrayBufferView->buffer()); | 335 RefPtr<ArrayBuffer> arrayBuffer(arrayBufferView->buffer()); |
| 336 handleSendResult(m_channel->send(*arrayBuffer, arrayBufferView->byteOffset()
, arrayBufferView->byteLength()), es); | 336 handleSendResult(m_channel->send(*arrayBuffer, arrayBufferView->byteOffset()
, arrayBufferView->byteLength()), es); |
| 337 } | 337 } |
| 338 | 338 |
| 339 void WebSocket::send(Blob* binaryData, ExceptionState& es) | 339 void WebSocket::send(Blob* binaryData, ExceptionState& es) |
| 340 { | 340 { |
| 341 LOG(Network, "WebSocket %p send() Sending Blob '%s'", this, binaryData->url(
).elidedString().utf8().data()); | 341 LOG(Network, "WebSocket %p send() Sending Blob '%s'", this, binaryData->uuid
().utf8().data()); |
| 342 ASSERT(binaryData); | 342 ASSERT(binaryData); |
| 343 if (m_state == CONNECTING) { | 343 if (m_state == CONNECTING) { |
| 344 es.throwDOMException(InvalidStateError, ExceptionMessages::failedToExecu
te("send", "WebSocket", "already in CONNECTING state.")); | 344 es.throwDOMException(InvalidStateError, ExceptionMessages::failedToExecu
te("send", "WebSocket", "already in CONNECTING state.")); |
| 345 return; | 345 return; |
| 346 } | 346 } |
| 347 if (m_state == CLOSING || m_state == CLOSED) { | 347 if (m_state == CLOSING || m_state == CLOSED) { |
| 348 updateBufferedAmountAfterClose(static_cast<unsigned long>(binaryData->si
ze())); | 348 updateBufferedAmountAfterClose(static_cast<unsigned long>(binaryData->si
ze())); |
| 349 return; | 349 return; |
| 350 } | 350 } |
| 351 ASSERT(m_channel); | 351 ASSERT(m_channel); |
| 352 handleSendResult(m_channel->send(*binaryData), es); | 352 handleSendResult(m_channel->send(binaryData->blobDataHandle()), es); |
| 353 } | 353 } |
| 354 | 354 |
| 355 void WebSocket::close(unsigned short code, const String& reason, ExceptionState&
es) | 355 void WebSocket::close(unsigned short code, const String& reason, ExceptionState&
es) |
| 356 { | 356 { |
| 357 closeInternal(code, reason, es); | 357 closeInternal(code, reason, es); |
| 358 } | 358 } |
| 359 | 359 |
| 360 void WebSocket::close(ExceptionState& es) | 360 void WebSocket::close(ExceptionState& es) |
| 361 { | 361 { |
| 362 closeInternal(WebSocketChannel::CloseEventCodeNotSpecified, String(), es); | 362 closeInternal(WebSocketChannel::CloseEventCodeNotSpecified, String(), es); |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 522 void WebSocket::didReceiveBinaryData(PassOwnPtr<Vector<char> > binaryData) | 522 void WebSocket::didReceiveBinaryData(PassOwnPtr<Vector<char> > binaryData) |
| 523 { | 523 { |
| 524 LOG(Network, "WebSocket %p didReceiveBinaryData() %lu byte binary message",
this, static_cast<unsigned long>(binaryData->size())); | 524 LOG(Network, "WebSocket %p didReceiveBinaryData() %lu byte binary message",
this, static_cast<unsigned long>(binaryData->size())); |
| 525 switch (m_binaryType) { | 525 switch (m_binaryType) { |
| 526 case BinaryTypeBlob: { | 526 case BinaryTypeBlob: { |
| 527 size_t size = binaryData->size(); | 527 size_t size = binaryData->size(); |
| 528 RefPtr<RawData> rawData = RawData::create(); | 528 RefPtr<RawData> rawData = RawData::create(); |
| 529 binaryData->swap(*rawData->mutableData()); | 529 binaryData->swap(*rawData->mutableData()); |
| 530 OwnPtr<BlobData> blobData = BlobData::create(); | 530 OwnPtr<BlobData> blobData = BlobData::create(); |
| 531 blobData->appendData(rawData.release(), 0, BlobDataItem::toEndOfFile); | 531 blobData->appendData(rawData.release(), 0, BlobDataItem::toEndOfFile); |
| 532 RefPtr<Blob> blob = Blob::create(blobData.release(), size); | 532 RefPtr<Blob> blob = Blob::create(BlobDataHandle::create(blobData.release
(), size)); |
| 533 dispatchEvent(MessageEvent::create(blob.release(), SecurityOrigin::creat
e(m_url)->toString())); | 533 dispatchEvent(MessageEvent::create(blob.release(), SecurityOrigin::creat
e(m_url)->toString())); |
| 534 break; | 534 break; |
| 535 } | 535 } |
| 536 | 536 |
| 537 case BinaryTypeArrayBuffer: | 537 case BinaryTypeArrayBuffer: |
| 538 dispatchEvent(MessageEvent::create(ArrayBuffer::create(binaryData->data(
), binaryData->size()), SecurityOrigin::create(m_url)->toString())); | 538 dispatchEvent(MessageEvent::create(ArrayBuffer::create(binaryData->data(
), binaryData->size()), SecurityOrigin::create(m_url)->toString())); |
| 539 break; | 539 break; |
| 540 } | 540 } |
| 541 } | 541 } |
| 542 | 542 |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 598 static const size_t minimumPayloadSizeWithEightByteExtendedPayloadLength = 0
x10000; | 598 static const size_t minimumPayloadSizeWithEightByteExtendedPayloadLength = 0
x10000; |
| 599 size_t overhead = hybiBaseFramingOverhead + hybiMaskingKeyLength; | 599 size_t overhead = hybiBaseFramingOverhead + hybiMaskingKeyLength; |
| 600 if (payloadSize >= minimumPayloadSizeWithEightByteExtendedPayloadLength) | 600 if (payloadSize >= minimumPayloadSizeWithEightByteExtendedPayloadLength) |
| 601 overhead += 8; | 601 overhead += 8; |
| 602 else if (payloadSize >= minimumPayloadSizeWithTwoByteExtendedPayloadLength) | 602 else if (payloadSize >= minimumPayloadSizeWithTwoByteExtendedPayloadLength) |
| 603 overhead += 2; | 603 overhead += 2; |
| 604 return overhead; | 604 return overhead; |
| 605 } | 605 } |
| 606 | 606 |
| 607 } // namespace WebCore | 607 } // namespace WebCore |
| OLD | NEW |