Use "ProxyResolverV8" instead of "SystemProxyResolver" as proxy service.

SystemProxyResolver is untested and could cause random crashes.
This commit is contained in:
Cheng Zhao 2013-12-05 02:56:28 -08:00
parent cf08bb098f
commit 0a1f756ca6
3 changed files with 25 additions and 6 deletions

View file

@ -6,6 +6,7 @@
#include "browser/browser_context.h"
#include "browser/web_ui_controller_factory.h"
#include "net/proxy/proxy_resolver_v8.h"
namespace brightray {
@ -29,6 +30,15 @@ void BrowserMainParts::PostMainMessageLoopRun() {
browser_context_.reset();
}
int BrowserMainParts::PreCreateThreads() {
#if defined(OS_WIN)
net::ProxyResolverV8::CreateIsolate();
#else
net::ProxyResolverV8::RememberDefaultIsolate();
#endif
return 0;
}
BrowserContext* BrowserMainParts::CreateBrowserContext() {
return new BrowserContext;
}

View file

@ -32,6 +32,7 @@ class BrowserMainParts : public content::BrowserMainParts {
virtual void PreMainMessageLoopRun() OVERRIDE;
virtual void PostMainMessageLoopRun() OVERRIDE;
virtual int PreCreateThreads() OVERRIDE;
private:
scoped_ptr<BrowserContext> browser_context_;

View file

@ -19,7 +19,11 @@
#include "net/http/http_auth_handler_factory.h"
#include "net/http/http_cache.h"
#include "net/http/http_server_properties_impl.h"
#include "net/proxy/dhcp_proxy_script_fetcher_factory.h"
#include "net/proxy/proxy_config_service.h"
#include "net/proxy/proxy_script_fetcher_impl.h"
#include "net/proxy/proxy_service.h"
#include "net/proxy/proxy_service_v8.h"
#include "net/ssl/default_server_bound_cert_store.h"
#include "net/ssl/server_bound_cert_service.h"
#include "net/ssl/ssl_config_service_defaults.h"
@ -83,12 +87,6 @@ net::URLRequestContext* URLRequestContextGetter::GetURLRequestContext() {
net::HostResolver::CreateDefaultResolver(NULL));
storage_->set_cert_verifier(net::CertVerifier::CreateDefault());
// TODO(jam): use v8 if possible, look at chrome code.
storage_->set_proxy_service(
net::ProxyService::CreateUsingSystemProxyResolver(
proxy_config_service_.release(),
0,
NULL));
storage_->set_ssl_config_service(new net::SSLConfigServiceDefaults);
storage_->set_http_auth_handler_factory(
net::HttpAuthHandlerFactory::CreateDefault(host_resolver.get()));
@ -128,6 +126,16 @@ net::URLRequestContext* URLRequestContextGetter::GetURLRequestContext() {
network_session_params.host_resolver =
url_request_context_->host_resolver();
net::DhcpProxyScriptFetcherFactory dhcp_factory;
storage_->set_proxy_service(
net::CreateProxyServiceUsingV8ProxyResolver(
proxy_config_service_.release(),
new net::ProxyScriptFetcherImpl(url_request_context_.get()),
dhcp_factory.Create(url_request_context_.get()),
url_request_context_->host_resolver(),
NULL,
url_request_context_->network_delegate()));
net::HttpCache* main_cache = new net::HttpCache(
network_session_params, main_backend);
storage_->set_http_transaction_factory(main_cache);