OLD | NEW |
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 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
290 ASSERT(m_handle); | 290 ASSERT(m_handle); |
291 unsigned long bufferedAmount = m_bufferedAmount; | 291 unsigned long bufferedAmount = m_bufferedAmount; |
292 while (!m_messages.isEmpty() && m_sendingQuota > 0 && !m_blobLoader) { | 292 while (!m_messages.isEmpty() && m_sendingQuota > 0 && !m_blobLoader) { |
293 bool final = false; | 293 bool final = false; |
294 const Message& message = m_messages.first(); | 294 const Message& message = m_messages.first(); |
295 switch (message.type) { | 295 switch (message.type) { |
296 case MessageTypeText: { | 296 case MessageTypeText: { |
297 WebSocketHandle::MessageType type = | 297 WebSocketHandle::MessageType type = |
298 m_sentSizeOfTopMessage ? WebSocketHandle::MessageTypeContinuatio
n : WebSocketHandle::MessageTypeText; | 298 m_sentSizeOfTopMessage ? WebSocketHandle::MessageTypeContinuatio
n : WebSocketHandle::MessageTypeText; |
299 size_t size = std::min(static_cast<size_t>(m_sendingQuota), message.
text.length() - m_sentSizeOfTopMessage); | 299 size_t size = std::min(static_cast<size_t>(m_sendingQuota), message.
text.length() - m_sentSizeOfTopMessage); |
300 final = (m_sendingQuota == size); | 300 final = (static_cast<size_t>(m_sendingQuota) == size); |
301 m_handle->send(final, type, message.text.data() + m_sentSizeOfTopMes
sage, size); | 301 m_handle->send(final, type, message.text.data() + m_sentSizeOfTopMes
sage, size); |
302 m_sentSizeOfTopMessage += size; | 302 m_sentSizeOfTopMessage += size; |
303 m_sendingQuota -= size; | 303 m_sendingQuota -= size; |
304 break; | 304 break; |
305 } | 305 } |
306 case MessageTypeBlob: | 306 case MessageTypeBlob: |
307 ASSERT(!m_blobLoader); | 307 ASSERT(!m_blobLoader); |
308 m_blobLoader = adoptPtr(new BlobLoader(message.blobDataHandle, this)
); | 308 m_blobLoader = adoptPtr(new BlobLoader(message.blobDataHandle, this)
); |
309 break; | 309 break; |
310 case MessageTypeArrayBuffer: { | 310 case MessageTypeArrayBuffer: { |
311 WebSocketHandle::MessageType type = | 311 WebSocketHandle::MessageType type = |
312 m_sentSizeOfTopMessage ? WebSocketHandle::MessageTypeContinuatio
n : WebSocketHandle::MessageTypeBinary; | 312 m_sentSizeOfTopMessage ? WebSocketHandle::MessageTypeContinuatio
n : WebSocketHandle::MessageTypeBinary; |
313 size_t size = std::min(static_cast<size_t>(m_sendingQuota), message.
arrayBuffer->byteLength() - m_sentSizeOfTopMessage); | 313 size_t size = std::min(static_cast<size_t>(m_sendingQuota), message.
arrayBuffer->byteLength() - m_sentSizeOfTopMessage); |
314 final = (m_sendingQuota == size); | 314 final = (static_cast<size_t>(m_sendingQuota) == size); |
315 m_handle->send(final, type, static_cast<const char*>(message.arrayBu
ffer->data()) + m_sentSizeOfTopMessage, size); | 315 m_handle->send(final, type, static_cast<const char*>(message.arrayBu
ffer->data()) + m_sentSizeOfTopMessage, size); |
316 m_sentSizeOfTopMessage += size; | 316 m_sentSizeOfTopMessage += size; |
317 m_sendingQuota -= size; | 317 m_sendingQuota -= size; |
318 break; | 318 break; |
319 } | 319 } |
320 } | 320 } |
321 if (final) { | 321 if (final) { |
322 m_messages.removeFirst(); | 322 m_messages.removeFirst(); |
323 m_sentSizeOfTopMessage = 0; | 323 m_sentSizeOfTopMessage = 0; |
324 } | 324 } |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
471 if (errorCode == FileError::ABORT_ERR) { | 471 if (errorCode == FileError::ABORT_ERR) { |
472 // The error is caused by cancel(). | 472 // The error is caused by cancel(). |
473 return; | 473 return; |
474 } | 474 } |
475 // FIXME: Generate human-friendly reason message. | 475 // FIXME: Generate human-friendly reason message. |
476 failAsError("Failed to load Blob: error code = " + String::number(errorCode)
); | 476 failAsError("Failed to load Blob: error code = " + String::number(errorCode)
); |
477 // |this| can be deleted here. | 477 // |this| can be deleted here. |
478 } | 478 } |
479 | 479 |
480 } // namespace WebCore | 480 } // namespace WebCore |
OLD | NEW |