| OLD | NEW |
| 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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 public: | 50 public: |
| 51 // A concrete object derived from ConnectDelegate is supplied by the caller to | 51 // A concrete object derived from ConnectDelegate is supplied by the caller to |
| 52 // CreateAndConnectStream() to receive the result of the connection. | 52 // CreateAndConnectStream() to receive the result of the connection. |
| 53 class NET_EXPORT_PRIVATE ConnectDelegate { | 53 class NET_EXPORT_PRIVATE ConnectDelegate { |
| 54 public: | 54 public: |
| 55 virtual ~ConnectDelegate(); | 55 virtual ~ConnectDelegate(); |
| 56 // Called on successful connection. The parameter is an object derived from | 56 // Called on successful connection. The parameter is an object derived from |
| 57 // WebSocketStream. | 57 // WebSocketStream. |
| 58 virtual void OnSuccess(scoped_ptr<WebSocketStream> stream) = 0; | 58 virtual void OnSuccess(scoped_ptr<WebSocketStream> stream) = 0; |
| 59 | 59 |
| 60 // Called on failure to connect. The parameter is either one of the values | 60 // Called on failure to connect. |
| 61 // defined in net::WebSocketError, or an error defined by some WebSocket | 61 // |message| contains defails of the failure. |
| 62 // extension protocol that we implement. | 62 virtual void OnFailure(const std::string& message) = 0; |
| 63 virtual void OnFailure(unsigned short websocket_error) = 0; | |
| 64 }; | 63 }; |
| 65 | 64 |
| 66 // Create and connect a WebSocketStream of an appropriate type. The actual | 65 // Create and connect a WebSocketStream of an appropriate type. The actual |
| 67 // concrete type returned depends on whether multiplexing or SPDY are being | 66 // concrete type returned depends on whether multiplexing or SPDY are being |
| 68 // used to communicate with the remote server. If the handshake completed | 67 // used to communicate with the remote server. If the handshake completed |
| 69 // successfully, then connect_delegate->OnSuccess() is called with a | 68 // successfully, then connect_delegate->OnSuccess() is called with a |
| 70 // WebSocketStream instance. If it failed, then connect_delegate->OnFailure() | 69 // WebSocketStream instance. If it failed, then connect_delegate->OnFailure() |
| 71 // is called with a WebSocket result code corresponding to the error. Deleting | 70 // is called with a WebSocket result code corresponding to the error. Deleting |
| 72 // the returned WebSocketStreamRequest object will cancel the connection, in | 71 // the returned WebSocketStreamRequest object will cancel the connection, in |
| 73 // which case the |connect_delegate| object that the caller passed will be | 72 // which case the |connect_delegate| object that the caller passed will be |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 protected: | 166 protected: |
| 168 WebSocketStream(); | 167 WebSocketStream(); |
| 169 | 168 |
| 170 private: | 169 private: |
| 171 DISALLOW_COPY_AND_ASSIGN(WebSocketStream); | 170 DISALLOW_COPY_AND_ASSIGN(WebSocketStream); |
| 172 }; | 171 }; |
| 173 | 172 |
| 174 } // namespace net | 173 } // namespace net |
| 175 | 174 |
| 176 #endif // NET_WEBSOCKETS_WEBSOCKET_STREAM_H_ | 175 #endif // NET_WEBSOCKETS_WEBSOCKET_STREAM_H_ |
| OLD | NEW |