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

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..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.
+
+#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.
+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
+ kStreamTypeSpdy,
+ // for testing purpose
+ kStreamTypeTest
+ };
+
+ // You can derive this class and implement each factory method.
+ class Factory {
+ 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() {}
+ };
+
+ StreamType type() const {
+ return type_;
+ }
+
+ virtual ~WebSocketStreamBase() { }
+
+ protected:
+ explicit WebSocketStreamBase(StreamType type): type_(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