Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / net / websockets / websocket_handshake_stream_create_helper.cc
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.
4
5 #include "net/websockets/websocket_handshake_stream_create_helper.h"
6
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"
13
14 namespace net {
15
16 WebSocketHandshakeStreamCreateHelper::WebSocketHandshakeStreamCreateHelper(
17     WebSocketStream::ConnectDelegate* connect_delegate,
18     const std::vector<std::string>& requested_subprotocols)
19     : requested_subprotocols_(requested_subprotocols),
20       stream_(NULL),
21       connect_delegate_(connect_delegate) {}
22
23 WebSocketHandshakeStreamCreateHelper::~WebSocketHandshakeStreamCreateHelper() {}
24
25 WebSocketHandshakeStreamBase*
26 WebSocketHandshakeStreamCreateHelper::CreateBasicStream(
27     scoped_ptr<ClientSocketHandle> connection,
28     bool using_proxy) {
29   // The list of supported extensions and parameters is hard-coded.
30   // TODO(ricea): If more extensions are added, consider a more flexible
31   // method.
32   std::vector<std::string> extensions(
33       1, "permessage-deflate; client_max_window_bits");
34   return stream_ =
35       new WebSocketBasicHandshakeStream(connection.Pass(),
36                                         connect_delegate_,
37                                         using_proxy,
38                                         requested_subprotocols_,
39                                         extensions);
40 }
41
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";
48   return NULL;
49 }
50
51 }  // namespace net