Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/proxy_resolver_v8_tracing.h" | 5 #include "net/proxy/proxy_resolver_v8_tracing.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/message_loop/message_loop_proxy.h" | 8 #include "base/message_loop/message_loop_proxy.h" |
| 9 #include "base/profiler/scoped_tracker.h" | 9 #include "base/profiler/scoped_tracker.h" |
| 10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
| (...skipping 689 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 700 if (!pending_dns_completed_synchronously_) | 700 if (!pending_dns_completed_synchronously_) |
| 701 host_resolver()->CancelRequest(dns_request); | 701 host_resolver()->CancelRequest(dns_request); |
| 702 return; | 702 return; |
| 703 } | 703 } |
| 704 | 704 |
| 705 if (pending_dns_completed_synchronously_) { | 705 if (pending_dns_completed_synchronously_) { |
| 706 OnDnsOperationComplete(result); | 706 OnDnsOperationComplete(result); |
| 707 } else { | 707 } else { |
| 708 DCHECK(dns_request); | 708 DCHECK(dns_request); |
| 709 pending_dns_ = dns_request; | 709 pending_dns_ = dns_request; |
| 710 if (!parent_->on_load_state_changed_.is_null()) { | |
| 711 parent_->on_load_state_changed_.Run( | |
| 712 this, LOAD_STATE_RESOLVING_HOST_IN_PROXY_SCRIPT); | |
| 713 } | |
| 710 // OnDnsOperationComplete() will be called by host resolver on completion. | 714 // OnDnsOperationComplete() will be called by host resolver on completion. |
| 711 } | 715 } |
| 712 | 716 |
| 713 if (!blocking_dns_) { | 717 if (!blocking_dns_) { |
| 714 // The worker thread always blocks waiting to see if the result can be | 718 // The worker thread always blocks waiting to see if the result can be |
| 715 // serviced from cache before restarting. | 719 // serviced from cache before restarting. |
| 716 event_.Signal(); | 720 event_.Signal(); |
| 717 } | 721 } |
| 718 } | 722 } |
| 719 | 723 |
| 720 void ProxyResolverV8Tracing::Job::OnDnsOperationComplete(int result) { | 724 void ProxyResolverV8Tracing::Job::OnDnsOperationComplete(int result) { |
| 721 // TODO(vadimt): Remove ScopedTracker below once crbug.com/436634 is fixed. | 725 // TODO(vadimt): Remove ScopedTracker below once crbug.com/436634 is fixed. |
| 722 tracked_objects::ScopedTracker tracking_profile( | 726 tracked_objects::ScopedTracker tracking_profile( |
| 723 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 727 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 724 "436634 ProxyResolverV8Tracing::Job::OnDnsOperationComplete")); | 728 "436634 ProxyResolverV8Tracing::Job::OnDnsOperationComplete")); |
| 725 | 729 |
| 726 CheckIsOnOriginThread(); | 730 CheckIsOnOriginThread(); |
| 727 | 731 |
| 728 DCHECK(!cancelled_.IsSet()); | 732 DCHECK(!cancelled_.IsSet()); |
| 729 DCHECK(pending_dns_completed_synchronously_ == (pending_dns_ == NULL)); | 733 DCHECK(pending_dns_completed_synchronously_ == (pending_dns_ == NULL)); |
| 730 | 734 |
| 731 SaveDnsToLocalCache(pending_dns_host_, pending_dns_op_, result, | 735 SaveDnsToLocalCache(pending_dns_host_, pending_dns_op_, result, |
| 732 pending_dns_addresses_); | 736 pending_dns_addresses_); |
| 733 pending_dns_ = NULL; | 737 pending_dns_ = NULL; |
| 734 | 738 |
| 739 if (!parent_->on_load_state_changed_.is_null()) { | |
| 740 parent_->on_load_state_changed_.Run(this, | |
| 741 LOAD_STATE_RESOLVING_PROXY_FOR_URL); | |
|
eroman
2015/02/25 00:08:06
Note that OnDnsOperationComplete() is called in re
Sam McNally
2015/02/26 04:00:01
Added a check for pending_dns_completed_synchronou
| |
| 742 } | |
| 743 | |
| 735 if (blocking_dns_) { | 744 if (blocking_dns_) { |
| 736 event_.Signal(); | 745 event_.Signal(); |
| 737 return; | 746 return; |
| 738 } | 747 } |
| 739 | 748 |
| 740 if (!blocking_dns_ && !pending_dns_completed_synchronously_) { | 749 if (!blocking_dns_ && !pending_dns_completed_synchronously_) { |
| 741 // Restart. This time it should make more progress due to having | 750 // Restart. This time it should make more progress due to having |
| 742 // cached items. | 751 // cached items. |
| 743 worker_loop()->PostTask(FROM_HERE, | 752 worker_loop()->PostTask(FROM_HERE, |
| 744 base::Bind(&Job::ExecuteNonBlocking, this)); | 753 base::Bind(&Job::ExecuteNonBlocking, this)); |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 927 | 936 |
| 928 // Emit to the global NetLog event stream. | 937 // Emit to the global NetLog event stream. |
| 929 if (net_log()) | 938 if (net_log()) |
| 930 net_log()->AddGlobalEntry(type, parameters_callback); | 939 net_log()->AddGlobalEntry(type, parameters_callback); |
| 931 } | 940 } |
| 932 | 941 |
| 933 ProxyResolverV8Tracing::ProxyResolverV8Tracing( | 942 ProxyResolverV8Tracing::ProxyResolverV8Tracing( |
| 934 HostResolver* host_resolver, | 943 HostResolver* host_resolver, |
| 935 ProxyResolverErrorObserver* error_observer, | 944 ProxyResolverErrorObserver* error_observer, |
| 936 NetLog* net_log) | 945 NetLog* net_log) |
| 946 : ProxyResolverV8Tracing(host_resolver, | |
| 947 error_observer, | |
| 948 net_log, | |
| 949 LoadStateChangedCallback<RequestHandle>()) { | |
| 950 } | |
| 951 | |
| 952 ProxyResolverV8Tracing::ProxyResolverV8Tracing( | |
| 953 HostResolver* host_resolver, | |
| 954 ProxyResolverErrorObserver* error_observer, | |
| 955 NetLog* net_log, | |
| 956 const LoadStateChangedCallback<RequestHandle>& on_load_state_changed) | |
| 937 : ProxyResolver(true /*expects_pac_bytes*/), | 957 : ProxyResolver(true /*expects_pac_bytes*/), |
| 938 host_resolver_(host_resolver), | 958 host_resolver_(host_resolver), |
| 939 error_observer_(error_observer), | 959 error_observer_(error_observer), |
| 940 net_log_(net_log), | 960 net_log_(net_log), |
| 941 num_outstanding_callbacks_(0) { | 961 num_outstanding_callbacks_(0), |
| 962 on_load_state_changed_(on_load_state_changed) { | |
| 942 DCHECK(host_resolver); | 963 DCHECK(host_resolver); |
| 943 // Start up the thread. | 964 // Start up the thread. |
| 944 thread_.reset(new base::Thread("Proxy resolver")); | 965 thread_.reset(new base::Thread("Proxy resolver")); |
| 945 base::Thread::Options options; | 966 base::Thread::Options options; |
| 946 options.timer_slack = base::TIMER_SLACK_MAXIMUM; | 967 options.timer_slack = base::TIMER_SLACK_MAXIMUM; |
| 947 CHECK(thread_->StartWithOptions(options)); | 968 CHECK(thread_->StartWithOptions(options)); |
| 948 | 969 |
| 949 v8_resolver_.reset(new ProxyResolverV8); | 970 v8_resolver_.reset(new ProxyResolverV8); |
| 950 } | 971 } |
| 951 | 972 |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1007 DCHECK(!set_pac_script_job_.get()); | 1028 DCHECK(!set_pac_script_job_.get()); |
| 1008 CHECK_EQ(0, num_outstanding_callbacks_); | 1029 CHECK_EQ(0, num_outstanding_callbacks_); |
| 1009 | 1030 |
| 1010 set_pac_script_job_ = new Job(this); | 1031 set_pac_script_job_ = new Job(this); |
| 1011 set_pac_script_job_->StartSetPacScript(script_data, callback); | 1032 set_pac_script_job_->StartSetPacScript(script_data, callback); |
| 1012 | 1033 |
| 1013 return ERR_IO_PENDING; | 1034 return ERR_IO_PENDING; |
| 1014 } | 1035 } |
| 1015 | 1036 |
| 1016 } // namespace net | 1037 } // namespace net |
| OLD | NEW |