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

Side by Side Diff: content/shell/shell_url_request_context_getter.cc

Issue 10912132: Move ProxyConfigService construction onto the IO thread. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Tiny fix for get_server_time Created 8 years, 2 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/shell/shell_url_request_context_getter.h" 5 #include "content/shell/shell_url_request_context_getter.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/string_number_conversions.h" 9 #include "base/string_number_conversions.h"
10 #include "base/string_split.h" 10 #include "base/string_split.h"
(...skipping 21 matching lines...) Expand all
32 32
33 ShellURLRequestContextGetter::ShellURLRequestContextGetter( 33 ShellURLRequestContextGetter::ShellURLRequestContextGetter(
34 bool ignore_certificate_errors, 34 bool ignore_certificate_errors,
35 const FilePath& base_path, 35 const FilePath& base_path,
36 MessageLoop* io_loop, 36 MessageLoop* io_loop,
37 MessageLoop* file_loop) 37 MessageLoop* file_loop)
38 : ignore_certificate_errors_(ignore_certificate_errors), 38 : ignore_certificate_errors_(ignore_certificate_errors),
39 base_path_(base_path), 39 base_path_(base_path),
40 io_loop_(io_loop), 40 io_loop_(io_loop),
41 file_loop_(file_loop) { 41 file_loop_(file_loop) {
42 // Must first be created on the UI thread.
43 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
44
45 // We must create the proxy config service on the UI loop on Linux because it
46 // must synchronously run on the glib message loop. This will be passed to
47 // the URLRequestContextStorage on the IO thread in GetURLRequestContext().
48 proxy_config_service_.reset(
49 net::ProxyService::CreateSystemProxyConfigService(
50 io_loop_->message_loop_proxy(), file_loop_));
51 } 42 }
52 43
53 ShellURLRequestContextGetter::~ShellURLRequestContextGetter() { 44 ShellURLRequestContextGetter::~ShellURLRequestContextGetter() {
54 } 45 }
55 46
56 net::URLRequestContext* ShellURLRequestContextGetter::GetURLRequestContext() { 47 net::URLRequestContext* ShellURLRequestContextGetter::GetURLRequestContext() {
57 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 48 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
58 49
59 if (!url_request_context_.get()) { 50 if (!url_request_context_.get()) {
60 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); 51 const CommandLine& command_line = *CommandLine::ForCurrentProcess();
61 52
62 url_request_context_.reset(new net::URLRequestContext()); 53 url_request_context_.reset(new net::URLRequestContext());
63 network_delegate_.reset(new ShellNetworkDelegate); 54 network_delegate_.reset(new ShellNetworkDelegate);
64 url_request_context_->set_network_delegate(network_delegate_.get()); 55 url_request_context_->set_network_delegate(network_delegate_.get());
65 storage_.reset( 56 storage_.reset(
66 new net::URLRequestContextStorage(url_request_context_.get())); 57 new net::URLRequestContextStorage(url_request_context_.get()));
67 storage_->set_cookie_store(new net::CookieMonster(NULL, NULL)); 58 storage_->set_cookie_store(new net::CookieMonster(NULL, NULL));
68 storage_->set_server_bound_cert_service(new net::ServerBoundCertService( 59 storage_->set_server_bound_cert_service(new net::ServerBoundCertService(
69 new net::DefaultServerBoundCertStore(NULL), 60 new net::DefaultServerBoundCertStore(NULL),
70 base::WorkerPool::GetTaskRunner(true))); 61 base::WorkerPool::GetTaskRunner(true)));
71 url_request_context_->set_accept_language("en-us,en"); 62 url_request_context_->set_accept_language("en-us,en");
72 url_request_context_->set_accept_charset("iso-8859-1,*,utf-8"); 63 url_request_context_->set_accept_charset("iso-8859-1,*,utf-8");
73 64
74 storage_->set_host_resolver( 65 storage_->set_host_resolver(
75 net::CreateSystemHostResolver(net::HostResolver::kDefaultParallelism, 66 net::CreateSystemHostResolver(net::HostResolver::kDefaultParallelism,
76 net::HostResolver::kDefaultRetryAttempts, 67 net::HostResolver::kDefaultRetryAttempts,
77 NULL)); 68 NULL));
78 storage_->set_cert_verifier(net::CertVerifier::CreateDefault()); 69 storage_->set_cert_verifier(net::CertVerifier::CreateDefault());
70 proxy_config_service_.reset(
71 net::ProxyService::CreateSystemProxyConfigService(
72 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI),
73 file_loop_));
79 // TODO(jam): use v8 if possible, look at chrome code. 74 // TODO(jam): use v8 if possible, look at chrome code.
80 storage_->set_proxy_service( 75 storage_->set_proxy_service(
81 net::ProxyService::CreateUsingSystemProxyResolver( 76 net::ProxyService::CreateUsingSystemProxyResolver(
82 proxy_config_service_.release(), 77 proxy_config_service_.release(),
83 0, 78 0,
84 NULL)); 79 NULL));
85 storage_->set_ssl_config_service(new net::SSLConfigServiceDefaults); 80 storage_->set_ssl_config_service(new net::SSLConfigServiceDefaults);
86 storage_->set_http_auth_handler_factory( 81 storage_->set_http_auth_handler_factory(
87 net::HttpAuthHandlerFactory::CreateDefault( 82 net::HttpAuthHandlerFactory::CreateDefault(
88 url_request_context_->host_resolver())); 83 url_request_context_->host_resolver()));
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 scoped_refptr<base::SingleThreadTaskRunner> 144 scoped_refptr<base::SingleThreadTaskRunner>
150 ShellURLRequestContextGetter::GetNetworkTaskRunner() const { 145 ShellURLRequestContextGetter::GetNetworkTaskRunner() const {
151 return BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO); 146 return BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO);
152 } 147 }
153 148
154 net::HostResolver* ShellURLRequestContextGetter::host_resolver() { 149 net::HostResolver* ShellURLRequestContextGetter::host_resolver() {
155 return url_request_context_->host_resolver(); 150 return url_request_context_->host_resolver();
156 } 151 }
157 152
158 } // namespace content 153 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698