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 #include "net/websockets/websocket_handshake_stream_create_helper.h"
7 #include "base/logging.h"
8 #include "base/memory/scoped_ptr.h"
9 #include "base/memory/weak_ptr.h"
10 #include "net/socket/client_socket_handle.h"
11 #include "net/spdy/spdy_session.h"
12 #include "net/websockets/websocket_basic_handshake_stream.h"
16 WebSocketHandshakeStreamCreateHelper::WebSocketHandshakeStreamCreateHelper(
17 WebSocketStream::ConnectDelegate
* connect_delegate
,
18 const std::vector
<std::string
>& requested_subprotocols
)
19 : requested_subprotocols_(requested_subprotocols
),
21 connect_delegate_(connect_delegate
) {}
23 WebSocketHandshakeStreamCreateHelper::~WebSocketHandshakeStreamCreateHelper() {}
25 WebSocketHandshakeStreamBase
*
26 WebSocketHandshakeStreamCreateHelper::CreateBasicStream(
27 scoped_ptr
<ClientSocketHandle
> connection
,
29 // The list of supported extensions and parameters is hard-coded.
30 // TODO(ricea): If more extensions are added, consider a more flexible
32 std::vector
<std::string
> extensions(
33 1, "permessage-deflate; client_max_window_bits");
35 new WebSocketBasicHandshakeStream(connection
.Pass(),
38 requested_subprotocols_
,
42 // TODO(ricea): Create a WebSocketSpdyHandshakeStream. crbug.com/323852
43 WebSocketHandshakeStreamBase
*
44 WebSocketHandshakeStreamCreateHelper::CreateSpdyStream(
45 const base::WeakPtr
<SpdySession
>& session
,
46 bool use_relative_url
) {
47 NOTREACHED() << "Not implemented";