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/network_service_impl.h" | 5 #include "mojo/services/network/network_service_impl.h" |
6 | 6 |
7 #include "mojo/services/network/cookie_store_impl.h" | 7 #include "mojo/services/network/cookie_store_impl.h" |
8 #include "mojo/services/network/net_adapters.h" | 8 #include "mojo/services/network/net_adapters.h" |
9 #include "mojo/services/network/tcp_bound_socket_impl.h" | 9 #include "mojo/services/network/tcp_bound_socket_impl.h" |
10 #include "mojo/services/network/udp_socket_impl.h" | 10 #include "mojo/services/network/udp_socket_impl.h" |
(...skipping 24 matching lines...) Expand all Loading... |
35 BindToRequest(new CookieStoreImpl(context_, origin_), &store); | 35 BindToRequest(new CookieStoreImpl(context_, origin_), &store); |
36 } | 36 } |
37 | 37 |
38 void NetworkServiceImpl::CreateWebSocket(InterfaceRequest<WebSocket> socket) { | 38 void NetworkServiceImpl::CreateWebSocket(InterfaceRequest<WebSocket> socket) { |
39 BindToRequest(new WebSocketImpl(context_), &socket); | 39 BindToRequest(new WebSocketImpl(context_), &socket); |
40 } | 40 } |
41 | 41 |
42 void NetworkServiceImpl::CreateTCPBoundSocket( | 42 void NetworkServiceImpl::CreateTCPBoundSocket( |
43 NetAddressPtr local_address, | 43 NetAddressPtr local_address, |
44 InterfaceRequest<TCPBoundSocket> bound_socket, | 44 InterfaceRequest<TCPBoundSocket> bound_socket, |
45 const Callback<void(NetworkErrorPtr, NetAddressPtr)>& callback) { | 45 const CreateTCPBoundSocketCallback& callback) { |
46 scoped_ptr<TCPBoundSocketImpl> bound(new TCPBoundSocketImpl); | 46 scoped_ptr<TCPBoundSocketImpl> bound(new TCPBoundSocketImpl); |
47 int net_error = bound->Bind(local_address.Pass()); | 47 int net_error = bound->Bind(local_address.Pass()); |
48 if (net_error != net::OK) { | 48 if (net_error != net::OK) { |
49 callback.Run(MakeNetworkError(net_error), NetAddressPtr()); | 49 callback.Run(MakeNetworkError(net_error), NetAddressPtr()); |
50 return; | 50 return; |
51 } | 51 } |
52 NetAddressPtr resulting_local_address(bound->GetLocalAddress()); | 52 NetAddressPtr resulting_local_address(bound->GetLocalAddress()); |
53 BindToRequest(bound.release(), &bound_socket); | 53 BindToRequest(bound.release(), &bound_socket); |
54 callback.Run(MakeNetworkError(net::OK), resulting_local_address.Pass()); | 54 callback.Run(MakeNetworkError(net::OK), resulting_local_address.Pass()); |
55 } | 55 } |
56 | 56 |
57 void NetworkServiceImpl::CreateTCPConnectedSocket( | 57 void NetworkServiceImpl::CreateTCPConnectedSocket( |
58 NetAddressPtr remote_address, | 58 NetAddressPtr remote_address, |
59 ScopedDataPipeConsumerHandle send_stream, | 59 ScopedDataPipeConsumerHandle send_stream, |
60 ScopedDataPipeProducerHandle receive_stream, | 60 ScopedDataPipeProducerHandle receive_stream, |
61 InterfaceRequest<TCPConnectedSocket> client_socket, | 61 InterfaceRequest<TCPConnectedSocket> client_socket, |
62 const Callback<void(NetworkErrorPtr, NetAddressPtr)>& callback) { | 62 const CreateTCPConnectedSocketCallback& callback) { |
63 // TODO(brettw) implement this. We need to know what type of socket to use | 63 // TODO(brettw) implement this. We need to know what type of socket to use |
64 // so we can create the right one (i.e. to pass to TCPSocket::Open) before | 64 // so we can create the right one (i.e. to pass to TCPSocket::Open) before |
65 // doing the connect. | 65 // doing the connect. |
66 callback.Run(MakeNetworkError(net::ERR_NOT_IMPLEMENTED), NetAddressPtr()); | 66 callback.Run(MakeNetworkError(net::ERR_NOT_IMPLEMENTED), NetAddressPtr()); |
67 } | 67 } |
68 | 68 |
69 void NetworkServiceImpl::CreateUDPSocket(InterfaceRequest<UDPSocket> request) { | 69 void NetworkServiceImpl::CreateUDPSocket(InterfaceRequest<UDPSocket> request) { |
70 // The lifetime of this UDPSocketImpl is bound to that of the underlying pipe. | 70 // The lifetime of this UDPSocketImpl is bound to that of the underlying pipe. |
71 new UDPSocketImpl(request.Pass()); | 71 new UDPSocketImpl(request.Pass()); |
72 } | 72 } |
73 | 73 |
| 74 void NetworkServiceImpl::CreateHttpServer( |
| 75 NetAddressPtr local_address, |
| 76 HttpServerDelegatePtr delegate, |
| 77 const CreateHttpServerCallback& callback) { |
| 78 // TODO(yzshen): implement this. |
| 79 callback.Run(MakeNetworkError(net::ERR_NOT_IMPLEMENTED), nullptr); |
| 80 } |
| 81 |
74 } // namespace mojo | 82 } // namespace mojo |
OLD | NEW |