Index: net/http/websocket_stream_base.h |
diff --git a/net/http/websocket_stream_base.h b/net/http/websocket_stream_base.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..94904d9a421571f3c809db5391f4ff0fb43dbc8e |
--- /dev/null |
+++ b/net/http/websocket_stream_base.h |
@@ -0,0 +1,67 @@ |
+// Copyright (c) 2013 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef NET_HTTP_WEBSOCKET_STREAM_BASE_H_ |
+#define NET_HTTP_WEBSOCKET_STREAM_BASE_H_ |
+ |
+// This file is placed on net/http because net/http classes depends it. |
+// Since net/http can be built without linking net/websockets code, |
+// you should not introduce dependency to net/websockets in this file. |
+ |
+#include <base/basictypes.h> |
+ |
+namespace net { |
+ |
+class ClientSocketHandle; |
+class SpdySession; |
+ |
+// WebSocketStreamBase is the base class of WebSocketStream. |
+// net/http code uses this interface to handle WebSocketStream. |
+// When net/websockets code gets a WebSocketStreamBase, it should downcast |
+// the object into a derived class depending on the object's type() property. |
mmenke
2013/05/30 19:27:12
Why will higher level code care about the type?
yhirano
2013/05/31 08:36:45
WebSocketStreamBase is not in "natural" design. Mo
Adam Rice
2013/05/31 16:46:42
How about a virtual AsWebSocketStream method that
yhirano
2013/05/31 18:40:06
Cool! I will do that. Thank you!
yhirano
2013/06/03 04:49:58
Done.
|
+class WebSocketStreamBase { |
+ public: |
+ // The enum describing the stream type. |
+ // Each type corresponds to a WebSocketStream derived class. |
+ enum StreamType { |
+ // Corresponds to WebSocketBasicStream. |
+ kStreamTypeBasic, |
+ // Corresponds to WebSockeSpdyStream. |
+ kStreamTypeSpdy |
+ }; |
+ |
+ class Factory { |
+ public: |
+ virtual ~Factory() {} |
+ |
+ // Create a WebSocketBasicStream. |
+ // This function (or the returned object) takes the ownership |
+ // of |connection|. |
+ virtual WebSocketStreamBase* CreateBasicStream( |
+ ClientSocketHandle* connection, |
+ bool using_proxy) = 0; |
+ |
+ // Create a WebSocketSpdyStream. |
+ virtual WebSocketStreamBase* CreateSpdyStream( |
+ SpdySession* session, |
+ bool use_relative_url) = 0; |
+ }; |
+ |
+ virtual ~WebSocketStreamBase() {} |
+ |
+ StreamType type() const { |
+ return type_; |
+ } |
+ |
+ protected: |
+ explicit WebSocketStreamBase(StreamType type); |
+ |
+ private: |
+ const StreamType type_; |
+ DISALLOW_COPY_AND_ASSIGN(WebSocketStreamBase); |
+}; |
+ |
+} // namespace net |
+ |
+#endif // NET_HTTP_WEBSOCKET_STREAM_BASE_H_ |