summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
Diffstat (limited to 'net')
-rw-r--r--net/base/load_states.h9
-rw-r--r--net/http/http_network_transaction_unittest.cc11
-rw-r--r--net/http/http_stream_factory_impl_job.cc2
-rw-r--r--net/proxy/init_proxy_resolver_unittest.cc11
-rw-r--r--net/proxy/mock_proxy_resolver.cc12
-rw-r--r--net/proxy/mock_proxy_resolver.h3
-rw-r--r--net/proxy/multi_threaded_proxy_resolver.cc16
-rw-r--r--net/proxy/multi_threaded_proxy_resolver.h3
-rw-r--r--net/proxy/multi_threaded_proxy_resolver_unittest.cc22
-rw-r--r--net/proxy/proxy_resolver.h7
-rw-r--r--net/proxy/proxy_resolver_mac.cc10
-rw-r--r--net/proxy/proxy_resolver_mac.h5
-rw-r--r--net/proxy/proxy_resolver_v8.cc54
-rw-r--r--net/proxy/proxy_resolver_v8.h3
-rw-r--r--net/proxy/proxy_resolver_winhttp.cc12
-rw-r--r--net/proxy/proxy_resolver_winhttp.h5
-rw-r--r--net/proxy/proxy_service.cc33
-rw-r--r--net/proxy/proxy_service.h4
-rw-r--r--net/proxy/sync_host_resolver_bridge_unittest.cc11
19 files changed, 227 insertions, 6 deletions
diff --git a/net/base/load_states.h b/net/base/load_states.h
index b5ca6a8..97d6855 100644
--- a/net/base/load_states.h
+++ b/net/base/load_states.h
@@ -40,11 +40,14 @@ enum LoadState {
LOAD_STATE_WAITING_FOR_APPCACHE,
// This state corresponds to a resource load that is blocked waiting for a
- // proxy autoconfig script to return a proxy server to use. This state may
- // take a while if the proxy script needs to resolve the IP address of the
- // host before deciding what proxy to use.
+ // proxy autoconfig script to return a proxy server to use.
LOAD_STATE_RESOLVING_PROXY_FOR_URL,
+ // This state corresponds to a resource load that is blocked waiting for a
+ // proxy autoconfig script to return a proxy server to use, but that proxy
+ // script is busy resolving the IP address of a host.
+ LOAD_STATE_RESOLVING_HOST_IN_PROXY_SCRIPT,
+
// This state indicates that we're in the process of establishing a tunnel
// through the proxy server.
LOAD_STATE_ESTABLISHING_PROXY_TUNNEL,
diff --git a/net/http/http_network_transaction_unittest.cc b/net/http/http_network_transaction_unittest.cc
index 7d4329e..ceb6b9e 100644
--- a/net/http/http_network_transaction_unittest.cc
+++ b/net/http/http_network_transaction_unittest.cc
@@ -7124,6 +7124,17 @@ class CapturingProxyResolver : public ProxyResolver {
NOTREACHED();
}
+ virtual LoadState GetLoadState(RequestHandle request) const OVERRIDE {
+ NOTREACHED();
+ return LOAD_STATE_IDLE;
+ }
+
+ virtual LoadState GetLoadStateThreadSafe(
+ RequestHandle request) const OVERRIDE {
+ NOTREACHED();
+ return LOAD_STATE_IDLE;
+ }
+
virtual void CancelSetPacScript() {
NOTREACHED();
}
diff --git a/net/http/http_stream_factory_impl_job.cc b/net/http/http_stream_factory_impl_job.cc
index 17cd769..46bc3f4 100644
--- a/net/http/http_stream_factory_impl_job.cc
+++ b/net/http/http_stream_factory_impl_job.cc
@@ -152,7 +152,7 @@ int HttpStreamFactoryImpl::Job::RestartTunnelWithProxyAuth(
LoadState HttpStreamFactoryImpl::Job::GetLoadState() const {
switch (next_state_) {
case STATE_RESOLVE_PROXY_COMPLETE:
- return LOAD_STATE_RESOLVING_PROXY_FOR_URL;
+ return session_->proxy_service()->GetLoadState(pac_request_);
case STATE_CREATE_STREAM_COMPLETE:
return connection_->GetLoadState();
case STATE_INIT_CONNECTION_COMPLETE:
diff --git a/net/proxy/init_proxy_resolver_unittest.cc b/net/proxy/init_proxy_resolver_unittest.cc
index 2e48429..d44dba51 100644
--- a/net/proxy/init_proxy_resolver_unittest.cc
+++ b/net/proxy/init_proxy_resolver_unittest.cc
@@ -135,6 +135,17 @@ class RuleBasedProxyResolver : public ProxyResolver {
NOTREACHED();
}
+ virtual LoadState GetLoadState(RequestHandle request_handle) const {
+ NOTREACHED();
+ return LOAD_STATE_IDLE;
+ }
+
+ virtual LoadState GetLoadStateThreadSafe(
+ RequestHandle request) const OVERRIDE {
+ NOTREACHED();
+ return LOAD_STATE_IDLE;
+ }
+
virtual void CancelSetPacScript() {
NOTREACHED();
}
diff --git a/net/proxy/mock_proxy_resolver.cc b/net/proxy/mock_proxy_resolver.cc
index c73daad..597a06c 100644
--- a/net/proxy/mock_proxy_resolver.cc
+++ b/net/proxy/mock_proxy_resolver.cc
@@ -77,6 +77,18 @@ void MockAsyncProxyResolverBase::CancelRequest(RequestHandle request_handle) {
RemovePendingRequest(request);
}
+LoadState MockAsyncProxyResolverBase::GetLoadState(
+ RequestHandle request_handle) const {
+ NOTREACHED();
+ return LOAD_STATE_IDLE;
+}
+
+LoadState MockAsyncProxyResolverBase::GetLoadStateThreadSafe(
+ RequestHandle request_handle) const {
+ NOTREACHED();
+ return LOAD_STATE_IDLE;
+}
+
int MockAsyncProxyResolverBase::SetPacScript(
const scoped_refptr<ProxyResolverScriptData>& script_data,
OldCompletionCallback* callback) {
diff --git a/net/proxy/mock_proxy_resolver.h b/net/proxy/mock_proxy_resolver.h
index 8aa0101..bff2a71 100644
--- a/net/proxy/mock_proxy_resolver.h
+++ b/net/proxy/mock_proxy_resolver.h
@@ -76,6 +76,9 @@ class MockAsyncProxyResolverBase : public ProxyResolver {
RequestHandle* request_handle,
const BoundNetLog& /*net_log*/) OVERRIDE;
virtual void CancelRequest(RequestHandle request_handle) OVERRIDE;
+ virtual LoadState GetLoadState(RequestHandle request_handle) const OVERRIDE;
+ virtual LoadState GetLoadStateThreadSafe(
+ RequestHandle request_handle) const OVERRIDE;
virtual int SetPacScript(
const scoped_refptr<ProxyResolverScriptData>& script_data,
OldCompletionCallback* callback) OVERRIDE;
diff --git a/net/proxy/multi_threaded_proxy_resolver.cc b/net/proxy/multi_threaded_proxy_resolver.cc
index 3f42dfe..03c3e44 100644
--- a/net/proxy/multi_threaded_proxy_resolver.cc
+++ b/net/proxy/multi_threaded_proxy_resolver.cc
@@ -457,6 +457,22 @@ void MultiThreadedProxyResolver::CancelRequest(RequestHandle req) {
}
}
+LoadState MultiThreadedProxyResolver::GetLoadState(RequestHandle req) const {
+ DCHECK(CalledOnValidThread());
+ DCHECK(req);
+
+ Job* job = reinterpret_cast<Job*>(req);
+ if (job->executor())
+ return job->executor()->resolver()->GetLoadStateThreadSafe(NULL);
+ return LOAD_STATE_RESOLVING_PROXY_FOR_URL;
+}
+
+LoadState MultiThreadedProxyResolver::GetLoadStateThreadSafe(
+ RequestHandle req) const {
+ NOTIMPLEMENTED();
+ return LOAD_STATE_IDLE;
+}
+
void MultiThreadedProxyResolver::CancelSetPacScript() {
DCHECK(CalledOnValidThread());
DCHECK_EQ(0u, pending_jobs_.size());
diff --git a/net/proxy/multi_threaded_proxy_resolver.h b/net/proxy/multi_threaded_proxy_resolver.h
index 4bd2f9e..deca2a5 100644
--- a/net/proxy/multi_threaded_proxy_resolver.h
+++ b/net/proxy/multi_threaded_proxy_resolver.h
@@ -98,6 +98,9 @@ class NET_EXPORT_PRIVATE MultiThreadedProxyResolver
RequestHandle* request,
const BoundNetLog& net_log) OVERRIDE;
virtual void CancelRequest(RequestHandle request) OVERRIDE;
+ virtual LoadState GetLoadState(RequestHandle request) const OVERRIDE;
+ virtual LoadState GetLoadStateThreadSafe(
+ RequestHandle request) const OVERRIDE;
virtual void CancelSetPacScript() OVERRIDE;
virtual void PurgeMemory() OVERRIDE;
virtual int SetPacScript(
diff --git a/net/proxy/multi_threaded_proxy_resolver_unittest.cc b/net/proxy/multi_threaded_proxy_resolver_unittest.cc
index 8e060a9..481d5b5 100644
--- a/net/proxy/multi_threaded_proxy_resolver_unittest.cc
+++ b/net/proxy/multi_threaded_proxy_resolver_unittest.cc
@@ -62,6 +62,17 @@ class MockProxyResolver : public ProxyResolver {
NOTREACHED();
}
+ virtual LoadState GetLoadState(RequestHandle request) const OVERRIDE {
+ NOTREACHED();
+ return LOAD_STATE_IDLE;
+ }
+
+ virtual LoadState GetLoadStateThreadSafe(
+ RequestHandle request) const OVERRIDE {
+ NOTREACHED();
+ return LOAD_STATE_IDLE;
+ }
+
virtual void CancelSetPacScript() OVERRIDE {
NOTREACHED();
}
@@ -175,6 +186,17 @@ class ForwardingProxyResolver : public ProxyResolver {
impl_->CancelRequest(request);
}
+ virtual LoadState GetLoadState(RequestHandle request) const OVERRIDE {
+ NOTREACHED();
+ return LOAD_STATE_IDLE;
+ }
+
+ virtual LoadState GetLoadStateThreadSafe(
+ RequestHandle request) const OVERRIDE {
+ NOTREACHED();
+ return LOAD_STATE_IDLE;
+ }
+
virtual void CancelSetPacScript() OVERRIDE {
impl_->CancelSetPacScript();
}
diff --git a/net/proxy/proxy_resolver.h b/net/proxy/proxy_resolver.h
index 20c903d..3bdfd28 100644
--- a/net/proxy/proxy_resolver.h
+++ b/net/proxy/proxy_resolver.h
@@ -11,6 +11,7 @@
#include "base/string16.h"
#include "googleurl/src/gurl.h"
#include "net/base/completion_callback.h"
+#include "net/base/load_states.h"
#include "net/base/net_export.h"
#include "net/proxy/proxy_resolver_script_data.h"
@@ -49,6 +50,12 @@ class NET_EXPORT_PRIVATE ProxyResolver {
// Cancels |request|.
virtual void CancelRequest(RequestHandle request) = 0;
+ // Gets the LoadState for |request|.
+ virtual LoadState GetLoadState(RequestHandle request) const = 0;
+
+ // Gets the LoadState for |request|. May be called from another thread.
+ virtual LoadState GetLoadStateThreadSafe(RequestHandle request) const = 0;
+
// The PAC script backend can be specified to the ProxyResolver either via
// URL, or via the javascript text itself. If |expects_pac_bytes| is true,
// then the ProxyResolverScriptData passed to SetPacScript() should
diff --git a/net/proxy/proxy_resolver_mac.cc b/net/proxy/proxy_resolver_mac.cc
index 935f6fb..6c5946c 100644
--- a/net/proxy/proxy_resolver_mac.cc
+++ b/net/proxy/proxy_resolver_mac.cc
@@ -187,6 +187,16 @@ void ProxyResolverMac::CancelRequest(RequestHandle request) {
NOTREACHED();
}
+LoadState ProxyResolverMac::GetLoadState(RequestHandle request) const {
+ NOTREACHED();
+ return LOAD_STATE_IDLE;
+}
+
+LoadState ProxyResolverMac::GetLoadStateThreadSafe(
+ RequestHandle request) const {
+ return LOAD_STATE_IDLE;
+}
+
void ProxyResolverMac::CancelSetPacScript() {
NOTREACHED();
}
diff --git a/net/proxy/proxy_resolver_mac.h b/net/proxy/proxy_resolver_mac.h
index d10aa3e..0df4e38 100644
--- a/net/proxy/proxy_resolver_mac.h
+++ b/net/proxy/proxy_resolver_mac.h
@@ -30,6 +30,11 @@ class NET_EXPORT ProxyResolverMac : public ProxyResolver {
virtual void CancelRequest(RequestHandle request) OVERRIDE;
+ virtual LoadState GetLoadState(RequestHandle request) const OVERRIDE;
+
+ virtual LoadState GetLoadStateThreadSafe(
+ RequestHandle request) const OVERRIDE;
+
virtual void CancelSetPacScript() OVERRIDE;
virtual int SetPacScript(
diff --git a/net/proxy/proxy_resolver_v8.cc b/net/proxy/proxy_resolver_v8.cc
index 1bd736c..ff597ce 100644
--- a/net/proxy/proxy_resolver_v8.cc
+++ b/net/proxy/proxy_resolver_v8.cc
@@ -12,6 +12,7 @@
#include "base/logging.h"
#include "base/string_tokenizer.h"
#include "base/string_util.h"
+#include "base/synchronization/lock.h"
#include "base/utf_string_conversions.h"
#include "googleurl/src/gurl.h"
#include "googleurl/src/url_canon.h"
@@ -335,7 +336,8 @@ bool IsInNetEx(const std::string& ip_address, const std::string& ip_prefix) {
class ProxyResolverV8::Context {
public:
explicit Context(ProxyResolverJSBindings* js_bindings)
- : js_bindings_(js_bindings) {
+ : is_resolving_host_(false),
+ js_bindings_(js_bindings) {
DCHECK(js_bindings != NULL);
}
@@ -495,7 +497,40 @@ class ProxyResolverV8::Context {
;
}
+ bool is_resolving_host() const {
+ base::AutoLock auto_lock(lock_);
+ return is_resolving_host_;
+ }
+
private:
+ class ScopedHostResolve {
+ public:
+ explicit ScopedHostResolve(Context* context)
+ : context_(context) {
+ context_->BeginHostResolve();
+ }
+
+ ~ScopedHostResolve() {
+ context_->EndHostResolve();
+ }
+
+ private:
+ Context* const context_;
+ DISALLOW_COPY_AND_ASSIGN(ScopedHostResolve);
+ };
+
+ void BeginHostResolve() {
+ base::AutoLock auto_lock(lock_);
+ DCHECK(!is_resolving_host_);
+ is_resolving_host_ = true;
+ }
+
+ void EndHostResolve() {
+ base::AutoLock auto_lock(lock_);
+ DCHECK(is_resolving_host_);
+ is_resolving_host_ = false;
+ }
+
bool GetFindProxyForURL(v8::Local<v8::Value>* function) {
*function = v8_context_->Global()->Get(
ASCIILiteralToV8String("FindProxyForURL"));
@@ -566,6 +601,7 @@ class ProxyResolverV8::Context {
{
v8::Unlocker unlocker;
+ ScopedHostResolve scoped_host_resolve(context);
// We shouldn't be called with any arguments, but will not complain if
// we are.
@@ -588,6 +624,7 @@ class ProxyResolverV8::Context {
{
v8::Unlocker unlocker;
+ ScopedHostResolve scoped_host_resolve(context);
// We shouldn't be called with any arguments, but will not complain if
// we are.
@@ -614,6 +651,7 @@ class ProxyResolverV8::Context {
{
v8::Unlocker unlocker;
+ ScopedHostResolve scoped_host_resolve(context);
success = context->js_bindings_->DnsResolve(hostname, &ip_address);
}
@@ -635,6 +673,7 @@ class ProxyResolverV8::Context {
{
v8::Unlocker unlocker;
+ ScopedHostResolve scoped_host_resolve(context);
success = context->js_bindings_->DnsResolveEx(hostname, &ip_address_list);
}
@@ -677,6 +716,8 @@ class ProxyResolverV8::Context {
return IsInNetEx(ip_address, ip_prefix) ? v8::True() : v8::False();
}
+ mutable base::Lock lock_;
+ bool is_resolving_host_;
ProxyResolverJSBindings* js_bindings_;
v8::Persistent<v8::External> v8_this_;
v8::Persistent<v8::Context> v8_context_;
@@ -728,6 +769,17 @@ void ProxyResolverV8::CancelRequest(RequestHandle request) {
NOTREACHED();
}
+LoadState ProxyResolverV8::GetLoadState(RequestHandle request) const {
+ NOTREACHED();
+ return LOAD_STATE_IDLE;
+}
+
+LoadState ProxyResolverV8::GetLoadStateThreadSafe(RequestHandle request) const {
+ if (context_->is_resolving_host())
+ return LOAD_STATE_RESOLVING_HOST_IN_PROXY_SCRIPT;
+ return LOAD_STATE_RESOLVING_PROXY_FOR_URL;
+}
+
void ProxyResolverV8::CancelSetPacScript() {
NOTREACHED();
}
diff --git a/net/proxy/proxy_resolver_v8.h b/net/proxy/proxy_resolver_v8.h
index 60d9c0c..4d7df97 100644
--- a/net/proxy/proxy_resolver_v8.h
+++ b/net/proxy/proxy_resolver_v8.h
@@ -51,6 +51,9 @@ class NET_EXPORT_PRIVATE ProxyResolverV8 : public ProxyResolver {
RequestHandle* /*request*/,
const BoundNetLog& net_log) OVERRIDE;
virtual void CancelRequest(RequestHandle request) OVERRIDE;
+ virtual LoadState GetLoadState(RequestHandle request) const OVERRIDE;
+ virtual LoadState GetLoadStateThreadSafe(
+ RequestHandle request) const OVERRIDE;
virtual void CancelSetPacScript() OVERRIDE;
virtual void PurgeMemory() OVERRIDE;
virtual void Shutdown() OVERRIDE;
diff --git a/net/proxy/proxy_resolver_winhttp.cc b/net/proxy/proxy_resolver_winhttp.cc
index 2581236..2f24ea9 100644
--- a/net/proxy/proxy_resolver_winhttp.cc
+++ b/net/proxy/proxy_resolver_winhttp.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -124,6 +124,16 @@ void ProxyResolverWinHttp::CancelRequest(RequestHandle request) {
NOTREACHED();
}
+LoadState ProxyResolverWinHttp::GetLoadState(RequestHandle request) const {
+ NOTREACHED();
+ return LOAD_STATE_IDLE;
+}
+
+LoadState ProxyResolverWinHttp::GetLoadStateThreadSafe(
+ RequestHandle request) const {
+ return LOAD_STATE_IDLE;
+}
+
void ProxyResolverWinHttp::CancelSetPacScript() {
NOTREACHED();
}
diff --git a/net/proxy/proxy_resolver_winhttp.h b/net/proxy/proxy_resolver_winhttp.h
index 7d278e4..c565808 100644
--- a/net/proxy/proxy_resolver_winhttp.h
+++ b/net/proxy/proxy_resolver_winhttp.h
@@ -29,6 +29,11 @@ class NET_EXPORT_PRIVATE ProxyResolverWinHttp : public ProxyResolver {
const BoundNetLog& /*net_log*/) OVERRIDE;
virtual void CancelRequest(RequestHandle request) OVERRIDE;
+ virtual LoadState GetLoadState(RequestHandle request) const OVERRIDE;
+
+ virtual LoadState GetLoadStateThreadSafe(
+ RequestHandle request) const OVERRIDE;
+
virtual void CancelSetPacScript() OVERRIDE;
virtual int SetPacScript(
diff --git a/net/proxy/proxy_service.cc b/net/proxy/proxy_service.cc
index 41ba41d..892d0f7 100644
--- a/net/proxy/proxy_service.cc
+++ b/net/proxy/proxy_service.cc
@@ -118,6 +118,17 @@ class ProxyResolverNull : public ProxyResolver {
NOTREACHED();
}
+ virtual LoadState GetLoadState(RequestHandle request) const OVERRIDE {
+ NOTREACHED();
+ return LOAD_STATE_IDLE;
+ }
+
+ virtual LoadState GetLoadStateThreadSafe(
+ RequestHandle request) const OVERRIDE {
+ NOTREACHED();
+ return LOAD_STATE_IDLE;
+ }
+
virtual void CancelSetPacScript() OVERRIDE {
NOTREACHED();
}
@@ -150,6 +161,17 @@ class ProxyResolverFromPacString : public ProxyResolver {
NOTREACHED();
}
+ virtual LoadState GetLoadState(RequestHandle request) const OVERRIDE {
+ NOTREACHED();
+ return LOAD_STATE_IDLE;
+ }
+
+ virtual LoadState GetLoadStateThreadSafe(
+ RequestHandle request) const OVERRIDE {
+ NOTREACHED();
+ return LOAD_STATE_IDLE;
+ }
+
virtual void CancelSetPacScript() OVERRIDE {
NOTREACHED();
}
@@ -382,6 +404,12 @@ class ProxyService::PacRequest
BoundNetLog* net_log() { return &net_log_; }
+ LoadState GetLoadState() const {
+ if (is_started())
+ return resolver()->GetLoadState(resolve_job_);
+ return LOAD_STATE_RESOLVING_PROXY_FOR_URL;
+ }
+
private:
friend class base::RefCounted<ProxyService::PacRequest>;
@@ -779,6 +807,11 @@ void ProxyService::CancelPacRequest(PacRequest* req) {
RemovePendingRequest(req);
}
+LoadState ProxyService::GetLoadState(const PacRequest* req) const {
+ CHECK(req);
+ return req->GetLoadState();
+}
+
bool ProxyService::ContainsPendingRequest(PacRequest* req) {
PendingRequests::iterator it = std::find(
pending_requests_.begin(), pending_requests_.end(), req);
diff --git a/net/proxy/proxy_service.h b/net/proxy/proxy_service.h
index e37b959..f8c866c 100644
--- a/net/proxy/proxy_service.h
+++ b/net/proxy/proxy_service.h
@@ -14,6 +14,7 @@
#include "base/synchronization/waitable_event.h"
#include "base/threading/non_thread_safe.h"
#include "net/base/completion_callback.h"
+#include "net/base/load_states.h"
#include "net/base/net_export.h"
#include "net/base/net_log.h"
#include "net/base/network_change_notifier.h"
@@ -105,6 +106,9 @@ class NET_EXPORT ProxyService : public NetworkChangeNotifier::IPAddressObserver,
// Call this method with a non-null |pac_request| to cancel the PAC request.
void CancelPacRequest(PacRequest* pac_request);
+ // Returns the LoadState for this |pac_request| which must be non-NULL.
+ LoadState GetLoadState(const PacRequest* pac_request) const;
+
// Sets the ProxyScriptFetcher and DhcpProxyScriptFetcher dependencies. This
// is needed if the ProxyResolver is of type ProxyResolverWithoutFetch.
// ProxyService takes ownership of both objects.
diff --git a/net/proxy/sync_host_resolver_bridge_unittest.cc b/net/proxy/sync_host_resolver_bridge_unittest.cc
index 4600ab3..327c44d 100644
--- a/net/proxy/sync_host_resolver_bridge_unittest.cc
+++ b/net/proxy/sync_host_resolver_bridge_unittest.cc
@@ -111,6 +111,17 @@ class SyncProxyResolver : public ProxyResolver {
NOTREACHED();
}
+ virtual LoadState GetLoadState(RequestHandle request) const OVERRIDE {
+ NOTREACHED();
+ return LOAD_STATE_IDLE;
+ }
+
+ virtual LoadState GetLoadStateThreadSafe(
+ RequestHandle request) const OVERRIDE {
+ NOTREACHED();
+ return LOAD_STATE_IDLE;
+ }
+
virtual void Shutdown() OVERRIDE {
host_resolver_->Shutdown();
}