Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(531)

Unified Diff: net/http/websocket_stream_base.h

Issue 14813024: Introduce RequestWebSocketStream into HttpStreamFactory (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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_

Powered by Google App Engine
This is Rietveld 408576698