OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/base/host_resolver_impl.h" | 5 #include "net/base/host_resolver_impl.h" |
6 | 6 |
7 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
8 #include <Winsock2.h> | 8 #include <Winsock2.h> |
9 #elif defined(OS_POSIX) | 9 #elif defined(OS_POSIX) |
10 #include <netdb.h> | 10 #include <netdb.h> |
11 #endif | 11 #endif |
12 | 12 |
13 #include <cmath> | 13 #include <cmath> |
14 #include <deque> | 14 #include <deque> |
15 #include <vector> | 15 #include <vector> |
16 | 16 |
17 #include "base/basictypes.h" | 17 #include "base/basictypes.h" |
18 #include "base/compiler_specific.h" | 18 #include "base/compiler_specific.h" |
19 #include "base/debug/debugger.h" | 19 #include "base/debug/debugger.h" |
20 #include "base/debug/stack_trace.h" | 20 #include "base/debug/stack_trace.h" |
21 #include "base/lock.h" | 21 #include "base/lock.h" |
22 #include "base/message_loop.h" | 22 #include "base/message_loop.h" |
23 #include "base/metrics/field_trial.h" | 23 #include "base/metrics/field_trial.h" |
24 #include "base/metrics/histogram.h" | 24 #include "base/metrics/histogram.h" |
25 #include "base/stl_util-inl.h" | 25 #include "base/stl_util-inl.h" |
26 #include "base/string_util.h" | 26 #include "base/string_util.h" |
27 #include "base/time.h" | 27 #include "base/time.h" |
28 #include "base/utf_string_conversions.h" | 28 #include "base/utf_string_conversions.h" |
29 #include "base/values.h" | 29 #include "base/values.h" |
30 #include "base/worker_pool.h" | 30 #include "base/worker_pool_job.h" |
31 #include "net/base/address_list.h" | 31 #include "net/base/address_list.h" |
32 #include "net/base/address_list_net_log_param.h" | 32 #include "net/base/address_list_net_log_param.h" |
33 #include "net/base/host_port_pair.h" | 33 #include "net/base/host_port_pair.h" |
34 #include "net/base/host_resolver_proc.h" | 34 #include "net/base/host_resolver_proc.h" |
35 #include "net/base/net_errors.h" | 35 #include "net/base/net_errors.h" |
36 #include "net/base/net_log.h" | 36 #include "net/base/net_log.h" |
37 #include "net/base/net_util.h" | 37 #include "net/base/net_util.h" |
38 | 38 |
39 #if defined(OS_WIN) | 39 #if defined(OS_WIN) |
40 #include "net/base/winsock_init.h" | 40 #include "net/base/winsock_init.h" |
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
331 | 331 |
332 //------------------------------------------------------------------------------ | 332 //------------------------------------------------------------------------------ |
333 | 333 |
334 // Provide a common macro to simplify code and readability. We must use a | 334 // Provide a common macro to simplify code and readability. We must use a |
335 // macros as the underlying HISTOGRAM macro creates static varibles. | 335 // macros as the underlying HISTOGRAM macro creates static varibles. |
336 #define DNS_HISTOGRAM(name, time) UMA_HISTOGRAM_CUSTOM_TIMES(name, time, \ | 336 #define DNS_HISTOGRAM(name, time) UMA_HISTOGRAM_CUSTOM_TIMES(name, time, \ |
337 base::TimeDelta::FromMicroseconds(1), base::TimeDelta::FromHours(1), 100) | 337 base::TimeDelta::FromMicroseconds(1), base::TimeDelta::FromHours(1), 100) |
338 | 338 |
339 // This class represents a request to the worker pool for a "getaddrinfo()" | 339 // This class represents a request to the worker pool for a "getaddrinfo()" |
340 // call. | 340 // call. |
341 class HostResolverImpl::Job | 341 class HostResolverImpl::Job : public base::WorkerPoolJob { |
342 : public base::RefCountedThreadSafe<HostResolverImpl::Job> { | |
343 public: | 342 public: |
344 Job(int id, | 343 Job(int id, |
345 HostResolverImpl* resolver, | 344 HostResolverImpl* resolver, |
346 const Key& key, | 345 const Key& key, |
347 const BoundNetLog& source_net_log, | 346 const BoundNetLog& source_net_log, |
348 NetLog* net_log) | 347 NetLog* net_log) |
349 : id_(id), | 348 : id_(id), |
350 key_(key), | 349 key_(key), |
351 resolver_(resolver), | 350 resolver_(resolver), |
352 origin_loop_(MessageLoop::current()), | |
353 resolver_proc_(resolver->effective_resolver_proc()), | 351 resolver_proc_(resolver->effective_resolver_proc()), |
354 error_(OK), | 352 error_(OK), |
355 os_error_(0), | 353 os_error_(0), |
356 had_non_speculative_request_(false), | 354 had_non_speculative_request_(false), |
357 net_log_(BoundNetLog::Make(net_log, | 355 net_log_(BoundNetLog::Make(net_log, |
358 NetLog::SOURCE_HOST_RESOLVER_IMPL_JOB)) { | 356 NetLog::SOURCE_HOST_RESOLVER_IMPL_JOB)) { |
359 net_log_.BeginEvent( | 357 net_log_.BeginEvent( |
360 NetLog::TYPE_HOST_RESOLVER_IMPL_JOB, | 358 NetLog::TYPE_HOST_RESOLVER_IMPL_JOB, |
361 make_scoped_refptr( | 359 make_scoped_refptr( |
362 new JobCreationParameters(key.hostname, source_net_log.source()))); | 360 new JobCreationParameters(key.hostname, source_net_log.source()))); |
(...skipping 11 matching lines...) Expand all Loading... |
374 requests_.push_back(req); | 372 requests_.push_back(req); |
375 | 373 |
376 if (!req->info().is_speculative()) | 374 if (!req->info().is_speculative()) |
377 had_non_speculative_request_ = true; | 375 had_non_speculative_request_ = true; |
378 } | 376 } |
379 | 377 |
380 // Called from origin loop. | 378 // Called from origin loop. |
381 void Start() { | 379 void Start() { |
382 start_time_ = base::TimeTicks::Now(); | 380 start_time_ = base::TimeTicks::Now(); |
383 | 381 |
384 // Dispatch the job to a worker thread. | 382 StartJob(); |
385 if (!WorkerPool::PostTask(FROM_HERE, | |
386 NewRunnableMethod(this, &Job::DoLookup), true)) { | |
387 NOTREACHED(); | |
388 | |
389 // Since we could be running within Resolve() right now, we can't just | |
390 // call OnLookupComplete(). Instead we must wait until Resolve() has | |
391 // returned (IO_PENDING). | |
392 error_ = ERR_UNEXPECTED; | |
393 MessageLoop::current()->PostTask( | |
394 FROM_HERE, NewRunnableMethod(this, &Job::OnLookupComplete)); | |
395 } | |
396 } | 383 } |
397 | 384 |
398 // Cancels the current job. Callable from origin thread. | 385 // Cancels the current job. Callable from origin thread. |
399 void Cancel() { | 386 void Cancel() { |
| 387 if (canceled()) |
| 388 return; |
| 389 |
| 390 CancelJob(); |
| 391 |
400 net_log_.AddEvent(NetLog::TYPE_CANCELLED, NULL); | 392 net_log_.AddEvent(NetLog::TYPE_CANCELLED, NULL); |
401 | 393 |
402 HostResolver* resolver = resolver_; | |
403 resolver_ = NULL; | |
404 | |
405 // Mark the job as cancelled, so when worker thread completes it will | |
406 // not try to post completion to origin loop. | |
407 { | |
408 AutoLock locked(origin_loop_lock_); | |
409 origin_loop_ = NULL; | |
410 } | |
411 | |
412 // End here to prevent issues when a Job outlives the HostResolver that | 394 // End here to prevent issues when a Job outlives the HostResolver that |
413 // spawned it. | 395 // spawned it. |
414 net_log_.EndEvent(NetLog::TYPE_HOST_RESOLVER_IMPL_JOB, NULL); | 396 net_log_.EndEvent(NetLog::TYPE_HOST_RESOLVER_IMPL_JOB, NULL); |
415 | 397 |
416 // We will call HostResolverImpl::CancelRequest(Request*) on each one | 398 // We will call HostResolverImpl::CancelRequest(Request*) on each one |
417 // in order to notify any observers. | 399 // in order to notify any observers. |
418 for (RequestsList::const_iterator it = requests_.begin(); | 400 for (RequestsList::const_iterator it = requests_.begin(); |
419 it != requests_.end(); ++it) { | 401 it != requests_.end(); ++it) { |
420 HostResolverImpl::Request* req = *it; | 402 HostResolverImpl::Request* req = *it; |
421 if (!req->was_cancelled()) | 403 if (!req->was_cancelled()) |
422 resolver->CancelRequest(req); | 404 resolver_->CancelRequest(req); |
423 } | 405 } |
424 } | 406 } |
425 | 407 |
426 // Called from origin thread. | 408 // Called from origin thread. |
427 bool was_cancelled() const { | |
428 return resolver_ == NULL; | |
429 } | |
430 | |
431 // Called from origin thread. | |
432 const Key& key() const { | 409 const Key& key() const { |
433 return key_; | 410 return key_; |
434 } | 411 } |
435 | 412 |
436 int id() const { | 413 int id() const { |
437 return id_; | 414 return id_; |
438 } | 415 } |
439 | 416 |
440 base::TimeTicks start_time() const { | 417 base::TimeTicks start_time() const { |
441 return start_time_; | 418 return start_time_; |
442 } | 419 } |
443 | 420 |
444 // Called from origin thread. | 421 // Called from origin thread. |
445 const RequestsList& requests() const { | 422 const RequestsList& requests() const { |
446 return requests_; | 423 return requests_; |
447 } | 424 } |
448 | 425 |
449 // Returns the first request attached to the job. | 426 // Returns the first request attached to the job. |
450 const Request* initial_request() const { | 427 const Request* initial_request() const { |
451 DCHECK_EQ(origin_loop_, MessageLoop::current()); | |
452 DCHECK(!requests_.empty()); | 428 DCHECK(!requests_.empty()); |
453 return requests_[0]; | 429 return requests_[0]; |
454 } | 430 } |
455 | 431 |
456 // Returns true if |req_info| can be fulfilled by this job. | 432 // Returns true if |req_info| can be fulfilled by this job. |
457 bool CanServiceRequest(const RequestInfo& req_info) const { | 433 bool CanServiceRequest(const RequestInfo& req_info) const { |
458 return key_ == resolver_->GetEffectiveKeyForRequest(req_info); | 434 return key_ == resolver_->GetEffectiveKeyForRequest(req_info); |
459 } | 435 } |
460 | 436 |
| 437 // TODO(willchan): Eliminate the need for this. |
| 438 using WorkerPoolJob::canceled; |
| 439 |
461 private: | 440 private: |
462 friend class base::RefCountedThreadSafe<HostResolverImpl::Job>; | 441 friend class base::RefCountedThreadSafe<HostResolverImpl::Job>; |
463 | 442 |
464 ~Job() { | 443 ~Job() { |
465 // Free the requests attached to this job. | 444 // Free the requests attached to this job. |
466 STLDeleteElements(&requests_); | 445 STLDeleteElements(&requests_); |
467 } | 446 } |
468 | 447 |
469 // WARNING: This code runs inside a worker pool. The shutdown code cannot | 448 // WARNING: This code runs inside a worker pool. The shutdown code cannot |
470 // wait for it to finish, so we must be very careful here about using other | 449 // wait for it to finish, so we must be very careful here about using other |
471 // objects (like MessageLoops, Singletons, etc). During shutdown these objects | 450 // objects (like MessageLoops, Singletons, etc). During shutdown these objects |
472 // may no longer exist. | 451 // may no longer exist. |
473 void DoLookup() { | 452 virtual void RunJob() { |
474 // Running on the worker thread | 453 // Running on the worker thread |
475 error_ = ResolveAddrInfo(resolver_proc_, | 454 error_ = ResolveAddrInfo(resolver_proc_, |
476 key_.hostname, | 455 key_.hostname, |
477 key_.address_family, | 456 key_.address_family, |
478 key_.host_resolver_flags, | 457 key_.host_resolver_flags, |
479 &results_, | 458 &results_, |
480 &os_error_); | 459 &os_error_); |
481 | |
482 // The origin loop could go away while we are trying to post to it, so we | |
483 // need to call its PostTask method inside a lock. See ~HostResolver. | |
484 { | |
485 AutoLock locked(origin_loop_lock_); | |
486 if (origin_loop_) { | |
487 origin_loop_->PostTask(FROM_HERE, | |
488 NewRunnableMethod(this, &Job::OnLookupComplete)); | |
489 } | |
490 } | |
491 } | 460 } |
492 | 461 |
493 // Callback for when DoLookup() completes (runs on origin thread). | 462 // Callback for when RunJob() completes (runs on origin thread). |
494 void OnLookupComplete() { | 463 virtual void CompleteJob() { |
495 // Should be running on origin loop. | |
496 // TODO(eroman): this is being hit by URLRequestTest.CancelTest*, | |
497 // because MessageLoop::current() == NULL. | |
498 //DCHECK_EQ(origin_loop_, MessageLoop::current()); | |
499 DCHECK(error_ || results_.head()); | 464 DCHECK(error_ || results_.head()); |
500 | 465 |
501 // Ideally the following code would be part of host_resolver_proc.cc, | 466 // Ideally the following code would be part of host_resolver_proc.cc, |
502 // however it isn't safe to call NetworkChangeNotifier from worker | 467 // however it isn't safe to call NetworkChangeNotifier from worker |
503 // threads. So we do it here on the IO thread instead. | 468 // threads. So we do it here on the IO thread instead. |
504 if (error_ != OK && NetworkChangeNotifier::IsOffline()) | 469 if (error_ != OK && NetworkChangeNotifier::IsOffline()) |
505 error_ = ERR_INTERNET_DISCONNECTED; | 470 error_ = ERR_INTERNET_DISCONNECTED; |
506 | 471 |
507 RecordPerformanceHistograms(); | 472 RecordPerformanceHistograms(); |
508 | 473 |
509 if (was_cancelled()) | |
510 return; | |
511 | |
512 scoped_refptr<NetLog::EventParameters> params; | 474 scoped_refptr<NetLog::EventParameters> params; |
513 if (error_ != OK) { | 475 if (error_ != OK) { |
514 params = new HostResolveFailedParams(error_, os_error_); | 476 params = new HostResolveFailedParams(error_, os_error_); |
515 } else { | 477 } else { |
516 params = new AddressListNetLogParam(results_); | 478 params = new AddressListNetLogParam(results_); |
517 } | 479 } |
518 | 480 |
519 // End here to prevent issues when a Job outlives the HostResolver that | 481 // End here to prevent issues when a Job outlives the HostResolver that |
520 // spawned it. | 482 // spawned it. |
521 net_log_.EndEvent(NetLog::TYPE_HOST_RESOLVER_IMPL_JOB, params); | 483 net_log_.EndEvent(NetLog::TYPE_HOST_RESOLVER_IMPL_JOB, params); |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
583 UMA_HISTOGRAM_ENUMERATION( | 545 UMA_HISTOGRAM_ENUMERATION( |
584 base::FieldTrial::MakeName("DNS.ResolveCategory", "DnsParallelism"), | 546 base::FieldTrial::MakeName("DNS.ResolveCategory", "DnsParallelism"), |
585 category, RESOLVE_MAX); | 547 category, RESOLVE_MAX); |
586 if (RESOLVE_SUCCESS == category) { | 548 if (RESOLVE_SUCCESS == category) { |
587 DNS_HISTOGRAM(base::FieldTrial::MakeName("DNS.ResolveSuccess", | 549 DNS_HISTOGRAM(base::FieldTrial::MakeName("DNS.ResolveSuccess", |
588 "DnsParallelism"), duration); | 550 "DnsParallelism"), duration); |
589 } | 551 } |
590 } | 552 } |
591 } | 553 } |
592 | 554 |
593 | |
594 | |
595 // Immutable. Can be read from either thread, | 555 // Immutable. Can be read from either thread, |
596 const int id_; | 556 const int id_; |
597 | 557 |
598 // Set on the origin thread, read on the worker thread. | 558 // Set on the origin thread, read on the worker thread. |
599 Key key_; | 559 Key key_; |
600 | 560 |
601 // Only used on the origin thread (where Resolve was called). | 561 // Only used on the origin thread (where Resolve was called). |
602 HostResolverImpl* resolver_; | 562 HostResolverImpl* resolver_; |
603 RequestsList requests_; // The requests waiting on this job. | 563 RequestsList requests_; // The requests waiting on this job. |
604 | 564 |
605 // Used to post ourselves onto the origin thread. | |
606 Lock origin_loop_lock_; | |
607 MessageLoop* origin_loop_; | |
608 | |
609 // Hold an owning reference to the HostResolverProc that we are going to use. | 565 // Hold an owning reference to the HostResolverProc that we are going to use. |
610 // This may not be the current resolver procedure by the time we call | 566 // This may not be the current resolver procedure by the time we call |
611 // ResolveAddrInfo, but that's OK... we'll use it anyways, and the owning | 567 // ResolveAddrInfo, but that's OK... we'll use it anyways, and the owning |
612 // reference ensures that it remains valid until we are done. | 568 // reference ensures that it remains valid until we are done. |
613 scoped_refptr<HostResolverProc> resolver_proc_; | 569 scoped_refptr<HostResolverProc> resolver_proc_; |
614 | 570 |
615 // Assigned on the worker thread, read on the origin thread. | 571 // Assigned on the worker thread, read on the origin thread. |
616 int error_; | 572 int error_; |
617 int os_error_; | 573 int os_error_; |
618 | 574 |
(...skipping 10 matching lines...) Expand all Loading... |
629 | 585 |
630 BoundNetLog net_log_; | 586 BoundNetLog net_log_; |
631 | 587 |
632 DISALLOW_COPY_AND_ASSIGN(Job); | 588 DISALLOW_COPY_AND_ASSIGN(Job); |
633 }; | 589 }; |
634 | 590 |
635 //----------------------------------------------------------------------------- | 591 //----------------------------------------------------------------------------- |
636 | 592 |
637 // This class represents a request to the worker pool for a "probe for IPv6 | 593 // This class represents a request to the worker pool for a "probe for IPv6 |
638 // support" call. | 594 // support" call. |
639 class HostResolverImpl::IPv6ProbeJob | 595 class HostResolverImpl::IPv6ProbeJob : public base::WorkerPoolJob { |
640 : public base::RefCountedThreadSafe<HostResolverImpl::IPv6ProbeJob> { | |
641 public: | 596 public: |
642 explicit IPv6ProbeJob(HostResolverImpl* resolver) | 597 explicit IPv6ProbeJob(HostResolverImpl* resolver) |
643 : resolver_(resolver), | 598 : resolver_(resolver), |
644 origin_loop_(MessageLoop::current()) { | 599 address_family_(ADDRESS_FAMILY_UNSPECIFIED) { |
645 DCHECK(!was_cancelled()); | 600 DCHECK(resolver_); |
646 } | 601 } |
647 | 602 |
648 void Start() { | 603 void Start() { StartJob(); } |
649 if (was_cancelled()) | 604 void Cancel() { CancelJob(); } |
650 return; | |
651 DCHECK(IsOnOriginThread()); | |
652 const bool kIsSlow = true; | |
653 WorkerPool::PostTask( | |
654 FROM_HERE, NewRunnableMethod(this, &IPv6ProbeJob::DoProbe), kIsSlow); | |
655 } | |
656 | |
657 // Cancels the current job. | |
658 void Cancel() { | |
659 if (was_cancelled()) | |
660 return; | |
661 DCHECK(IsOnOriginThread()); | |
662 resolver_ = NULL; // Read/write ONLY on origin thread. | |
663 { | |
664 AutoLock locked(origin_loop_lock_); | |
665 // Origin loop may be destroyed before we can use it! | |
666 origin_loop_ = NULL; // Write ONLY on origin thread. | |
667 } | |
668 } | |
669 | 605 |
670 private: | 606 private: |
671 friend class base::RefCountedThreadSafe<HostResolverImpl::IPv6ProbeJob>; | 607 friend class base::RefCountedThreadSafe<HostResolverImpl::IPv6ProbeJob>; |
672 | 608 |
673 ~IPv6ProbeJob() { | 609 ~IPv6ProbeJob() { |
674 } | 610 } |
675 | 611 |
676 // Should be run on |orgin_thread_|, but that may not be well defined now. | |
677 bool was_cancelled() const { | |
678 if (!resolver_ || !origin_loop_) { | |
679 DCHECK(!resolver_); | |
680 DCHECK(!origin_loop_); | |
681 return true; | |
682 } | |
683 return false; | |
684 } | |
685 | |
686 // Run on worker thread. | 612 // Run on worker thread. |
687 void DoProbe() { | 613 virtual void RunJob() { |
688 // Do actual testing on this thread, as it takes 40-100ms. | 614 // Do actual testing on this thread, as it takes 40-100ms. |
689 AddressFamily family = IPv6Supported() ? ADDRESS_FAMILY_UNSPECIFIED | 615 address_family_ = IPv6Supported() ? ADDRESS_FAMILY_UNSPECIFIED |
690 : ADDRESS_FAMILY_IPV4; | 616 : ADDRESS_FAMILY_IPV4; |
691 | |
692 Task* reply = NewRunnableMethod(this, &IPv6ProbeJob::OnProbeComplete, | |
693 family); | |
694 | |
695 // The origin loop could go away while we are trying to post to it, so we | |
696 // need to call its PostTask method inside a lock. See ~HostResolver. | |
697 { | |
698 AutoLock locked(origin_loop_lock_); | |
699 if (origin_loop_) { | |
700 origin_loop_->PostTask(FROM_HERE, reply); | |
701 return; | |
702 } | |
703 } | |
704 | |
705 // We didn't post, so delete the reply. | |
706 delete reply; | |
707 } | 617 } |
708 | 618 |
709 // Callback for when DoProbe() completes (runs on origin thread). | 619 // Callback for when DoProbe() completes (runs on origin thread). |
710 void OnProbeComplete(AddressFamily address_family) { | 620 virtual void CompleteJob() { |
711 if (was_cancelled()) | 621 resolver_->IPv6ProbeSetDefaultAddressFamily(address_family_); |
712 return; | |
713 DCHECK(IsOnOriginThread()); | |
714 resolver_->IPv6ProbeSetDefaultAddressFamily(address_family); | |
715 } | |
716 | |
717 bool IsOnOriginThread() const { | |
718 return !MessageLoop::current() || origin_loop_ == MessageLoop::current(); | |
719 } | 622 } |
720 | 623 |
721 // Used/set only on origin thread. | 624 // Used/set only on origin thread. |
722 HostResolverImpl* resolver_; | 625 HostResolverImpl* const resolver_; |
723 | 626 |
724 // Used to post ourselves onto the origin thread. | 627 AddressFamily address_family_; |
725 Lock origin_loop_lock_; | |
726 MessageLoop* origin_loop_; | |
727 | 628 |
728 DISALLOW_COPY_AND_ASSIGN(IPv6ProbeJob); | 629 DISALLOW_COPY_AND_ASSIGN(IPv6ProbeJob); |
729 }; | 630 }; |
730 | 631 |
731 //----------------------------------------------------------------------------- | 632 //----------------------------------------------------------------------------- |
732 | 633 |
733 // We rely on the priority enum values being sequential having starting at 0, | 634 // We rely on the priority enum values being sequential having starting at 0, |
734 // and increasing for lower priorities. | 635 // and increasing for lower priorities. |
735 COMPILE_ASSERT(HIGHEST == 0u && | 636 COMPILE_ASSERT(HIGHEST == 0u && |
736 LOWEST > HIGHEST && | 637 LOWEST > HIGHEST && |
(...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1223 NetLog::TYPE_HOST_RESOLVER_IMPL_JOB_ATTACH, NULL); | 1124 NetLog::TYPE_HOST_RESOLVER_IMPL_JOB_ATTACH, NULL); |
1224 | 1125 |
1225 // Update the net log and notify registered observers. | 1126 // Update the net log and notify registered observers. |
1226 OnFinishRequest(req->source_net_log(), req->request_net_log(), req->id(), | 1127 OnFinishRequest(req->source_net_log(), req->request_net_log(), req->id(), |
1227 req->info(), net_error, os_error); | 1128 req->info(), net_error, os_error); |
1228 | 1129 |
1229 req->OnComplete(net_error, addrlist); | 1130 req->OnComplete(net_error, addrlist); |
1230 | 1131 |
1231 // Check if the job was cancelled as a result of running the callback. | 1132 // Check if the job was cancelled as a result of running the callback. |
1232 // (Meaning that |this| was deleted). | 1133 // (Meaning that |this| was deleted). |
1233 if (job->was_cancelled()) | 1134 if (job->canceled()) |
1234 return; | 1135 return; |
1235 } | 1136 } |
1236 } | 1137 } |
1237 | 1138 |
1238 cur_completing_job_ = NULL; | 1139 cur_completing_job_ = NULL; |
1239 } | 1140 } |
1240 | 1141 |
1241 void HostResolverImpl::OnStartRequest(const BoundNetLog& source_net_log, | 1142 void HostResolverImpl::OnStartRequest(const BoundNetLog& source_net_log, |
1242 const BoundNetLog& request_net_log, | 1143 const BoundNetLog& request_net_log, |
1243 int request_id, | 1144 int request_id, |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1452 job_pools_[i]->ResetNumOutstandingJobs(); | 1353 job_pools_[i]->ResetNumOutstandingJobs(); |
1453 JobMap jobs; | 1354 JobMap jobs; |
1454 jobs.swap(jobs_); | 1355 jobs.swap(jobs_); |
1455 for (JobMap::iterator it = jobs.begin(); it != jobs.end(); ++it) { | 1356 for (JobMap::iterator it = jobs.begin(); it != jobs.end(); ++it) { |
1456 AbortJob(it->second); | 1357 AbortJob(it->second); |
1457 it->second->Cancel(); | 1358 it->second->Cancel(); |
1458 } | 1359 } |
1459 } | 1360 } |
1460 | 1361 |
1461 } // namespace net | 1362 } // namespace net |
OLD | NEW |