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

Side by Side Diff: chrome/browser/io_thread.cc

Issue 10203002: Make URLRequestThrottlerManager a member of URLRequestContext. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Ready for review. Created 8 years, 7 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 "chrome/browser/io_thread.h" 5 #include "chrome/browser/io_thread.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 #include "net/cookies/cookie_monster.h" 46 #include "net/cookies/cookie_monster.h"
47 #include "net/ftp/ftp_network_layer.h" 47 #include "net/ftp/ftp_network_layer.h"
48 #include "net/http/http_auth_filter.h" 48 #include "net/http/http_auth_filter.h"
49 #include "net/http/http_auth_handler_factory.h" 49 #include "net/http/http_auth_handler_factory.h"
50 #include "net/http/http_network_layer.h" 50 #include "net/http/http_network_layer.h"
51 #include "net/http/http_network_session.h" 51 #include "net/http/http_network_session.h"
52 #include "net/http/http_server_properties_impl.h" 52 #include "net/http/http_server_properties_impl.h"
53 #include "net/proxy/proxy_config_service.h" 53 #include "net/proxy/proxy_config_service.h"
54 #include "net/proxy/proxy_script_fetcher_impl.h" 54 #include "net/proxy/proxy_script_fetcher_impl.h"
55 #include "net/proxy/proxy_service.h" 55 #include "net/proxy/proxy_service.h"
56 #include "net/url_request/url_request_throttler_manager.h"
56 57
57 #if defined(USE_NSS) 58 #if defined(USE_NSS)
58 #include "net/ocsp/nss_ocsp.h" 59 #include "net/ocsp/nss_ocsp.h"
59 #endif // defined(USE_NSS) 60 #endif // defined(USE_NSS)
60 61
61 #if defined(OS_CHROMEOS) 62 #if defined(OS_CHROMEOS)
62 #include "chrome/browser/chromeos/proxy_config_service_impl.h" 63 #include "chrome/browser/chromeos/proxy_config_service_impl.h"
63 #endif // defined(OS_CHROMEOS) 64 #endif // defined(OS_CHROMEOS)
64 65
65 using content::BrowserThread; 66 using content::BrowserThread;
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 globals->http_auth_handler_factory.get()); 210 globals->http_auth_handler_factory.get());
210 context->set_proxy_service(globals->proxy_script_fetcher_proxy_service.get()); 211 context->set_proxy_service(globals->proxy_script_fetcher_proxy_service.get());
211 context->set_http_transaction_factory( 212 context->set_http_transaction_factory(
212 globals->proxy_script_fetcher_http_transaction_factory.get()); 213 globals->proxy_script_fetcher_http_transaction_factory.get());
213 context->set_ftp_transaction_factory( 214 context->set_ftp_transaction_factory(
214 globals->proxy_script_fetcher_ftp_transaction_factory.get()); 215 globals->proxy_script_fetcher_ftp_transaction_factory.get());
215 context->set_cookie_store(globals->system_cookie_store.get()); 216 context->set_cookie_store(globals->system_cookie_store.get());
216 context->set_server_bound_cert_service( 217 context->set_server_bound_cert_service(
217 globals->system_server_bound_cert_service.get()); 218 globals->system_server_bound_cert_service.get());
218 context->set_network_delegate(globals->system_network_delegate.get()); 219 context->set_network_delegate(globals->system_network_delegate.get());
220 context->set_throttler_manager(globals->throttler_manager.get());
eroman 2012/04/24 19:05:57 I'm not sure that we would ever want the ProxyScri
Jói 2012/04/27 13:20:26 Right, it checks each request for now, because ext
willchan no longer on Chromium 2012/04/27 17:39:25 Why don't we just check NULL in URLRequestHttpJob?
219 // TODO(rtenneti): We should probably use HttpServerPropertiesManager for the 221 // TODO(rtenneti): We should probably use HttpServerPropertiesManager for the
220 // system URLRequestContext too. There's no reason this should be tied to a 222 // system URLRequestContext too. There's no reason this should be tied to a
221 // profile. 223 // profile.
222 return context; 224 return context;
223 } 225 }
224 226
225 scoped_refptr<net::URLRequestContext> 227 scoped_refptr<net::URLRequestContext>
226 ConstructSystemRequestContext(IOThread::Globals* globals, 228 ConstructSystemRequestContext(IOThread::Globals* globals,
227 net::NetLog* net_log) { 229 net::NetLog* net_log) {
228 scoped_refptr<net::URLRequestContext> context( 230 scoped_refptr<net::URLRequestContext> context(
229 new SystemURLRequestContext); 231 new SystemURLRequestContext);
230 context->set_net_log(net_log); 232 context->set_net_log(net_log);
231 context->set_host_resolver(globals->host_resolver.get()); 233 context->set_host_resolver(globals->host_resolver.get());
232 context->set_cert_verifier(globals->cert_verifier.get()); 234 context->set_cert_verifier(globals->cert_verifier.get());
233 context->set_transport_security_state( 235 context->set_transport_security_state(
234 globals->transport_security_state.get()); 236 globals->transport_security_state.get());
235 context->set_http_auth_handler_factory( 237 context->set_http_auth_handler_factory(
236 globals->http_auth_handler_factory.get()); 238 globals->http_auth_handler_factory.get());
237 context->set_proxy_service(globals->system_proxy_service.get()); 239 context->set_proxy_service(globals->system_proxy_service.get());
238 context->set_http_transaction_factory( 240 context->set_http_transaction_factory(
239 globals->system_http_transaction_factory.get()); 241 globals->system_http_transaction_factory.get());
240 context->set_ftp_transaction_factory( 242 context->set_ftp_transaction_factory(
241 globals->system_ftp_transaction_factory.get()); 243 globals->system_ftp_transaction_factory.get());
242 context->set_cookie_store(globals->system_cookie_store.get()); 244 context->set_cookie_store(globals->system_cookie_store.get());
243 context->set_server_bound_cert_service( 245 context->set_server_bound_cert_service(
244 globals->system_server_bound_cert_service.get()); 246 globals->system_server_bound_cert_service.get());
247 context->set_throttler_manager(globals->throttler_manager.get());
245 return context; 248 return context;
246 } 249 }
247 250
248 } // namespace 251 } // namespace
249 252
250 class SystemURLRequestContextGetter : public net::URLRequestContextGetter { 253 class SystemURLRequestContextGetter : public net::URLRequestContextGetter {
251 public: 254 public:
252 explicit SystemURLRequestContextGetter(IOThread* io_thread); 255 explicit SystemURLRequestContextGetter(IOThread* io_thread);
253 256
254 // Implementation for net::UrlRequestContextGetter. 257 // Implementation for net::UrlRequestContextGetter.
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
438 globals_->http_server_properties.get(); 441 globals_->http_server_properties.get();
439 session_params.net_log = net_log_; 442 session_params.net_log = net_log_;
440 session_params.ssl_config_service = globals_->ssl_config_service; 443 session_params.ssl_config_service = globals_->ssl_config_service;
441 scoped_refptr<net::HttpNetworkSession> network_session( 444 scoped_refptr<net::HttpNetworkSession> network_session(
442 new net::HttpNetworkSession(session_params)); 445 new net::HttpNetworkSession(session_params));
443 globals_->proxy_script_fetcher_http_transaction_factory.reset( 446 globals_->proxy_script_fetcher_http_transaction_factory.reset(
444 new net::HttpNetworkLayer(network_session)); 447 new net::HttpNetworkLayer(network_session));
445 globals_->proxy_script_fetcher_ftp_transaction_factory.reset( 448 globals_->proxy_script_fetcher_ftp_transaction_factory.reset(
446 new net::FtpNetworkLayer(globals_->host_resolver.get())); 449 new net::FtpNetworkLayer(globals_->host_resolver.get()));
447 450
451 globals_->throttler_manager.reset(new net::URLRequestThrottlerManager());
452 // Always done in production, disabled only for unit tests.
453 globals_->throttler_manager->set_enable_thread_checks(true);
454 if (CommandLine::ForCurrentProcess()->HasSwitch(
455 switches::kDisableExtensionsHttpThrottling)) {
456 globals_->throttler_manager->set_enforce_throttling(false);
457 }
458 globals_->throttler_manager->set_net_log(net_log_);
459
448 globals_->proxy_script_fetcher_context = 460 globals_->proxy_script_fetcher_context =
449 ConstructProxyScriptFetcherContext(globals_, net_log_); 461 ConstructProxyScriptFetcherContext(globals_, net_log_);
450 462
451 sdch_manager_ = new net::SdchManager(); 463 sdch_manager_ = new net::SdchManager();
452 464
453 // InitSystemRequestContext turns right around and posts a task back 465 // InitSystemRequestContext turns right around and posts a task back
454 // to the IO thread, so we can't let it run until we know the IO 466 // to the IO thread, so we can't let it run until we know the IO
455 // thread has started. 467 // thread has started.
456 // 468 //
457 // Note that since we are at BrowserThread::Init time, the UI thread 469 // Note that since we are at BrowserThread::Init time, the UI thread
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
613 new net::HttpNetworkLayer( 625 new net::HttpNetworkLayer(
614 new net::HttpNetworkSession(system_params))); 626 new net::HttpNetworkSession(system_params)));
615 globals_->system_ftp_transaction_factory.reset( 627 globals_->system_ftp_transaction_factory.reset(
616 new net::FtpNetworkLayer(globals_->host_resolver.get())); 628 new net::FtpNetworkLayer(globals_->host_resolver.get()));
617 globals_->system_request_context = 629 globals_->system_request_context =
618 ConstructSystemRequestContext(globals_, net_log_); 630 ConstructSystemRequestContext(globals_, net_log_);
619 631
620 sdch_manager_->set_sdch_fetcher( 632 sdch_manager_->set_sdch_fetcher(
621 new SdchDictionaryFetcher(system_url_request_context_getter_.get())); 633 new SdchDictionaryFetcher(system_url_request_context_getter_.get()));
622 } 634 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698