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

Unified Diff: net/proxy/proxy_service.cc

Issue 14142: Start using the proxy resolve IPC for plugins.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/proxy/proxy_service.h ('k') | webkit/glue/plugins/mozilla_extensions.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/proxy/proxy_service.cc
===================================================================
--- net/proxy/proxy_service.cc (revision 8931)
+++ net/proxy/proxy_service.cc (working copy)
@@ -11,6 +11,7 @@
#include <algorithm>
+#include "base/compiler_specific.h"
#include "base/logging.h"
#include "base/message_loop.h"
#include "base/string_tokenizer.h"
@@ -522,7 +523,7 @@
if (url.host().find('.') == std::string::npos)
return true;
}
-
+
for(std::vector<std::string>::const_iterator i = config_.proxy_bypass.begin();
i != config_.proxy_bypass.end(); ++i) {
std::string bypass_url_domain = *i;
@@ -543,7 +544,7 @@
if (MatchPattern(url_domain, bypass_url_domain))
return true;
-
+
// Some systems (the Mac, for example) allow CIDR-style specification of
// proxy bypass for IP-specified hosts (e.g. "10.0.0.0/8"; see
// http://www.tcd.ie/iss/internet/osx_proxy.php for a real-world example).
@@ -554,5 +555,65 @@
return false;
}
+SyncProxyServiceHelper::SyncProxyServiceHelper(MessageLoop* io_message_loop,
+ ProxyService* proxy_service)
+ : io_message_loop_(io_message_loop),
+ proxy_service_(proxy_service),
+ event_(false, false),
+ ALLOW_THIS_IN_INITIALIZER_LIST(callback_(
+ this, &SyncProxyServiceHelper::OnCompletion)) {
+ DCHECK(io_message_loop_ != MessageLoop::current());
+}
+
+int SyncProxyServiceHelper::ResolveProxy(const GURL& url,
+ ProxyInfo* proxy_info) {
+ DCHECK(io_message_loop_ != MessageLoop::current());
+
+ io_message_loop_->PostTask(FROM_HERE, NewRunnableMethod(
+ this, &SyncProxyServiceHelper::StartAsyncResolve, url));
+
+ event_.Wait();
+
+ if (result_ == net::OK) {
+ *proxy_info = proxy_info_;
+ }
+ return result_;
+}
+
+int SyncProxyServiceHelper::ReconsiderProxyAfterError(const GURL& url,
+ ProxyInfo* proxy_info) {
+ DCHECK(io_message_loop_ != MessageLoop::current());
+
+ io_message_loop_->PostTask(FROM_HERE, NewRunnableMethod(
+ this, &SyncProxyServiceHelper::StartAsyncReconsider, url));
+
+ event_.Wait();
+
+ if (result_ == net::OK) {
+ *proxy_info = proxy_info_;
+ }
+ return result_;
+}
+
+void SyncProxyServiceHelper::StartAsyncResolve(const GURL& url) {
+ result_ = proxy_service_->ResolveProxy(url, &proxy_info_, &callback_, NULL);
+ if (result_ != net::ERR_IO_PENDING) {
+ OnCompletion(result_);
+ }
+}
+
+void SyncProxyServiceHelper::StartAsyncReconsider(const GURL& url) {
+ result_ = proxy_service_->ReconsiderProxyAfterError(
+ url, &proxy_info_, &callback_, NULL);
+ if (result_ != net::ERR_IO_PENDING) {
+ OnCompletion(result_);
+ }
+}
+
+void SyncProxyServiceHelper::OnCompletion(int rv) {
+ result_ = rv;
+ event_.Signal();
+}
+
} // namespace net
« no previous file with comments | « net/proxy/proxy_service.h ('k') | webkit/glue/plugins/mozilla_extensions.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698