Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2011, 2012 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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 70 virtual ~MainThreadWebSocketChannel(); | 70 virtual ~MainThreadWebSocketChannel(); |
| 71 | 71 |
| 72 // WebSocketChannel functions. | 72 // WebSocketChannel functions. |
| 73 virtual bool connect(const KURL&, const String& protocol) OVERRIDE; | 73 virtual bool connect(const KURL&, const String& protocol) OVERRIDE; |
| 74 virtual String subprotocol() OVERRIDE; | 74 virtual String subprotocol() OVERRIDE; |
| 75 virtual String extensions() OVERRIDE; | 75 virtual String extensions() OVERRIDE; |
| 76 virtual WebSocketChannel::SendResult send(const String& message) OVERRIDE; | 76 virtual WebSocketChannel::SendResult send(const String& message) OVERRIDE; |
| 77 virtual WebSocketChannel::SendResult send(const ArrayBuffer&, unsigned byteO ffset, unsigned byteLength) OVERRIDE; | 77 virtual WebSocketChannel::SendResult send(const ArrayBuffer&, unsigned byteO ffset, unsigned byteLength) OVERRIDE; |
| 78 virtual WebSocketChannel::SendResult send(PassRefPtr<BlobDataHandle>) OVERRI DE; | 78 virtual WebSocketChannel::SendResult send(PassRefPtr<BlobDataHandle>) OVERRI DE; |
| 79 virtual WebSocketChannel::SendResult send(PassOwnPtr<Vector<char> > data) OV ERRIDE; | 79 virtual WebSocketChannel::SendResult send(PassOwnPtr<Vector<char> > data) OV ERRIDE; |
| 80 virtual unsigned long bufferedAmount() const OVERRIDE; | |
| 81 // Start closing handshake. Use the CloseEventCodeNotSpecified for the code | 80 // Start closing handshake. Use the CloseEventCodeNotSpecified for the code |
| 82 // argument to omit payload. | 81 // argument to omit payload. |
| 83 virtual void close(int code, const String& reason) OVERRIDE; | 82 virtual void close(int code, const String& reason) OVERRIDE; |
| 84 virtual void fail(const String& reason, MessageLevel, const String&, unsigne d lineNumber) OVERRIDE; | 83 virtual void fail(const String& reason, MessageLevel, const String&, unsigne d lineNumber) OVERRIDE; |
| 85 virtual void disconnect() OVERRIDE; | 84 virtual void disconnect() OVERRIDE; |
| 86 | 85 |
| 87 virtual void suspend() OVERRIDE; | 86 virtual void suspend() OVERRIDE; |
| 88 virtual void resume() OVERRIDE; | 87 virtual void resume() OVERRIDE; |
| 89 | 88 |
| 90 // SocketStreamHandleClient functions. | 89 // SocketStreamHandleClient functions. |
| 91 virtual void didOpenSocketStream(SocketStreamHandle*) OVERRIDE; | 90 virtual void didOpenSocketStream(SocketStreamHandle*) OVERRIDE; |
| 92 virtual void didCloseSocketStream(SocketStreamHandle*) OVERRIDE; | 91 virtual void didCloseSocketStream(SocketStreamHandle*) OVERRIDE; |
| 93 virtual void didReceiveSocketStreamData(SocketStreamHandle*, const char*, in t) OVERRIDE; | 92 virtual void didReceiveSocketStreamData(SocketStreamHandle*, const char*, in t) OVERRIDE; |
| 94 virtual void didUpdateBufferedAmount(SocketStreamHandle*, size_t bufferedAmo unt) OVERRIDE; | 93 virtual void didConsumeBufferedAmount(SocketStreamHandle*, size_t consumed) OVERRIDE; |
| 95 virtual void didFailSocketStream(SocketStreamHandle*, const SocketStreamErro r&) OVERRIDE; | 94 virtual void didFailSocketStream(SocketStreamHandle*, const SocketStreamErro r&) OVERRIDE; |
| 96 | 95 |
| 97 // FileReaderLoaderClient functions. | 96 // FileReaderLoaderClient functions. |
| 98 virtual void didStartLoading() OVERRIDE; | 97 virtual void didStartLoading() OVERRIDE; |
| 99 virtual void didReceiveData() OVERRIDE; | 98 virtual void didReceiveData() OVERRIDE; |
| 100 virtual void didFinishLoading() OVERRIDE; | 99 virtual void didFinishLoading() OVERRIDE; |
| 101 virtual void didFail(FileError::ErrorCode) OVERRIDE; | 100 virtual void didFail(FileError::ErrorCode) OVERRIDE; |
| 102 | 101 |
| 103 private: | 102 private: |
| 104 MainThreadWebSocketChannel(Document*, WebSocketChannelClient*, const String& , unsigned); | 103 MainThreadWebSocketChannel(Document*, WebSocketChannelClient*, const String& , unsigned); |
| 105 | 104 |
| 105 class FramingOverhead { | |
| 106 public: | |
| 107 FramingOverhead(WebSocketFrame::OpCode opcode, size_t frameDataSize, siz e_t originalPayloadLength) | |
| 108 : m_opcode(opcode) | |
| 109 , m_frameDataSize(frameDataSize) | |
| 110 , m_originalPayloadLength(originalPayloadLength) | |
| 111 { | |
| 112 } | |
| 113 | |
| 114 WebSocketFrame::OpCode opcode() const { return m_opcode; } | |
| 115 size_t frameDataSize() const { return m_frameDataSize; } | |
| 116 size_t originalPayloadLength() const { return m_originalPayloadLength; } | |
| 117 | |
| 118 private: | |
| 119 WebSocketFrame::OpCode m_opcode; | |
| 120 size_t m_frameDataSize; | |
| 121 size_t m_originalPayloadLength; | |
| 122 }; | |
| 123 | |
| 106 void clearDocument(); | 124 void clearDocument(); |
| 107 | 125 |
| 108 void disconnectHandle(); | 126 void disconnectHandle(); |
| 109 | 127 |
| 110 // Calls didReceiveMessageError() on m_client if we haven't yet. | 128 // Calls didReceiveMessageError() on m_client if we haven't yet. |
| 111 void callDidReceiveMessageError(); | 129 void callDidReceiveMessageError(); |
| 112 | 130 |
| 113 bool appendToBuffer(const char* data, size_t len); | 131 bool appendToBuffer(const char* data, size_t len); |
| 114 void skipBuffer(size_t len); | 132 void skipBuffer(size_t len); |
| 115 // Repeats parsing data from m_buffer until instructed to stop. | 133 // Repeats parsing data from m_buffer until instructed to stop. |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 191 | 209 |
| 192 Timer<MainThreadWebSocketChannel> m_resumeTimer; | 210 Timer<MainThreadWebSocketChannel> m_resumeTimer; |
| 193 bool m_suspended; | 211 bool m_suspended; |
| 194 bool m_didFailOfClientAlreadyRun; | 212 bool m_didFailOfClientAlreadyRun; |
| 195 // Set to true iff this instance called disconnect() on m_handle. | 213 // Set to true iff this instance called disconnect() on m_handle. |
| 196 bool m_hasCalledDisconnectOnHandle; | 214 bool m_hasCalledDisconnectOnHandle; |
| 197 bool m_receivedClosingHandshake; | 215 bool m_receivedClosingHandshake; |
| 198 Timer<MainThreadWebSocketChannel> m_closingTimer; | 216 Timer<MainThreadWebSocketChannel> m_closingTimer; |
| 199 ChannelState m_state; | 217 ChannelState m_state; |
| 200 bool m_shouldDiscardReceivedData; | 218 bool m_shouldDiscardReceivedData; |
| 201 unsigned long m_unhandledBufferedAmount; | |
| 202 | 219 |
| 203 unsigned long m_identifier; // m_identifier == 0 means that we could not obt ain a valid identifier. | 220 unsigned long m_identifier; // m_identifier == 0 means that we could not obt ain a valid identifier. |
| 204 | 221 |
| 205 // Private members only for hybi-10 protocol. | 222 // Private members only for hybi-10 protocol. |
| 206 bool m_hasContinuousFrame; | 223 bool m_hasContinuousFrame; |
| 207 WebSocketFrame::OpCode m_continuousFrameOpCode; | 224 WebSocketFrame::OpCode m_continuousFrameOpCode; |
| 208 Vector<char> m_continuousFrameData; | 225 Vector<char> m_continuousFrameData; |
| 209 unsigned short m_closeEventCode; | 226 unsigned short m_closeEventCode; |
| 210 String m_closeEventReason; | 227 String m_closeEventReason; |
| 211 | 228 |
| 212 Deque<OwnPtr<QueuedFrame> > m_outgoingFrameQueue; | 229 Deque<OwnPtr<QueuedFrame> > m_outgoingFrameQueue; |
| 213 OutgoingFrameQueueStatus m_outgoingFrameQueueStatus; | 230 OutgoingFrameQueueStatus m_outgoingFrameQueueStatus; |
| 231 Deque<FramingOverhead> m_framingOverheadQueue; | |
| 232 size_t m_numConsumedBytesInCurrentFrame; | |
|
tyoshino (SeeGerritForStatus)
2014/06/16 07:31:42
write comment for this variable please
yhirano
2014/06/16 10:19:44
Done.
| |
| 214 | 233 |
| 215 // FIXME: Load two or more Blobs simultaneously for better performance. | 234 // FIXME: Load two or more Blobs simultaneously for better performance. |
| 216 OwnPtr<FileReaderLoader> m_blobLoader; | 235 OwnPtr<FileReaderLoader> m_blobLoader; |
| 217 BlobLoaderStatus m_blobLoaderStatus; | 236 BlobLoaderStatus m_blobLoaderStatus; |
| 218 | 237 |
| 219 // Source code position where construction happened. To be used to show a | 238 // Source code position where construction happened. To be used to show a |
| 220 // console message where no JS callstack info available. | 239 // console message where no JS callstack info available. |
| 221 String m_sourceURLAtConstruction; | 240 String m_sourceURLAtConstruction; |
| 222 unsigned m_lineNumberAtConstruction; | 241 unsigned m_lineNumberAtConstruction; |
| 223 | 242 |
| 224 WebSocketPerMessageDeflate m_perMessageDeflate; | 243 WebSocketPerMessageDeflate m_perMessageDeflate; |
| 225 | 244 |
| 226 WebSocketDeflateFramer m_deflateFramer; | 245 WebSocketDeflateFramer m_deflateFramer; |
| 227 }; | 246 }; |
| 228 | 247 |
| 229 } // namespace WebCore | 248 } // namespace WebCore |
| 230 | 249 |
| 231 #endif // MainThreadWebSocketChannel_h | 250 #endif // MainThreadWebSocketChannel_h |
| OLD | NEW |