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

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

Issue 2325983002: Replace ASSERT*() with DCHECK*() in modules/websockets (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove ALLOW_UNUSED_LOCAL() Created 4 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) 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 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 , m_identifier(createUniqueIdentifier()) 136 , m_identifier(createUniqueIdentifier())
137 , m_sendingQuota(0) 137 , m_sendingQuota(0)
138 , m_receivedDataSizeForFlowControl(receivedDataSizeForFlowControlHighWaterMa rk * 2) // initial quota 138 , m_receivedDataSizeForFlowControl(receivedDataSizeForFlowControlHighWaterMa rk * 2) // initial quota
139 , m_sentSizeOfTopMessage(0) 139 , m_sentSizeOfTopMessage(0)
140 , m_locationAtConstruction(std::move(location)) 140 , m_locationAtConstruction(std::move(location))
141 { 141 {
142 } 142 }
143 143
144 DocumentWebSocketChannel::~DocumentWebSocketChannel() 144 DocumentWebSocketChannel::~DocumentWebSocketChannel()
145 { 145 {
146 ASSERT(!m_blobLoader); 146 DCHECK(!m_blobLoader);
147 } 147 }
148 148
149 bool DocumentWebSocketChannel::connect(const KURL& url, const String& protocol) 149 bool DocumentWebSocketChannel::connect(const KURL& url, const String& protocol)
150 { 150 {
151 NETWORK_DVLOG(1) << this << " connect()"; 151 NETWORK_DVLOG(1) << this << " connect()";
152 if (!m_handle) 152 if (!m_handle)
153 return false; 153 return false;
154 154
155 if (document()->frame()) { 155 if (document()->frame()) {
156 if (MixedContentChecker::shouldBlockWebSocket(document()->frame(), url)) 156 if (MixedContentChecker::shouldBlockWebSocket(document()->frame(), url))
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 // FIXME: Change the inspector API to show the entire message instead 240 // FIXME: Change the inspector API to show the entire message instead
241 // of individual frames. 241 // of individual frames.
242 InspectorInstrumentation::didSendWebSocketFrame(document(), m_identifier, We bSocketFrame::OpCodeBinary, true, data->data(), data->size()); 242 InspectorInstrumentation::didSendWebSocketFrame(document(), m_identifier, We bSocketFrame::OpCodeBinary, true, data->data(), data->size());
243 m_messages.append(new Message(std::move(data), MessageTypeBinaryAsCharVector )); 243 m_messages.append(new Message(std::move(data), MessageTypeBinaryAsCharVector ));
244 processSendQueue(); 244 processSendQueue();
245 } 245 }
246 246
247 void DocumentWebSocketChannel::close(int code, const String& reason) 247 void DocumentWebSocketChannel::close(int code, const String& reason)
248 { 248 {
249 NETWORK_DVLOG(1) << this << " close(" << code << ", " << reason << ")"; 249 NETWORK_DVLOG(1) << this << " close(" << code << ", " << reason << ")";
250 ASSERT(m_handle); 250 DCHECK(m_handle);
251 unsigned short codeToSend = static_cast<unsigned short>(code == CloseEventCo deNotSpecified ? CloseEventCodeNoStatusRcvd : code); 251 unsigned short codeToSend = static_cast<unsigned short>(code == CloseEventCo deNotSpecified ? CloseEventCodeNoStatusRcvd : code);
252 m_messages.append(new Message(codeToSend, reason)); 252 m_messages.append(new Message(codeToSend, reason));
253 processSendQueue(); 253 processSendQueue();
254 } 254 }
255 255
256 void DocumentWebSocketChannel::fail(const String& reason, MessageLevel level, st d::unique_ptr<SourceLocation> location) 256 void DocumentWebSocketChannel::fail(const String& reason, MessageLevel level, st d::unique_ptr<SourceLocation> location)
257 { 257 {
258 NETWORK_DVLOG(1) << this << " fail(" << reason << ")"; 258 NETWORK_DVLOG(1) << this << " fail(" << reason << ")";
259 // m_handle and m_client can be null here. 259 // m_handle and m_client can be null here.
260 260
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 , blobDataHandle(blobDataHandle) { } 292 , blobDataHandle(blobDataHandle) { }
293 293
294 DocumentWebSocketChannel::Message::Message(DOMArrayBuffer* arrayBuffer) 294 DocumentWebSocketChannel::Message::Message(DOMArrayBuffer* arrayBuffer)
295 : type(MessageTypeArrayBuffer) 295 : type(MessageTypeArrayBuffer)
296 , arrayBuffer(arrayBuffer) { } 296 , arrayBuffer(arrayBuffer) { }
297 297
298 DocumentWebSocketChannel::Message::Message(std::unique_ptr<Vector<char>> vectorD ata, MessageType type) 298 DocumentWebSocketChannel::Message::Message(std::unique_ptr<Vector<char>> vectorD ata, MessageType type)
299 : type(type) 299 : type(type)
300 , vectorData(std::move(vectorData)) 300 , vectorData(std::move(vectorData))
301 { 301 {
302 ASSERT(type == MessageTypeTextAsCharVector || type == MessageTypeBinaryAsCha rVector); 302 DCHECK(type == MessageTypeTextAsCharVector || type == MessageTypeBinaryAsCha rVector);
303 } 303 }
304 304
305 DocumentWebSocketChannel::Message::Message(unsigned short code, const String& re ason) 305 DocumentWebSocketChannel::Message::Message(unsigned short code, const String& re ason)
306 : type(MessageTypeClose) 306 : type(MessageTypeClose)
307 , code(code) 307 , code(code)
308 , reason(reason) { } 308 , reason(reason) { }
309 309
310 void DocumentWebSocketChannel::sendInternal(WebSocketHandle::MessageType message Type, const char* data, size_t totalSize, uint64_t* consumedBufferedAmount) 310 void DocumentWebSocketChannel::sendInternal(WebSocketHandle::MessageType message Type, const char* data, size_t totalSize, uint64_t* consumedBufferedAmount)
311 { 311 {
312 WebSocketHandle::MessageType frameType = 312 WebSocketHandle::MessageType frameType =
313 m_sentSizeOfTopMessage ? WebSocketHandle::MessageTypeContinuation : mess ageType; 313 m_sentSizeOfTopMessage ? WebSocketHandle::MessageTypeContinuation : mess ageType;
314 ASSERT(totalSize >= m_sentSizeOfTopMessage); 314 DCHECK_GE(totalSize, m_sentSizeOfTopMessage);
315 // The first cast is safe since the result of min() never exceeds 315 // The first cast is safe since the result of min() never exceeds
316 // the range of size_t. The second cast is necessary to compile 316 // the range of size_t. The second cast is necessary to compile
317 // min() on ILP32. 317 // min() on ILP32.
318 size_t size = static_cast<size_t>(std::min(m_sendingQuota, static_cast<uint6 4_t>(totalSize - m_sentSizeOfTopMessage))); 318 size_t size = static_cast<size_t>(std::min(m_sendingQuota, static_cast<uint6 4_t>(totalSize - m_sentSizeOfTopMessage)));
319 bool final = (m_sentSizeOfTopMessage + size == totalSize); 319 bool final = (m_sentSizeOfTopMessage + size == totalSize);
320 320
321 m_handle->send(final, frameType, data + m_sentSizeOfTopMessage, size); 321 m_handle->send(final, frameType, data + m_sentSizeOfTopMessage, size);
322 322
323 m_sentSizeOfTopMessage += size; 323 m_sentSizeOfTopMessage += size;
324 m_sendingQuota -= size; 324 m_sendingQuota -= size;
325 *consumedBufferedAmount += size; 325 *consumedBufferedAmount += size;
326 326
327 if (final) { 327 if (final) {
328 m_messages.removeFirst(); 328 m_messages.removeFirst();
329 m_sentSizeOfTopMessage = 0; 329 m_sentSizeOfTopMessage = 0;
330 } 330 }
331 } 331 }
332 332
333 void DocumentWebSocketChannel::processSendQueue() 333 void DocumentWebSocketChannel::processSendQueue()
334 { 334 {
335 ASSERT(m_handle); 335 DCHECK(m_handle);
336 uint64_t consumedBufferedAmount = 0; 336 uint64_t consumedBufferedAmount = 0;
337 while (!m_messages.isEmpty() && !m_blobLoader) { 337 while (!m_messages.isEmpty() && !m_blobLoader) {
338 Message* message = m_messages.first().get(); 338 Message* message = m_messages.first().get();
339 if (m_sendingQuota == 0 && message->type != MessageTypeClose) 339 if (m_sendingQuota == 0 && message->type != MessageTypeClose)
340 break; 340 break;
341 switch (message->type) { 341 switch (message->type) {
342 case MessageTypeText: 342 case MessageTypeText:
343 sendInternal(WebSocketHandle::MessageTypeText, message->text.data(), message->text.length(), &consumedBufferedAmount); 343 sendInternal(WebSocketHandle::MessageTypeText, message->text.data(), message->text.length(), &consumedBufferedAmount);
344 break; 344 break;
345 case MessageTypeBlob: 345 case MessageTypeBlob:
346 ASSERT(!m_blobLoader); 346 DCHECK(!m_blobLoader);
347 m_blobLoader = new BlobLoader(message->blobDataHandle, this); 347 m_blobLoader = new BlobLoader(message->blobDataHandle, this);
348 break; 348 break;
349 case MessageTypeArrayBuffer: 349 case MessageTypeArrayBuffer:
350 sendInternal(WebSocketHandle::MessageTypeBinary, static_cast<const c har*>(message->arrayBuffer->data()), message->arrayBuffer->byteLength(), &consum edBufferedAmount); 350 sendInternal(WebSocketHandle::MessageTypeBinary, static_cast<const c har*>(message->arrayBuffer->data()), message->arrayBuffer->byteLength(), &consum edBufferedAmount);
351 break; 351 break;
352 case MessageTypeTextAsCharVector: 352 case MessageTypeTextAsCharVector:
353 sendInternal(WebSocketHandle::MessageTypeText, message->vectorData-> data(), message->vectorData->size(), &consumedBufferedAmount); 353 sendInternal(WebSocketHandle::MessageTypeText, message->vectorData-> data(), message->vectorData->size(), &consumedBufferedAmount);
354 break; 354 break;
355 case MessageTypeBinaryAsCharVector: 355 case MessageTypeBinaryAsCharVector:
356 sendInternal(WebSocketHandle::MessageTypeBinary, message->vectorData ->data(), message->vectorData->size(), &consumedBufferedAmount); 356 sendInternal(WebSocketHandle::MessageTypeBinary, message->vectorData ->data(), message->vectorData->size(), &consumedBufferedAmount);
357 break; 357 break;
358 case MessageTypeClose: { 358 case MessageTypeClose: {
359 // No message should be sent from now on. 359 // No message should be sent from now on.
360 ASSERT(m_messages.size() == 1); 360 DCHECK_EQ(m_messages.size(), 1u);
361 ASSERT(m_sentSizeOfTopMessage == 0); 361 DCHECK_EQ(m_sentSizeOfTopMessage, 0u);
362 m_handle->close(message->code, message->reason); 362 m_handle->close(message->code, message->reason);
363 m_messages.removeFirst(); 363 m_messages.removeFirst();
364 break; 364 break;
365 } 365 }
366 } 366 }
367 } 367 }
368 if (m_client && consumedBufferedAmount > 0) 368 if (m_client && consumedBufferedAmount > 0)
369 m_client->didConsumeBufferedAmount(consumedBufferedAmount); 369 m_client->didConsumeBufferedAmount(consumedBufferedAmount);
370 } 370 }
371 371
(...skipping 26 matching lines...) Expand all
398 WebSocketChannelClient::ClosingHandshakeCompletionStatus status = 398 WebSocketChannelClient::ClosingHandshakeCompletionStatus status =
399 wasClean ? WebSocketChannelClient::ClosingHandshakeComplete : WebSocketC hannelClient::ClosingHandshakeIncomplete; 399 wasClean ? WebSocketChannelClient::ClosingHandshakeComplete : WebSocketC hannelClient::ClosingHandshakeIncomplete;
400 client->didClose(status, code, reason); 400 client->didClose(status, code, reason);
401 // client->didClose may delete this object. 401 // client->didClose may delete this object.
402 } 402 }
403 403
404 Document* DocumentWebSocketChannel::document() 404 Document* DocumentWebSocketChannel::document()
405 { 405 {
406 // This context is always a Document. See the constructor. 406 // This context is always a Document. See the constructor.
407 ExecutionContext* context = getExecutionContext(); 407 ExecutionContext* context = getExecutionContext();
408 ASSERT(context->isDocument()); 408 DCHECK(context->isDocument());
409 return toDocument(context); 409 return toDocument(context);
410 } 410 }
411 411
412 void DocumentWebSocketChannel::didConnect(WebSocketHandle* handle, const String& selectedProtocol, const String& extensions) 412 void DocumentWebSocketChannel::didConnect(WebSocketHandle* handle, const String& selectedProtocol, const String& extensions)
413 { 413 {
414 NETWORK_DVLOG(1) << this << " didConnect(" << handle << ", " << String(selec tedProtocol) << ", " << String(extensions) << ")"; 414 NETWORK_DVLOG(1) << this << " didConnect(" << handle << ", " << String(selec tedProtocol) << ", " << String(extensions) << ")";
415 415
416 ASSERT(m_handle); 416 DCHECK(m_handle);
417 ASSERT(handle == m_handle.get()); 417 DCHECK_EQ(handle, m_handle.get());
418 ASSERT(m_client); 418 DCHECK(m_client);
419 419
420 m_client->didConnect(selectedProtocol, extensions); 420 m_client->didConnect(selectedProtocol, extensions);
421 } 421 }
422 422
423 void DocumentWebSocketChannel::didStartOpeningHandshake(WebSocketHandle* handle, PassRefPtr<WebSocketHandshakeRequest> request) 423 void DocumentWebSocketChannel::didStartOpeningHandshake(WebSocketHandle* handle, PassRefPtr<WebSocketHandshakeRequest> request)
424 { 424 {
425 NETWORK_DVLOG(1) << this << " didStartOpeningHandshake(" << handle << ")"; 425 NETWORK_DVLOG(1) << this << " didStartOpeningHandshake(" << handle << ")";
426 426
427 ASSERT(m_handle); 427 DCHECK(m_handle);
428 ASSERT(handle == m_handle.get()); 428 DCHECK_EQ(handle, m_handle.get());
429 429
430 TRACE_EVENT_INSTANT1("devtools.timeline", "WebSocketSendHandshakeRequest", T RACE_EVENT_SCOPE_THREAD, "data", InspectorWebSocketEvent::data(document(), m_ide ntifier)); 430 TRACE_EVENT_INSTANT1("devtools.timeline", "WebSocketSendHandshakeRequest", T RACE_EVENT_SCOPE_THREAD, "data", InspectorWebSocketEvent::data(document(), m_ide ntifier));
431 InspectorInstrumentation::willSendWebSocketHandshakeRequest(document(), m_id entifier, request.get()); 431 InspectorInstrumentation::willSendWebSocketHandshakeRequest(document(), m_id entifier, request.get());
432 m_handshakeRequest = request; 432 m_handshakeRequest = request;
433 } 433 }
434 434
435 void DocumentWebSocketChannel::didFinishOpeningHandshake(WebSocketHandle* handle , const WebSocketHandshakeResponse* response) 435 void DocumentWebSocketChannel::didFinishOpeningHandshake(WebSocketHandle* handle , const WebSocketHandshakeResponse* response)
436 { 436 {
437 NETWORK_DVLOG(1) << this << " didFinishOpeningHandshake(" << handle << ")"; 437 NETWORK_DVLOG(1) << this << " didFinishOpeningHandshake(" << handle << ")";
438 438
439 ASSERT(m_handle); 439 DCHECK(m_handle);
440 ASSERT(handle == m_handle.get()); 440 DCHECK_EQ(handle, m_handle.get());
441 441
442 TRACE_EVENT_INSTANT1("devtools.timeline", "WebSocketReceiveHandshakeResponse ", TRACE_EVENT_SCOPE_THREAD, "data", InspectorWebSocketEvent::data(document(), m _identifier)); 442 TRACE_EVENT_INSTANT1("devtools.timeline", "WebSocketReceiveHandshakeResponse ", TRACE_EVENT_SCOPE_THREAD, "data", InspectorWebSocketEvent::data(document(), m _identifier));
443 InspectorInstrumentation::didReceiveWebSocketHandshakeResponse(document(), m _identifier, m_handshakeRequest.get(), response); 443 InspectorInstrumentation::didReceiveWebSocketHandshakeResponse(document(), m _identifier, m_handshakeRequest.get(), response);
444 m_handshakeRequest.clear(); 444 m_handshakeRequest.clear();
445 } 445 }
446 446
447 void DocumentWebSocketChannel::didFail(WebSocketHandle* handle, const String& me ssage) 447 void DocumentWebSocketChannel::didFail(WebSocketHandle* handle, const String& me ssage)
448 { 448 {
449 NETWORK_DVLOG(1) << this << " didFail(" << handle << ", " << String(message) << ")"; 449 NETWORK_DVLOG(1) << this << " didFail(" << handle << ", " << String(message) << ")";
450 450
451 ASSERT(m_handle); 451 DCHECK(m_handle);
452 ASSERT(handle == m_handle.get()); 452 DCHECK_EQ(handle, m_handle.get());
453 453
454 // This function is called when the browser is required to fail the 454 // This function is called when the browser is required to fail the
455 // WebSocketConnection. Hence we fail this channel by calling 455 // WebSocketConnection. Hence we fail this channel by calling
456 // |this->failAsError| function. 456 // |this->failAsError| function.
457 failAsError(message); 457 failAsError(message);
458 // |this| may be deleted. 458 // |this| may be deleted.
459 } 459 }
460 460
461 void DocumentWebSocketChannel::didReceiveData(WebSocketHandle* handle, bool fin, WebSocketHandle::MessageType type, const char* data, size_t size) 461 void DocumentWebSocketChannel::didReceiveData(WebSocketHandle* handle, bool fin, WebSocketHandle::MessageType type, const char* data, size_t size)
462 { 462 {
463 NETWORK_DVLOG(1) << this << " didReceiveData(" << handle << ", " << fin << " , " << type << ", (" << static_cast<const void*>(data) << ", " << size << "))"; 463 NETWORK_DVLOG(1) << this << " didReceiveData(" << handle << ", " << fin << " , " << type << ", (" << static_cast<const void*>(data) << ", " << size << "))";
464 464
465 ASSERT(m_handle); 465 DCHECK(m_handle);
466 ASSERT(handle == m_handle.get()); 466 DCHECK_EQ(handle, m_handle.get());
467 ASSERT(m_client); 467 DCHECK(m_client);
468 // Non-final frames cannot be empty. 468 // Non-final frames cannot be empty.
469 ASSERT(fin || size); 469 DCHECK(fin || size);
470 470
471 switch (type) { 471 switch (type) {
472 case WebSocketHandle::MessageTypeText: 472 case WebSocketHandle::MessageTypeText:
473 ASSERT(m_receivingMessageData.isEmpty()); 473 DCHECK(m_receivingMessageData.isEmpty());
474 m_receivingMessageTypeIsText = true; 474 m_receivingMessageTypeIsText = true;
475 break; 475 break;
476 case WebSocketHandle::MessageTypeBinary: 476 case WebSocketHandle::MessageTypeBinary:
477 ASSERT(m_receivingMessageData.isEmpty()); 477 DCHECK(m_receivingMessageData.isEmpty());
478 m_receivingMessageTypeIsText = false; 478 m_receivingMessageTypeIsText = false;
479 break; 479 break;
480 case WebSocketHandle::MessageTypeContinuation: 480 case WebSocketHandle::MessageTypeContinuation:
481 ASSERT(!m_receivingMessageData.isEmpty()); 481 DCHECK(!m_receivingMessageData.isEmpty());
482 break; 482 break;
483 } 483 }
484 484
485 m_receivingMessageData.append(data, size); 485 m_receivingMessageData.append(data, size);
486 m_receivedDataSizeForFlowControl += size; 486 m_receivedDataSizeForFlowControl += size;
487 flowControlIfNecessary(); 487 flowControlIfNecessary();
488 if (!fin) { 488 if (!fin) {
489 return; 489 return;
490 } 490 }
491 // FIXME: Change the inspector API to show the entire message instead 491 // FIXME: Change the inspector API to show the entire message instead
(...skipping 14 matching lines...) Expand all
506 std::unique_ptr<Vector<char>> binaryData = wrapUnique(new Vector<char>); 506 std::unique_ptr<Vector<char>> binaryData = wrapUnique(new Vector<char>);
507 binaryData->swap(m_receivingMessageData); 507 binaryData->swap(m_receivingMessageData);
508 m_client->didReceiveBinaryMessage(std::move(binaryData)); 508 m_client->didReceiveBinaryMessage(std::move(binaryData));
509 } 509 }
510 } 510 }
511 511
512 void DocumentWebSocketChannel::didClose(WebSocketHandle* handle, bool wasClean, unsigned short code, const String& reason) 512 void DocumentWebSocketChannel::didClose(WebSocketHandle* handle, bool wasClean, unsigned short code, const String& reason)
513 { 513 {
514 NETWORK_DVLOG(1) << this << " didClose(" << handle << ", " << wasClean << ", " << code << ", " << String(reason) << ")"; 514 NETWORK_DVLOG(1) << this << " didClose(" << handle << ", " << wasClean << ", " << code << ", " << String(reason) << ")";
515 515
516 ASSERT(m_handle); 516 DCHECK(m_handle);
517 ASSERT(handle == m_handle.get()); 517 DCHECK_EQ(handle, m_handle.get());
518 518
519 m_handle.reset(); 519 m_handle.reset();
520 520
521 if (m_identifier) { 521 if (m_identifier) {
522 TRACE_EVENT_INSTANT1("devtools.timeline", "WebSocketDestroy", TRACE_EVEN T_SCOPE_THREAD, "data", InspectorWebSocketEvent::data(document(), m_identifier)) ; 522 TRACE_EVENT_INSTANT1("devtools.timeline", "WebSocketDestroy", TRACE_EVEN T_SCOPE_THREAD, "data", InspectorWebSocketEvent::data(document(), m_identifier)) ;
523 InspectorInstrumentation::didCloseWebSocket(document(), m_identifier); 523 InspectorInstrumentation::didCloseWebSocket(document(), m_identifier);
524 m_identifier = 0; 524 m_identifier = 0;
525 } 525 }
526 526
527 handleDidClose(wasClean, code, reason); 527 handleDidClose(wasClean, code, reason);
528 // handleDidClose may delete this object. 528 // handleDidClose may delete this object.
529 } 529 }
530 530
531 void DocumentWebSocketChannel::didReceiveFlowControl(WebSocketHandle* handle, in t64_t quota) 531 void DocumentWebSocketChannel::didReceiveFlowControl(WebSocketHandle* handle, in t64_t quota)
532 { 532 {
533 NETWORK_DVLOG(1) << this << " didReceiveFlowControl(" << handle << ", " << q uota << ")"; 533 NETWORK_DVLOG(1) << this << " didReceiveFlowControl(" << handle << ", " << q uota << ")";
534 534
535 ASSERT(m_handle); 535 DCHECK(m_handle);
536 ASSERT(handle == m_handle.get()); 536 DCHECK_EQ(handle, m_handle.get());
537 ASSERT(quota >= 0); 537 DCHECK_GE(quota, 0);
538 538
539 m_sendingQuota += quota; 539 m_sendingQuota += quota;
540 processSendQueue(); 540 processSendQueue();
541 } 541 }
542 542
543 void DocumentWebSocketChannel::didStartClosingHandshake(WebSocketHandle* handle) 543 void DocumentWebSocketChannel::didStartClosingHandshake(WebSocketHandle* handle)
544 { 544 {
545 NETWORK_DVLOG(1) << this << " didStartClosingHandshake(" << handle << ")"; 545 NETWORK_DVLOG(1) << this << " didStartClosingHandshake(" << handle << ")";
546 546
547 ASSERT(m_handle); 547 DCHECK(m_handle);
548 ASSERT(handle == m_handle.get()); 548 DCHECK_EQ(handle, m_handle.get());
549 549
550 if (m_client) 550 if (m_client)
551 m_client->didStartClosingHandshake(); 551 m_client->didStartClosingHandshake();
552 } 552 }
553 553
554 void DocumentWebSocketChannel::didFinishLoadingBlob(DOMArrayBuffer* buffer) 554 void DocumentWebSocketChannel::didFinishLoadingBlob(DOMArrayBuffer* buffer)
555 { 555 {
556 m_blobLoader.clear(); 556 m_blobLoader.clear();
557 ASSERT(m_handle); 557 DCHECK(m_handle);
558 // The loaded blob is always placed on m_messages[0]. 558 // The loaded blob is always placed on m_messages[0].
559 ASSERT(m_messages.size() > 0 && m_messages.first()->type == MessageTypeBlob) ; 559 DCHECK_GT(m_messages.size(), 0u);
560 DCHECK_EQ(m_messages.first()->type, MessageTypeBlob);
560 // We replace it with the loaded blob. 561 // We replace it with the loaded blob.
561 m_messages.first() = new Message(buffer); 562 m_messages.first() = new Message(buffer);
562 processSendQueue(); 563 processSendQueue();
563 } 564 }
564 565
565 void DocumentWebSocketChannel::didFailLoadingBlob(FileError::ErrorCode errorCode ) 566 void DocumentWebSocketChannel::didFailLoadingBlob(FileError::ErrorCode errorCode )
566 { 567 {
567 m_blobLoader.clear(); 568 m_blobLoader.clear();
568 if (errorCode == FileError::kAbortErr) { 569 if (errorCode == FileError::kAbortErr) {
569 // The error is caused by cancel(). 570 // The error is caused by cancel().
(...skipping 12 matching lines...) Expand all
582 WebSocketChannel::trace(visitor); 583 WebSocketChannel::trace(visitor);
583 ContextLifecycleObserver::trace(visitor); 584 ContextLifecycleObserver::trace(visitor);
584 } 585 }
585 586
586 std::ostream& operator<<(std::ostream& ostream, const DocumentWebSocketChannel* channel) 587 std::ostream& operator<<(std::ostream& ostream, const DocumentWebSocketChannel* channel)
587 { 588 {
588 return ostream << "DocumentWebSocketChannel " << static_cast<const void*>(ch annel); 589 return ostream << "DocumentWebSocketChannel " << static_cast<const void*>(ch annel);
589 } 590 }
590 591
591 } // namespace blink 592 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698