Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(666)

Side by Side Diff: mojo/services/network/network_service_impl.cc

Issue 1227373002: Roll mojo SDK to 734c6e1652ff2f3b696e441722838f453f4f9b42 (Closed) Base URL: https://github.com/domokit/monet.git@master
Patch Set: Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/host_resolver_impl.h" 8 #include "mojo/services/network/host_resolver_impl.h"
9 #include "mojo/services/network/http_server_impl.h" 9 #include "mojo/services/network/http_server_impl.h"
10 #include "mojo/services/network/net_adapters.h" 10 #include "mojo/services/network/net_adapters.h"
11 #include "mojo/services/network/tcp_bound_socket_impl.h" 11 #include "mojo/services/network/tcp_bound_socket_impl.h"
12 #include "mojo/services/network/udp_socket_impl.h" 12 #include "mojo/services/network/udp_socket_impl.h"
13 #include "mojo/services/network/url_loader_impl.h" 13 #include "mojo/services/network/url_loader_impl.h"
14 #include "mojo/services/network/web_socket_impl.h" 14 #include "mojo/services/network/web_socket_impl.h"
15 #include "third_party/mojo/src/mojo/public/cpp/application/application_connectio n.h" 15 #include "third_party/mojo/src/mojo/public/cpp/application/application_connectio n.h"
16 16
17 namespace mojo { 17 namespace mojo {
18 18
19 NetworkServiceImpl::NetworkServiceImpl(ApplicationConnection* connection, 19 NetworkServiceImpl::NetworkServiceImpl(InterfaceRequest<NetworkService> request,
20 ApplicationConnection* connection,
20 NetworkContext* context) 21 NetworkContext* context)
21 : context_(context), 22 : context_(context),
22 origin_(GURL(connection->GetRemoteApplicationURL()).GetOrigin()) { 23 origin_(GURL(connection->GetRemoteApplicationURL()).GetOrigin()),
24 binding_(this, request.Pass()) {
23 } 25 }
24 26
25 NetworkServiceImpl::~NetworkServiceImpl() { 27 NetworkServiceImpl::~NetworkServiceImpl() {
26 } 28 }
27 29
28 void NetworkServiceImpl::CreateURLLoader(InterfaceRequest<URLLoader> loader) { 30 void NetworkServiceImpl::CreateURLLoader(InterfaceRequest<URLLoader> loader) {
29 // TODO(darin): Plumb origin_. Use for CORS. 31 // TODO(darin): Plumb origin_. Use for CORS.
30 // The loader will delete itself when the pipe is closed, unless a request is 32 // The loader will delete itself when the pipe is closed, unless a request is
31 // in progress. In which case, the loader will delete itself when the request 33 // in progress. In which case, the loader will delete itself when the request
32 // is finished. 34 // is finished.
33 std::vector<URLLoaderInterceptorPtr> interceptors; 35 std::vector<URLLoaderInterceptorPtr> interceptors;
34 url_loader_interceptor_factories_.ForAllPtrs( 36 url_loader_interceptor_factories_.ForAllPtrs(
35 [&interceptors](URLLoaderInterceptorFactory* factory) { 37 [&interceptors](URLLoaderInterceptorFactory* factory) {
36 URLLoaderInterceptorPtr interceptor; 38 URLLoaderInterceptorPtr interceptor;
37 factory->Create(GetProxy(&interceptor)); 39 factory->Create(GetProxy(&interceptor));
38 interceptors.push_back(interceptor.Pass()); 40 interceptors.push_back(interceptor.Pass());
39 }); 41 });
40 new URLLoaderImpl(context_, loader.Pass(), std::move(interceptors)); 42 new URLLoaderImpl(context_, loader.Pass(), std::move(interceptors));
41 } 43 }
42 44
43 void NetworkServiceImpl::GetCookieStore(InterfaceRequest<CookieStore> store) { 45 void NetworkServiceImpl::GetCookieStore(InterfaceRequest<CookieStore> store) {
44 BindToRequest(new CookieStoreImpl(context_, origin_), &store); 46 new CookieStoreImpl(store.Pass(), context_, origin_);
45 } 47 }
46 48
47 void NetworkServiceImpl::CreateWebSocket(InterfaceRequest<WebSocket> socket) { 49 void NetworkServiceImpl::CreateWebSocket(InterfaceRequest<WebSocket> socket) {
48 BindToRequest(new WebSocketImpl(context_), &socket); 50 new WebSocketImpl(socket.Pass(), context_);
49 } 51 }
50 52
51 void NetworkServiceImpl::CreateTCPBoundSocket( 53 void NetworkServiceImpl::CreateTCPBoundSocket(
52 NetAddressPtr local_address, 54 NetAddressPtr local_address,
53 InterfaceRequest<TCPBoundSocket> bound_socket, 55 InterfaceRequest<TCPBoundSocket> bound_socket,
54 const CreateTCPBoundSocketCallback& callback) { 56 const CreateTCPBoundSocketCallback& callback) {
55 scoped_ptr<TCPBoundSocketImpl> bound(new TCPBoundSocketImpl); 57 scoped_ptr<TCPBoundSocketImpl> bound(
58 new TCPBoundSocketImpl(bound_socket.Pass()));
56 int net_error = bound->Bind(local_address.Pass()); 59 int net_error = bound->Bind(local_address.Pass());
57 if (net_error != net::OK) { 60 if (net_error != net::OK) {
58 callback.Run(MakeNetworkError(net_error), NetAddressPtr()); 61 callback.Run(MakeNetworkError(net_error), NetAddressPtr());
59 return; 62 return;
60 } 63 }
61 NetAddressPtr resulting_local_address(bound->GetLocalAddress()); 64 NetAddressPtr resulting_local_address(bound->GetLocalAddress());
62 BindToRequest(bound.release(), &bound_socket); 65 // Release the implementation and let its lifecycle be managed by the pipe.
66 ignore_result(bound.release());
63 callback.Run(MakeNetworkError(net::OK), resulting_local_address.Pass()); 67 callback.Run(MakeNetworkError(net::OK), resulting_local_address.Pass());
64 } 68 }
65 69
66 void NetworkServiceImpl::CreateTCPConnectedSocket( 70 void NetworkServiceImpl::CreateTCPConnectedSocket(
67 NetAddressPtr remote_address, 71 NetAddressPtr remote_address,
68 ScopedDataPipeConsumerHandle send_stream, 72 ScopedDataPipeConsumerHandle send_stream,
69 ScopedDataPipeProducerHandle receive_stream, 73 ScopedDataPipeProducerHandle receive_stream,
70 InterfaceRequest<TCPConnectedSocket> client_socket, 74 InterfaceRequest<TCPConnectedSocket> client_socket,
71 const CreateTCPConnectedSocketCallback& callback) { 75 const CreateTCPConnectedSocketCallback& callback) {
72 // TODO(brettw) implement this. We need to know what type of socket to use 76 // TODO(brettw) implement this. We need to know what type of socket to use
(...skipping 20 matching lines...) Expand all
93 } 97 }
94 98
95 void NetworkServiceImpl::CreateHostResolver( 99 void NetworkServiceImpl::CreateHostResolver(
96 InterfaceRequest<HostResolver> host_resolver) { 100 InterfaceRequest<HostResolver> host_resolver) {
97 // The lifetime of this HostResolverImpl is bound to that of the underlying 101 // The lifetime of this HostResolverImpl is bound to that of the underlying
98 // pipe. 102 // pipe.
99 new HostResolverImpl(host_resolver.Pass()); 103 new HostResolverImpl(host_resolver.Pass());
100 } 104 }
101 105
102 } // namespace mojo 106 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698