| 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 #ifndef MOJO_SERVICES_NETWORK_TCP_BOUND_SOCKET_H_ | 5 #ifndef MOJO_SERVICES_NETWORK_TCP_BOUND_SOCKET_H_ |
| 6 #define MOJO_SERVICES_NETWORK_TCP_BOUND_SOCKET_H_ | 6 #define MOJO_SERVICES_NETWORK_TCP_BOUND_SOCKET_H_ |
| 7 | 7 |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "mojo/public/cpp/bindings/strong_binding.h" | 9 #include "mojo/public/cpp/bindings/strong_binding.h" |
| 10 #include "mojo/services/network/public/interfaces/tcp_bound_socket.mojom.h" | 10 #include "mojo/services/network/public/interfaces/tcp_bound_socket.mojom.h" |
| 11 #include "mojo/shell/public/cpp/shell.h" | 11 #include "mojo/shell/public/cpp/message_loop_ref.h" |
| 12 #include "net/socket/tcp_socket.h" | 12 #include "net/socket/tcp_socket.h" |
| 13 | 13 |
| 14 namespace mojo { | 14 namespace mojo { |
| 15 | 15 |
| 16 class TCPBoundSocketImpl : public TCPBoundSocket { | 16 class TCPBoundSocketImpl : public TCPBoundSocket { |
| 17 public: | 17 public: |
| 18 TCPBoundSocketImpl(scoped_ptr<mojo::AppRefCount> app_refcount, | 18 TCPBoundSocketImpl(scoped_ptr<mojo::MessageLoopRef> app_refcount, |
| 19 InterfaceRequest<TCPBoundSocket> request); | 19 InterfaceRequest<TCPBoundSocket> request); |
| 20 ~TCPBoundSocketImpl() override; | 20 ~TCPBoundSocketImpl() override; |
| 21 | 21 |
| 22 // Does the actual binding. Returns a net error code. On net::OK, the bound | 22 // Does the actual binding. Returns a net error code. On net::OK, the bound |
| 23 // socket will be ready to use and send back to the client. On failure, this | 23 // socket will be ready to use and send back to the client. On failure, this |
| 24 // object should be destroyed and no longer used. | 24 // object should be destroyed and no longer used. |
| 25 int Bind(NetAddressPtr local_address); | 25 int Bind(NetAddressPtr local_address); |
| 26 | 26 |
| 27 // Returns the local address associated with this socket. This should only | 27 // Returns the local address associated with this socket. This should only |
| 28 // be called after Bind has succeeded. | 28 // be called after Bind has succeeded. |
| (...skipping 11 matching lines...) Expand all Loading... |
| 40 private: | 40 private: |
| 41 void OnConnected(int result); | 41 void OnConnected(int result); |
| 42 | 42 |
| 43 scoped_ptr<net::TCPSocket> socket_; | 43 scoped_ptr<net::TCPSocket> socket_; |
| 44 | 44 |
| 45 // Valid when waiting for a connect callback. | 45 // Valid when waiting for a connect callback. |
| 46 ScopedDataPipeConsumerHandle pending_connect_send_stream_; | 46 ScopedDataPipeConsumerHandle pending_connect_send_stream_; |
| 47 ScopedDataPipeProducerHandle pending_connect_receive_stream_; | 47 ScopedDataPipeProducerHandle pending_connect_receive_stream_; |
| 48 InterfaceRequest<TCPConnectedSocket> pending_connect_socket_; | 48 InterfaceRequest<TCPConnectedSocket> pending_connect_socket_; |
| 49 Callback<void(NetworkErrorPtr)> pending_connect_callback_; | 49 Callback<void(NetworkErrorPtr)> pending_connect_callback_; |
| 50 scoped_ptr<mojo::AppRefCount> app_refcount_; | 50 scoped_ptr<mojo::MessageLoopRef> app_refcount_; |
| 51 StrongBinding<TCPBoundSocket> binding_; | 51 StrongBinding<TCPBoundSocket> binding_; |
| 52 }; | 52 }; |
| 53 | 53 |
| 54 } // namespace mojo | 54 } // namespace mojo |
| 55 | 55 |
| 56 #endif // MOJO_SERVICES_NETWORK_TCP_BOUND_SOCKET_H_ | 56 #endif // MOJO_SERVICES_NETWORK_TCP_BOUND_SOCKET_H_ |
| OLD | NEW |