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

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

Issue 2050123002: Remove OwnPtr from Blink. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: First attempt to land. Created 4 years, 6 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 "wtf/PtrUtil.h"
59 #include <memory>
58 60
59 using blink::WebSocketHandle; 61 using blink::WebSocketHandle;
60 62
61 namespace blink { 63 namespace blink {
62 64
63 class DocumentWebSocketChannel::BlobLoader final : public GarbageCollectedFinali zed<DocumentWebSocketChannel::BlobLoader>, public FileReaderLoaderClient { 65 class DocumentWebSocketChannel::BlobLoader final : public GarbageCollectedFinali zed<DocumentWebSocketChannel::BlobLoader>, public FileReaderLoaderClient {
64 public: 66 public:
65 BlobLoader(PassRefPtr<BlobDataHandle>, DocumentWebSocketChannel*); 67 BlobLoader(PassRefPtr<BlobDataHandle>, DocumentWebSocketChannel*);
66 ~BlobLoader() override { } 68 ~BlobLoader() override { }
67 69
(...skipping 14 matching lines...) Expand all
82 Member<DocumentWebSocketChannel> m_channel; 84 Member<DocumentWebSocketChannel> m_channel;
83 FileReaderLoader m_loader; 85 FileReaderLoader m_loader;
84 }; 86 };
85 87
86 class DocumentWebSocketChannel::Message : public GarbageCollectedFinalized<Docum entWebSocketChannel::Message> { 88 class DocumentWebSocketChannel::Message : public GarbageCollectedFinalized<Docum entWebSocketChannel::Message> {
87 public: 89 public:
88 explicit Message(const CString&); 90 explicit Message(const CString&);
89 explicit Message(PassRefPtr<BlobDataHandle>); 91 explicit Message(PassRefPtr<BlobDataHandle>);
90 explicit Message(DOMArrayBuffer*); 92 explicit Message(DOMArrayBuffer*);
91 // For WorkerWebSocketChannel 93 // For WorkerWebSocketChannel
92 explicit Message(PassOwnPtr<Vector<char>>, MessageType); 94 explicit Message(std::unique_ptr<Vector<char>>, MessageType);
93 // Close message 95 // Close message
94 Message(unsigned short code, const String& reason); 96 Message(unsigned short code, const String& reason);
95 97
96 DEFINE_INLINE_TRACE() 98 DEFINE_INLINE_TRACE()
97 { 99 {
98 visitor->trace(arrayBuffer); 100 visitor->trace(arrayBuffer);
99 } 101 }
100 102
101 MessageType type; 103 MessageType type;
102 104
103 CString text; 105 CString text;
104 RefPtr<BlobDataHandle> blobDataHandle; 106 RefPtr<BlobDataHandle> blobDataHandle;
105 Member<DOMArrayBuffer> arrayBuffer; 107 Member<DOMArrayBuffer> arrayBuffer;
106 OwnPtr<Vector<char>> vectorData; 108 std::unique_ptr<Vector<char>> vectorData;
107 unsigned short code; 109 unsigned short code;
108 String reason; 110 String reason;
109 }; 111 };
110 112
111 DocumentWebSocketChannel::BlobLoader::BlobLoader(PassRefPtr<BlobDataHandle> blob DataHandle, DocumentWebSocketChannel* channel) 113 DocumentWebSocketChannel::BlobLoader::BlobLoader(PassRefPtr<BlobDataHandle> blob DataHandle, DocumentWebSocketChannel* channel)
112 : m_channel(channel) 114 : m_channel(channel)
113 , m_loader(FileReaderLoader::ReadAsArrayBuffer, this) 115 , m_loader(FileReaderLoader::ReadAsArrayBuffer, this)
114 { 116 {
115 m_loader.start(channel->getExecutionContext(), blobDataHandle); 117 m_loader.start(channel->getExecutionContext(), blobDataHandle);
116 } 118 }
(...skipping 10 matching lines...) Expand all
127 m_channel->didFinishLoadingBlob(m_loader.arrayBufferResult()); 129 m_channel->didFinishLoadingBlob(m_loader.arrayBufferResult());
128 // |this| is deleted here. 130 // |this| is deleted here.
129 } 131 }
130 132
131 void DocumentWebSocketChannel::BlobLoader::didFail(FileError::ErrorCode errorCod e) 133 void DocumentWebSocketChannel::BlobLoader::didFail(FileError::ErrorCode errorCod e)
132 { 134 {
133 m_channel->didFailLoadingBlob(errorCode); 135 m_channel->didFailLoadingBlob(errorCode);
134 // |this| is deleted here. 136 // |this| is deleted here.
135 } 137 }
136 138
137 DocumentWebSocketChannel::DocumentWebSocketChannel(Document* document, WebSocket ChannelClient* client, PassOwnPtr<SourceLocation> location, WebSocketHandle *han dle) 139 DocumentWebSocketChannel::DocumentWebSocketChannel(Document* document, WebSocket ChannelClient* client, std::unique_ptr<SourceLocation> location, WebSocketHandle *handle)
138 : ContextLifecycleObserver(document) 140 : ContextLifecycleObserver(document)
139 , m_handle(adoptPtr(handle ? handle : Platform::current()->createWebSocketHa ndle())) 141 , m_handle(wrapUnique(handle ? handle : Platform::current()->createWebSocket Handle()))
140 , m_client(client) 142 , m_client(client)
141 , m_identifier(createUniqueIdentifier()) 143 , m_identifier(createUniqueIdentifier())
142 , m_sendingQuota(0) 144 , m_sendingQuota(0)
143 , m_receivedDataSizeForFlowControl(receivedDataSizeForFlowControlHighWaterMa rk * 2) // initial quota 145 , m_receivedDataSizeForFlowControl(receivedDataSizeForFlowControlHighWaterMa rk * 2) // initial quota
144 , m_sentSizeOfTopMessage(0) 146 , m_sentSizeOfTopMessage(0)
145 , m_locationAtConstruction(std::move(location)) 147 , m_locationAtConstruction(std::move(location))
146 { 148 {
147 } 149 }
148 150
149 DocumentWebSocketChannel::~DocumentWebSocketChannel() 151 DocumentWebSocketChannel::~DocumentWebSocketChannel()
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 // FIXME: Change the inspector API to show the entire message instead 221 // FIXME: Change the inspector API to show the entire message instead
220 // of individual frames. 222 // of individual frames.
221 InspectorInstrumentation::didSendWebSocketFrame(document(), m_identifier, We bSocketFrame::OpCodeBinary, true, static_cast<const char*>(buffer.data()) + byte Offset, byteLength); 223 InspectorInstrumentation::didSendWebSocketFrame(document(), m_identifier, We bSocketFrame::OpCodeBinary, true, static_cast<const char*>(buffer.data()) + byte Offset, byteLength);
222 // buffer.slice copies its contents. 224 // buffer.slice copies its contents.
223 // FIXME: Reduce copy by sending the data immediately when we don't need to 225 // FIXME: Reduce copy by sending the data immediately when we don't need to
224 // queue the data. 226 // queue the data.
225 m_messages.append(new Message(buffer.slice(byteOffset, byteOffset + byteLeng th))); 227 m_messages.append(new Message(buffer.slice(byteOffset, byteOffset + byteLeng th)));
226 processSendQueue(); 228 processSendQueue();
227 } 229 }
228 230
229 void DocumentWebSocketChannel::sendTextAsCharVector(PassOwnPtr<Vector<char>> dat a) 231 void DocumentWebSocketChannel::sendTextAsCharVector(std::unique_ptr<Vector<char> > data)
230 { 232 {
231 WTF_LOG(Network, "DocumentWebSocketChannel %p sendTextAsCharVector(%p, %llu) ", this, data.get(), static_cast<unsigned long long>(data->size())); 233 WTF_LOG(Network, "DocumentWebSocketChannel %p sendTextAsCharVector(%p, %llu) ", this, data.get(), static_cast<unsigned long long>(data->size()));
232 // FIXME: Change the inspector API to show the entire message instead 234 // FIXME: Change the inspector API to show the entire message instead
233 // of individual frames. 235 // of individual frames.
234 InspectorInstrumentation::didSendWebSocketFrame(document(), m_identifier, We bSocketFrame::OpCodeText, true, data->data(), data->size()); 236 InspectorInstrumentation::didSendWebSocketFrame(document(), m_identifier, We bSocketFrame::OpCodeText, true, data->data(), data->size());
235 m_messages.append(new Message(std::move(data), MessageTypeTextAsCharVector)) ; 237 m_messages.append(new Message(std::move(data), MessageTypeTextAsCharVector)) ;
236 processSendQueue(); 238 processSendQueue();
237 } 239 }
238 240
239 void DocumentWebSocketChannel::sendBinaryAsCharVector(PassOwnPtr<Vector<char>> d ata) 241 void DocumentWebSocketChannel::sendBinaryAsCharVector(std::unique_ptr<Vector<cha r>> data)
240 { 242 {
241 WTF_LOG(Network, "DocumentWebSocketChannel %p sendBinaryAsCharVector(%p, %ll u)", this, data.get(), static_cast<unsigned long long>(data->size())); 243 WTF_LOG(Network, "DocumentWebSocketChannel %p sendBinaryAsCharVector(%p, %ll u)", this, data.get(), static_cast<unsigned long long>(data->size()));
242 // FIXME: Change the inspector API to show the entire message instead 244 // FIXME: Change the inspector API to show the entire message instead
243 // of individual frames. 245 // of individual frames.
244 InspectorInstrumentation::didSendWebSocketFrame(document(), m_identifier, We bSocketFrame::OpCodeBinary, true, data->data(), data->size()); 246 InspectorInstrumentation::didSendWebSocketFrame(document(), m_identifier, We bSocketFrame::OpCodeBinary, true, data->data(), data->size());
245 m_messages.append(new Message(std::move(data), MessageTypeBinaryAsCharVector )); 247 m_messages.append(new Message(std::move(data), MessageTypeBinaryAsCharVector ));
246 processSendQueue(); 248 processSendQueue();
247 } 249 }
248 250
249 void DocumentWebSocketChannel::close(int code, const String& reason) 251 void DocumentWebSocketChannel::close(int code, const String& reason)
250 { 252 {
251 WTF_LOG(Network, "DocumentWebSocketChannel %p close(%d, %s)", this, code, re ason.utf8().data()); 253 WTF_LOG(Network, "DocumentWebSocketChannel %p close(%d, %s)", this, code, re ason.utf8().data());
252 ASSERT(m_handle); 254 ASSERT(m_handle);
253 unsigned short codeToSend = static_cast<unsigned short>(code == CloseEventCo deNotSpecified ? CloseEventCodeNoStatusRcvd : code); 255 unsigned short codeToSend = static_cast<unsigned short>(code == CloseEventCo deNotSpecified ? CloseEventCodeNoStatusRcvd : code);
254 m_messages.append(new Message(codeToSend, reason)); 256 m_messages.append(new Message(codeToSend, reason));
255 processSendQueue(); 257 processSendQueue();
256 } 258 }
257 259
258 void DocumentWebSocketChannel::fail(const String& reason, MessageLevel level, Pa ssOwnPtr<SourceLocation> location) 260 void DocumentWebSocketChannel::fail(const String& reason, MessageLevel level, st d::unique_ptr<SourceLocation> location)
259 { 261 {
260 WTF_LOG(Network, "DocumentWebSocketChannel %p fail(%s)", this, reason.utf8() .data()); 262 WTF_LOG(Network, "DocumentWebSocketChannel %p fail(%s)", this, reason.utf8() .data());
261 // m_handle and m_client can be null here. 263 // m_handle and m_client can be null here.
262 264
263 InspectorInstrumentation::didReceiveWebSocketFrameError(document(), m_identi fier, reason); 265 InspectorInstrumentation::didReceiveWebSocketFrameError(document(), m_identi fier, reason);
264 const String message = "WebSocket connection to '" + m_url.elidedString() + "' failed: " + reason; 266 const String message = "WebSocket connection to '" + m_url.elidedString() + "' failed: " + reason;
265 getExecutionContext()->addConsoleMessage(ConsoleMessage::create(JSMessageSou rce, level, message, std::move(location))); 267 getExecutionContext()->addConsoleMessage(ConsoleMessage::create(JSMessageSou rce, level, message, std::move(location)));
266 268
267 if (m_client) 269 if (m_client)
268 m_client->didError(); 270 m_client->didError();
(...skipping 21 matching lines...) Expand all
290 , text(text) { } 292 , text(text) { }
291 293
292 DocumentWebSocketChannel::Message::Message(PassRefPtr<BlobDataHandle> blobDataHa ndle) 294 DocumentWebSocketChannel::Message::Message(PassRefPtr<BlobDataHandle> blobDataHa ndle)
293 : type(MessageTypeBlob) 295 : type(MessageTypeBlob)
294 , blobDataHandle(blobDataHandle) { } 296 , blobDataHandle(blobDataHandle) { }
295 297
296 DocumentWebSocketChannel::Message::Message(DOMArrayBuffer* arrayBuffer) 298 DocumentWebSocketChannel::Message::Message(DOMArrayBuffer* arrayBuffer)
297 : type(MessageTypeArrayBuffer) 299 : type(MessageTypeArrayBuffer)
298 , arrayBuffer(arrayBuffer) { } 300 , arrayBuffer(arrayBuffer) { }
299 301
300 DocumentWebSocketChannel::Message::Message(PassOwnPtr<Vector<char>> vectorData, MessageType type) 302 DocumentWebSocketChannel::Message::Message(std::unique_ptr<Vector<char>> vectorD ata, MessageType type)
301 : type(type) 303 : type(type)
302 , vectorData(std::move(vectorData)) 304 , vectorData(std::move(vectorData))
303 { 305 {
304 ASSERT(type == MessageTypeTextAsCharVector || type == MessageTypeBinaryAsCha rVector); 306 ASSERT(type == MessageTypeTextAsCharVector || type == MessageTypeBinaryAsCha rVector);
305 } 307 }
306 308
307 DocumentWebSocketChannel::Message::Message(unsigned short code, const String& re ason) 309 DocumentWebSocketChannel::Message::Message(unsigned short code, const String& re ason)
308 : type(MessageTypeClose) 310 : type(MessageTypeClose)
309 , code(code) 311 , code(code)
310 , reason(reason) { } 312 , reason(reason) { }
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
409 ExecutionContext* context = getExecutionContext(); 411 ExecutionContext* context = getExecutionContext();
410 ASSERT(context->isDocument()); 412 ASSERT(context->isDocument());
411 return toDocument(context); 413 return toDocument(context);
412 } 414 }
413 415
414 void DocumentWebSocketChannel::didConnect(WebSocketHandle* handle, const WebStri ng& selectedProtocol, const WebString& extensions) 416 void DocumentWebSocketChannel::didConnect(WebSocketHandle* handle, const WebStri ng& selectedProtocol, const WebString& extensions)
415 { 417 {
416 WTF_LOG(Network, "DocumentWebSocketChannel %p didConnect(%p, %s, %s)", this, handle, selectedProtocol.utf8().c_str(), extensions.utf8().c_str()); 418 WTF_LOG(Network, "DocumentWebSocketChannel %p didConnect(%p, %s, %s)", this, handle, selectedProtocol.utf8().c_str(), extensions.utf8().c_str());
417 419
418 ASSERT(m_handle); 420 ASSERT(m_handle);
419 ASSERT(handle == m_handle); 421 ASSERT(handle == m_handle.get());
420 ASSERT(m_client); 422 ASSERT(m_client);
421 423
422 m_client->didConnect(selectedProtocol, extensions); 424 m_client->didConnect(selectedProtocol, extensions);
423 } 425 }
424 426
425 void DocumentWebSocketChannel::didStartOpeningHandshake(WebSocketHandle* handle, const WebSocketHandshakeRequestInfo& request) 427 void DocumentWebSocketChannel::didStartOpeningHandshake(WebSocketHandle* handle, const WebSocketHandshakeRequestInfo& request)
426 { 428 {
427 WTF_LOG(Network, "DocumentWebSocketChannel %p didStartOpeningHandshake(%p)", this, handle); 429 WTF_LOG(Network, "DocumentWebSocketChannel %p didStartOpeningHandshake(%p)", this, handle);
428 430
429 ASSERT(m_handle); 431 ASSERT(m_handle);
430 ASSERT(handle == m_handle); 432 ASSERT(handle == m_handle.get());
431 433
432 TRACE_EVENT_INSTANT1("devtools.timeline", "WebSocketSendHandshakeRequest", T RACE_EVENT_SCOPE_THREAD, "data", InspectorWebSocketEvent::data(document(), m_ide ntifier)); 434 TRACE_EVENT_INSTANT1("devtools.timeline", "WebSocketSendHandshakeRequest", T RACE_EVENT_SCOPE_THREAD, "data", InspectorWebSocketEvent::data(document(), m_ide ntifier));
433 InspectorInstrumentation::willSendWebSocketHandshakeRequest(document(), m_id entifier, &request.toCoreRequest()); 435 InspectorInstrumentation::willSendWebSocketHandshakeRequest(document(), m_id entifier, &request.toCoreRequest());
434 m_handshakeRequest = WebSocketHandshakeRequest::create(request.toCoreRequest ()); 436 m_handshakeRequest = WebSocketHandshakeRequest::create(request.toCoreRequest ());
435 } 437 }
436 438
437 void DocumentWebSocketChannel::didFinishOpeningHandshake(WebSocketHandle* handle , const WebSocketHandshakeResponseInfo& response) 439 void DocumentWebSocketChannel::didFinishOpeningHandshake(WebSocketHandle* handle , const WebSocketHandshakeResponseInfo& response)
438 { 440 {
439 WTF_LOG(Network, "DocumentWebSocketChannel %p didFinishOpeningHandshake(%p)" , this, handle); 441 WTF_LOG(Network, "DocumentWebSocketChannel %p didFinishOpeningHandshake(%p)" , this, handle);
440 442
441 ASSERT(m_handle); 443 ASSERT(m_handle);
442 ASSERT(handle == m_handle); 444 ASSERT(handle == m_handle.get());
443 445
444 TRACE_EVENT_INSTANT1("devtools.timeline", "WebSocketReceiveHandshakeResponse ", TRACE_EVENT_SCOPE_THREAD, "data", InspectorWebSocketEvent::data(document(), m _identifier)); 446 TRACE_EVENT_INSTANT1("devtools.timeline", "WebSocketReceiveHandshakeResponse ", TRACE_EVENT_SCOPE_THREAD, "data", InspectorWebSocketEvent::data(document(), m _identifier));
445 InspectorInstrumentation::didReceiveWebSocketHandshakeResponse(document(), m _identifier, m_handshakeRequest.get(), &response.toCoreResponse()); 447 InspectorInstrumentation::didReceiveWebSocketHandshakeResponse(document(), m _identifier, m_handshakeRequest.get(), &response.toCoreResponse());
446 m_handshakeRequest.clear(); 448 m_handshakeRequest.clear();
447 } 449 }
448 450
449 void DocumentWebSocketChannel::didFail(WebSocketHandle* handle, const WebString& message) 451 void DocumentWebSocketChannel::didFail(WebSocketHandle* handle, const WebString& message)
450 { 452 {
451 WTF_LOG(Network, "DocumentWebSocketChannel %p didFail(%p, %s)", this, handle , message.utf8().data()); 453 WTF_LOG(Network, "DocumentWebSocketChannel %p didFail(%p, %s)", this, handle , message.utf8().data());
452 454
453 ASSERT(m_handle); 455 ASSERT(m_handle);
454 ASSERT(handle == m_handle); 456 ASSERT(handle == m_handle.get());
455 457
456 // This function is called when the browser is required to fail the 458 // This function is called when the browser is required to fail the
457 // WebSocketConnection. Hence we fail this channel by calling 459 // WebSocketConnection. Hence we fail this channel by calling
458 // |this->failAsError| function. 460 // |this->failAsError| function.
459 failAsError(message); 461 failAsError(message);
460 // |this| may be deleted. 462 // |this| may be deleted.
461 } 463 }
462 464
463 void DocumentWebSocketChannel::didReceiveData(WebSocketHandle* handle, bool fin, WebSocketHandle::MessageType type, const char* data, size_t size) 465 void DocumentWebSocketChannel::didReceiveData(WebSocketHandle* handle, bool fin, WebSocketHandle::MessageType type, const char* data, size_t size)
464 { 466 {
465 WTF_LOG(Network, "DocumentWebSocketChannel %p didReceiveData(%p, %d, %d, (%p , %zu))", this, handle, fin, type, data, size); 467 WTF_LOG(Network, "DocumentWebSocketChannel %p didReceiveData(%p, %d, %d, (%p , %zu))", this, handle, fin, type, data, size);
466 468
467 ASSERT(m_handle); 469 ASSERT(m_handle);
468 ASSERT(handle == m_handle); 470 ASSERT(handle == m_handle.get());
469 ASSERT(m_client); 471 ASSERT(m_client);
470 // Non-final frames cannot be empty. 472 // Non-final frames cannot be empty.
471 ASSERT(fin || size); 473 ASSERT(fin || size);
472 474
473 switch (type) { 475 switch (type) {
474 case WebSocketHandle::MessageTypeText: 476 case WebSocketHandle::MessageTypeText:
475 ASSERT(m_receivingMessageData.isEmpty()); 477 ASSERT(m_receivingMessageData.isEmpty());
476 m_receivingMessageTypeIsText = true; 478 m_receivingMessageTypeIsText = true;
477 break; 479 break;
478 case WebSocketHandle::MessageTypeBinary: 480 case WebSocketHandle::MessageTypeBinary:
(...skipping 19 matching lines...) Expand all
498 if (m_receivingMessageTypeIsText) { 500 if (m_receivingMessageTypeIsText) {
499 String message = m_receivingMessageData.isEmpty() ? emptyString() : Stri ng::fromUTF8(m_receivingMessageData.data(), m_receivingMessageData.size()); 501 String message = m_receivingMessageData.isEmpty() ? emptyString() : Stri ng::fromUTF8(m_receivingMessageData.data(), m_receivingMessageData.size());
500 m_receivingMessageData.clear(); 502 m_receivingMessageData.clear();
501 if (message.isNull()) { 503 if (message.isNull()) {
502 failAsError("Could not decode a text frame as UTF-8."); 504 failAsError("Could not decode a text frame as UTF-8.");
503 // failAsError may delete this object. 505 // failAsError may delete this object.
504 } else { 506 } else {
505 m_client->didReceiveTextMessage(message); 507 m_client->didReceiveTextMessage(message);
506 } 508 }
507 } else { 509 } else {
508 OwnPtr<Vector<char>> binaryData = adoptPtr(new Vector<char>); 510 std::unique_ptr<Vector<char>> binaryData = wrapUnique(new Vector<char>);
509 binaryData->swap(m_receivingMessageData); 511 binaryData->swap(m_receivingMessageData);
510 m_client->didReceiveBinaryMessage(std::move(binaryData)); 512 m_client->didReceiveBinaryMessage(std::move(binaryData));
511 } 513 }
512 } 514 }
513 515
514 void DocumentWebSocketChannel::didClose(WebSocketHandle* handle, bool wasClean, unsigned short code, const WebString& reason) 516 void DocumentWebSocketChannel::didClose(WebSocketHandle* handle, bool wasClean, unsigned short code, const WebString& reason)
515 { 517 {
516 WTF_LOG(Network, "DocumentWebSocketChannel %p didClose(%p, %d, %u, %s)", thi s, handle, wasClean, code, String(reason).utf8().data()); 518 WTF_LOG(Network, "DocumentWebSocketChannel %p didClose(%p, %d, %u, %s)", thi s, handle, wasClean, code, String(reason).utf8().data());
517 519
518 ASSERT(m_handle); 520 ASSERT(m_handle);
519 ASSERT(handle == m_handle); 521 ASSERT(handle == m_handle.get());
520 522
521 m_handle.reset(); 523 m_handle.reset();
522 524
523 if (m_identifier) { 525 if (m_identifier) {
524 TRACE_EVENT_INSTANT1("devtools.timeline", "WebSocketDestroy", TRACE_EVEN T_SCOPE_THREAD, "data", InspectorWebSocketEvent::data(document(), m_identifier)) ; 526 TRACE_EVENT_INSTANT1("devtools.timeline", "WebSocketDestroy", TRACE_EVEN T_SCOPE_THREAD, "data", InspectorWebSocketEvent::data(document(), m_identifier)) ;
525 InspectorInstrumentation::didCloseWebSocket(document(), m_identifier); 527 InspectorInstrumentation::didCloseWebSocket(document(), m_identifier);
526 m_identifier = 0; 528 m_identifier = 0;
527 } 529 }
528 530
529 handleDidClose(wasClean, code, reason); 531 handleDidClose(wasClean, code, reason);
530 // handleDidClose may delete this object. 532 // handleDidClose may delete this object.
531 } 533 }
532 534
533 void DocumentWebSocketChannel::didReceiveFlowControl(WebSocketHandle* handle, in t64_t quota) 535 void DocumentWebSocketChannel::didReceiveFlowControl(WebSocketHandle* handle, in t64_t quota)
534 { 536 {
535 WTF_LOG(Network, "DocumentWebSocketChannel %p didReceiveFlowControl(%p, %ld) ", this, handle, static_cast<long>(quota)); 537 WTF_LOG(Network, "DocumentWebSocketChannel %p didReceiveFlowControl(%p, %ld) ", this, handle, static_cast<long>(quota));
536 538
537 ASSERT(m_handle); 539 ASSERT(m_handle);
538 ASSERT(handle == m_handle); 540 ASSERT(handle == m_handle.get());
539 ASSERT(quota >= 0); 541 ASSERT(quota >= 0);
540 542
541 m_sendingQuota += quota; 543 m_sendingQuota += quota;
542 processSendQueue(); 544 processSendQueue();
543 } 545 }
544 546
545 void DocumentWebSocketChannel::didStartClosingHandshake(WebSocketHandle* handle) 547 void DocumentWebSocketChannel::didStartClosingHandshake(WebSocketHandle* handle)
546 { 548 {
547 WTF_LOG(Network, "DocumentWebSocketChannel %p didStartClosingHandshake(%p)", this, handle); 549 WTF_LOG(Network, "DocumentWebSocketChannel %p didStartClosingHandshake(%p)", this, handle);
548 550
549 ASSERT(m_handle); 551 ASSERT(m_handle);
550 ASSERT(handle == m_handle); 552 ASSERT(handle == m_handle.get());
551 553
552 if (m_client) 554 if (m_client)
553 m_client->didStartClosingHandshake(); 555 m_client->didStartClosingHandshake();
554 } 556 }
555 557
556 void DocumentWebSocketChannel::didFinishLoadingBlob(DOMArrayBuffer* buffer) 558 void DocumentWebSocketChannel::didFinishLoadingBlob(DOMArrayBuffer* buffer)
557 { 559 {
558 m_blobLoader.clear(); 560 m_blobLoader.clear();
559 ASSERT(m_handle); 561 ASSERT(m_handle);
560 // The loaded blob is always placed on m_messages[0]. 562 // The loaded blob is always placed on m_messages[0].
(...skipping 18 matching lines...) Expand all
579 DEFINE_TRACE(DocumentWebSocketChannel) 581 DEFINE_TRACE(DocumentWebSocketChannel)
580 { 582 {
581 visitor->trace(m_blobLoader); 583 visitor->trace(m_blobLoader);
582 visitor->trace(m_messages); 584 visitor->trace(m_messages);
583 visitor->trace(m_client); 585 visitor->trace(m_client);
584 WebSocketChannel::trace(visitor); 586 WebSocketChannel::trace(visitor);
585 ContextLifecycleObserver::trace(visitor); 587 ContextLifecycleObserver::trace(visitor);
586 } 588 }
587 589
588 } // namespace blink 590 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698