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

Side by Side Diff: remoting/protocol/jingle_stream_connector.cc

Issue 8824006: Migrate net/socket/socket.h, net/socket/stream_socket.h to base::Bind(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased 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
« no previous file with comments | « remoting/protocol/jingle_stream_connector.h ('k') | remoting/protocol/message_reader.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "remoting/protocol/jingle_stream_connector.h" 5 #include "remoting/protocol/jingle_stream_connector.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "jingle/glue/channel_socket_adapter.h" 8 #include "jingle/glue/channel_socket_adapter.h"
9 #include "jingle/glue/pseudotcp_adapter.h" 9 #include "jingle/glue/pseudotcp_adapter.h"
10 #include "net/base/cert_status_flags.h" 10 #include "net/base/cert_status_flags.h"
(...skipping 23 matching lines...) Expand all
34 34
35 } // namespace 35 } // namespace
36 36
37 JingleStreamConnector::JingleStreamConnector( 37 JingleStreamConnector::JingleStreamConnector(
38 JingleSession* session, 38 JingleSession* session,
39 const std::string& name, 39 const std::string& name,
40 const Session::StreamChannelCallback& callback) 40 const Session::StreamChannelCallback& callback)
41 : session_(session), 41 : session_(session),
42 name_(name), 42 name_(name),
43 callback_(callback), 43 callback_(callback),
44 raw_channel_(NULL), 44 raw_channel_(NULL) {
45 ALLOW_THIS_IN_INITIALIZER_LIST(tcp_connect_callback_(
46 this, &JingleStreamConnector::OnTCPConnect)) {
47 } 45 }
48 46
49 JingleStreamConnector::~JingleStreamConnector() { 47 JingleStreamConnector::~JingleStreamConnector() {
50 } 48 }
51 49
52 void JingleStreamConnector::Connect(ChannelAuthenticator* authenticator, 50 void JingleStreamConnector::Connect(ChannelAuthenticator* authenticator,
53 cricket::TransportChannel* raw_channel) { 51 cricket::TransportChannel* raw_channel) {
54 DCHECK(CalledOnValidThread()); 52 DCHECK(CalledOnValidThread());
55 DCHECK(!raw_channel_); 53 DCHECK(!raw_channel_);
56 54
(...skipping 19 matching lines...) Expand all
76 74
77 // Set options for the TCP layer. 75 // Set options for the TCP layer.
78 jingle_glue::PseudoTcpAdapter* adapter = 76 jingle_glue::PseudoTcpAdapter* adapter =
79 new jingle_glue::PseudoTcpAdapter(socket); 77 new jingle_glue::PseudoTcpAdapter(socket);
80 adapter->SetAckDelay(kTcpAckDelayMilliseconds); 78 adapter->SetAckDelay(kTcpAckDelayMilliseconds);
81 adapter->SetNoDelay(true); 79 adapter->SetNoDelay(true);
82 adapter->SetReceiveBufferSize(kTcpReceiveBufferSize); 80 adapter->SetReceiveBufferSize(kTcpReceiveBufferSize);
83 adapter->SetSendBufferSize(kTcpSendBufferSize); 81 adapter->SetSendBufferSize(kTcpSendBufferSize);
84 82
85 tcp_socket_.reset(adapter); 83 tcp_socket_.reset(adapter);
86 int result = tcp_socket_->Connect(&tcp_connect_callback_); 84 int result = tcp_socket_->Connect(
85 base::Bind(&JingleStreamConnector::OnTCPConnect,
86 base::Unretained(this)));
87 if (result == net::ERR_IO_PENDING) { 87 if (result == net::ERR_IO_PENDING) {
88 return true; 88 return true;
89 } else if (result == net::OK) { 89 } else if (result == net::OK) {
90 tcp_connect_callback_.Run(result); 90 OnTCPConnect(result);
91 return true; 91 return true;
92 } 92 }
93 93
94 return false; 94 return false;
95 } 95 }
96 96
97 void JingleStreamConnector::OnTCPConnect(int result) { 97 void JingleStreamConnector::OnTCPConnect(int result) {
98 DCHECK(CalledOnValidThread()); 98 DCHECK(CalledOnValidThread());
99 99
100 if (result != net::OK) { 100 if (result != net::OK) {
(...skipping 20 matching lines...) Expand all
121 callback_.Run(socket); 121 callback_.Run(socket);
122 delete this; 122 delete this;
123 } 123 }
124 124
125 void JingleStreamConnector::NotifyError() { 125 void JingleStreamConnector::NotifyError() {
126 NotifyDone(NULL); 126 NotifyDone(NULL);
127 } 127 }
128 128
129 } // namespace protocol 129 } // namespace protocol
130 } // namespace remoting 130 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/protocol/jingle_stream_connector.h ('k') | remoting/protocol/message_reader.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698