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

Side by Side Diff: net/proxy/mojo_proxy_resolver_impl.cc

Issue 1545233002: Convert Pass()→std::move() in //net (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "net/proxy/mojo_proxy_resolver_impl.h" 5 #include "net/proxy/mojo_proxy_resolver_impl.h"
6 6
7 #include <utility>
8
7 #include "base/macros.h" 9 #include "base/macros.h"
8 #include "base/stl_util.h" 10 #include "base/stl_util.h"
9 #include "mojo/common/url_type_converters.h" 11 #include "mojo/common/url_type_converters.h"
10 #include "net/base/net_errors.h" 12 #include "net/base/net_errors.h"
11 #include "net/log/net_log.h" 13 #include "net/log/net_log.h"
12 #include "net/proxy/mojo_proxy_resolver_v8_tracing_bindings.h" 14 #include "net/proxy/mojo_proxy_resolver_v8_tracing_bindings.h"
13 #include "net/proxy/mojo_proxy_type_converters.h" 15 #include "net/proxy/mojo_proxy_type_converters.h"
14 #include "net/proxy/proxy_info.h" 16 #include "net/proxy/proxy_info.h"
15 #include "net/proxy/proxy_resolver_script_data.h" 17 #include "net/proxy/proxy_resolver_script_data.h"
16 #include "net/proxy/proxy_resolver_v8_tracing.h" 18 #include "net/proxy/proxy_resolver_v8_tracing.h"
(...skipping 22 matching lines...) Expand all
39 ProxyInfo result_; 41 ProxyInfo result_;
40 GURL url_; 42 GURL url_;
41 net::ProxyResolver::RequestHandle request_handle_; 43 net::ProxyResolver::RequestHandle request_handle_;
42 bool done_; 44 bool done_;
43 45
44 DISALLOW_COPY_AND_ASSIGN(Job); 46 DISALLOW_COPY_AND_ASSIGN(Job);
45 }; 47 };
46 48
47 MojoProxyResolverImpl::MojoProxyResolverImpl( 49 MojoProxyResolverImpl::MojoProxyResolverImpl(
48 scoped_ptr<ProxyResolverV8Tracing> resolver) 50 scoped_ptr<ProxyResolverV8Tracing> resolver)
49 : resolver_(resolver.Pass()) { 51 : resolver_(std::move(resolver)) {}
50 }
51 52
52 MojoProxyResolverImpl::~MojoProxyResolverImpl() { 53 MojoProxyResolverImpl::~MojoProxyResolverImpl() {
53 STLDeleteElements(&resolve_jobs_); 54 STLDeleteElements(&resolve_jobs_);
54 } 55 }
55 56
56 void MojoProxyResolverImpl::GetProxyForUrl( 57 void MojoProxyResolverImpl::GetProxyForUrl(
57 const mojo::String& url, 58 const mojo::String& url,
58 interfaces::ProxyResolverRequestClientPtr client) { 59 interfaces::ProxyResolverRequestClientPtr client) {
59 DVLOG(1) << "GetProxyForUrl(" << url << ")"; 60 DVLOG(1) << "GetProxyForUrl(" << url << ")";
60 Job* job = new Job(client.Pass(), this, url.To<GURL>()); 61 Job* job = new Job(std::move(client), this, url.To<GURL>());
61 bool inserted = resolve_jobs_.insert(job).second; 62 bool inserted = resolve_jobs_.insert(job).second;
62 DCHECK(inserted); 63 DCHECK(inserted);
63 job->Start(); 64 job->Start();
64 } 65 }
65 66
66 void MojoProxyResolverImpl::DeleteJob(Job* job) { 67 void MojoProxyResolverImpl::DeleteJob(Job* job) {
67 size_t num_erased = resolve_jobs_.erase(job); 68 size_t num_erased = resolve_jobs_.erase(job);
68 DCHECK(num_erased); 69 DCHECK(num_erased);
69 delete job; 70 delete job;
70 } 71 }
71 72
72 MojoProxyResolverImpl::Job::Job( 73 MojoProxyResolverImpl::Job::Job(
73 interfaces::ProxyResolverRequestClientPtr client, 74 interfaces::ProxyResolverRequestClientPtr client,
74 MojoProxyResolverImpl* resolver, 75 MojoProxyResolverImpl* resolver,
75 const GURL& url) 76 const GURL& url)
76 : resolver_(resolver), 77 : resolver_(resolver),
77 client_(client.Pass()), 78 client_(std::move(client)),
78 url_(url), 79 url_(url),
79 request_handle_(nullptr), 80 request_handle_(nullptr),
80 done_(false) {} 81 done_(false) {}
81 82
82 MojoProxyResolverImpl::Job::~Job() { 83 MojoProxyResolverImpl::Job::~Job() {
83 if (request_handle_ && !done_) 84 if (request_handle_ && !done_)
84 resolver_->resolver_->CancelRequest(request_handle_); 85 resolver_->resolver_->CancelRequest(request_handle_);
85 } 86 }
86 87
87 void MojoProxyResolverImpl::Job::Start() { 88 void MojoProxyResolverImpl::Job::Start() {
(...skipping 11 matching lines...) Expand all
99 DVLOG(1) << "GetProxyForUrl(" << url_ << ") finished with error " << error 100 DVLOG(1) << "GetProxyForUrl(" << url_ << ") finished with error " << error
100 << ". " << result_.proxy_list().size() << " Proxies returned:"; 101 << ". " << result_.proxy_list().size() << " Proxies returned:";
101 for (const auto& proxy : result_.proxy_list().GetAll()) { 102 for (const auto& proxy : result_.proxy_list().GetAll()) {
102 DVLOG(1) << proxy.ToURI(); 103 DVLOG(1) << proxy.ToURI();
103 } 104 }
104 mojo::Array<interfaces::ProxyServerPtr> result; 105 mojo::Array<interfaces::ProxyServerPtr> result;
105 if (error == OK) { 106 if (error == OK) {
106 result = mojo::Array<interfaces::ProxyServerPtr>::From( 107 result = mojo::Array<interfaces::ProxyServerPtr>::From(
107 result_.proxy_list().GetAll()); 108 result_.proxy_list().GetAll());
108 } 109 }
109 client_->ReportResult(error, result.Pass()); 110 client_->ReportResult(error, std::move(result));
110 resolver_->DeleteJob(this); 111 resolver_->DeleteJob(this);
111 } 112 }
112 113
113 void MojoProxyResolverImpl::Job::OnConnectionError() { 114 void MojoProxyResolverImpl::Job::OnConnectionError() {
114 resolver_->DeleteJob(this); 115 resolver_->DeleteJob(this);
115 } 116 }
116 117
117 } // namespace net 118 } // namespace net
OLDNEW
« no previous file with comments | « net/proxy/mojo_proxy_resolver_factory_impl_unittest.cc ('k') | net/proxy/mojo_proxy_resolver_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698