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

Side by Side Diff: net/tools/gdig/gdig.cc

Issue 2116983002: Change HostResolver::Resolve() to take an std::unique_ptr<Request>* rather than a RequestHandle* (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: mmenke's comments and rebasing Created 4 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <stdio.h> 5 #include <stdio.h>
6 6
7 #include <memory> 7 #include <memory>
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 unsigned replay_log_index_; 224 unsigned replay_log_index_;
225 base::Time start_time_; 225 base::Time start_time_;
226 int active_resolves_; 226 int active_resolves_;
227 Result result_; 227 Result result_;
228 228
229 base::CancelableClosure timeout_closure_; 229 base::CancelableClosure timeout_closure_;
230 std::unique_ptr<DnsConfigService> dns_config_service_; 230 std::unique_ptr<DnsConfigService> dns_config_service_;
231 std::unique_ptr<FileNetLogObserver> log_observer_; 231 std::unique_ptr<FileNetLogObserver> log_observer_;
232 std::unique_ptr<NetLog> log_; 232 std::unique_ptr<NetLog> log_;
233 std::unique_ptr<HostResolver> resolver_; 233 std::unique_ptr<HostResolver> resolver_;
234 std::unique_ptr<HostResolver::Request> request_;
234 235
235 #if defined(OS_MACOSX) 236 #if defined(OS_MACOSX)
236 // Without this there will be a mem leak on osx. 237 // Without this there will be a mem leak on osx.
237 base::mac::ScopedNSAutoreleasePool scoped_pool_; 238 base::mac::ScopedNSAutoreleasePool scoped_pool_;
238 #endif 239 #endif
239 240
240 // Need AtExitManager to support AsWeakPtr (in NetLog). 241 // Need AtExitManager to support AsWeakPtr (in NetLog).
241 base::AtExitManager exit_manager_; 242 base::AtExitManager exit_manager_;
242 }; 243 };
243 244
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
458 } 459 }
459 460
460 HostResolver::RequestInfo info(HostPortPair(entry.domain_name.c_str(), 80)); 461 HostResolver::RequestInfo info(HostPortPair(entry.domain_name.c_str(), 80));
461 AddressList* addrlist = new AddressList(); 462 AddressList* addrlist = new AddressList();
462 unsigned current_index = replay_log_index_; 463 unsigned current_index = replay_log_index_;
463 CompletionCallback callback = base::Bind(&GDig::OnResolveComplete, 464 CompletionCallback callback = base::Bind(&GDig::OnResolveComplete,
464 base::Unretained(this), 465 base::Unretained(this),
465 current_index, 466 current_index,
466 base::Owned(addrlist), 467 base::Owned(addrlist),
467 time_since_start); 468 time_since_start);
469 std::unique_ptr<HostResolver::Request> request;
mmenke 2016/07/21 16:00:40 Not needed.
maksims (do not use this acc) 2016/07/22 10:16:00 Done.
468 ++active_resolves_; 470 ++active_resolves_;
469 ++replay_log_index_; 471 ++replay_log_index_;
470 int ret = resolver_->Resolve( 472 int ret = resolver_->Resolve(
471 info, 473 info, DEFAULT_PRIORITY, addrlist, callback, &request,
472 DEFAULT_PRIORITY,
473 addrlist,
474 callback,
475 NULL,
476 BoundNetLog::Make(log_.get(), net::NetLog::SOURCE_NONE)); 474 BoundNetLog::Make(log_.get(), net::NetLog::SOURCE_NONE));
477 if (ret != ERR_IO_PENDING) 475 if (ret != ERR_IO_PENDING)
478 callback.Run(ret); 476 callback.Run(ret);
477 else if (ret == ERR_IO_PENDING)
478 request_ = std::move(request);
479 } 479 }
480 } 480 }
481 481
482 void GDig::OnResolveComplete(unsigned entry_index, 482 void GDig::OnResolveComplete(unsigned entry_index,
483 AddressList* address_list, 483 AddressList* address_list,
484 base::TimeDelta resolve_start_time, 484 base::TimeDelta resolve_start_time,
485 int val) { 485 int val) {
486 DCHECK_GT(active_resolves_, 0); 486 DCHECK_GT(active_resolves_, 0);
487 DCHECK(address_list); 487 DCHECK(address_list);
488 DCHECK_LT(entry_index, replay_log_.size()); 488 DCHECK_LT(entry_index, replay_log_.size());
(...skipping 26 matching lines...) Expand all
515 } 515 }
516 516
517 } // empty namespace 517 } // empty namespace
518 518
519 } // namespace net 519 } // namespace net
520 520
521 int main(int argc, const char* argv[]) { 521 int main(int argc, const char* argv[]) {
522 net::GDig dig; 522 net::GDig dig;
523 return dig.Main(argc, argv); 523 return dig.Main(argc, argv);
524 } 524 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698