| OLD | NEW |
| 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_server_socket_impl.h" | 5 #include "mojo/services/network/tcp_server_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 "net/base/net_errors.h" | 10 #include "net/base/net_errors.h" |
| 11 | 11 |
| 12 namespace mojo { | 12 namespace mojo { |
| 13 | 13 |
| 14 TCPServerSocketImpl::TCPServerSocketImpl(scoped_ptr<net::TCPSocket> socket) | 14 TCPServerSocketImpl::TCPServerSocketImpl( |
| 15 : socket_(socket.Pass()) { | 15 scoped_ptr<net::TCPSocket> socket, |
| 16 scoped_ptr<mojo::AppRefCount> app_refcount) |
| 17 : socket_(socket.Pass()), app_refcount_(app_refcount.Pass()) { |
| 16 } | 18 } |
| 17 | 19 |
| 18 TCPServerSocketImpl::~TCPServerSocketImpl() { | 20 TCPServerSocketImpl::~TCPServerSocketImpl() { |
| 19 } | 21 } |
| 20 | 22 |
| 21 void TCPServerSocketImpl::Accept( | 23 void TCPServerSocketImpl::Accept( |
| 22 ScopedDataPipeConsumerHandle send_stream, | 24 ScopedDataPipeConsumerHandle send_stream, |
| 23 ScopedDataPipeProducerHandle receive_stream, | 25 ScopedDataPipeProducerHandle receive_stream, |
| 24 InterfaceRequest<TCPConnectedSocket> client_socket, | 26 InterfaceRequest<TCPConnectedSocket> client_socket, |
| 25 const AcceptCallback& callback) { | 27 const AcceptCallback& callback) { |
| (...skipping 24 matching lines...) Expand all Loading... |
| 50 | 52 |
| 51 void TCPServerSocketImpl::OnAcceptCompleted(int result) { | 53 void TCPServerSocketImpl::OnAcceptCompleted(int result) { |
| 52 if (result != net::OK) { | 54 if (result != net::OK) { |
| 53 pending_callback_.Run(MakeNetworkError(result), NetAddressPtr()); | 55 pending_callback_.Run(MakeNetworkError(result), NetAddressPtr()); |
| 54 pending_send_stream_.reset(); | 56 pending_send_stream_.reset(); |
| 55 pending_receive_stream_.reset(); | 57 pending_receive_stream_.reset(); |
| 56 pending_client_socket_ = InterfaceRequest<TCPConnectedSocket>(); | 58 pending_client_socket_ = InterfaceRequest<TCPConnectedSocket>(); |
| 57 } else { | 59 } else { |
| 58 new TCPConnectedSocketImpl( | 60 new TCPConnectedSocketImpl( |
| 59 accepted_socket_.Pass(), pending_send_stream_.Pass(), | 61 accepted_socket_.Pass(), pending_send_stream_.Pass(), |
| 60 pending_receive_stream_.Pass(), pending_client_socket_.Pass()); | 62 pending_receive_stream_.Pass(), pending_client_socket_.Pass(), |
| 63 app_refcount_->Clone()); |
| 61 pending_callback_.Run(MakeNetworkError(net::OK), | 64 pending_callback_.Run(MakeNetworkError(net::OK), |
| 62 NetAddress::From(accepted_address_)); | 65 NetAddress::From(accepted_address_)); |
| 63 } | 66 } |
| 64 | 67 |
| 65 pending_callback_ = AcceptCallback(); | 68 pending_callback_ = AcceptCallback(); |
| 66 } | 69 } |
| 67 | 70 |
| 68 } // namespace mojo | 71 } // namespace mojo |
| OLD | NEW |