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

Side by Side Diff: third_party/WebKit/Source/modules/websockets/DocumentWebSocketChannel.cpp

Issue 1666893003: [ABANDONED] WebSocket Blob receive in the browser process: renderer changes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@websocket_blob_receive_host_merged
Patch Set: Created 4 years, 10 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) 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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 #include "platform/Logging.h" 48 #include "platform/Logging.h"
49 #include "platform/network/WebSocketHandshakeRequest.h" 49 #include "platform/network/WebSocketHandshakeRequest.h"
50 #include "platform/weborigin/SecurityOrigin.h" 50 #include "platform/weborigin/SecurityOrigin.h"
51 #include "public/platform/Platform.h" 51 #include "public/platform/Platform.h"
52 #include "public/platform/WebSecurityOrigin.h" 52 #include "public/platform/WebSecurityOrigin.h"
53 #include "public/platform/WebString.h" 53 #include "public/platform/WebString.h"
54 #include "public/platform/WebURL.h" 54 #include "public/platform/WebURL.h"
55 #include "public/platform/WebVector.h" 55 #include "public/platform/WebVector.h"
56 #include "public/platform/modules/websockets/WebSocketHandshakeRequestInfo.h" 56 #include "public/platform/modules/websockets/WebSocketHandshakeRequestInfo.h"
57 #include "public/platform/modules/websockets/WebSocketHandshakeResponseInfo.h" 57 #include "public/platform/modules/websockets/WebSocketHandshakeResponseInfo.h"
58 #include <inttypes.h>
58 59
59 using blink::WebSocketHandle; 60 using blink::WebSocketHandle;
60 61
61 namespace blink { 62 namespace blink {
62 63
63 class DocumentWebSocketChannel::BlobLoader final : public GarbageCollectedFinali zed<DocumentWebSocketChannel::BlobLoader>, public FileReaderLoaderClient { 64 class DocumentWebSocketChannel::BlobLoader final : public GarbageCollectedFinali zed<DocumentWebSocketChannel::BlobLoader>, public FileReaderLoaderClient {
64 public: 65 public:
65 BlobLoader(PassRefPtr<BlobDataHandle>, DocumentWebSocketChannel*); 66 BlobLoader(PassRefPtr<BlobDataHandle>, DocumentWebSocketChannel*);
66 ~BlobLoader() override { } 67 ~BlobLoader() override { }
67 68
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 225
225 void DocumentWebSocketChannel::close(int code, const String& reason) 226 void DocumentWebSocketChannel::close(int code, const String& reason)
226 { 227 {
227 WTF_LOG(Network, "DocumentWebSocketChannel %p close(%d, %s)", this, code, re ason.utf8().data()); 228 WTF_LOG(Network, "DocumentWebSocketChannel %p close(%d, %s)", this, code, re ason.utf8().data());
228 ASSERT(m_handle); 229 ASSERT(m_handle);
229 unsigned short codeToSend = static_cast<unsigned short>(code == CloseEventCo deNotSpecified ? CloseEventCodeNoStatusRcvd : code); 230 unsigned short codeToSend = static_cast<unsigned short>(code == CloseEventCo deNotSpecified ? CloseEventCodeNoStatusRcvd : code);
230 m_messages.append(adoptPtr(new Message(codeToSend, reason))); 231 m_messages.append(adoptPtr(new Message(codeToSend, reason)));
231 processSendQueue(); 232 processSendQueue();
232 } 233 }
233 234
235 static WebSocketHandle::BinaryType toHandleBinaryType(DocumentWebSocketChannel:: BinaryType binaryType)
236 {
237 static_assert(static_cast<WebSocketHandle::BinaryType>(DocumentWebSocketChan nel::BinaryTypeBlob) == WebSocketHandle::BinaryTypeBlob, "enums must match");
238 static_assert(static_cast<WebSocketHandle::BinaryType>(DocumentWebSocketChan nel::BinaryTypeArrayBuffer) == WebSocketHandle::BinaryTypeArrayBuffer, "enums mu st match");
239 ASSERT(binaryType == DocumentWebSocketChannel::BinaryTypeBlob || binaryType == DocumentWebSocketChannel::BinaryTypeArrayBuffer);
240 return static_cast<WebSocketHandle::BinaryType>(binaryType);
241 }
242
243 void DocumentWebSocketChannel::changeBinaryType(BinaryType newBinaryType)
244 {
245 WTF_LOG(Network, "DocumentWebSocketChannel %p changeBinaryType(%d)", this, n ewBinaryType);
246 ASSERT(m_handle);
247 m_handle->changeBinaryType(toHandleBinaryType(newBinaryType));
248 }
249
234 void DocumentWebSocketChannel::fail(const String& reason, MessageLevel level, co nst String& sourceURL, unsigned lineNumber) 250 void DocumentWebSocketChannel::fail(const String& reason, MessageLevel level, co nst String& sourceURL, unsigned lineNumber)
235 { 251 {
236 WTF_LOG(Network, "DocumentWebSocketChannel %p fail(%s)", this, reason.utf8() .data()); 252 WTF_LOG(Network, "DocumentWebSocketChannel %p fail(%s)", this, reason.utf8() .data());
237 // m_handle and m_client can be null here. 253 // m_handle and m_client can be null here.
238 254
239 InspectorInstrumentation::didReceiveWebSocketFrameError(document(), m_identi fier, reason); 255 InspectorInstrumentation::didReceiveWebSocketFrameError(document(), m_identi fier, reason);
240 const String message = "WebSocket connection to '" + m_url.elidedString() + "' failed: " + reason; 256 const String message = "WebSocket connection to '" + m_url.elidedString() + "' failed: " + reason;
241 executionContext()->addConsoleMessage(ConsoleMessage::create(JSMessageSource , level, message, sourceURL, lineNumber)); 257 executionContext()->addConsoleMessage(ConsoleMessage::create(JSMessageSource , level, message, sourceURL, lineNumber));
242 258
243 if (m_client) 259 if (m_client)
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
476 m_receivingMessageData.clear(); 492 m_receivingMessageData.clear();
477 if (message.isNull()) { 493 if (message.isNull()) {
478 failAsError("Could not decode a text frame as UTF-8."); 494 failAsError("Could not decode a text frame as UTF-8.");
479 // failAsError may delete this object. 495 // failAsError may delete this object.
480 } else { 496 } else {
481 m_client->didReceiveTextMessage(message); 497 m_client->didReceiveTextMessage(message);
482 } 498 }
483 } else { 499 } else {
484 OwnPtr<Vector<char>> binaryData = adoptPtr(new Vector<char>); 500 OwnPtr<Vector<char>> binaryData = adoptPtr(new Vector<char>);
485 binaryData->swap(m_receivingMessageData); 501 binaryData->swap(m_receivingMessageData);
486 m_client->didReceiveBinaryMessage(binaryData.release()); 502 m_client->didReceiveArrayBuffer(binaryData.release());
487 } 503 }
488 } 504 }
489 505
506 void DocumentWebSocketChannel::didReceiveBlob(WebSocketHandle* handle,
507 const WebString& uuid,
508 uint64_t size)
509 {
510 WTF_LOG(Network, "DocumentWebSocketChannel %p didReceiveBlob(%p, %s, %" PRIu 64 ")", this, handle, uuid.utf8().c_str(), size);
511
512 ASSERT(m_handle);
513 ASSERT(handle == m_handle);
514 ASSERT(m_client);
515
516 // FIXME: Report the Blob to InspectorInstrumentation.
517 RefPtr<BlobDataHandle> blobDataHandle = BlobDataHandle::create(uuid, "", siz e);
518 handle->confirmBlob();
519 m_client->didReceiveBlob(blobDataHandle.release());
520 }
521
490 void DocumentWebSocketChannel::didClose(WebSocketHandle* handle, bool wasClean, unsigned short code, const WebString& reason) 522 void DocumentWebSocketChannel::didClose(WebSocketHandle* handle, bool wasClean, unsigned short code, const WebString& reason)
491 { 523 {
492 WTF_LOG(Network, "DocumentWebSocketChannel %p didClose(%p, %d, %u, %s)", thi s, handle, wasClean, code, String(reason).utf8().data()); 524 WTF_LOG(Network, "DocumentWebSocketChannel %p didClose(%p, %d, %u, %s)", thi s, handle, wasClean, code, String(reason).utf8().data());
493 525
494 ASSERT(m_handle); 526 ASSERT(m_handle);
495 ASSERT(handle == m_handle); 527 ASSERT(handle == m_handle);
496 528
497 m_handle.clear(); 529 m_handle.clear();
498 530
499 if (m_identifier) { 531 if (m_identifier) {
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
554 586
555 DEFINE_TRACE(DocumentWebSocketChannel) 587 DEFINE_TRACE(DocumentWebSocketChannel)
556 { 588 {
557 visitor->trace(m_blobLoader); 589 visitor->trace(m_blobLoader);
558 visitor->trace(m_client); 590 visitor->trace(m_client);
559 WebSocketChannel::trace(visitor); 591 WebSocketChannel::trace(visitor);
560 ContextLifecycleObserver::trace(visitor); 592 ContextLifecycleObserver::trace(visitor);
561 } 593 }
562 594
563 } // namespace blink 595 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698