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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 | 64 |
65 namespace WebCore { | 65 namespace WebCore { |
66 | 66 |
67 WebSocket::EventQueue::EventQueue(EventTarget* target) | 67 WebSocket::EventQueue::EventQueue(EventTarget* target) |
68 : m_state(Active) | 68 : m_state(Active) |
69 , m_target(target) | 69 , m_target(target) |
70 , m_resumeTimer(this, &EventQueue::resumeTimerFired) { } | 70 , m_resumeTimer(this, &EventQueue::resumeTimerFired) { } |
71 | 71 |
72 WebSocket::EventQueue::~EventQueue() { stop(); } | 72 WebSocket::EventQueue::~EventQueue() { stop(); } |
73 | 73 |
74 void WebSocket::EventQueue::dispatch(PassRefPtr<Event> event) | 74 void WebSocket::EventQueue::dispatch(PassRefPtrWillBeRawPtr<Event> event) |
75 { | 75 { |
76 switch (m_state) { | 76 switch (m_state) { |
77 case Active: | 77 case Active: |
78 ASSERT(m_events.isEmpty()); | 78 ASSERT(m_events.isEmpty()); |
79 ASSERT(m_target->executionContext()); | 79 ASSERT(m_target->executionContext()); |
80 m_target->dispatchEvent(event); | 80 m_target->dispatchEvent(event); |
81 break; | 81 break; |
82 case Suspended: | 82 case Suspended: |
83 m_events.append(event); | 83 m_events.append(event); |
84 break; | 84 break; |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 m_events.clear(); | 120 m_events.clear(); |
121 } | 121 } |
122 | 122 |
123 void WebSocket::EventQueue::dispatchQueuedEvents() | 123 void WebSocket::EventQueue::dispatchQueuedEvents() |
124 { | 124 { |
125 if (m_state != Active) | 125 if (m_state != Active) |
126 return; | 126 return; |
127 | 127 |
128 RefPtr<EventQueue> protect(this); | 128 RefPtr<EventQueue> protect(this); |
129 | 129 |
130 Deque<RefPtr<Event> > events; | 130 Deque<RefPtrWillBePersistent<Event> > events; |
131 events.swap(m_events); | 131 events.swap(m_events); |
132 while (!events.isEmpty()) { | 132 while (!events.isEmpty()) { |
133 if (m_state == Stopped || m_state == Suspended) | 133 if (m_state == Stopped || m_state == Suspended) |
134 break; | 134 break; |
135 ASSERT(m_state == Active); | 135 ASSERT(m_state == Active); |
136 ASSERT(m_target->executionContext()); | 136 ASSERT(m_target->executionContext()); |
137 m_target->dispatchEvent(events.takeFirst()); | 137 m_target->dispatchEvent(events.takeFirst()); |
138 // |this| can be stopped here. | 138 // |this| can be stopped here. |
139 } | 139 } |
140 if (m_state == Suspended) { | 140 if (m_state == Suspended) { |
(...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
681 static const size_t minimumPayloadSizeWithEightByteExtendedPayloadLength = 0
x10000; | 681 static const size_t minimumPayloadSizeWithEightByteExtendedPayloadLength = 0
x10000; |
682 size_t overhead = hybiBaseFramingOverhead + hybiMaskingKeyLength; | 682 size_t overhead = hybiBaseFramingOverhead + hybiMaskingKeyLength; |
683 if (payloadSize >= minimumPayloadSizeWithEightByteExtendedPayloadLength) | 683 if (payloadSize >= minimumPayloadSizeWithEightByteExtendedPayloadLength) |
684 overhead += 8; | 684 overhead += 8; |
685 else if (payloadSize >= minimumPayloadSizeWithTwoByteExtendedPayloadLength) | 685 else if (payloadSize >= minimumPayloadSizeWithTwoByteExtendedPayloadLength) |
686 overhead += 2; | 686 overhead += 2; |
687 return overhead; | 687 return overhead; |
688 } | 688 } |
689 | 689 |
690 } // namespace WebCore | 690 } // namespace WebCore |
OLD | NEW |