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

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

Issue 1539863002: Convert Pass()→std::move() in mojo/services/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix missing forward declare that was masked by pre-existing incorrect #include ordering. Created 5 years 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 <utility>
8
7 #include "mojo/services/network/http_server_impl.h" 9 #include "mojo/services/network/http_server_impl.h"
8 #include "mojo/services/network/net_adapters.h" 10 #include "mojo/services/network/net_adapters.h"
9 #include "mojo/services/network/tcp_bound_socket_impl.h" 11 #include "mojo/services/network/tcp_bound_socket_impl.h"
10 #include "mojo/services/network/udp_socket_impl.h" 12 #include "mojo/services/network/udp_socket_impl.h"
11 #include "mojo/services/network/url_loader_impl.h" 13 #include "mojo/services/network/url_loader_impl.h"
12 #include "net/base/mime_util.h" 14 #include "net/base/mime_util.h"
13 15
14 namespace mojo { 16 namespace mojo {
15 17
16 NetworkServiceImpl::NetworkServiceImpl( 18 NetworkServiceImpl::NetworkServiceImpl(
17 scoped_ptr<mojo::AppRefCount> app_refcount, 19 scoped_ptr<mojo::AppRefCount> app_refcount,
18 InterfaceRequest<NetworkService> request) 20 InterfaceRequest<NetworkService> request)
19 : app_refcount_(app_refcount.Pass()), 21 : app_refcount_(std::move(app_refcount)),
20 binding_(this, request.Pass()) { 22 binding_(this, std::move(request)) {}
21 }
22 23
23 NetworkServiceImpl::~NetworkServiceImpl() { 24 NetworkServiceImpl::~NetworkServiceImpl() {
24 } 25 }
25 26
26 void NetworkServiceImpl::CreateTCPBoundSocket( 27 void NetworkServiceImpl::CreateTCPBoundSocket(
27 NetAddressPtr local_address, 28 NetAddressPtr local_address,
28 InterfaceRequest<TCPBoundSocket> bound_socket, 29 InterfaceRequest<TCPBoundSocket> bound_socket,
29 const CreateTCPBoundSocketCallback& callback) { 30 const CreateTCPBoundSocketCallback& callback) {
30 scoped_ptr<TCPBoundSocketImpl> bound(new TCPBoundSocketImpl( 31 scoped_ptr<TCPBoundSocketImpl> bound(
31 app_refcount_->Clone(), bound_socket.Pass())); 32 new TCPBoundSocketImpl(app_refcount_->Clone(), std::move(bound_socket)));
32 int net_error = bound->Bind(local_address.Pass()); 33 int net_error = bound->Bind(std::move(local_address));
33 if (net_error != net::OK) { 34 if (net_error != net::OK) {
34 callback.Run(MakeNetworkError(net_error), NetAddressPtr()); 35 callback.Run(MakeNetworkError(net_error), NetAddressPtr());
35 return; 36 return;
36 } 37 }
37 ignore_result(bound.release()); // Strongly owned by the message pipe. 38 ignore_result(bound.release()); // Strongly owned by the message pipe.
38 NetAddressPtr resulting_local_address(bound->GetLocalAddress()); 39 NetAddressPtr resulting_local_address(bound->GetLocalAddress());
39 callback.Run(MakeNetworkError(net::OK), resulting_local_address.Pass()); 40 callback.Run(MakeNetworkError(net::OK), std::move(resulting_local_address));
40 } 41 }
41 42
42 void NetworkServiceImpl::CreateTCPConnectedSocket( 43 void NetworkServiceImpl::CreateTCPConnectedSocket(
43 NetAddressPtr remote_address, 44 NetAddressPtr remote_address,
44 ScopedDataPipeConsumerHandle send_stream, 45 ScopedDataPipeConsumerHandle send_stream,
45 ScopedDataPipeProducerHandle receive_stream, 46 ScopedDataPipeProducerHandle receive_stream,
46 InterfaceRequest<TCPConnectedSocket> client_socket, 47 InterfaceRequest<TCPConnectedSocket> client_socket,
47 const CreateTCPConnectedSocketCallback& callback) { 48 const CreateTCPConnectedSocketCallback& callback) {
48 // TODO(brettw) implement this. We need to know what type of socket to use 49 // TODO(brettw) implement this. We need to know what type of socket to use
49 // so we can create the right one (i.e. to pass to TCPSocket::Open) before 50 // so we can create the right one (i.e. to pass to TCPSocket::Open) before
50 // doing the connect. 51 // doing the connect.
51 callback.Run(MakeNetworkError(net::ERR_NOT_IMPLEMENTED), NetAddressPtr()); 52 callback.Run(MakeNetworkError(net::ERR_NOT_IMPLEMENTED), NetAddressPtr());
52 } 53 }
53 54
54 void NetworkServiceImpl::CreateUDPSocket(InterfaceRequest<UDPSocket> request) { 55 void NetworkServiceImpl::CreateUDPSocket(InterfaceRequest<UDPSocket> request) {
55 // The lifetime of this UDPSocketImpl is bound to that of the underlying pipe. 56 // The lifetime of this UDPSocketImpl is bound to that of the underlying pipe.
56 new UDPSocketImpl(request.Pass(), app_refcount_->Clone()); 57 new UDPSocketImpl(std::move(request), app_refcount_->Clone());
57 } 58 }
58 59
59 void NetworkServiceImpl::CreateHttpServer( 60 void NetworkServiceImpl::CreateHttpServer(
60 NetAddressPtr local_address, 61 NetAddressPtr local_address,
61 HttpServerDelegatePtr delegate, 62 HttpServerDelegatePtr delegate,
62 const CreateHttpServerCallback& callback) { 63 const CreateHttpServerCallback& callback) {
63 HttpServerImpl::Create(local_address.Pass(), delegate.Pass(), 64 HttpServerImpl::Create(std::move(local_address), std::move(delegate),
64 app_refcount_->Clone(), callback); 65 app_refcount_->Clone(), callback);
65 } 66 }
66 67
67 void NetworkServiceImpl::GetMimeTypeFromFile( 68 void NetworkServiceImpl::GetMimeTypeFromFile(
68 const mojo::String& file_path, 69 const mojo::String& file_path,
69 const GetMimeTypeFromFileCallback& callback) { 70 const GetMimeTypeFromFileCallback& callback) {
70 std::string mime; 71 std::string mime;
71 net::GetMimeTypeFromFile( 72 net::GetMimeTypeFromFile(
72 base::FilePath::FromUTF8Unsafe(file_path.To<std::string>()), &mime); 73 base::FilePath::FromUTF8Unsafe(file_path.To<std::string>()), &mime);
73 callback.Run(mime); 74 callback.Run(mime);
74 } 75 }
75 76
76 } // namespace mojo 77 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/services/network/network_service_delegate.cc ('k') | mojo/services/network/public/cpp/udp_socket_wrapper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698