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

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: Rebase (again). 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
« no previous file with comments | « net/websockets/websocket_event_interface.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 // a frame is available, then the frame will be split, and the available data 112 // a frame is available, then the frame will be split, and the available data
113 // will be returned immediately. 113 // will be returned immediately.
114 // 114 //
115 // When the socket is closed on the remote side, this method will return 115 // When the socket is closed on the remote side, this method will return
116 // ERR_CONNECTION_CLOSED. It will not return OK with an empty vector. 116 // ERR_CONNECTION_CLOSED. It will not return OK with an empty vector.
117 // 117 //
118 // If the connection is closed in the middle of receiving an incomplete frame, 118 // If the connection is closed in the middle of receiving an incomplete frame,
119 // ReadFrames may discard the incomplete frame. Since the renderer will 119 // ReadFrames may discard the incomplete frame. Since the renderer will
120 // discard any incomplete messages when the connection is closed, this makes 120 // discard any incomplete messages when the connection is closed, this makes
121 // no difference to the overall semantics. 121 // no difference to the overall semantics.
122 //
123 // Implementations of ReadFrames() must be able to handle being deleted during
124 // the execution of callback.Run(). In practice this means that the method
125 // calling callback.Run() (and any calling methods in the same object) must
126 // return immediately without any further method calls or access to member
127 // variables. Implementors should write test(s) for this case.
122 virtual int ReadFrames(ScopedVector<WebSocketFrame>* frames, 128 virtual int ReadFrames(ScopedVector<WebSocketFrame>* frames,
123 const CompletionCallback& callback) = 0; 129 const CompletionCallback& callback) = 0;
124 130
125 // Writes WebSocket frame data. 131 // Writes WebSocket frame data.
126 // 132 //
127 // |frames| must be valid until the operation completes or Close() is called. 133 // |frames| must be valid until the operation completes or Close() is called.
128 // 134 //
129 // This function must not be called while a previous call of WriteFrames() is 135 // This function must not be called while a previous call of WriteFrames() is
130 // still pending. 136 // still pending.
131 // 137 //
132 // This method will only return OK if all frames were written completely. 138 // This method will only return OK if all frames were written completely.
133 // Otherwise it will return an appropriate net error code. 139 // Otherwise it will return an appropriate net error code.
140 //
141 // The callback implementation is permitted to delete this
142 // object. Implementations of WriteFrames() should be robust against
143 // this. This generally means returning to the event loop immediately after
144 // calling the callback.
134 virtual int WriteFrames(ScopedVector<WebSocketFrame>* frames, 145 virtual int WriteFrames(ScopedVector<WebSocketFrame>* frames,
135 const CompletionCallback& callback) = 0; 146 const CompletionCallback& callback) = 0;
136 147
137 // Closes the stream. All pending I/O operations (if any) are cancelled 148 // Closes the stream. All pending I/O operations (if any) are cancelled
138 // at this point, so |frames| can be freed. 149 // at this point, so |frames| can be freed.
139 virtual void Close() = 0; 150 virtual void Close() = 0;
140 151
141 // The subprotocol that was negotiated for the stream. If no protocol was 152 // The subprotocol that was negotiated for the stream. If no protocol was
142 // negotiated, then the empty string is returned. 153 // negotiated, then the empty string is returned.
143 virtual std::string GetSubProtocol() const = 0; 154 virtual std::string GetSubProtocol() const = 0;
(...skipping 12 matching lines...) Expand all
156 protected: 167 protected:
157 WebSocketStream(); 168 WebSocketStream();
158 169
159 private: 170 private:
160 DISALLOW_COPY_AND_ASSIGN(WebSocketStream); 171 DISALLOW_COPY_AND_ASSIGN(WebSocketStream);
161 }; 172 };
162 173
163 } // namespace net 174 } // namespace net
164 175
165 #endif // NET_WEBSOCKETS_WEBSOCKET_STREAM_H_ 176 #endif // NET_WEBSOCKETS_WEBSOCKET_STREAM_H_
OLDNEW
« no previous file with comments | « net/websockets/websocket_event_interface.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698