1 // Copyright 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.
5 #ifndef NET_WEBSOCKETS_WEBSOCKET_HANDSHAKE_STREAM_BASE_H_
6 #define NET_WEBSOCKETS_WEBSOCKET_HANDSHAKE_STREAM_BASE_H_
8 // This file is included from net/http files.
9 // Since net/http can be built without linking net/websockets code,
10 // this file must not introduce any link-time dependencies on websockets.
12 #include "base/basictypes.h"
13 #include "base/memory/weak_ptr.h"
14 #include "net/http/http_stream_base.h"
15 #include "net/websockets/websocket_stream.h"
19 class ClientSocketHandle;
22 // WebSocketHandshakeStreamBase is the base class of
23 // WebSocketBasicHandshakeStream. net/http code uses this interface to handle
24 // WebSocketBasicHandshakeStream when it needs to be treated differently from
26 class NET_EXPORT WebSocketHandshakeStreamBase : public HttpStreamBase {
32 // Create a WebSocketBasicHandshakeStream. This function (or the returned
33 // object) takes the ownership of |connection|. This is called after the
34 // underlying connection has been established but before any handshake data
35 // has been transferred.
36 virtual WebSocketHandshakeStreamBase* CreateBasicStream(
37 ClientSocketHandle* connection,
38 bool using_proxy) = 0;
40 // Create a WebSocketSpdyHandshakeStream (unimplemented as of October 2013)
41 virtual WebSocketHandshakeStreamBase* CreateSpdyStream(
42 const base::WeakPtr<SpdySession>& session,
43 bool use_relative_url) = 0;
46 virtual ~WebSocketHandshakeStreamBase() {}
48 // After the handshake has completed, this method creates a WebSocketStream
49 // (of the appropriate type) from the WebSocketHandshakeStreamBase object.
50 // The WebSocketHandshakeStreamBase object is unusable after Upgrade() has
52 virtual scoped_ptr<WebSocketStream> Upgrade() = 0;
55 WebSocketHandshakeStreamBase() {}
58 DISALLOW_COPY_AND_ASSIGN(WebSocketHandshakeStreamBase);
63 #endif // NET_WEBSOCKETS_WEBSOCKET_HANDSHAKE_STREAM_BASE_H_