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