OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef NET_HTTP_WEBSOCKET_STREAM_BASE_H_ |
| 6 #define NET_HTTP_WEBSOCKET_STREAM_BASE_H_ |
| 7 |
| 8 // This file is placed on net/http because net/http classes depends it. |
| 9 // Since net/http can be built without linking net/websockets code, |
| 10 // you should not introduce dependency to net/websockets in this file. |
| 11 |
| 12 #include <base/basictypes.h> |
| 13 |
| 14 namespace net { |
| 15 |
| 16 class ClientSocketHandle; |
| 17 class SpdySession; |
| 18 |
| 19 // WebSocketStreamBase is the base class of WebSocketStream. |
| 20 // net/http code can hold WebSocketStream objects via this interface |
| 21 // without linking net/websockets code. |
| 22 class WebSocketStreamBase { |
| 23 public: |
| 24 // The enum describing the stream type. |
| 25 // Each type corresponds to a WebSocketStream derived class. |
| 26 enum StreamType { |
| 27 // correspond to WebSocketBasicStream |
| 28 kStreamTypeBasic, |
| 29 // correspond to WebSockeSpdyStream |
| 30 kStreamTypeSpdy, |
| 31 // for testing purpose |
| 32 kStreamTypeTest |
| 33 }; |
| 34 |
| 35 // You can derive this class and implement each factory method. |
| 36 class Factory { |
| 37 public: |
| 38 // Create a WebSocketBasicStream. |
| 39 // This function (or the returned object) takes the ownership |
| 40 // of |connection|. |
| 41 virtual WebSocketStreamBase* CreateBasicStream( |
| 42 ClientSocketHandle* connection, |
| 43 bool using_proxy) = 0; |
| 44 |
| 45 // Create a WebSocketSpdyStream. |
| 46 virtual WebSocketStreamBase* CreateSpdyStream( |
| 47 SpdySession* session, |
| 48 bool use_relative_url) = 0; |
| 49 |
| 50 virtual ~Factory() {} |
| 51 }; |
| 52 |
| 53 StreamType type() const { |
| 54 return type_; |
| 55 } |
| 56 |
| 57 virtual ~WebSocketStreamBase() { } |
| 58 |
| 59 protected: |
| 60 explicit WebSocketStreamBase(StreamType type): type_(type) {} |
| 61 |
| 62 private: |
| 63 const StreamType type_; |
| 64 DISALLOW_COPY_AND_ASSIGN(WebSocketStreamBase); |
| 65 }; |
| 66 |
| 67 } // namespace net |
| 68 |
| 69 #endif // NET_HTTP_WEBSOCKET_STREAM_BASE_H_ |
OLD | NEW |