Lots of random cleanups, mostly for native_theme_win.cc:
[chromium-blink-merge.git] / net / websockets / websocket_handshake_stream_create_helper.cc
blob2bd59a125325d39eda5d909910503c03a253b3d3
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"
14 namespace net {
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 failure_message_(NULL) {
23 DCHECK(connect_delegate_);
26 WebSocketHandshakeStreamCreateHelper::~WebSocketHandshakeStreamCreateHelper() {}
28 WebSocketHandshakeStreamBase*
29 WebSocketHandshakeStreamCreateHelper::CreateBasicStream(
30 scoped_ptr<ClientSocketHandle> connection,
31 bool using_proxy) {
32 DCHECK(failure_message_) << "set_failure_message() must be called";
33 // The list of supported extensions and parameters is hard-coded.
34 // TODO(ricea): If more extensions are added, consider a more flexible
35 // method.
36 std::vector<std::string> extensions(
37 1, "permessage-deflate; client_max_window_bits");
38 WebSocketBasicHandshakeStream* stream =
39 new WebSocketBasicHandshakeStream(connection.Pass(),
40 connect_delegate_,
41 using_proxy,
42 requested_subprotocols_,
43 extensions,
44 failure_message_);
45 OnStreamCreated(stream);
46 stream_ = stream;
47 return stream;
50 // TODO(ricea): Create a WebSocketSpdyHandshakeStream. crbug.com/323852
51 WebSocketHandshakeStreamBase*
52 WebSocketHandshakeStreamCreateHelper::CreateSpdyStream(
53 const base::WeakPtr<SpdySession>& session,
54 bool use_relative_url) {
55 NOTREACHED() << "Not implemented";
56 return NULL;
59 scoped_ptr<WebSocketStream> WebSocketHandshakeStreamCreateHelper::Upgrade() {
60 DCHECK(stream_);
61 WebSocketHandshakeStreamBase* stream = stream_;
62 stream_ = NULL;
63 return stream->Upgrade();
66 void WebSocketHandshakeStreamCreateHelper::OnStreamCreated(
67 WebSocketBasicHandshakeStream* stream) {
70 } // namespace net