Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1261)

Side by Side Diff: net/spdy/spdy_websocket_stream.cc

Issue 8990001: base::Bind: Convert most of net/http. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Clang. Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/spdy/spdy_websocket_stream.h" 5 #include "net/spdy/spdy_websocket_stream.h"
6 6
7 #include "base/bind.h"
8 #include "base/bind_helpers.h"
7 #include "googleurl/src/gurl.h" 9 #include "googleurl/src/gurl.h"
8 #include "net/base/net_errors.h" 10 #include "net/base/net_errors.h"
9 #include "net/base/io_buffer.h" 11 #include "net/base/io_buffer.h"
10 #include "net/spdy/spdy_framer.h" 12 #include "net/spdy/spdy_framer.h"
11 #include "net/spdy/spdy_protocol.h" 13 #include "net/spdy/spdy_protocol.h"
12 #include "net/spdy/spdy_session.h" 14 #include "net/spdy/spdy_session.h"
13 #include "net/spdy/spdy_stream.h" 15 #include "net/spdy/spdy_stream.h"
14 16
15 namespace net { 17 namespace net {
16 18
17 SpdyWebSocketStream::SpdyWebSocketStream( 19 SpdyWebSocketStream::SpdyWebSocketStream(
18 SpdySession* spdy_session, Delegate* delegate) 20 SpdySession* spdy_session, Delegate* delegate)
19 : stream_(NULL), 21 : stream_(NULL),
20 spdy_session_(spdy_session), 22 spdy_session_(spdy_session),
21 delegate_(delegate), 23 delegate_(delegate) {
22 ALLOW_THIS_IN_INITIALIZER_LIST(spdy_stream_created_callback_(
23 this, &SpdyWebSocketStream::OnSpdyStreamCreated)) {
24 DCHECK(spdy_session_); 24 DCHECK(spdy_session_);
25 DCHECK(delegate_); 25 DCHECK(delegate_);
26 } 26 }
27 27
28 SpdyWebSocketStream::~SpdyWebSocketStream() { 28 SpdyWebSocketStream::~SpdyWebSocketStream() {
29 if (stream_) { 29 if (stream_) {
30 // If Close() has not already been called, DetachDelegate() will send a 30 // If Close() has not already been called, DetachDelegate() will send a
31 // SPDY RST_STREAM. Deleting SpdyWebSocketStream is good enough to initiate 31 // SPDY RST_STREAM. Deleting SpdyWebSocketStream is good enough to initiate
32 // graceful shutdown, so we call Close() to avoid sending a RST_STREAM. 32 // graceful shutdown, so we call Close() to avoid sending a RST_STREAM.
33 // For safe, we should eliminate |delegate_| for OnClose() calback. 33 // For safe, we should eliminate |delegate_| for OnClose() calback.
34 delegate_ = NULL; 34 delegate_ = NULL;
35 stream_->Close(); 35 stream_->Close();
36 } 36 }
37 } 37 }
38 38
39 int SpdyWebSocketStream::InitializeStream(const GURL& url, 39 int SpdyWebSocketStream::InitializeStream(const GURL& url,
40 RequestPriority request_priority, 40 RequestPriority request_priority,
41 const BoundNetLog& net_log) { 41 const BoundNetLog& net_log) {
42 if (spdy_session_->IsClosed()) 42 if (spdy_session_->IsClosed())
43 return ERR_SOCKET_NOT_CONNECTED; 43 return ERR_SOCKET_NOT_CONNECTED;
44 44
45 int result = spdy_session_->CreateStream( 45 int result = spdy_session_->CreateStream(
46 url, request_priority, &stream_, net_log, 46 url, request_priority, &stream_, net_log,
47 &spdy_stream_created_callback_); 47 base::Bind(&SpdyWebSocketStream::OnSpdyStreamCreated,
48 base::Unretained(this)));
48 49
49 if (result == OK) { 50 if (result == OK) {
50 DCHECK(stream_); 51 DCHECK(stream_);
51 stream_->SetDelegate(this); 52 stream_->SetDelegate(this);
52 } 53 }
53 return result; 54 return result;
54 } 55 }
55 56
56 int SpdyWebSocketStream::SendRequest( 57 int SpdyWebSocketStream::SendRequest(
57 const linked_ptr<spdy::SpdyHeaderBlock>& headers) { 58 const linked_ptr<spdy::SpdyHeaderBlock>& headers) {
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 DCHECK_NE(ERR_IO_PENDING, result); 137 DCHECK_NE(ERR_IO_PENDING, result);
137 if (result == OK) { 138 if (result == OK) {
138 DCHECK(stream_); 139 DCHECK(stream_);
139 stream_->SetDelegate(this); 140 stream_->SetDelegate(this);
140 } 141 }
141 DCHECK(delegate_); 142 DCHECK(delegate_);
142 delegate_->OnCreatedSpdyStream(result); 143 delegate_->OnCreatedSpdyStream(result);
143 } 144 }
144 145
145 } // namespace net 146 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698