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 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 virtual bool hasPendingActivity() const OVERRIDE; | 113 virtual bool hasPendingActivity() const OVERRIDE; |
114 virtual void suspend() OVERRIDE; | 114 virtual void suspend() OVERRIDE; |
115 virtual void resume() OVERRIDE; | 115 virtual void resume() OVERRIDE; |
116 virtual void stop() OVERRIDE; | 116 virtual void stop() OVERRIDE; |
117 | 117 |
118 // WebSocketChannelClient functions. | 118 // WebSocketChannelClient functions. |
119 virtual void didConnect(const String& subprotocol, const String& extensions)
OVERRIDE; | 119 virtual void didConnect(const String& subprotocol, const String& extensions)
OVERRIDE; |
120 virtual void didReceiveMessage(const String& message) OVERRIDE; | 120 virtual void didReceiveMessage(const String& message) OVERRIDE; |
121 virtual void didReceiveBinaryData(PassOwnPtr<Vector<char> >) OVERRIDE; | 121 virtual void didReceiveBinaryData(PassOwnPtr<Vector<char> >) OVERRIDE; |
122 virtual void didReceiveMessageError() OVERRIDE; | 122 virtual void didReceiveMessageError() OVERRIDE; |
123 virtual void didConsumeBufferedAmount(unsigned long) OVERRIDE; | 123 virtual void didUpdateBufferedAmount(unsigned long bufferedAmount) OVERRIDE; |
124 virtual void didStartClosingHandshake() OVERRIDE; | 124 virtual void didStartClosingHandshake() OVERRIDE; |
125 virtual void didClose(ClosingHandshakeCompletionStatus, unsigned short code,
const String& reason) OVERRIDE; | 125 virtual void didClose(unsigned long unhandledBufferedAmount, ClosingHandshak
eCompletionStatus, unsigned short code, const String& reason) OVERRIDE; |
126 | 126 |
127 virtual void trace(Visitor*) OVERRIDE; | 127 virtual void trace(Visitor*) OVERRIDE; |
128 | 128 |
129 static bool isValidSubprotocolString(const String&); | 129 static bool isValidSubprotocolString(const String&); |
130 | 130 |
131 protected: | 131 protected: |
132 explicit WebSocket(ExecutionContext*); | 132 explicit WebSocket(ExecutionContext*); |
133 | 133 |
134 private: | 134 private: |
135 // FIXME: This should inherit WebCore::EventQueue. | 135 // FIXME: This should inherit WebCore::EventQueue. |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 | 201 |
202 // Checks the result of WebSocketChannel::send() method, and: | 202 // Checks the result of WebSocketChannel::send() method, and: |
203 // - shows console message | 203 // - shows console message |
204 // - sets ExceptionState appropriately | 204 // - sets ExceptionState appropriately |
205 // - reports data for UMA. | 205 // - reports data for UMA. |
206 void handleSendResult(WebSocketChannel::SendResult, ExceptionState&, WebSock
etSendType); | 206 void handleSendResult(WebSocketChannel::SendResult, ExceptionState&, WebSock
etSendType); |
207 | 207 |
208 // Updates m_bufferedAmountAfterClose given the amount of data passed to | 208 // Updates m_bufferedAmountAfterClose given the amount of data passed to |
209 // send() method after the state changed to CLOSING or CLOSED. | 209 // send() method after the state changed to CLOSING or CLOSED. |
210 void updateBufferedAmountAfterClose(unsigned long); | 210 void updateBufferedAmountAfterClose(unsigned long); |
211 void reflectBufferedAmountConsumption(Timer<WebSocket>*); | |
212 | 211 |
213 void releaseChannel(); | 212 void releaseChannel(); |
214 | 213 |
215 enum BinaryType { | 214 enum BinaryType { |
216 BinaryTypeBlob, | 215 BinaryTypeBlob, |
217 BinaryTypeArrayBuffer | 216 BinaryTypeArrayBuffer |
218 }; | 217 }; |
219 | 218 |
220 RefPtrWillBeMember<WebSocketChannel> m_channel; | 219 RefPtrWillBeMember<WebSocketChannel> m_channel; |
221 | 220 |
222 State m_state; | 221 State m_state; |
223 KURL m_url; | 222 KURL m_url; |
224 unsigned long m_bufferedAmount; | 223 unsigned long m_bufferedAmount; |
225 // The consumed buffered amount that will be reflected to m_bufferedAmount | |
226 // later. It will be cleared once reflected. | |
227 unsigned long m_consumedBufferedAmount; | |
228 unsigned long m_bufferedAmountAfterClose; | 224 unsigned long m_bufferedAmountAfterClose; |
229 BinaryType m_binaryType; | 225 BinaryType m_binaryType; |
230 // The subprotocol the server selected. | 226 // The subprotocol the server selected. |
231 String m_subprotocol; | 227 String m_subprotocol; |
232 String m_extensions; | 228 String m_extensions; |
233 | 229 |
234 RefPtrWillBeMember<EventQueue> m_eventQueue; | 230 RefPtrWillBeMember<EventQueue> m_eventQueue; |
235 Timer<WebSocket> m_bufferedAmountConsumeTimer; | |
236 }; | 231 }; |
237 | 232 |
238 } // namespace WebCore | 233 } // namespace WebCore |
239 | 234 |
240 #endif // WebSocket_h | 235 #endif // WebSocket_h |
OLD | NEW |