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

Side by Side Diff: mojo/services/network/tcp_bound_socket_impl.cc

Issue 1227373002: Roll mojo SDK to 734c6e1652ff2f3b696e441722838f453f4f9b42 (Closed) Base URL: https://github.com/domokit/monet.git@master
Patch Set: Follow review Created 5 years, 5 months 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "mojo/services/network/tcp_bound_socket_impl.h" 5 #include "mojo/services/network/tcp_bound_socket_impl.h"
6 6
7 #include "mojo/services/network/net_adapters.h" 7 #include "mojo/services/network/net_adapters.h"
8 #include "mojo/services/network/net_address_type_converters.h" 8 #include "mojo/services/network/net_address_type_converters.h"
9 #include "mojo/services/network/tcp_connected_socket_impl.h" 9 #include "mojo/services/network/tcp_connected_socket_impl.h"
10 #include "mojo/services/network/tcp_server_socket_impl.h" 10 #include "mojo/services/network/tcp_server_socket_impl.h"
11 #include "net/base/net_errors.h" 11 #include "net/base/net_errors.h"
12 12
13 namespace mojo { 13 namespace mojo {
14 14
15 TCPBoundSocketImpl::TCPBoundSocketImpl() { 15 TCPBoundSocketImpl::TCPBoundSocketImpl(InterfaceRequest<TCPBoundSocket> request)
16 : binding_(this, request.Pass()) {
16 } 17 }
17 18
18 TCPBoundSocketImpl::~TCPBoundSocketImpl() { 19 TCPBoundSocketImpl::~TCPBoundSocketImpl() {
19 } 20 }
20 21
21 int TCPBoundSocketImpl::Bind(NetAddressPtr local_address) { 22 int TCPBoundSocketImpl::Bind(NetAddressPtr local_address) {
22 net::IPEndPoint end_point = local_address.To<net::IPEndPoint>(); 23 net::IPEndPoint end_point = local_address.To<net::IPEndPoint>();
23 24
24 socket_.reset(new net::TCPSocket(NULL, net::NetLog::Source())); 25 socket_.reset(new net::TCPSocket(NULL, net::NetLog::Source()));
25 int result = socket_->Open(end_point.GetFamily()); 26 int result = socket_->Open(end_point.GetFamily());
(...skipping 30 matching lines...) Expand all
56 } 57 }
57 58
58 // TODO(brettw) set the backlog properly. 59 // TODO(brettw) set the backlog properly.
59 int result = socket_->Listen(4); 60 int result = socket_->Listen(4);
60 if (result != net::OK) { 61 if (result != net::OK) {
61 callback.Run(MakeNetworkError(result)); 62 callback.Run(MakeNetworkError(result));
62 return; 63 return;
63 } 64 }
64 65
65 // The server socket object takes ownership of the socket. 66 // The server socket object takes ownership of the socket.
66 BindToRequest(new TCPServerSocketImpl(socket_.Pass()), &server); 67 new TCPServerSocketImpl(server.Pass(), socket_.Pass());
67 callback.Run(MakeNetworkError(net::OK)); 68 callback.Run(MakeNetworkError(net::OK));
68 } 69 }
69 70
70 void TCPBoundSocketImpl::Connect( 71 void TCPBoundSocketImpl::Connect(
71 NetAddressPtr remote_address, 72 NetAddressPtr remote_address,
72 ScopedDataPipeConsumerHandle send_stream, 73 ScopedDataPipeConsumerHandle send_stream,
73 ScopedDataPipeProducerHandle receive_stream, 74 ScopedDataPipeProducerHandle receive_stream,
74 InterfaceRequest<TCPConnectedSocket> client_socket, 75 InterfaceRequest<TCPConnectedSocket> client_socket,
75 const Callback<void(NetworkErrorPtr)>& callback) { 76 const Callback<void(NetworkErrorPtr)>& callback) {
76 if (!socket_ || pending_connect_socket_.is_pending()) { 77 if (!socket_ || pending_connect_socket_.is_pending()) {
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 } else { 111 } else {
111 pending_connect_send_stream_.reset(); 112 pending_connect_send_stream_.reset();
112 pending_connect_receive_stream_.reset(); 113 pending_connect_receive_stream_.reset();
113 pending_connect_socket_ = InterfaceRequest<TCPConnectedSocket>(); 114 pending_connect_socket_ = InterfaceRequest<TCPConnectedSocket>();
114 } 115 }
115 pending_connect_callback_.Run(MakeNetworkError(result)); 116 pending_connect_callback_.Run(MakeNetworkError(result));
116 pending_connect_callback_ = Callback<void(NetworkErrorPtr)>(); 117 pending_connect_callback_ = Callback<void(NetworkErrorPtr)>();
117 } 118 }
118 119
119 } // namespace mojo 120 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/services/network/tcp_bound_socket_impl.h ('k') | mojo/services/network/tcp_connected_socket_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698