Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(8)

Side by Side Diff: trunk/Source/modules/websockets/MainThreadWebSocketChannel.h

Issue 338243006: Revert 176298 "[WebSocket] bufferedAmount should not decrease in..." (Closed) Base URL: svn://svn.chromium.org/blink/
Patch Set: Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 return adoptRefWillBeRefCountedGarbageCollected(new MainThreadWebSocketC hannel(document, client, sourceURL, lineNumber)); 68 return adoptRefWillBeRefCountedGarbageCollected(new MainThreadWebSocketC hannel(document, client, sourceURL, lineNumber));
69 } 69 }
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 WebSocketChannel::SendResult send(const String& message) OVERRIDE; 74 virtual WebSocketChannel::SendResult send(const String& message) OVERRIDE;
75 virtual WebSocketChannel::SendResult send(const ArrayBuffer&, unsigned byteO ffset, unsigned byteLength) OVERRIDE; 75 virtual WebSocketChannel::SendResult send(const ArrayBuffer&, unsigned byteO ffset, unsigned byteLength) OVERRIDE;
76 virtual WebSocketChannel::SendResult send(PassRefPtr<BlobDataHandle>) OVERRI DE; 76 virtual WebSocketChannel::SendResult send(PassRefPtr<BlobDataHandle>) OVERRI DE;
77 virtual WebSocketChannel::SendResult send(PassOwnPtr<Vector<char> > data) OV ERRIDE; 77 virtual WebSocketChannel::SendResult send(PassOwnPtr<Vector<char> > data) OV ERRIDE;
78 virtual unsigned long bufferedAmount() const OVERRIDE;
78 // Start closing handshake. Use the CloseEventCodeNotSpecified for the code 79 // Start closing handshake. Use the CloseEventCodeNotSpecified for the code
79 // argument to omit payload. 80 // argument to omit payload.
80 virtual void close(int code, const String& reason) OVERRIDE; 81 virtual void close(int code, const String& reason) OVERRIDE;
81 virtual void fail(const String& reason, MessageLevel, const String&, unsigne d lineNumber) OVERRIDE; 82 virtual void fail(const String& reason, MessageLevel, const String&, unsigne d lineNumber) OVERRIDE;
82 virtual void disconnect() OVERRIDE; 83 virtual void disconnect() OVERRIDE;
83 84
84 virtual void suspend() OVERRIDE; 85 virtual void suspend() OVERRIDE;
85 virtual void resume() OVERRIDE; 86 virtual void resume() OVERRIDE;
86 87
87 // SocketStreamHandleClient functions. 88 // SocketStreamHandleClient functions.
88 virtual void didOpenSocketStream(SocketStreamHandle*) OVERRIDE; 89 virtual void didOpenSocketStream(SocketStreamHandle*) OVERRIDE;
89 virtual void didCloseSocketStream(SocketStreamHandle*) OVERRIDE; 90 virtual void didCloseSocketStream(SocketStreamHandle*) OVERRIDE;
90 virtual void didReceiveSocketStreamData(SocketStreamHandle*, const char*, in t) OVERRIDE; 91 virtual void didReceiveSocketStreamData(SocketStreamHandle*, const char*, in t) OVERRIDE;
91 virtual void didConsumeBufferedAmount(SocketStreamHandle*, size_t consumed) OVERRIDE; 92 virtual void didUpdateBufferedAmount(SocketStreamHandle*, size_t bufferedAmo unt) OVERRIDE;
92 virtual void didFailSocketStream(SocketStreamHandle*, const SocketStreamErro r&) OVERRIDE; 93 virtual void didFailSocketStream(SocketStreamHandle*, const SocketStreamErro r&) OVERRIDE;
93 94
94 // FileReaderLoaderClient functions. 95 // FileReaderLoaderClient functions.
95 virtual void didStartLoading() OVERRIDE; 96 virtual void didStartLoading() OVERRIDE;
96 virtual void didReceiveData() OVERRIDE; 97 virtual void didReceiveData() OVERRIDE;
97 virtual void didFinishLoading() OVERRIDE; 98 virtual void didFinishLoading() OVERRIDE;
98 virtual void didFail(FileError::ErrorCode) OVERRIDE; 99 virtual void didFail(FileError::ErrorCode) OVERRIDE;
99 100
100 private: 101 private:
101 MainThreadWebSocketChannel(Document*, WebSocketChannelClient*, const String& , unsigned); 102 MainThreadWebSocketChannel(Document*, WebSocketChannelClient*, const String& , unsigned);
102 103
103 class FramingOverhead {
104 public:
105 FramingOverhead(WebSocketFrame::OpCode opcode, size_t frameDataSize, siz e_t originalPayloadLength)
106 : m_opcode(opcode)
107 , m_frameDataSize(frameDataSize)
108 , m_originalPayloadLength(originalPayloadLength)
109 {
110 }
111
112 WebSocketFrame::OpCode opcode() const { return m_opcode; }
113 size_t frameDataSize() const { return m_frameDataSize; }
114 size_t originalPayloadLength() const { return m_originalPayloadLength; }
115
116 private:
117 WebSocketFrame::OpCode m_opcode;
118 size_t m_frameDataSize;
119 size_t m_originalPayloadLength;
120 };
121
122 void clearDocument(); 104 void clearDocument();
123 105
124 void disconnectHandle(); 106 void disconnectHandle();
125 107
126 // Calls didReceiveMessageError() on m_client if we haven't yet. 108 // Calls didReceiveMessageError() on m_client if we haven't yet.
127 void callDidReceiveMessageError(); 109 void callDidReceiveMessageError();
128 110
129 bool appendToBuffer(const char* data, size_t len); 111 bool appendToBuffer(const char* data, size_t len);
130 void skipBuffer(size_t len); 112 void skipBuffer(size_t len);
131 // Repeats parsing data from m_buffer until instructed to stop. 113 // Repeats parsing data from m_buffer until instructed to stop.
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 189
208 Timer<MainThreadWebSocketChannel> m_resumeTimer; 190 Timer<MainThreadWebSocketChannel> m_resumeTimer;
209 bool m_suspended; 191 bool m_suspended;
210 bool m_didFailOfClientAlreadyRun; 192 bool m_didFailOfClientAlreadyRun;
211 // Set to true iff this instance called disconnect() on m_handle. 193 // Set to true iff this instance called disconnect() on m_handle.
212 bool m_hasCalledDisconnectOnHandle; 194 bool m_hasCalledDisconnectOnHandle;
213 bool m_receivedClosingHandshake; 195 bool m_receivedClosingHandshake;
214 Timer<MainThreadWebSocketChannel> m_closingTimer; 196 Timer<MainThreadWebSocketChannel> m_closingTimer;
215 ChannelState m_state; 197 ChannelState m_state;
216 bool m_shouldDiscardReceivedData; 198 bool m_shouldDiscardReceivedData;
199 unsigned long m_unhandledBufferedAmount;
217 200
218 unsigned long m_identifier; // m_identifier == 0 means that we could not obt ain a valid identifier. 201 unsigned long m_identifier; // m_identifier == 0 means that we could not obt ain a valid identifier.
219 202
220 // Private members only for hybi-10 protocol. 203 // Private members only for hybi-10 protocol.
221 bool m_hasContinuousFrame; 204 bool m_hasContinuousFrame;
222 WebSocketFrame::OpCode m_continuousFrameOpCode; 205 WebSocketFrame::OpCode m_continuousFrameOpCode;
223 Vector<char> m_continuousFrameData; 206 Vector<char> m_continuousFrameData;
224 unsigned short m_closeEventCode; 207 unsigned short m_closeEventCode;
225 String m_closeEventReason; 208 String m_closeEventReason;
226 209
227 Deque<OwnPtr<QueuedFrame> > m_outgoingFrameQueue; 210 Deque<OwnPtr<QueuedFrame> > m_outgoingFrameQueue;
228 OutgoingFrameQueueStatus m_outgoingFrameQueueStatus; 211 OutgoingFrameQueueStatus m_outgoingFrameQueueStatus;
229 Deque<FramingOverhead> m_framingOverheadQueue;
230 // The number of bytes that are already consumed (i.e. sent) in the
231 // current frame.
232 size_t m_numConsumedBytesInCurrentFrame;
233 212
234 // FIXME: Load two or more Blobs simultaneously for better performance. 213 // FIXME: Load two or more Blobs simultaneously for better performance.
235 OwnPtr<FileReaderLoader> m_blobLoader; 214 OwnPtr<FileReaderLoader> m_blobLoader;
236 BlobLoaderStatus m_blobLoaderStatus; 215 BlobLoaderStatus m_blobLoaderStatus;
237 216
238 // Source code position where construction happened. To be used to show a 217 // Source code position where construction happened. To be used to show a
239 // console message where no JS callstack info available. 218 // console message where no JS callstack info available.
240 String m_sourceURLAtConstruction; 219 String m_sourceURLAtConstruction;
241 unsigned m_lineNumberAtConstruction; 220 unsigned m_lineNumberAtConstruction;
242 221
243 WebSocketPerMessageDeflate m_perMessageDeflate; 222 WebSocketPerMessageDeflate m_perMessageDeflate;
244 223
245 WebSocketDeflateFramer m_deflateFramer; 224 WebSocketDeflateFramer m_deflateFramer;
246 }; 225 };
247 226
248 } // namespace WebCore 227 } // namespace WebCore
249 228
250 #endif // MainThreadWebSocketChannel_h 229 #endif // MainThreadWebSocketChannel_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698