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

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

Issue 46143003: NewWebSocketChannel sends a message endlessly (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 years, 1 month 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 ASSERT(m_handle); 295 ASSERT(m_handle);
296 unsigned long bufferedAmount = m_bufferedAmount; 296 unsigned long bufferedAmount = m_bufferedAmount;
297 while (!m_messages.isEmpty() && m_sendingQuota > 0 && !m_blobLoader) { 297 while (!m_messages.isEmpty() && m_sendingQuota > 0 && !m_blobLoader) {
298 bool final = false; 298 bool final = false;
299 const Message& message = m_messages.first(); 299 const Message& message = m_messages.first();
300 switch (message.type) { 300 switch (message.type) {
301 case MessageTypeText: { 301 case MessageTypeText: {
302 WebSocketHandle::MessageType type = 302 WebSocketHandle::MessageType type =
303 m_sentSizeOfTopMessage ? WebSocketHandle::MessageTypeContinuatio n : WebSocketHandle::MessageTypeText; 303 m_sentSizeOfTopMessage ? WebSocketHandle::MessageTypeContinuatio n : WebSocketHandle::MessageTypeText;
304 size_t size = std::min(static_cast<size_t>(m_sendingQuota), message. text.length() - m_sentSizeOfTopMessage); 304 size_t size = std::min(static_cast<size_t>(m_sendingQuota), message. text.length() - m_sentSizeOfTopMessage);
305 final = (static_cast<size_t>(m_sendingQuota) == size); 305 final = (m_sentSizeOfTopMessage + size == message.text.length());
306 m_handle->send(final, type, message.text.data() + m_sentSizeOfTopMes sage, size); 306 m_handle->send(final, type, message.text.data() + m_sentSizeOfTopMes sage, size);
307 m_sentSizeOfTopMessage += size; 307 m_sentSizeOfTopMessage += size;
308 m_sendingQuota -= size; 308 m_sendingQuota -= size;
309 break; 309 break;
310 } 310 }
311 case MessageTypeBlob: 311 case MessageTypeBlob:
312 ASSERT(!m_blobLoader); 312 ASSERT(!m_blobLoader);
313 m_blobLoader = adoptPtr(new BlobLoader(message.blobDataHandle, this) ); 313 m_blobLoader = adoptPtr(new BlobLoader(message.blobDataHandle, this) );
314 break; 314 break;
315 case MessageTypeArrayBuffer: { 315 case MessageTypeArrayBuffer: {
316 WebSocketHandle::MessageType type = 316 WebSocketHandle::MessageType type =
317 m_sentSizeOfTopMessage ? WebSocketHandle::MessageTypeContinuatio n : WebSocketHandle::MessageTypeBinary; 317 m_sentSizeOfTopMessage ? WebSocketHandle::MessageTypeContinuatio n : WebSocketHandle::MessageTypeBinary;
318 size_t size = std::min(static_cast<size_t>(m_sendingQuota), message. arrayBuffer->byteLength() - m_sentSizeOfTopMessage); 318 size_t size = std::min(static_cast<size_t>(m_sendingQuota), message. arrayBuffer->byteLength() - m_sentSizeOfTopMessage);
319 final = (static_cast<size_t>(m_sendingQuota) == size); 319 final = (m_sentSizeOfTopMessage + size == message.text.length());
tyoshino (SeeGerritForStatus) 2013/10/31 09:04:32 message.arrayBuffer->byteLength() ?
yhirano 2013/10/31 09:16:12 Thanks, done
320 m_handle->send(final, type, static_cast<const char*>(message.arrayBu ffer->data()) + m_sentSizeOfTopMessage, size); 320 m_handle->send(final, type, static_cast<const char*>(message.arrayBu ffer->data()) + m_sentSizeOfTopMessage, size);
321 m_sentSizeOfTopMessage += size; 321 m_sentSizeOfTopMessage += size;
322 m_sendingQuota -= size; 322 m_sendingQuota -= size;
323 break; 323 break;
324 } 324 }
325 } 325 }
326 if (final) { 326 if (final) {
327 m_messages.removeFirst(); 327 m_messages.removeFirst();
328 m_sentSizeOfTopMessage = 0; 328 m_sentSizeOfTopMessage = 0;
329 } 329 }
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
476 if (errorCode == FileError::ABORT_ERR) { 476 if (errorCode == FileError::ABORT_ERR) {
477 // The error is caused by cancel(). 477 // The error is caused by cancel().
478 return; 478 return;
479 } 479 }
480 // FIXME: Generate human-friendly reason message. 480 // FIXME: Generate human-friendly reason message.
481 failAsError("Failed to load Blob: error code = " + String::number(errorCode) ); 481 failAsError("Failed to load Blob: error code = " + String::number(errorCode) );
482 // |this| can be deleted here. 482 // |this| can be deleted here.
483 } 483 }
484 484
485 } // namespace WebCore 485 } // namespace WebCore
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698