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

Side by Side Diff: net/proxy/proxy_service.cc

Issue 545633002: Don't preresolve DNS if a fixed proxy configuration is in place. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remote superfluous net:: prefix Created 6 years, 2 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/proxy/proxy_service.h ('k') | net/proxy/proxy_service_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 (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 "net/proxy/proxy_service.h" 5 #include "net/proxy/proxy_service.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 961 matching lines...) Expand 10 before | Expand all | Expand 10 after
972 NULL); 972 NULL);
973 } 973 }
974 974
975 int ProxyService::ResolveProxy(const GURL& raw_url, 975 int ProxyService::ResolveProxy(const GURL& raw_url,
976 int load_flags, 976 int load_flags,
977 ProxyInfo* result, 977 ProxyInfo* result,
978 const net::CompletionCallback& callback, 978 const net::CompletionCallback& callback,
979 PacRequest** pac_request, 979 PacRequest** pac_request,
980 NetworkDelegate* network_delegate, 980 NetworkDelegate* network_delegate,
981 const BoundNetLog& net_log) { 981 const BoundNetLog& net_log) {
982 DCHECK(!callback.is_null());
983 return ResolveProxyHelper(raw_url,
984 load_flags,
985 result,
986 callback,
987 pac_request,
988 network_delegate,
989 net_log);
990 }
991
992 int ProxyService::ResolveProxyHelper(const GURL& raw_url,
993 int load_flags,
994 ProxyInfo* result,
995 const net::CompletionCallback& callback,
996 PacRequest** pac_request,
997 NetworkDelegate* network_delegate,
998 const BoundNetLog& net_log) {
982 DCHECK(CalledOnValidThread()); 999 DCHECK(CalledOnValidThread());
983 DCHECK(!callback.is_null());
984 1000
985 net_log.BeginEvent(NetLog::TYPE_PROXY_SERVICE); 1001 net_log.BeginEvent(NetLog::TYPE_PROXY_SERVICE);
986 1002
987 // Notify our polling-based dependencies that a resolve is taking place. 1003 // Notify our polling-based dependencies that a resolve is taking place.
988 // This way they can schedule their polls in response to network activity. 1004 // This way they can schedule their polls in response to network activity.
989 config_service_->OnLazyPoll(); 1005 config_service_->OnLazyPoll();
990 if (script_poller_.get()) 1006 if (script_poller_.get())
991 script_poller_->OnLazyPoll(); 1007 script_poller_->OnLazyPoll();
992 1008
993 if (current_state_ == STATE_NONE) 1009 if (current_state_ == STATE_NONE)
994 ApplyProxyConfigIfAvailable(); 1010 ApplyProxyConfigIfAvailable();
995 1011
996 // Strip away any reference fragments and the username/password, as they 1012 // Strip away any reference fragments and the username/password, as they
997 // are not relevant to proxy resolution. 1013 // are not relevant to proxy resolution.
998 GURL url = SimplifyUrlForRequest(raw_url); 1014 GURL url = SimplifyUrlForRequest(raw_url);
999 1015
1000 // Check if the request can be completed right away. (This is the case when 1016 // Check if the request can be completed right away. (This is the case when
1001 // using a direct connection for example). 1017 // using a direct connection for example).
1002 int rv = TryToCompleteSynchronously(url, load_flags, 1018 int rv = TryToCompleteSynchronously(url, load_flags,
1003 network_delegate, result); 1019 network_delegate, result);
1004 if (rv != ERR_IO_PENDING) 1020 if (rv != ERR_IO_PENDING)
1005 return DidFinishResolvingProxy(url, load_flags, network_delegate, 1021 return DidFinishResolvingProxy(url, load_flags, network_delegate,
1006 result, rv, net_log); 1022 result, rv, net_log);
1007 1023
1024 if (callback.is_null())
1025 return ERR_IO_PENDING;
1026
1008 scoped_refptr<PacRequest> req( 1027 scoped_refptr<PacRequest> req(
1009 new PacRequest(this, url, load_flags, network_delegate, 1028 new PacRequest(this, url, load_flags, network_delegate,
1010 result, callback, net_log)); 1029 result, callback, net_log));
1011 1030
1012 if (current_state_ == STATE_READY) { 1031 if (current_state_ == STATE_READY) {
1013 // Start the resolve request. 1032 // Start the resolve request.
1014 rv = req->Start(); 1033 rv = req->Start();
1015 if (rv != ERR_IO_PENDING) 1034 if (rv != ERR_IO_PENDING)
1016 return req->QueryDidComplete(rv); 1035 return req->QueryDidComplete(rv);
1017 } else { 1036 } else {
1018 req->net_log()->BeginEvent(NetLog::TYPE_PROXY_SERVICE_WAITING_FOR_INIT_PAC); 1037 req->net_log()->BeginEvent(NetLog::TYPE_PROXY_SERVICE_WAITING_FOR_INIT_PAC);
1019 } 1038 }
1020 1039
1021 DCHECK_EQ(ERR_IO_PENDING, rv); 1040 DCHECK_EQ(ERR_IO_PENDING, rv);
1022 DCHECK(!ContainsPendingRequest(req.get())); 1041 DCHECK(!ContainsPendingRequest(req.get()));
1023 pending_requests_.push_back(req); 1042 pending_requests_.push_back(req);
1024 1043
1025 // Completion will be notified through |callback|, unless the caller cancels 1044 // Completion will be notified through |callback|, unless the caller cancels
1026 // the request using |pac_request|. 1045 // the request using |pac_request|.
1027 if (pac_request) 1046 if (pac_request)
1028 *pac_request = req.get(); 1047 *pac_request = req.get();
1029 return rv; // ERR_IO_PENDING 1048 return rv; // ERR_IO_PENDING
1030 } 1049 }
1031 1050
1051 bool ProxyService:: TryResolveProxySynchronously(
1052 const GURL& raw_url,
1053 int load_flags,
1054 ProxyInfo* result,
1055 NetworkDelegate* network_delegate,
1056 const BoundNetLog& net_log) {
1057 net::CompletionCallback null_callback;
1058 return ResolveProxyHelper(raw_url,
1059 load_flags,
1060 result,
1061 null_callback,
1062 NULL /* pac_request*/,
1063 network_delegate,
1064 net_log) == OK;
1065 }
1066
1032 int ProxyService::TryToCompleteSynchronously(const GURL& url, 1067 int ProxyService::TryToCompleteSynchronously(const GURL& url,
1033 int load_flags, 1068 int load_flags,
1034 NetworkDelegate* network_delegate, 1069 NetworkDelegate* network_delegate,
1035 ProxyInfo* result) { 1070 ProxyInfo* result) {
1036 DCHECK_NE(STATE_NONE, current_state_); 1071 DCHECK_NE(STATE_NONE, current_state_);
1037 1072
1038 if (current_state_ != STATE_READY) 1073 if (current_state_ != STATE_READY)
1039 return ERR_IO_PENDING; // Still initializing. 1074 return ERR_IO_PENDING; // Still initializing.
1040 1075
1041 DCHECK_NE(config_.id(), ProxyConfig::kInvalidConfigID); 1076 DCHECK_NE(config_.id(), ProxyConfig::kInvalidConfigID);
(...skipping 512 matching lines...) Expand 10 before | Expand all | Expand 10 after
1554 State previous_state = ResetProxyConfig(false); 1589 State previous_state = ResetProxyConfig(false);
1555 if (previous_state != STATE_NONE) 1590 if (previous_state != STATE_NONE)
1556 ApplyProxyConfigIfAvailable(); 1591 ApplyProxyConfigIfAvailable();
1557 } 1592 }
1558 1593
1559 void ProxyService::OnDNSChanged() { 1594 void ProxyService::OnDNSChanged() {
1560 OnIPAddressChanged(); 1595 OnIPAddressChanged();
1561 } 1596 }
1562 1597
1563 } // namespace net 1598 } // namespace net
OLDNEW
« no previous file with comments | « net/proxy/proxy_service.h ('k') | net/proxy/proxy_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698