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

Unified Diff: net/proxy/proxy_resolver_v8.cc

Issue 8373014: Add new text for indicating we are resolving hosts during proxy resolution. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Address eroman's nits. Created 9 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/proxy/proxy_resolver_v8.h ('k') | net/proxy/proxy_resolver_winhttp.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/proxy/proxy_resolver_v8.cc
diff --git a/net/proxy/proxy_resolver_v8.cc b/net/proxy/proxy_resolver_v8.cc
index 1bd736cb480c8bf28f3e2a251edb07d0ae4dd7e1..ff597ce99aebf79756f92c275030e5d9c521d487 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();
}
« no previous file with comments | « net/proxy/proxy_resolver_v8.h ('k') | net/proxy/proxy_resolver_winhttp.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698