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..3816147445fcc8ce5bd040f60043c8f274bcd5ca |
--- /dev/null |
+++ b/net/http/websocket_stream_base.h |
@@ -0,0 +1,69 @@ |
+// 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. |
mmenke
2013/05/28 21:22:37
My suggestion is just to put this in net/websocket
yhirano
2013/05/30 04:44:32
Currently, files in net/websockets are excluded in
mmenke
2013/05/30 19:27:12
Header files excluded from the build don't break c
yhirano
2013/05/31 08:36:45
Done.
|
+ |
+#include <base/basictypes.h> |
+ |
+namespace net { |
+ |
+class ClientSocketHandle; |
+class SpdySession; |
+ |
+// WebSocketStreamBase is the base class of WebSocketStream. |
+// net/http code can hold WebSocketStream objects via this interface |
+// without linking net/websockets code. |
mmenke
2013/05/28 21:22:37
Not really following the second sentence here.
yhirano
2013/05/30 04:44:32
Done?
|
+class WebSocketStreamBase { |
+ public: |
+ // The enum describing the stream type. |
+ // Each type corresponds to a WebSocketStream derived class. |
+ enum StreamType { |
+ // correspond to WebSocketBasicStream |
+ kStreamTypeBasic, |
+ // correspond to WebSockeSpdyStream |
mmenke
2013/05/28 21:22:37
nit: Comments should generally start with a capit
yhirano
2013/05/30 04:44:32
Done.
|
+ kStreamTypeSpdy, |
+ // for testing purpose |
+ kStreamTypeTest |
mmenke
2013/05/28 21:22:37
Prefer not to add this unless / until we need it.
yhirano
2013/05/30 04:44:32
Done.
|
+ }; |
+ |
+ // You can derive this class and implement each factory method. |
mmenke
2013/05/28 21:22:37
Comment doesn't add anything useful.
yhirano
2013/05/30 04:44:32
Done.
|
+ class Factory { |
mmenke
2013/05/28 21:22:37
Long term, I'd like to get rid of this class, and
yhirano
2013/05/30 04:44:32
Likely enough. Or, perhaps we may be able to decou
|
+ public: |
+ // 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 ~Factory() {} |
mmenke
2013/05/28 21:22:37
The destructor should go first (It could also be p
yhirano
2013/05/30 04:44:32
Done.
|
+ }; |
+ |
+ StreamType type() const { |
+ return type_; |
+ } |
+ |
+ virtual ~WebSocketStreamBase() { } |
mmenke
2013/05/28 21:22:37
nit: Google style guide says no horizontal whites
yhirano
2013/05/30 04:44:32
Done.
|
+ |
+ protected: |
+ explicit WebSocketStreamBase(StreamType type): type_(type) {} |
mmenke
2013/05/28 21:22:37
Mind de-inlining this?
mmenke
2013/05/28 21:22:37
nit: Space before the colon.
yhirano
2013/05/30 04:44:32
Done.
yhirano
2013/05/30 04:44:32
Done.
|
+ |
+ private: |
+ const StreamType type_; |
+ DISALLOW_COPY_AND_ASSIGN(WebSocketStreamBase); |
+}; |
+ |
+} // namespace net |
+ |
+#endif // NET_HTTP_WEBSOCKET_STREAM_BASE_H_ |