Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(115)

Side by Side Diff: Source/modules/websockets/WebSocket.cpp

Issue 23992003: blob hacking webcore style (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 updateBufferedAmountAfterClose(arrayBufferView->byteLength()); 333 updateBufferedAmountAfterClose(arrayBufferView->byteLength());
334 return; 334 return;
335 } 335 }
336 ASSERT(m_channel); 336 ASSERT(m_channel);
337 RefPtr<ArrayBuffer> arrayBuffer(arrayBufferView->buffer()); 337 RefPtr<ArrayBuffer> arrayBuffer(arrayBufferView->buffer());
338 handleSendResult(m_channel->send(*arrayBuffer, arrayBufferView->byteOffset() , arrayBufferView->byteLength()), es); 338 handleSendResult(m_channel->send(*arrayBuffer, arrayBufferView->byteOffset() , arrayBufferView->byteLength()), es);
339 } 339 }
340 340
341 void WebSocket::send(Blob* binaryData, ExceptionState& es) 341 void WebSocket::send(Blob* binaryData, ExceptionState& es)
342 { 342 {
343 LOG(Network, "WebSocket %p send() Sending Blob '%s'", this, binaryData->url( ).elidedString().utf8().data()); 343 LOG(Network, "WebSocket %p send() Sending Blob '%s'", this, binaryData->uuid ().utf8().data());
344 ASSERT(binaryData); 344 ASSERT(binaryData);
345 if (m_state == CONNECTING) { 345 if (m_state == CONNECTING) {
346 es.throwDOMException(InvalidStateError, ExceptionMessages::failedToExecu te("send", "WebSocket", "already in CONNECTING state.")); 346 es.throwDOMException(InvalidStateError, ExceptionMessages::failedToExecu te("send", "WebSocket", "already in CONNECTING state."));
347 return; 347 return;
348 } 348 }
349 if (m_state == CLOSING || m_state == CLOSED) { 349 if (m_state == CLOSING || m_state == CLOSED) {
350 updateBufferedAmountAfterClose(static_cast<unsigned long>(binaryData->si ze())); 350 updateBufferedAmountAfterClose(static_cast<unsigned long>(binaryData->si ze()));
351 return; 351 return;
352 } 352 }
353 ASSERT(m_channel); 353 ASSERT(m_channel);
354 handleSendResult(m_channel->send(*binaryData), es); 354 handleSendResult(m_channel->send(binaryData->blobDataHandle()), es);
355 } 355 }
356 356
357 void WebSocket::close(unsigned short code, const String& reason, ExceptionState& es) 357 void WebSocket::close(unsigned short code, const String& reason, ExceptionState& es)
358 { 358 {
359 closeInternal(code, reason, es); 359 closeInternal(code, reason, es);
360 } 360 }
361 361
362 void WebSocket::close(ExceptionState& es) 362 void WebSocket::close(ExceptionState& es)
363 { 363 {
364 closeInternal(WebSocketChannel::CloseEventCodeNotSpecified, String(), es); 364 closeInternal(WebSocketChannel::CloseEventCodeNotSpecified, String(), es);
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
542 void WebSocket::didReceiveBinaryData(PassOwnPtr<Vector<char> > binaryData) 542 void WebSocket::didReceiveBinaryData(PassOwnPtr<Vector<char> > binaryData)
543 { 543 {
544 LOG(Network, "WebSocket %p didReceiveBinaryData() %lu byte binary message", this, static_cast<unsigned long>(binaryData->size())); 544 LOG(Network, "WebSocket %p didReceiveBinaryData() %lu byte binary message", this, static_cast<unsigned long>(binaryData->size()));
545 switch (m_binaryType) { 545 switch (m_binaryType) {
546 case BinaryTypeBlob: { 546 case BinaryTypeBlob: {
547 size_t size = binaryData->size(); 547 size_t size = binaryData->size();
548 RefPtr<RawData> rawData = RawData::create(); 548 RefPtr<RawData> rawData = RawData::create();
549 binaryData->swap(*rawData->mutableData()); 549 binaryData->swap(*rawData->mutableData());
550 OwnPtr<BlobData> blobData = BlobData::create(); 550 OwnPtr<BlobData> blobData = BlobData::create();
551 blobData->appendData(rawData.release(), 0, BlobDataItem::toEndOfFile); 551 blobData->appendData(rawData.release(), 0, BlobDataItem::toEndOfFile);
552 RefPtr<Blob> blob = Blob::create(blobData.release(), size); 552 RefPtr<Blob> blob = Blob::create(BlobDataHandle::create(blobData.release (), size));
553
554 if (!m_stopped) 553 if (!m_stopped)
555 dispatchEvent(MessageEvent::create(blob.release(), SecurityOrigin::c reate(m_url)->toString())); 554 dispatchEvent(MessageEvent::create(blob.release(), SecurityOrigin::c reate(m_url)->toString()));
556
557 break; 555 break;
558 } 556 }
559 557
560 case BinaryTypeArrayBuffer: 558 case BinaryTypeArrayBuffer:
561 if (!m_stopped) 559 if (!m_stopped)
562 dispatchEvent(MessageEvent::create(ArrayBuffer::create(binaryData->d ata(), binaryData->size()), SecurityOrigin::create(m_url)->toString())); 560 dispatchEvent(MessageEvent::create(ArrayBuffer::create(binaryData->d ata(), binaryData->size()), SecurityOrigin::create(m_url)->toString()));
563 561
564 break; 562 break;
565 } 563 }
566 } 564 }
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
620 static const size_t minimumPayloadSizeWithEightByteExtendedPayloadLength = 0 x10000; 618 static const size_t minimumPayloadSizeWithEightByteExtendedPayloadLength = 0 x10000;
621 size_t overhead = hybiBaseFramingOverhead + hybiMaskingKeyLength; 619 size_t overhead = hybiBaseFramingOverhead + hybiMaskingKeyLength;
622 if (payloadSize >= minimumPayloadSizeWithEightByteExtendedPayloadLength) 620 if (payloadSize >= minimumPayloadSizeWithEightByteExtendedPayloadLength)
623 overhead += 8; 621 overhead += 8;
624 else if (payloadSize >= minimumPayloadSizeWithTwoByteExtendedPayloadLength) 622 else if (payloadSize >= minimumPayloadSizeWithTwoByteExtendedPayloadLength)
625 overhead += 2; 623 overhead += 2;
626 return overhead; 624 return overhead;
627 } 625 }
628 626
629 } // namespace WebCore 627 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/modules/websockets/NewWebSocketChannelImpl.cpp ('k') | Source/modules/websockets/WebSocketChannel.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698