OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 #include "platform/Histogram.h" | 51 #include "platform/Histogram.h" |
52 #include "platform/Logging.h" | 52 #include "platform/Logging.h" |
53 #include "platform/blob/BlobData.h" | 53 #include "platform/blob/BlobData.h" |
54 #include "platform/heap/Handle.h" | 54 #include "platform/heap/Handle.h" |
55 #include "platform/weborigin/KnownPorts.h" | 55 #include "platform/weborigin/KnownPorts.h" |
56 #include "platform/weborigin/SecurityOrigin.h" | 56 #include "platform/weborigin/SecurityOrigin.h" |
57 #include "public/platform/Platform.h" | 57 #include "public/platform/Platform.h" |
58 #include "public/platform/WebInsecureRequestPolicy.h" | 58 #include "public/platform/WebInsecureRequestPolicy.h" |
59 #include "wtf/Assertions.h" | 59 #include "wtf/Assertions.h" |
60 #include "wtf/HashSet.h" | 60 #include "wtf/HashSet.h" |
| 61 #include "wtf/PassOwnPtr.h" |
61 #include "wtf/StdLibExtras.h" | 62 #include "wtf/StdLibExtras.h" |
62 #include "wtf/text/CString.h" | 63 #include "wtf/text/CString.h" |
63 #include "wtf/text/StringBuilder.h" | 64 #include "wtf/text/StringBuilder.h" |
64 #include "wtf/text/WTFString.h" | 65 #include "wtf/text/WTFString.h" |
65 #include <memory> | |
66 | 66 |
67 namespace blink { | 67 namespace blink { |
68 | 68 |
69 DOMWebSocket::EventQueue::EventQueue(EventTarget* target) | 69 DOMWebSocket::EventQueue::EventQueue(EventTarget* target) |
70 : m_state(Active) | 70 : m_state(Active) |
71 , m_target(target) | 71 , m_target(target) |
72 , m_resumeTimer(this, &EventQueue::resumeTimerFired) { } | 72 , m_resumeTimer(this, &EventQueue::resumeTimerFired) { } |
73 | 73 |
74 DOMWebSocket::EventQueue::~EventQueue() { stop(); } | 74 DOMWebSocket::EventQueue::~EventQueue() { stop(); } |
75 | 75 |
(...skipping 555 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
631 void DOMWebSocket::didReceiveTextMessage(const String& msg) | 631 void DOMWebSocket::didReceiveTextMessage(const String& msg) |
632 { | 632 { |
633 WTF_LOG(Network, "WebSocket %p didReceiveTextMessage() Text message '%s'", t
his, msg.utf8().data()); | 633 WTF_LOG(Network, "WebSocket %p didReceiveTextMessage() Text message '%s'", t
his, msg.utf8().data()); |
634 if (m_state != OPEN) | 634 if (m_state != OPEN) |
635 return; | 635 return; |
636 recordReceiveTypeHistogram(WebSocketReceiveTypeString); | 636 recordReceiveTypeHistogram(WebSocketReceiveTypeString); |
637 | 637 |
638 m_eventQueue->dispatch(MessageEvent::create(msg, SecurityOrigin::create(m_ur
l)->toString())); | 638 m_eventQueue->dispatch(MessageEvent::create(msg, SecurityOrigin::create(m_ur
l)->toString())); |
639 } | 639 } |
640 | 640 |
641 void DOMWebSocket::didReceiveBinaryMessage(std::unique_ptr<Vector<char>> binaryD
ata) | 641 void DOMWebSocket::didReceiveBinaryMessage(PassOwnPtr<Vector<char>> binaryData) |
642 { | 642 { |
643 WTF_LOG(Network, "WebSocket %p didReceiveBinaryMessage() %lu byte binary mes
sage", this, static_cast<unsigned long>(binaryData->size())); | 643 WTF_LOG(Network, "WebSocket %p didReceiveBinaryMessage() %lu byte binary mes
sage", this, static_cast<unsigned long>(binaryData->size())); |
644 switch (m_binaryType) { | 644 switch (m_binaryType) { |
645 case BinaryTypeBlob: { | 645 case BinaryTypeBlob: { |
646 size_t size = binaryData->size(); | 646 size_t size = binaryData->size(); |
647 RefPtr<RawData> rawData = RawData::create(); | 647 RefPtr<RawData> rawData = RawData::create(); |
648 binaryData->swap(*rawData->mutableData()); | 648 binaryData->swap(*rawData->mutableData()); |
649 std::unique_ptr<BlobData> blobData = BlobData::create(); | 649 OwnPtr<BlobData> blobData = BlobData::create(); |
650 blobData->appendData(rawData.release(), 0, BlobDataItem::toEndOfFile); | 650 blobData->appendData(rawData.release(), 0, BlobDataItem::toEndOfFile); |
651 Blob* blob = Blob::create(BlobDataHandle::create(std::move(blobData), si
ze)); | 651 Blob* blob = Blob::create(BlobDataHandle::create(std::move(blobData), si
ze)); |
652 recordReceiveTypeHistogram(WebSocketReceiveTypeBlob); | 652 recordReceiveTypeHistogram(WebSocketReceiveTypeBlob); |
653 m_eventQueue->dispatch(MessageEvent::create(blob, SecurityOrigin::create
(m_url)->toString())); | 653 m_eventQueue->dispatch(MessageEvent::create(blob, SecurityOrigin::create
(m_url)->toString())); |
654 break; | 654 break; |
655 } | 655 } |
656 | 656 |
657 case BinaryTypeArrayBuffer: | 657 case BinaryTypeArrayBuffer: |
658 DOMArrayBuffer* arrayBuffer = DOMArrayBuffer::create(binaryData->data(),
binaryData->size()); | 658 DOMArrayBuffer* arrayBuffer = DOMArrayBuffer::create(binaryData->data(),
binaryData->size()); |
659 recordReceiveTypeHistogram(WebSocketReceiveTypeArrayBuffer); | 659 recordReceiveTypeHistogram(WebSocketReceiveTypeArrayBuffer); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
716 DEFINE_TRACE(DOMWebSocket) | 716 DEFINE_TRACE(DOMWebSocket) |
717 { | 717 { |
718 visitor->trace(m_channel); | 718 visitor->trace(m_channel); |
719 visitor->trace(m_eventQueue); | 719 visitor->trace(m_eventQueue); |
720 WebSocketChannelClient::trace(visitor); | 720 WebSocketChannelClient::trace(visitor); |
721 EventTargetWithInlineData::trace(visitor); | 721 EventTargetWithInlineData::trace(visitor); |
722 ActiveDOMObject::trace(visitor); | 722 ActiveDOMObject::trace(visitor); |
723 } | 723 } |
724 | 724 |
725 } // namespace blink | 725 } // namespace blink |
OLD | NEW |