| 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/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
| 10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
| (...skipping 829 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 840 } | 840 } |
| 841 | 841 |
| 842 void ProxyResolverV8Tracing::Job::DoDnsOperation() { | 842 void ProxyResolverV8Tracing::Job::DoDnsOperation() { |
| 843 CheckIsOnOriginThread(); | 843 CheckIsOnOriginThread(); |
| 844 DCHECK(!pending_dns_); | 844 DCHECK(!pending_dns_); |
| 845 | 845 |
| 846 if (cancelled_.IsSet()) | 846 if (cancelled_.IsSet()) |
| 847 return; | 847 return; |
| 848 | 848 |
| 849 HostResolver::RequestHandle dns_request = NULL; | 849 HostResolver::RequestHandle dns_request = NULL; |
| 850 int result = host_resolver()->Resolve( | 850 int result = OK; |
| 851 MakeDnsRequestInfo(pending_dns_host_, pending_dns_op_), | 851 pending_dns_completed_synchronously_ = false; |
| 852 DEFAULT_PRIORITY, | |
| 853 &pending_dns_addresses_, | |
| 854 base::Bind(&Job::OnDnsOperationComplete, this), | |
| 855 &dns_request, | |
| 856 bound_net_log_); | |
| 857 | 852 |
| 858 pending_dns_completed_synchronously_ = result != ERR_IO_PENDING; | 853 // If a system (e.g. Chrome OS) has specified an IP address, use it. |
| 854 if (pending_dns_op_ == MY_IP_ADDRESS || pending_dns_op_ == MY_IP_ADDRESS_EX) { |
| 855 bool include_ipv6 = pending_dns_op_ == MY_IP_ADDRESS_EX; |
| 856 if (host_resolver()->ResolveFromMyIpAddress(include_ipv6, |
| 857 &pending_dns_addresses_)) { |
| 858 pending_dns_completed_synchronously_ = true; |
| 859 } |
| 860 } |
| 859 | 861 |
| 860 // Check if the request was cancelled as a side-effect of calling into the | 862 if (!pending_dns_completed_synchronously_) { |
| 861 // HostResolver. This isn't the ordinary execution flow, however it is | 863 result = host_resolver()->Resolve( |
| 862 // exercised by unit-tests. | 864 MakeDnsRequestInfo(pending_dns_host_, pending_dns_op_), |
| 863 if (cancelled_.IsSet()) { | 865 DEFAULT_PRIORITY, |
| 864 if (!pending_dns_completed_synchronously_) | 866 &pending_dns_addresses_, |
| 865 host_resolver()->CancelRequest(dns_request); | 867 base::Bind(&Job::OnDnsOperationComplete, this), |
| 866 return; | 868 &dns_request, |
| 869 bound_net_log_); |
| 870 pending_dns_completed_synchronously_ = result != ERR_IO_PENDING; |
| 871 |
| 872 // Check if the request was cancelled as a side-effect of calling into the |
| 873 // HostResolver. This isn't the ordinary execution flow, however it is |
| 874 // exercised by unit-tests. |
| 875 if (cancelled_.IsSet()) { |
| 876 if (!pending_dns_completed_synchronously_) |
| 877 host_resolver()->CancelRequest(dns_request); |
| 878 return; |
| 879 } |
| 867 } | 880 } |
| 868 | 881 |
| 869 if (pending_dns_completed_synchronously_) { | 882 if (pending_dns_completed_synchronously_) { |
| 870 OnDnsOperationComplete(result); | 883 OnDnsOperationComplete(result); |
| 871 } else { | 884 } else { |
| 872 DCHECK(dns_request); | 885 DCHECK(dns_request); |
| 873 pending_dns_ = dns_request; | 886 pending_dns_ = dns_request; |
| 874 // OnDnsOperationComplete() will be called by host resolver on completion. | 887 // OnDnsOperationComplete() will be called by host resolver on completion. |
| 875 } | 888 } |
| 876 | 889 |
| (...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1164 DCHECK(!set_pac_script_job_.get()); | 1177 DCHECK(!set_pac_script_job_.get()); |
| 1165 CHECK_EQ(0, num_outstanding_callbacks_); | 1178 CHECK_EQ(0, num_outstanding_callbacks_); |
| 1166 | 1179 |
| 1167 set_pac_script_job_ = new Job(this); | 1180 set_pac_script_job_ = new Job(this); |
| 1168 set_pac_script_job_->StartSetPacScript(script_data, callback); | 1181 set_pac_script_job_->StartSetPacScript(script_data, callback); |
| 1169 | 1182 |
| 1170 return ERR_IO_PENDING; | 1183 return ERR_IO_PENDING; |
| 1171 } | 1184 } |
| 1172 | 1185 |
| 1173 } // namespace net | 1186 } // namespace net |
| OLD | NEW |