Index: chrome/browser/io_thread.cc |
diff --git a/chrome/browser/io_thread.cc b/chrome/browser/io_thread.cc |
index c6b8c7b97efbda9f416161587ae26cd3ca8919c4..30a3d6054bcd5eefb3fb033254fbb0c855e3b1cb 100644 |
--- a/chrome/browser/io_thread.cc |
+++ b/chrome/browser/io_thread.cc |
@@ -15,7 +15,11 @@ |
#include "base/string_split.h" |
#include "base/string_util.h" |
#include "base/threading/thread_restrictions.h" |
+#include "chrome/browser/browser_process.h" |
#include "chrome/browser/browser_thread.h" |
+#if defined(OS_CHROMEOS) |
+#include "chrome/browser/chromeos/proxy_config_service_impl.h" |
+#endif // defined(OS_CHROMEOS) |
#include "chrome/browser/gpu_process_host.h" |
#include "chrome/browser/in_process_webkit/indexed_db_key_utility_client.h" |
#include "chrome/browser/net/chrome_net_log.h" |
@@ -23,6 +27,7 @@ |
#include "chrome/browser/net/connect_interceptor.h" |
#include "chrome/browser/net/passive_log_collector.h" |
#include "chrome/browser/net/predictor_api.h" |
+#include "chrome/browser/net/pref_proxy_config_service.h" |
#include "chrome/browser/prefs/pref_service.h" |
#include "chrome/common/chrome_switches.h" |
#include "chrome/common/net/raw_host_resolver_proc.h" |
@@ -35,6 +40,7 @@ |
#include "net/base/host_resolver_impl.h" |
#include "net/base/mapped_host_resolver.h" |
#include "net/base/net_util.h" |
+#include "net/proxy/proxy_config_service_fixed.h" |
#include "net/http/http_auth_filter.h" |
#include "net/http/http_auth_handler_factory.h" |
#include "net/http/http_network_layer.h" |
@@ -195,6 +201,57 @@ ConstructProxyScriptFetcherContext(IOThread::Globals* globals, |
return context; |
} |
+scoped_refptr<net::URLRequestContext> |
+ConstructSystemRequestContext(IOThread::Globals* globals, |
+ net::NetLog* net_log) { |
+ scoped_refptr<net::URLRequestContext> context(new net::URLRequestContext); |
+ context->set_net_log(net_log); |
+ context->set_host_resolver(globals->host_resolver.get()); |
+ context->set_cert_verifier(globals->cert_verifier.get()); |
+ context->set_dnsrr_resolver(globals->dnsrr_resolver.get()); |
+ context->set_http_auth_handler_factory( |
+ globals->http_auth_handler_factory.get()); |
+ context->set_proxy_service(globals->system_proxy_service.get()); |
+ context->set_http_transaction_factory( |
+ globals->system_http_transaction_factory.get()); |
+ // In-memory cookie store. |
+ context->set_cookie_store(new net::CookieMonster(NULL, NULL)); |
+ return context; |
+} |
+ |
+class SystemURLRequestContextGetter : public URLRequestContextGetter { |
+ public: |
+ explicit SystemURLRequestContextGetter(IOThread * io_thread); |
willchan no longer on Chromium
2011/02/15 01:05:58
We don't have spaces between types and '*', so I'd
battre
2011/02/15 19:32:49
Done.
|
+ virtual ~SystemURLRequestContextGetter(); |
+ |
+ // Implementation for UrlRequestContextGetter. |
+ virtual net::URLRequestContext* GetURLRequestContext(); |
+ virtual scoped_refptr<base::MessageLoopProxy> GetIOMessageLoopProxy() const; |
+ |
+ private: |
+ IOThread * const io_thread_; // Weak pointer, owned by BrowserProcess. |
willchan no longer on Chromium
2011/02/15 01:05:58
We don't have spaces between types and '*', so I'd
battre
2011/02/15 19:32:49
Done.
|
+ scoped_refptr<base::MessageLoopProxy> io_message_loop_proxy_; |
+ |
+ base::debug::LeakTracker<SystemURLRequestContextGetter> leak_tracker_; |
+}; |
+ |
+SystemURLRequestContextGetter::SystemURLRequestContextGetter( |
+ IOThread* io_thread) |
+ : io_thread_(io_thread), |
+ io_message_loop_proxy_(io_thread->message_loop_proxy()) { |
+} |
+ |
+SystemURLRequestContextGetter::~SystemURLRequestContextGetter() {} |
+ |
+net::URLRequestContext* SystemURLRequestContextGetter::GetURLRequestContext() { |
willchan no longer on Chromium
2011/02/15 01:05:58
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::I
battre
2011/02/15 19:32:49
Done.
|
+ return io_thread_->globals()->system_request_context; |
+} |
+ |
+scoped_refptr<base::MessageLoopProxy> |
+SystemURLRequestContextGetter::GetIOMessageLoopProxy() const { |
+ return io_message_loop_proxy_; |
+} |
+ |
} // namespace |
// The IOThread object must outlive any tasks posted to the IO thread before the |
@@ -243,6 +300,44 @@ ChromeNetLog* IOThread::net_log() { |
return net_log_; |
} |
+void IOThread::InitSystemRequestContext( |
+ net::ProxyConfigService* config_service) { |
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
+ message_loop()->PostTask( |
+ FROM_HERE, |
+ NewRunnableMethod( |
+ this, |
+ &IOThread::InitSystemRequestContextOnIOThread, |
+ config_service)); |
+} |
+ |
+void IOThread::InitSystemRequestContextOnIOThread( |
+ net::ProxyConfigService* config_service) { |
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
+ |
+ size_t num_pac_threads = 0u; // Use default number of threads. |
+ globals_->system_proxy_service = |
+ net::ProxyService::CreateUsingSystemProxyResolver( |
+ config_service, num_pac_threads, net_log_); |
+ net::HttpNetworkSession::Params system_params; |
+ system_params.host_resolver = globals_->host_resolver.get(); |
+ system_params.cert_verifier = globals_->cert_verifier.get(); |
+ system_params.dnsrr_resolver = globals_->dnsrr_resolver.get(); |
+ system_params.dns_cert_checker = NULL; |
+ system_params.ssl_host_info_factory = NULL; |
+ system_params.proxy_service = globals_->system_proxy_service.get(); |
+ system_params.ssl_config_service = globals_->ssl_config_service.get(); |
+ system_params.http_auth_handler_factory = |
+ globals_->http_auth_handler_factory.get(); |
+ system_params.network_delegate = &globals_->network_delegate; |
+ system_params.net_log = net_log_; |
+ globals_->system_http_transaction_factory.reset( |
+ new net::HttpNetworkLayer( |
+ new net::HttpNetworkSession(system_params))); |
+ globals_->system_request_context = |
+ ConstructSystemRequestContext(globals_, net_log_); |
+} |
+ |
void IOThread::InitNetworkPredictor( |
bool prefetching_enabled, |
base::TimeDelta max_dns_queue_delay, |
@@ -294,6 +389,16 @@ void IOThread::ChangedToOnTheRecord() { |
&IOThread::ChangedToOnTheRecordOnIOThread)); |
} |
+scoped_refptr<URLRequestContextGetter> |
+IOThread::system_url_request_context_getter() { |
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
+ if (!system_url_request_context_getter_) { |
+ system_url_request_context_getter_ = |
+ new SystemURLRequestContextGetter(this); |
+ } |
+ return system_url_request_context_getter_; |
+} |
+ |
void IOThread::Init() { |
// Though this thread is called the "IO" thread, it actually just routes |
// messages around; it shouldn't be allowed to perform any blocking disk I/O. |
@@ -409,6 +514,9 @@ void IOThread::CleanUp() { |
delete globals_; |
globals_ = NULL; |
+ system_url_request_context_getter_ = NULL; |
willchan no longer on Chromium
2011/02/15 01:05:58
Please move this line to the end of "Step 1". See
battre
2011/02/15 19:32:49
Done.
|
+ base::debug::LeakTracker<SystemURLRequestContextGetter>::CheckForLeaks(); |
willchan no longer on Chromium
2011/02/15 01:05:58
Please move this to CleanUpAfterMessageLoopDestruc
battre
2011/02/15 19:32:49
Done.
|
+ |
BrowserProcessSubThread::CleanUp(); |
} |