| 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 didUpdateBufferedAmount(unsigned long bufferedAmount) OVERRIDE; | 123 virtual void didConsumeBufferedAmount(unsigned long) OVERRIDE; |
| 124 virtual void didStartClosingHandshake() OVERRIDE; | 124 virtual void didStartClosingHandshake() OVERRIDE; |
| 125 virtual void didClose(unsigned long unhandledBufferedAmount, ClosingHandshak
eCompletionStatus, unsigned short code, const String& reason) OVERRIDE; | 125 virtual void didClose(ClosingHandshakeCompletionStatus, 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>*); |
| 211 | 212 |
| 212 void releaseChannel(); | 213 void releaseChannel(); |
| 213 | 214 |
| 214 enum BinaryType { | 215 enum BinaryType { |
| 215 BinaryTypeBlob, | 216 BinaryTypeBlob, |
| 216 BinaryTypeArrayBuffer | 217 BinaryTypeArrayBuffer |
| 217 }; | 218 }; |
| 218 | 219 |
| 219 RefPtrWillBeMember<WebSocketChannel> m_channel; | 220 RefPtrWillBeMember<WebSocketChannel> m_channel; |
| 220 | 221 |
| 221 State m_state; | 222 State m_state; |
| 222 KURL m_url; | 223 KURL m_url; |
| 223 unsigned long m_bufferedAmount; | 224 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; |
| 224 unsigned long m_bufferedAmountAfterClose; | 228 unsigned long m_bufferedAmountAfterClose; |
| 225 BinaryType m_binaryType; | 229 BinaryType m_binaryType; |
| 226 // The subprotocol the server selected. | 230 // The subprotocol the server selected. |
| 227 String m_subprotocol; | 231 String m_subprotocol; |
| 228 String m_extensions; | 232 String m_extensions; |
| 229 | 233 |
| 230 RefPtrWillBeMember<EventQueue> m_eventQueue; | 234 RefPtrWillBeMember<EventQueue> m_eventQueue; |
| 235 Timer<WebSocket> m_bufferedAmountConsumeTimer; |
| 231 }; | 236 }; |
| 232 | 237 |
| 233 } // namespace WebCore | 238 } // namespace WebCore |
| 234 | 239 |
| 235 #endif // WebSocket_h | 240 #endif // WebSocket_h |
| OLD | NEW |