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

Side by Side Diff: net/dns/host_resolver_mojo.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, 12 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
« no previous file with comments | « net/dns/host_resolver_impl.cc ('k') | net/dns/host_resolver_mojo_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/dns/host_resolver_mojo.h" 5 #include "net/dns/host_resolver_mojo.h"
6 6
7 #include <utility>
8
7 #include "mojo/public/cpp/bindings/binding.h" 9 #include "mojo/public/cpp/bindings/binding.h"
8 #include "net/base/address_list.h" 10 #include "net/base/address_list.h"
9 #include "net/base/net_errors.h" 11 #include "net/base/net_errors.h"
10 #include "net/dns/mojo_host_type_converters.h" 12 #include "net/dns/mojo_host_type_converters.h"
11 #include "net/log/net_log.h" 13 #include "net/log/net_log.h"
12 14
13 namespace net { 15 namespace net {
14 namespace { 16 namespace {
15 17
16 // Default TTL for successful host resolutions. 18 // Default TTL for successful host resolutions.
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 if (cached_result != ERR_DNS_CACHE_MISS) { 73 if (cached_result != ERR_DNS_CACHE_MISS) {
72 DVLOG(1) << "Resolved " << info.host_port_pair().ToString() 74 DVLOG(1) << "Resolved " << info.host_port_pair().ToString()
73 << " from cache"; 75 << " from cache";
74 return cached_result; 76 return cached_result;
75 } 77 }
76 78
77 interfaces::HostResolverRequestClientPtr handle; 79 interfaces::HostResolverRequestClientPtr handle;
78 *request_handle = new Job(key, addresses, callback, mojo::GetProxy(&handle), 80 *request_handle = new Job(key, addresses, callback, mojo::GetProxy(&handle),
79 host_cache_weak_factory_.GetWeakPtr()); 81 host_cache_weak_factory_.GetWeakPtr());
80 impl_->ResolveDns(interfaces::HostResolverRequestInfo::From(info), 82 impl_->ResolveDns(interfaces::HostResolverRequestInfo::From(info),
81 handle.Pass()); 83 std::move(handle));
82 return ERR_IO_PENDING; 84 return ERR_IO_PENDING;
83 } 85 }
84 86
85 int HostResolverMojo::ResolveFromCache(const RequestInfo& info, 87 int HostResolverMojo::ResolveFromCache(const RequestInfo& info,
86 AddressList* addresses, 88 AddressList* addresses,
87 const BoundNetLog& source_net_log) { 89 const BoundNetLog& source_net_log) {
88 DCHECK(thread_checker_.CalledOnValidThread()); 90 DCHECK(thread_checker_.CalledOnValidThread());
89 DVLOG(1) << "ResolveFromCache " << info.host_port_pair().ToString(); 91 DVLOG(1) << "ResolveFromCache " << info.host_port_pair().ToString();
90 return ResolveFromCacheInternal(info, CacheKeyForRequest(info), addresses); 92 return ResolveFromCacheInternal(info, CacheKeyForRequest(info), addresses);
91 } 93 }
(...skipping 26 matching lines...) Expand all
118 120
119 HostResolverMojo::Job::Job( 121 HostResolverMojo::Job::Job(
120 const HostCache::Key& key, 122 const HostCache::Key& key,
121 AddressList* addresses, 123 AddressList* addresses,
122 const CompletionCallback& callback, 124 const CompletionCallback& callback,
123 mojo::InterfaceRequest<interfaces::HostResolverRequestClient> request, 125 mojo::InterfaceRequest<interfaces::HostResolverRequestClient> request,
124 base::WeakPtr<HostCache> host_cache) 126 base::WeakPtr<HostCache> host_cache)
125 : key_(key), 127 : key_(key),
126 addresses_(addresses), 128 addresses_(addresses),
127 callback_(callback), 129 callback_(callback),
128 binding_(this, request.Pass()), 130 binding_(this, std::move(request)),
129 host_cache_(host_cache) { 131 host_cache_(host_cache) {
130 binding_.set_connection_error_handler(base::Bind( 132 binding_.set_connection_error_handler(base::Bind(
131 &HostResolverMojo::Job::OnConnectionError, base::Unretained(this))); 133 &HostResolverMojo::Job::OnConnectionError, base::Unretained(this)));
132 } 134 }
133 135
134 void HostResolverMojo::Job::ReportResult( 136 void HostResolverMojo::Job::ReportResult(
135 int32_t error, 137 int32_t error,
136 interfaces::AddressListPtr address_list) { 138 interfaces::AddressListPtr address_list) {
137 if (error == OK && address_list) 139 if (error == OK && address_list)
138 *addresses_ = address_list->To<AddressList>(); 140 *addresses_ = address_list->To<AddressList>();
139 if (host_cache_) { 141 if (host_cache_) {
140 base::TimeDelta ttl = base::TimeDelta::FromSeconds( 142 base::TimeDelta ttl = base::TimeDelta::FromSeconds(
141 error == OK ? kCacheEntryTTLSeconds : kNegativeCacheEntryTTLSeconds); 143 error == OK ? kCacheEntryTTLSeconds : kNegativeCacheEntryTTLSeconds);
142 HostCache::Entry entry(error, *addresses_, ttl); 144 HostCache::Entry entry(error, *addresses_, ttl);
143 host_cache_->Set(key_, entry, base::TimeTicks::Now(), ttl); 145 host_cache_->Set(key_, entry, base::TimeTicks::Now(), ttl);
144 } 146 }
145 callback_.Run(error); 147 callback_.Run(error);
146 delete this; 148 delete this;
147 } 149 }
148 150
149 void HostResolverMojo::Job::OnConnectionError() { 151 void HostResolverMojo::Job::OnConnectionError() {
150 ReportResult(ERR_FAILED, interfaces::AddressListPtr()); 152 ReportResult(ERR_FAILED, interfaces::AddressListPtr());
151 } 153 }
152 154
153 } // namespace net 155 } // namespace net
OLDNEW
« no previous file with comments | « net/dns/host_resolver_impl.cc ('k') | net/dns/host_resolver_mojo_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698