summaryrefslogtreecommitdiffstats
path: root/net/proxy/init_proxy_resolver.cc
diff options
context:
space:
mode:
authoreroman@chromium.org <eroman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-26 05:12:47 +0000
committereroman@chromium.org <eroman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-26 05:12:47 +0000
commit1b8740fcc945425012ecc755987286dd22a098f6 (patch)
tree263ebd87b1ac8b50af8303085043f4bd930bd42f /net/proxy/init_proxy_resolver.cc
parent924cad8b1c5bccdd34dd02d9391e57e5ed8a0f06 (diff)
downloadchromium_src-1b8740fcc945425012ecc755987286dd22a098f6.zip
chromium_src-1b8740fcc945425012ecc755987286dd22a098f6.tar.gz
chromium_src-1b8740fcc945425012ecc755987286dd22a098f6.tar.bz2
Introduce an artificial 2 second delay after network IP address changes before re-running proxy auto-config.
During this time network requests will be stalled. This is to work around a problem where DNS gives transient failures shortly after IP address changes. BUG=50779 TEST=On a linux laptop switch between wireless networks while using auto-detect. When you switch to a network that contains the host 'wpad' verify that when InitProxyResolver runs it does not get a DNS error resolving 'wpad'. (Use about:net-internals to view this information). Review URL: http://codereview.chromium.org/3151040 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@57471 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/proxy/init_proxy_resolver.cc')
-rw-r--r--net/proxy/init_proxy_resolver.cc43
1 files changed, 42 insertions, 1 deletions
diff --git a/net/proxy/init_proxy_resolver.cc b/net/proxy/init_proxy_resolver.cc
index 04f828b..9cffa67 100644
--- a/net/proxy/init_proxy_resolver.cc
+++ b/net/proxy/init_proxy_resolver.cc
@@ -36,6 +36,7 @@ InitProxyResolver::~InitProxyResolver() {
}
int InitProxyResolver::Init(const ProxyConfig& config,
+ const base::TimeDelta wait_delay,
CompletionCallback* callback) {
DCHECK_EQ(STATE_NONE, next_state_);
DCHECK(callback);
@@ -43,10 +44,15 @@ int InitProxyResolver::Init(const ProxyConfig& config,
net_log_.BeginEvent(NetLog::TYPE_INIT_PROXY_RESOLVER, NULL);
+ // Save the |wait_delay| as a non-negative value.
+ wait_delay_ = wait_delay;
+ if (wait_delay_ < base::TimeDelta())
+ wait_delay_ = base::TimeDelta();
+
pac_urls_ = BuildPacUrlsFallbackList(config);
DCHECK(!pac_urls_.empty());
- next_state_ = GetStartState();
+ next_state_ = STATE_WAIT;
int rv = DoLoop(OK);
if (rv == ERR_IO_PENDING)
@@ -86,6 +92,13 @@ int InitProxyResolver::DoLoop(int result) {
State state = next_state_;
next_state_ = STATE_NONE;
switch (state) {
+ case STATE_WAIT:
+ DCHECK_EQ(OK, rv);
+ rv = DoWait();
+ break;
+ case STATE_WAIT_COMPLETE:
+ rv = DoWaitComplete(rv);
+ break;
case STATE_FETCH_PAC_SCRIPT:
DCHECK_EQ(OK, rv);
rv = DoFetchPacScript();
@@ -115,6 +128,27 @@ void InitProxyResolver::DoCallback(int result) {
user_callback_->Run(result);
}
+int InitProxyResolver::DoWait() {
+ next_state_ = STATE_WAIT_COMPLETE;
+
+ // If no waiting is required, continue on to the next state.
+ if (wait_delay_.ToInternalValue() == 0)
+ return OK;
+
+ // Otherwise wait the specified amount of time.
+ wait_timer_.Start(wait_delay_, this, &InitProxyResolver::OnWaitTimerFired);
+ net_log_.BeginEvent(NetLog::TYPE_INIT_PROXY_RESOLVER_WAIT, NULL);
+ return ERR_IO_PENDING;
+}
+
+int InitProxyResolver::DoWaitComplete(int result) {
+ DCHECK_EQ(OK, result);
+ if (wait_delay_.ToInternalValue() != 0)
+ net_log_.EndEvent(NetLog::TYPE_INIT_PROXY_RESOLVER_WAIT, NULL);
+ next_state_ = GetStartState();
+ return OK;
+}
+
int InitProxyResolver::DoFetchPacScript() {
DCHECK(resolver_->expects_pac_bytes());
@@ -217,6 +251,10 @@ const InitProxyResolver::PacURL& InitProxyResolver::current_pac_url() const {
return pac_urls_[current_pac_url_index_];
}
+void InitProxyResolver::OnWaitTimerFired() {
+ OnIOCompletion(OK);
+}
+
void InitProxyResolver::DidCompleteInit() {
net_log_.EndEvent(NetLog::TYPE_INIT_PROXY_RESOLVER, NULL);
}
@@ -227,6 +265,9 @@ void InitProxyResolver::Cancel() {
net_log_.AddEvent(NetLog::TYPE_CANCELLED, NULL);
switch (next_state_) {
+ case STATE_WAIT_COMPLETE:
+ wait_timer_.Stop();
+ break;
case STATE_FETCH_PAC_SCRIPT_COMPLETE:
proxy_script_fetcher_->Cancel();
break;