Single-purpose extensions policy FAQ
[chromium-blink-merge.git] / net / websockets / websocket_handshake_stream_create_helper.h
blobef4baeb53e41cce0dde2f67d0e2dbabcd263bb3e
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_CREATE_HELPER_H_
6 #define NET_WEBSOCKETS_WEBSOCKET_HANDSHAKE_STREAM_CREATE_HELPER_H_
8 #include <string>
9 #include <vector>
11 #include "net/base/net_export.h"
12 #include "net/websockets/websocket_handshake_stream_base.h"
13 #include "net/websockets/websocket_stream.h"
15 namespace net {
17 // Implementation of WebSocketHandshakeStreamBase::CreateHelper. This class is
18 // used in the implementation of WebSocketStream::CreateAndConnectStream() and
19 // is not intended to be used by itself.
21 // Holds the information needed to construct a
22 // WebSocketBasicHandshakeStreamBase.
23 class NET_EXPORT_PRIVATE WebSocketHandshakeStreamCreateHelper
24 : public WebSocketHandshakeStreamBase::CreateHelper {
25 public:
26 explicit WebSocketHandshakeStreamCreateHelper(
27 WebSocketStream::ConnectDelegate* connect_delegate,
28 const std::vector<std::string>& requested_subprotocols);
30 virtual ~WebSocketHandshakeStreamCreateHelper();
32 // WebSocketHandshakeStreamBase::CreateHelper methods
34 // Create a WebSocketBasicHandshakeStream.
35 virtual WebSocketHandshakeStreamBase* CreateBasicStream(
36 scoped_ptr<ClientSocketHandle> connection,
37 bool using_proxy) OVERRIDE;
39 // Unimplemented as of November 2013.
40 virtual WebSocketHandshakeStreamBase* CreateSpdyStream(
41 const base::WeakPtr<SpdySession>& session,
42 bool use_relative_url) OVERRIDE;
44 // Return the WebSocketHandshakeStreamBase object that we created. In the case
45 // where CreateBasicStream() was called more than once, returns the most
46 // recent stream, which will be the one on which the handshake succeeded.
47 WebSocketHandshakeStreamBase* stream() { return stream_; }
49 private:
50 const std::vector<std::string> requested_subprotocols_;
52 // This is owned by the caller of CreateBaseStream() or
53 // CreateSpdyStream(). Both the stream and this object will be destroyed
54 // during the destruction of the URLRequest object associated with the
55 // handshake.
56 WebSocketHandshakeStreamBase* stream_;
58 WebSocketStream::ConnectDelegate* connect_delegate_;
60 DISALLOW_COPY_AND_ASSIGN(WebSocketHandshakeStreamCreateHelper);
63 } // namespace net
65 #endif // NET_WEBSOCKETS_WEBSOCKET_HANDSHAKE_STREAM_CREATE_HELPER_H_