| 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 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 // of individual frames. | 208 // of individual frames. |
| 209 InspectorInstrumentation::didSendWebSocketFrame(document(), m_identifier
, WebSocketFrame::OpCodeBinary, true, static_cast<const char*>(buffer.data()) +
byteOffset, byteLength); | 209 InspectorInstrumentation::didSendWebSocketFrame(document(), m_identifier
, WebSocketFrame::OpCodeBinary, true, static_cast<const char*>(buffer.data()) +
byteOffset, byteLength); |
| 210 } | 210 } |
| 211 // buffer.slice copies its contents. | 211 // buffer.slice copies its contents. |
| 212 // FIXME: Reduce copy by sending the data immediately when we don't need to | 212 // FIXME: Reduce copy by sending the data immediately when we don't need to |
| 213 // queue the data. | 213 // queue the data. |
| 214 m_messages.append(adoptPtr(new Message(buffer.slice(byteOffset, byteOffset +
byteLength)))); | 214 m_messages.append(adoptPtr(new Message(buffer.slice(byteOffset, byteOffset +
byteLength)))); |
| 215 sendInternal(); | 215 sendInternal(); |
| 216 } | 216 } |
| 217 | 217 |
| 218 void DocumentWebSocketChannel::send(PassOwnPtr<Vector<char> > data) | 218 void DocumentWebSocketChannel::send(PassOwnPtr<Vector<char>> data) |
| 219 { | 219 { |
| 220 WTF_LOG(Network, "DocumentWebSocketChannel %p sendVector(%p, %llu)", this, d
ata.get(), static_cast<unsigned long long>(data->size())); | 220 WTF_LOG(Network, "DocumentWebSocketChannel %p sendVector(%p, %llu)", this, d
ata.get(), static_cast<unsigned long long>(data->size())); |
| 221 if (m_identifier) { | 221 if (m_identifier) { |
| 222 // FIXME: Change the inspector API to show the entire message instead | 222 // FIXME: Change the inspector API to show the entire message instead |
| 223 // of individual frames. | 223 // of individual frames. |
| 224 InspectorInstrumentation::didSendWebSocketFrame(document(), m_identifier
, WebSocketFrame::OpCodeBinary, true, data->data(), data->size()); | 224 InspectorInstrumentation::didSendWebSocketFrame(document(), m_identifier
, WebSocketFrame::OpCodeBinary, true, data->data(), data->size()); |
| 225 } | 225 } |
| 226 m_messages.append(adoptPtr(new Message(data))); | 226 m_messages.append(adoptPtr(new Message(data))); |
| 227 sendInternal(); | 227 sendInternal(); |
| 228 } | 228 } |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 273 , text(text.utf8(StrictUTF8ConversionReplacingUnpairedSurrogatesWithFFFD)) {
} | 273 , text(text.utf8(StrictUTF8ConversionReplacingUnpairedSurrogatesWithFFFD)) {
} |
| 274 | 274 |
| 275 DocumentWebSocketChannel::Message::Message(PassRefPtr<BlobDataHandle> blobDataHa
ndle) | 275 DocumentWebSocketChannel::Message::Message(PassRefPtr<BlobDataHandle> blobDataHa
ndle) |
| 276 : type(MessageTypeBlob) | 276 : type(MessageTypeBlob) |
| 277 , blobDataHandle(blobDataHandle) { } | 277 , blobDataHandle(blobDataHandle) { } |
| 278 | 278 |
| 279 DocumentWebSocketChannel::Message::Message(PassRefPtr<DOMArrayBuffer> arrayBuffe
r) | 279 DocumentWebSocketChannel::Message::Message(PassRefPtr<DOMArrayBuffer> arrayBuffe
r) |
| 280 : type(MessageTypeArrayBuffer) | 280 : type(MessageTypeArrayBuffer) |
| 281 , arrayBuffer(arrayBuffer) { } | 281 , arrayBuffer(arrayBuffer) { } |
| 282 | 282 |
| 283 DocumentWebSocketChannel::Message::Message(PassOwnPtr<Vector<char> > vectorData) | 283 DocumentWebSocketChannel::Message::Message(PassOwnPtr<Vector<char>> vectorData) |
| 284 : type(MessageTypeVector) | 284 : type(MessageTypeVector) |
| 285 , vectorData(vectorData) { } | 285 , vectorData(vectorData) { } |
| 286 | 286 |
| 287 DocumentWebSocketChannel::Message::Message(unsigned short code, const String& re
ason) | 287 DocumentWebSocketChannel::Message::Message(unsigned short code, const String& re
ason) |
| 288 : type(MessageTypeClose) | 288 : type(MessageTypeClose) |
| 289 , code(code) | 289 , code(code) |
| 290 , reason(reason) { } | 290 , reason(reason) { } |
| 291 | 291 |
| 292 void DocumentWebSocketChannel::sendInternal() | 292 void DocumentWebSocketChannel::sendInternal() |
| 293 { | 293 { |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 508 if (m_receivingMessageTypeIsText) { | 508 if (m_receivingMessageTypeIsText) { |
| 509 String message = m_receivingMessageData.isEmpty() ? emptyString() : Stri
ng::fromUTF8(m_receivingMessageData.data(), m_receivingMessageData.size()); | 509 String message = m_receivingMessageData.isEmpty() ? emptyString() : Stri
ng::fromUTF8(m_receivingMessageData.data(), m_receivingMessageData.size()); |
| 510 m_receivingMessageData.clear(); | 510 m_receivingMessageData.clear(); |
| 511 if (message.isNull()) { | 511 if (message.isNull()) { |
| 512 failAsError("Could not decode a text frame as UTF-8."); | 512 failAsError("Could not decode a text frame as UTF-8."); |
| 513 // failAsError may delete this object. | 513 // failAsError may delete this object. |
| 514 } else { | 514 } else { |
| 515 m_client->didReceiveTextMessage(message); | 515 m_client->didReceiveTextMessage(message); |
| 516 } | 516 } |
| 517 } else { | 517 } else { |
| 518 OwnPtr<Vector<char> > binaryData = adoptPtr(new Vector<char>); | 518 OwnPtr<Vector<char>> binaryData = adoptPtr(new Vector<char>); |
| 519 binaryData->swap(m_receivingMessageData); | 519 binaryData->swap(m_receivingMessageData); |
| 520 m_client->didReceiveBinaryMessage(binaryData.release()); | 520 m_client->didReceiveBinaryMessage(binaryData.release()); |
| 521 } | 521 } |
| 522 } | 522 } |
| 523 | 523 |
| 524 void DocumentWebSocketChannel::didClose(WebSocketHandle* handle, bool wasClean,
unsigned short code, const WebString& reason) | 524 void DocumentWebSocketChannel::didClose(WebSocketHandle* handle, bool wasClean,
unsigned short code, const WebString& reason) |
| 525 { | 525 { |
| 526 WTF_LOG(Network, "DocumentWebSocketChannel %p didClose(%p, %d, %u, %s)", thi
s, handle, wasClean, code, String(reason).utf8().data()); | 526 WTF_LOG(Network, "DocumentWebSocketChannel %p didClose(%p, %d, %u, %s)", thi
s, handle, wasClean, code, String(reason).utf8().data()); |
| 527 | 527 |
| 528 ASSERT(m_handle); | 528 ASSERT(m_handle); |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 589 | 589 |
| 590 void DocumentWebSocketChannel::trace(Visitor* visitor) | 590 void DocumentWebSocketChannel::trace(Visitor* visitor) |
| 591 { | 591 { |
| 592 visitor->trace(m_blobLoader); | 592 visitor->trace(m_blobLoader); |
| 593 visitor->trace(m_client); | 593 visitor->trace(m_client); |
| 594 WebSocketChannel::trace(visitor); | 594 WebSocketChannel::trace(visitor); |
| 595 ContextLifecycleObserver::trace(visitor); | 595 ContextLifecycleObserver::trace(visitor); |
| 596 } | 596 } |
| 597 | 597 |
| 598 } // namespace blink | 598 } // namespace blink |
| OLD | NEW |