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

Side by Side Diff: net/websockets/websocket_stream.h

Issue 26544003: Make net::WebSocketChannel deletion safe and enable new IPCs (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Minor comment fix. Created 7 years, 2 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef NET_WEBSOCKETS_WEBSOCKET_STREAM_H_ 5 #ifndef NET_WEBSOCKETS_WEBSOCKET_STREAM_H_
6 #define NET_WEBSOCKETS_WEBSOCKET_STREAM_H_ 6 #define NET_WEBSOCKETS_WEBSOCKET_STREAM_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 // a frame is available, then the frame will be split, and the available data 115 // a frame is available, then the frame will be split, and the available data
116 // will be returned immediately. 116 // will be returned immediately.
117 // 117 //
118 // When the socket is closed on the remote side, this method will return 118 // When the socket is closed on the remote side, this method will return
119 // ERR_CONNECTION_CLOSED. It will not return OK with an empty vector. 119 // ERR_CONNECTION_CLOSED. It will not return OK with an empty vector.
120 // 120 //
121 // If the connection is closed in the middle of receiving an incomplete frame, 121 // If the connection is closed in the middle of receiving an incomplete frame,
122 // ReadFrames may discard the incomplete frame. Since the renderer will 122 // ReadFrames may discard the incomplete frame. Since the renderer will
123 // discard any incomplete messages when the connection is closed, this makes 123 // discard any incomplete messages when the connection is closed, this makes
124 // no difference to the overall semantics. 124 // no difference to the overall semantics.
125 //
126 // Implementations of ReadFrames() must be able to handle being deleted during
127 // the execution of callback.Run(). In practice this means that the method
128 // calling callback.Run() (and any calling methods in the same object) must
129 // return immediately without any further method calls or access to member
130 // variables. Implementors should write test(s) for this case.
125 virtual int ReadFrames(ScopedVector<WebSocketFrame>* frames, 131 virtual int ReadFrames(ScopedVector<WebSocketFrame>* frames,
126 const CompletionCallback& callback) = 0; 132 const CompletionCallback& callback) = 0;
127 133
128 // Writes WebSocket frame data. 134 // Writes WebSocket frame data.
129 // 135 //
130 // |frames| must be valid until the operation completes or Close() is called. 136 // |frames| must be valid until the operation completes or Close() is called.
131 // 137 //
132 // This function must not be called while a previous call of WriteFrames() is 138 // This function must not be called while a previous call of WriteFrames() is
133 // still pending. 139 // still pending.
134 // 140 //
135 // This method will only return OK if all frames were written completely. 141 // This method will only return OK if all frames were written completely.
136 // Otherwise it will return an appropriate net error code. 142 // Otherwise it will return an appropriate net error code.
143 //
144 // The callback implementation is permitted to delete this
145 // object. Implementations of WriteFrames() should be robust against
146 // this. This generally means returning to the event loop immediately after
147 // calling the callback.
137 virtual int WriteFrames(ScopedVector<WebSocketFrame>* frames, 148 virtual int WriteFrames(ScopedVector<WebSocketFrame>* frames,
138 const CompletionCallback& callback) = 0; 149 const CompletionCallback& callback) = 0;
139 150
140 // Closes the stream. All pending I/O operations (if any) are cancelled 151 // Closes the stream. All pending I/O operations (if any) are cancelled
141 // at this point, so |frames| can be freed. 152 // at this point, so |frames| can be freed.
142 virtual void Close() = 0; 153 virtual void Close() = 0;
143 154
144 // The subprotocol that was negotiated for the stream. If no protocol was 155 // The subprotocol that was negotiated for the stream. If no protocol was
145 // negotiated, then the empty string is returned. 156 // negotiated, then the empty string is returned.
146 virtual std::string GetSubProtocol() const = 0; 157 virtual std::string GetSubProtocol() const = 0;
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 protected: 204 protected:
194 WebSocketStream(); 205 WebSocketStream();
195 206
196 private: 207 private:
197 DISALLOW_COPY_AND_ASSIGN(WebSocketStream); 208 DISALLOW_COPY_AND_ASSIGN(WebSocketStream);
198 }; 209 };
199 210
200 } // namespace net 211 } // namespace net
201 212
202 #endif // NET_WEBSOCKETS_WEBSOCKET_STREAM_H_ 213 #endif // NET_WEBSOCKETS_WEBSOCKET_STREAM_H_
OLDNEW
« net/websockets/websocket_event_interface.h ('K') | « net/websockets/websocket_event_interface.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698