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_connected_socket_impl.h" | 5 #include "mojo/services/network/tcp_connected_socket_impl.h" |
6 | 6 |
| 7 #include <utility> |
| 8 |
7 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
8 #include "mojo/services/network/net_adapters.h" | 10 #include "mojo/services/network/net_adapters.h" |
9 #include "net/base/net_errors.h" | 11 #include "net/base/net_errors.h" |
10 | 12 |
11 namespace mojo { | 13 namespace mojo { |
12 | 14 |
13 TCPConnectedSocketImpl::TCPConnectedSocketImpl( | 15 TCPConnectedSocketImpl::TCPConnectedSocketImpl( |
14 scoped_ptr<net::TCPSocket> socket, | 16 scoped_ptr<net::TCPSocket> socket, |
15 ScopedDataPipeConsumerHandle send_stream, | 17 ScopedDataPipeConsumerHandle send_stream, |
16 ScopedDataPipeProducerHandle receive_stream, | 18 ScopedDataPipeProducerHandle receive_stream, |
17 InterfaceRequest<TCPConnectedSocket> request, | 19 InterfaceRequest<TCPConnectedSocket> request, |
18 scoped_ptr<mojo::AppRefCount> app_refcount) | 20 scoped_ptr<mojo::AppRefCount> app_refcount) |
19 : socket_(socket.Pass()), | 21 : socket_(std::move(socket)), |
20 send_stream_(send_stream.Pass()), | 22 send_stream_(std::move(send_stream)), |
21 receive_stream_(receive_stream.Pass()), | 23 receive_stream_(std::move(receive_stream)), |
22 binding_(this, request.Pass()), | 24 binding_(this, std::move(request)), |
23 app_refcount_(app_refcount.Pass()), | 25 app_refcount_(std::move(app_refcount)), |
24 weak_ptr_factory_(this) { | 26 weak_ptr_factory_(this) { |
25 // Queue up async communication. | 27 // Queue up async communication. |
26 binding_.set_connection_error_handler([this]() { OnConnectionError(); }); | 28 binding_.set_connection_error_handler([this]() { OnConnectionError(); }); |
27 ListenForReceivePeerClosed(); | 29 ListenForReceivePeerClosed(); |
28 ListenForSendPeerClosed(); | 30 ListenForSendPeerClosed(); |
29 ReceiveMore(); | 31 ReceiveMore(); |
30 SendMore(); | 32 SendMore(); |
31 } | 33 } |
32 | 34 |
33 TCPConnectedSocketImpl::~TCPConnectedSocketImpl() { | 35 TCPConnectedSocketImpl::~TCPConnectedSocketImpl() { |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
247 } | 249 } |
248 | 250 |
249 void TCPConnectedSocketImpl::DeleteIfNeeded() { | 251 void TCPConnectedSocketImpl::DeleteIfNeeded() { |
250 bool has_send = pending_send_ || send_stream_.is_valid(); | 252 bool has_send = pending_send_ || send_stream_.is_valid(); |
251 bool has_receive = pending_receive_ || receive_stream_.is_valid(); | 253 bool has_receive = pending_receive_ || receive_stream_.is_valid(); |
252 if (!binding_.is_bound() && !has_send && !has_receive) | 254 if (!binding_.is_bound() && !has_send && !has_receive) |
253 delete this; | 255 delete this; |
254 } | 256 } |
255 | 257 |
256 } // namespace mojo | 258 } // namespace mojo |
OLD | NEW |