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 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 m_state = Stopped; | 118 m_state = Stopped; |
119 m_resumeTimer.stop(); | 119 m_resumeTimer.stop(); |
120 m_events.clear(); | 120 m_events.clear(); |
121 } | 121 } |
122 | 122 |
123 void DOMWebSocket::EventQueue::dispatchQueuedEvents() | 123 void DOMWebSocket::EventQueue::dispatchQueuedEvents() |
124 { | 124 { |
125 if (m_state != Active) | 125 if (m_state != Active) |
126 return; | 126 return; |
127 | 127 |
128 WillBeHeapDeque<RefPtrWillBeMember<Event> > events; | 128 WillBeHeapDeque<RefPtrWillBeMember<Event>> events; |
129 events.swap(m_events); | 129 events.swap(m_events); |
130 while (!events.isEmpty()) { | 130 while (!events.isEmpty()) { |
131 if (m_state == Stopped || m_state == Suspended) | 131 if (m_state == Stopped || m_state == Suspended) |
132 break; | 132 break; |
133 ASSERT(m_state == Active); | 133 ASSERT(m_state == Active); |
134 ASSERT(m_target->executionContext()); | 134 ASSERT(m_target->executionContext()); |
135 m_target->dispatchEvent(events.takeFirst()); | 135 m_target->dispatchEvent(events.takeFirst()); |
136 // |this| can be stopped here. | 136 // |this| can be stopped here. |
137 } | 137 } |
138 if (m_state == Suspended) { | 138 if (m_state == Suspended) { |
(...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
587 } | 587 } |
588 | 588 |
589 void DOMWebSocket::didReceiveTextMessage(const String& msg) | 589 void DOMWebSocket::didReceiveTextMessage(const String& msg) |
590 { | 590 { |
591 WTF_LOG(Network, "WebSocket %p didReceiveTextMessage() Text message '%s'", t
his, msg.utf8().data()); | 591 WTF_LOG(Network, "WebSocket %p didReceiveTextMessage() Text message '%s'", t
his, msg.utf8().data()); |
592 if (m_state != OPEN) | 592 if (m_state != OPEN) |
593 return; | 593 return; |
594 m_eventQueue->dispatch(MessageEvent::create(msg, SecurityOrigin::create(m_ur
l)->toString())); | 594 m_eventQueue->dispatch(MessageEvent::create(msg, SecurityOrigin::create(m_ur
l)->toString())); |
595 } | 595 } |
596 | 596 |
597 void DOMWebSocket::didReceiveBinaryMessage(PassOwnPtr<Vector<char> > binaryData) | 597 void DOMWebSocket::didReceiveBinaryMessage(PassOwnPtr<Vector<char>> binaryData) |
598 { | 598 { |
599 WTF_LOG(Network, "WebSocket %p didReceiveBinaryMessage() %lu byte binary mes
sage", this, static_cast<unsigned long>(binaryData->size())); | 599 WTF_LOG(Network, "WebSocket %p didReceiveBinaryMessage() %lu byte binary mes
sage", this, static_cast<unsigned long>(binaryData->size())); |
600 switch (m_binaryType) { | 600 switch (m_binaryType) { |
601 case BinaryTypeBlob: { | 601 case BinaryTypeBlob: { |
602 size_t size = binaryData->size(); | 602 size_t size = binaryData->size(); |
603 RefPtr<RawData> rawData = RawData::create(); | 603 RefPtr<RawData> rawData = RawData::create(); |
604 binaryData->swap(*rawData->mutableData()); | 604 binaryData->swap(*rawData->mutableData()); |
605 OwnPtr<BlobData> blobData = BlobData::create(); | 605 OwnPtr<BlobData> blobData = BlobData::create(); |
606 blobData->appendData(rawData.release(), 0, BlobDataItem::toEndOfFile); | 606 blobData->appendData(rawData.release(), 0, BlobDataItem::toEndOfFile); |
607 Blob* blob = Blob::create(BlobDataHandle::create(blobData.release(), siz
e)); | 607 Blob* blob = Blob::create(BlobDataHandle::create(blobData.release(), siz
e)); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
658 void DOMWebSocket::trace(Visitor* visitor) | 658 void DOMWebSocket::trace(Visitor* visitor) |
659 { | 659 { |
660 visitor->trace(m_channel); | 660 visitor->trace(m_channel); |
661 visitor->trace(m_eventQueue); | 661 visitor->trace(m_eventQueue); |
662 WebSocketChannelClient::trace(visitor); | 662 WebSocketChannelClient::trace(visitor); |
663 RefCountedGarbageCollectedEventTargetWithInlineData<DOMWebSocket>::trace(vis
itor); | 663 RefCountedGarbageCollectedEventTargetWithInlineData<DOMWebSocket>::trace(vis
itor); |
664 ActiveDOMObject::trace(visitor); | 664 ActiveDOMObject::trace(visitor); |
665 } | 665 } |
666 | 666 |
667 } // namespace blink | 667 } // namespace blink |
OLD | NEW |