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/public/cpp/application/application_connection.h" | 7 #include "mojo/public/cpp/application/application_connection.h" |
8 #include "mojo/services/network/cookie_store_impl.h" | 8 #include "mojo/services/network/cookie_store_impl.h" |
9 #include "mojo/services/network/net_adapters.h" | 9 #include "mojo/services/network/net_adapters.h" |
10 #include "mojo/services/network/tcp_bound_socket_impl.h" | 10 #include "mojo/services/network/tcp_bound_socket_impl.h" |
11 #include "mojo/services/network/udp_socket_impl.h" | 11 #include "mojo/services/network/udp_socket_impl.h" |
12 #include "mojo/services/network/url_loader_impl.h" | 12 #include "mojo/services/network/url_loader_impl.h" |
13 #include "mojo/services/network/web_socket_impl.h" | 13 #include "mojo/services/network/web_socket_impl.h" |
14 | 14 |
15 namespace mojo { | 15 namespace mojo { |
16 | 16 |
17 NetworkServiceImpl::NetworkServiceImpl(ApplicationConnection* connection, | 17 NetworkServiceImpl::NetworkServiceImpl(ApplicationConnection* connection, |
18 NetworkContext* context) | 18 NetworkContext* context) |
19 : context_(context), | 19 : context_(context), |
20 origin_(GURL(connection->GetRemoteApplicationURL()).GetOrigin()) { | 20 origin_(GURL(connection->GetRemoteApplicationURL()).GetOrigin()) { |
21 } | 21 } |
22 | 22 |
23 NetworkServiceImpl::~NetworkServiceImpl() { | 23 NetworkServiceImpl::~NetworkServiceImpl() { |
24 } | 24 } |
25 | 25 |
26 void NetworkServiceImpl::CreateURLLoader(InterfaceRequest<URLLoader> loader) { | 26 void NetworkServiceImpl::CreateURLLoader(InterfaceRequest<URLLoader> loader) { |
27 // TODO(darin): Plumb origin_. Use for CORS. | 27 // TODO(darin): Plumb origin_. Use for CORS. |
28 BindToRequest(new URLLoaderImpl(context_), &loader); | 28 // The loader will delete itself when the pipe is closed, unless a request is |
| 29 // in progress. In which case, the loader will delete itself when the request |
| 30 // is finished. |
| 31 new URLLoaderImpl(context_, loader.Pass()); |
29 } | 32 } |
30 | 33 |
31 void NetworkServiceImpl::GetCookieStore(InterfaceRequest<CookieStore> store) { | 34 void NetworkServiceImpl::GetCookieStore(InterfaceRequest<CookieStore> store) { |
32 BindToRequest(new CookieStoreImpl(context_, origin_), &store); | 35 BindToRequest(new CookieStoreImpl(context_, origin_), &store); |
33 } | 36 } |
34 | 37 |
35 void NetworkServiceImpl::CreateWebSocket(InterfaceRequest<WebSocket> socket) { | 38 void NetworkServiceImpl::CreateWebSocket(InterfaceRequest<WebSocket> socket) { |
36 BindToRequest(new WebSocketImpl(context_), &socket); | 39 BindToRequest(new WebSocketImpl(context_), &socket); |
37 } | 40 } |
38 | 41 |
(...skipping 22 matching lines...) Expand all Loading... |
61 // 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 |
62 // doing the connect. | 65 // doing the connect. |
63 callback.Run(MakeNetworkError(net::ERR_NOT_IMPLEMENTED), NetAddressPtr()); | 66 callback.Run(MakeNetworkError(net::ERR_NOT_IMPLEMENTED), NetAddressPtr()); |
64 } | 67 } |
65 | 68 |
66 void NetworkServiceImpl::CreateUDPSocket(InterfaceRequest<UDPSocket> socket) { | 69 void NetworkServiceImpl::CreateUDPSocket(InterfaceRequest<UDPSocket> socket) { |
67 BindToRequest(new UDPSocketImpl(), &socket); | 70 BindToRequest(new UDPSocketImpl(), &socket); |
68 } | 71 } |
69 | 72 |
70 } // namespace mojo | 73 } // namespace mojo |
OLD | NEW |