| 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 // Prevent this instance from being collected while it's not in CLOSED | 118 // Prevent this instance from being collected while it's not in CLOSED |
| 119 // state. | 119 // state. |
| 120 bool hasPendingActivity() const override; | 120 bool hasPendingActivity() const override; |
| 121 void suspend() override; | 121 void suspend() override; |
| 122 void resume() override; | 122 void resume() override; |
| 123 void stop() override; | 123 void stop() override; |
| 124 | 124 |
| 125 // WebSocketChannelClient functions. | 125 // WebSocketChannelClient functions. |
| 126 void didConnect(const String& subprotocol, const String& extensions) overrid
e; | 126 void didConnect(const String& subprotocol, const String& extensions) overrid
e; |
| 127 void didReceiveTextMessage(const String& message) override; | 127 void didReceiveTextMessage(const String& message) override; |
| 128 void didReceiveBinaryMessage(PassOwnPtr<Vector<char>>) override; | 128 void didReceiveArrayBuffer(PassOwnPtr<Vector<char>>) override; |
| 129 void didReceiveBlob(PassRefPtr<BlobDataHandle>) override; |
| 129 void didError() override; | 130 void didError() override; |
| 130 void didConsumeBufferedAmount(uint64_t) override; | 131 void didConsumeBufferedAmount(uint64_t) override; |
| 131 void didStartClosingHandshake() override; | 132 void didStartClosingHandshake() override; |
| 132 void didClose(ClosingHandshakeCompletionStatus, unsigned short code, const S
tring& reason) override; | 133 void didClose(ClosingHandshakeCompletionStatus, unsigned short code, const S
tring& reason) override; |
| 133 | 134 |
| 134 DECLARE_VIRTUAL_TRACE(); | 135 DECLARE_VIRTUAL_TRACE(); |
| 135 | 136 |
| 136 static bool isValidSubprotocolString(const String&); | 137 static bool isValidSubprotocolString(const String&); |
| 137 | 138 |
| 138 protected: | 139 protected: |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 WebSocketSendTypeMax, | 190 WebSocketSendTypeMax, |
| 190 }; | 191 }; |
| 191 | 192 |
| 192 enum WebSocketReceiveType { | 193 enum WebSocketReceiveType { |
| 193 WebSocketReceiveTypeString, | 194 WebSocketReceiveTypeString, |
| 194 WebSocketReceiveTypeArrayBuffer, | 195 WebSocketReceiveTypeArrayBuffer, |
| 195 WebSocketReceiveTypeBlob, | 196 WebSocketReceiveTypeBlob, |
| 196 WebSocketReceiveTypeMax, | 197 WebSocketReceiveTypeMax, |
| 197 }; | 198 }; |
| 198 | 199 |
| 200 enum BinaryType { |
| 201 BinaryTypeBlob, |
| 202 BinaryTypeArrayBuffer |
| 203 }; |
| 204 |
| 205 static WebSocketChannel::BinaryType toChannelBinaryType(BinaryType); |
| 206 |
| 199 // This function is virtual for unittests. | 207 // This function is virtual for unittests. |
| 200 // FIXME: Move WebSocketChannel::create here. | 208 // FIXME: Move WebSocketChannel::create here. |
| 201 virtual WebSocketChannel* createChannel(ExecutionContext* context, WebSocket
ChannelClient* client) | 209 virtual WebSocketChannel* createChannel(ExecutionContext* context, WebSocket
ChannelClient* client) |
| 202 { | 210 { |
| 203 return WebSocketChannel::create(context, client); | 211 return WebSocketChannel::create(context, client); |
| 204 } | 212 } |
| 205 | 213 |
| 206 // Adds a console message with JSMessageSource and ErrorMessageLevel. | 214 // Adds a console message with JSMessageSource and ErrorMessageLevel. |
| 207 void logError(const String& message); | 215 void logError(const String& message); |
| 208 | 216 |
| 209 // Handle the JavaScript close method call. close() methods on this class | 217 // Handle the JavaScript close method call. close() methods on this class |
| 210 // are just for determining if the optional code argument is supplied or | 218 // are just for determining if the optional code argument is supplied or |
| 211 // not. | 219 // not. |
| 212 void closeInternal(int, const String&, ExceptionState&); | 220 void closeInternal(int, const String&, ExceptionState&); |
| 213 | 221 |
| 214 // Updates m_bufferedAmountAfterClose given the amount of data passed to | 222 // Updates m_bufferedAmountAfterClose given the amount of data passed to |
| 215 // send() method after the state changed to CLOSING or CLOSED. | 223 // send() method after the state changed to CLOSING or CLOSED. |
| 216 void updateBufferedAmountAfterClose(uint64_t); | 224 void updateBufferedAmountAfterClose(uint64_t); |
| 217 void reflectBufferedAmountConsumption(Timer<DOMWebSocket>*); | 225 void reflectBufferedAmountConsumption(Timer<DOMWebSocket>*); |
| 218 | 226 |
| 219 void releaseChannel(); | 227 void releaseChannel(); |
| 220 | 228 |
| 221 enum BinaryType { | |
| 222 BinaryTypeBlob, | |
| 223 BinaryTypeArrayBuffer | |
| 224 }; | |
| 225 | |
| 226 Member<WebSocketChannel> m_channel; | 229 Member<WebSocketChannel> m_channel; |
| 227 | 230 |
| 228 State m_state; | 231 State m_state; |
| 229 KURL m_url; | 232 KURL m_url; |
| 230 uint64_t m_bufferedAmount; | 233 uint64_t m_bufferedAmount; |
| 231 // The consumed buffered amount that will be reflected to m_bufferedAmount | 234 // The consumed buffered amount that will be reflected to m_bufferedAmount |
| 232 // later. It will be cleared once reflected. | 235 // later. It will be cleared once reflected. |
| 233 uint64_t m_consumedBufferedAmount; | 236 uint64_t m_consumedBufferedAmount; |
| 234 uint64_t m_bufferedAmountAfterClose; | 237 uint64_t m_bufferedAmountAfterClose; |
| 235 BinaryType m_binaryType; | 238 BinaryType m_binaryType; |
| 236 // The subprotocol the server selected. | 239 // The subprotocol the server selected. |
| 237 String m_subprotocol; | 240 String m_subprotocol; |
| 238 String m_extensions; | 241 String m_extensions; |
| 239 | 242 |
| 240 Member<EventQueue> m_eventQueue; | 243 Member<EventQueue> m_eventQueue; |
| 241 Timer<DOMWebSocket> m_bufferedAmountConsumeTimer; | 244 Timer<DOMWebSocket> m_bufferedAmountConsumeTimer; |
| 242 }; | 245 }; |
| 243 | 246 |
| 244 } // namespace blink | 247 } // namespace blink |
| 245 | 248 |
| 246 #endif // DOMWebSocket_h | 249 #endif // DOMWebSocket_h |
| OLD | NEW |