| 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 "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/memory/scoped_vector.h" | 9 #include "base/memory/scoped_vector.h" |
| 10 #include "net/base/completion_callback.h" | 10 #include "net/base/completion_callback.h" |
| 11 #include "net/websockets/websocket_stream_base.h" |
| 11 | 12 |
| 12 namespace net { | 13 namespace net { |
| 13 | 14 |
| 14 class BoundNetLog; | 15 class BoundNetLog; |
| 15 class HttpRequestHeaders; | 16 class HttpRequestHeaders; |
| 16 struct HttpRequestInfo; | 17 struct HttpRequestInfo; |
| 17 class HttpResponseInfo; | 18 class HttpResponseInfo; |
| 18 struct WebSocketFrameChunk; | 19 struct WebSocketFrameChunk; |
| 19 | 20 |
| 20 // WebSocketStream is a transport-agnostic interface for reading and writing | 21 // WebSocketStream is a transport-agnostic interface for reading and writing |
| 21 // WebSocket frames. This class provides an abstraction for WebSocket streams | 22 // WebSocket frames. This class provides an abstraction for WebSocket streams |
| 22 // based on various transport layer, such as normal WebSocket connections | 23 // based on various transport layer, such as normal WebSocket connections |
| 23 // (WebSocket protocol upgraded from HTTP handshake), SPDY transports, or | 24 // (WebSocket protocol upgraded from HTTP handshake), SPDY transports, or |
| 24 // WebSocket connections with multiplexing extension. Subtypes of | 25 // WebSocket connections with multiplexing extension. Subtypes of |
| 25 // WebSocketStream are responsible for managing the underlying transport | 26 // WebSocketStream are responsible for managing the underlying transport |
| 26 // appropriately. | 27 // appropriately. |
| 27 // | 28 // |
| 28 // All functions except Close() can be asynchronous. If an operation cannot | 29 // All functions except Close() can be asynchronous. If an operation cannot |
| 29 // be finished synchronously, the function returns ERR_IO_PENDING, and | 30 // be finished synchronously, the function returns ERR_IO_PENDING, and |
| 30 // |callback| will be called when the operation is finished. Non-null |callback| | 31 // |callback| will be called when the operation is finished. Non-null |callback| |
| 31 // must be provided to these functions. | 32 // must be provided to these functions. |
| 32 | 33 |
| 33 class WebSocketStream { | 34 class WebSocketStream : public WebSocketStreamBase { |
| 34 public: | 35 public: |
| 35 WebSocketStream() {} | 36 WebSocketStream() {} |
| 36 | 37 |
| 37 // Derived classes must make sure Close() is called when the stream is not | 38 // Derived classes must make sure Close() is called when the stream is not |
| 38 // closed on destruction. | 39 // closed on destruction. |
| 39 virtual ~WebSocketStream() {} | 40 virtual ~WebSocketStream() {} |
| 40 | 41 |
| 41 // Initializes stream. Must be called before calling SendHandshakeRequest(). | 42 // Initializes stream. Must be called before calling SendHandshakeRequest(). |
| 42 // Returns a net error code, possibly ERR_IO_PENDING, as stated above. | 43 // Returns a net error code, possibly ERR_IO_PENDING, as stated above. |
| 43 // | 44 // |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 const CompletionCallback& callback) = 0; | 89 const CompletionCallback& callback) = 0; |
| 89 | 90 |
| 90 // Closes the stream. All pending I/O operations (if any) are canceled | 91 // Closes the stream. All pending I/O operations (if any) are canceled |
| 91 // at this point, so |frame_chunks| can be freed. | 92 // at this point, so |frame_chunks| can be freed. |
| 92 virtual void Close() = 0; | 93 virtual void Close() = 0; |
| 93 | 94 |
| 94 // TODO(yutak): Add following interfaces: | 95 // TODO(yutak): Add following interfaces: |
| 95 // - RenewStreamForAuth for authentication (is this necessary?) | 96 // - RenewStreamForAuth for authentication (is this necessary?) |
| 96 // - GetSSLInfo, GetSSLCertRequsetInfo for SSL | 97 // - GetSSLInfo, GetSSLCertRequsetInfo for SSL |
| 97 | 98 |
| 99 // WebSocketStreamBase derived functions |
| 100 virtual WebSocketStream* AsWebSocketStream() { return this; } |
| 101 |
| 98 private: | 102 private: |
| 99 DISALLOW_COPY_AND_ASSIGN(WebSocketStream); | 103 DISALLOW_COPY_AND_ASSIGN(WebSocketStream); |
| 100 }; | 104 }; |
| 101 | 105 |
| 102 } // namespace net | 106 } // namespace net |
| 103 | 107 |
| 104 #endif // NET_WEBSOCKETS_WEBSOCKET_STREAM_H_ | 108 #endif // NET_WEBSOCKETS_WEBSOCKET_STREAM_H_ |
| OLD | NEW |