OLD | NEW |
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 14 matching lines...) Expand all Loading... |
25 #include "chrome/browser/net/chrome_network_delegate.h" | 25 #include "chrome/browser/net/chrome_network_delegate.h" |
26 #include "chrome/browser/net/chrome_url_request_context.h" | 26 #include "chrome/browser/net/chrome_url_request_context.h" |
27 #include "chrome/browser/net/connect_interceptor.h" | 27 #include "chrome/browser/net/connect_interceptor.h" |
28 #include "chrome/browser/net/http_pipelining_compatibility_client.h" | 28 #include "chrome/browser/net/http_pipelining_compatibility_client.h" |
29 #include "chrome/browser/net/pref_proxy_config_tracker.h" | 29 #include "chrome/browser/net/pref_proxy_config_tracker.h" |
30 #include "chrome/browser/net/proxy_service_factory.h" | 30 #include "chrome/browser/net/proxy_service_factory.h" |
31 #include "chrome/browser/net/sdch_dictionary_fetcher.h" | 31 #include "chrome/browser/net/sdch_dictionary_fetcher.h" |
32 #include "chrome/browser/prefs/pref_service.h" | 32 #include "chrome/browser/prefs/pref_service.h" |
33 #include "chrome/common/chrome_switches.h" | 33 #include "chrome/common/chrome_switches.h" |
34 #include "chrome/common/pref_names.h" | 34 #include "chrome/common/pref_names.h" |
| 35 #include "chrome/common/url_constants.h" |
35 #include "content/public/browser/browser_thread.h" | 36 #include "content/public/browser/browser_thread.h" |
36 #include "content/public/common/content_client.h" | 37 #include "content/public/common/content_client.h" |
37 #include "content/public/common/url_fetcher.h" | 38 #include "content/public/common/url_fetcher.h" |
38 #include "net/base/cert_verifier.h" | 39 #include "net/base/cert_verifier.h" |
39 #include "net/base/default_server_bound_cert_store.h" | 40 #include "net/base/default_server_bound_cert_store.h" |
40 #include "net/base/host_cache.h" | 41 #include "net/base/host_cache.h" |
41 #include "net/base/host_resolver.h" | 42 #include "net/base/host_resolver.h" |
42 #include "net/base/mapped_host_resolver.h" | 43 #include "net/base/mapped_host_resolver.h" |
43 #include "net/base/net_util.h" | 44 #include "net/base/net_util.h" |
44 #include "net/base/sdch_manager.h" | 45 #include "net/base/sdch_manager.h" |
45 #include "net/base/server_bound_cert_service.h" | 46 #include "net/base/server_bound_cert_service.h" |
46 #include "net/cookies/cookie_monster.h" | 47 #include "net/cookies/cookie_monster.h" |
47 #include "net/ftp/ftp_network_layer.h" | 48 #include "net/ftp/ftp_network_layer.h" |
48 #include "net/http/http_auth_filter.h" | 49 #include "net/http/http_auth_filter.h" |
49 #include "net/http/http_auth_handler_factory.h" | 50 #include "net/http/http_auth_handler_factory.h" |
50 #include "net/http/http_network_layer.h" | 51 #include "net/http/http_network_layer.h" |
51 #include "net/http/http_network_session.h" | 52 #include "net/http/http_network_session.h" |
52 #include "net/http/http_server_properties_impl.h" | 53 #include "net/http/http_server_properties_impl.h" |
53 #include "net/proxy/proxy_config_service.h" | 54 #include "net/proxy/proxy_config_service.h" |
54 #include "net/proxy/proxy_script_fetcher_impl.h" | 55 #include "net/proxy/proxy_script_fetcher_impl.h" |
55 #include "net/proxy/proxy_service.h" | 56 #include "net/proxy/proxy_service.h" |
| 57 #include "net/url_request/url_request.h" |
56 #include "net/url_request/url_request_throttler_manager.h" | 58 #include "net/url_request/url_request_throttler_manager.h" |
57 | 59 |
58 #if defined(USE_NSS) | 60 #if defined(USE_NSS) |
59 #include "net/ocsp/nss_ocsp.h" | 61 #include "net/ocsp/nss_ocsp.h" |
60 #endif // defined(USE_NSS) | 62 #endif // defined(USE_NSS) |
61 | 63 |
62 #if defined(OS_CHROMEOS) | 64 #if defined(OS_CHROMEOS) |
63 #include "chrome/browser/chromeos/proxy_config_service_impl.h" | 65 #include "chrome/browser/chromeos/proxy_config_service_impl.h" |
64 #endif // defined(OS_CHROMEOS) | 66 #endif // defined(OS_CHROMEOS) |
65 | 67 |
66 using content::BrowserThread; | 68 using content::BrowserThread; |
67 | 69 |
68 class SafeBrowsingURLRequestContext; | 70 class SafeBrowsingURLRequestContext; |
69 | 71 |
70 // The IOThread object must outlive any tasks posted to the IO thread before the | 72 // The IOThread object must outlive any tasks posted to the IO thread before the |
71 // Quit task, so base::Bind() calls are not refcounted. | 73 // Quit task, so base::Bind() calls are not refcounted. |
72 | 74 |
73 namespace { | 75 namespace { |
74 | 76 |
| 77 // Makes it so that the URLRequestThrottlerManager may only reject |
| 78 // requests that originate from extensions. |
| 79 class ChromeURLRequestThrottlerManagerDelegate |
| 80 : public net::URLRequestThrottlerManagerDelegate { |
| 81 public: |
| 82 explicit ChromeURLRequestThrottlerManagerDelegate(bool enforce) |
| 83 : enforce_(enforce) { |
| 84 } |
| 85 |
| 86 virtual bool MayRejectRequest(net::URLRequest* request) OVERRIDE { |
| 87 if (enforce_) { |
| 88 return request->first_party_for_cookies().scheme() != |
| 89 chrome::kExtensionScheme; |
| 90 } else { |
| 91 return false; |
| 92 } |
| 93 } |
| 94 |
| 95 private: |
| 96 bool enforce_; |
| 97 }; |
| 98 |
75 // Custom URLRequestContext used by requests which aren't associated with a | 99 // Custom URLRequestContext used by requests which aren't associated with a |
76 // particular profile. We need to use a subclass of URLRequestContext in order | 100 // particular profile. We need to use a subclass of URLRequestContext in order |
77 // to provide the correct User-Agent. | 101 // to provide the correct User-Agent. |
78 class URLRequestContextWithUserAgent : public net::URLRequestContext { | 102 class URLRequestContextWithUserAgent : public net::URLRequestContext { |
79 public: | 103 public: |
80 virtual const std::string& GetUserAgent( | 104 virtual const std::string& GetUserAgent( |
81 const GURL& url) const OVERRIDE { | 105 const GURL& url) const OVERRIDE { |
82 return content::GetUserAgent(url); | 106 return content::GetUserAgent(url); |
83 } | 107 } |
84 | 108 |
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
439 globals_->http_server_properties.get(); | 463 globals_->http_server_properties.get(); |
440 session_params.net_log = net_log_; | 464 session_params.net_log = net_log_; |
441 session_params.ssl_config_service = globals_->ssl_config_service; | 465 session_params.ssl_config_service = globals_->ssl_config_service; |
442 scoped_refptr<net::HttpNetworkSession> network_session( | 466 scoped_refptr<net::HttpNetworkSession> network_session( |
443 new net::HttpNetworkSession(session_params)); | 467 new net::HttpNetworkSession(session_params)); |
444 globals_->proxy_script_fetcher_http_transaction_factory.reset( | 468 globals_->proxy_script_fetcher_http_transaction_factory.reset( |
445 new net::HttpNetworkLayer(network_session)); | 469 new net::HttpNetworkLayer(network_session)); |
446 globals_->proxy_script_fetcher_ftp_transaction_factory.reset( | 470 globals_->proxy_script_fetcher_ftp_transaction_factory.reset( |
447 new net::FtpNetworkLayer(globals_->host_resolver.get())); | 471 new net::FtpNetworkLayer(globals_->host_resolver.get())); |
448 | 472 |
449 globals_->throttler_manager.reset(new net::URLRequestThrottlerManager()); | 473 bool enforce_throttling = CommandLine::ForCurrentProcess()->HasSwitch( |
| 474 switches::kDisableExtensionsHttpThrottling); |
| 475 globals_->throttler_manager_delegate.reset( |
| 476 new ChromeURLRequestThrottlerManagerDelegate(enforce_throttling)); |
| 477 |
| 478 globals_->throttler_manager.reset(new net::URLRequestThrottlerManager( |
| 479 globals_->throttler_manager_delegate.get())); |
450 // Always done in production, disabled only for unit tests. | 480 // Always done in production, disabled only for unit tests. |
451 globals_->throttler_manager->set_enable_thread_checks(true); | 481 globals_->throttler_manager->set_enable_thread_checks(true); |
452 if (CommandLine::ForCurrentProcess()->HasSwitch( | |
453 switches::kDisableExtensionsHttpThrottling)) { | |
454 globals_->throttler_manager->set_enforce_throttling(false); | |
455 } | |
456 globals_->throttler_manager->set_net_log(net_log_); | 482 globals_->throttler_manager->set_net_log(net_log_); |
457 | 483 |
458 globals_->proxy_script_fetcher_context.reset( | 484 globals_->proxy_script_fetcher_context.reset( |
459 ConstructProxyScriptFetcherContext(globals_, net_log_)); | 485 ConstructProxyScriptFetcherContext(globals_, net_log_)); |
460 | 486 |
461 sdch_manager_ = new net::SdchManager(); | 487 sdch_manager_ = new net::SdchManager(); |
462 | 488 |
463 // InitSystemRequestContext turns right around and posts a task back | 489 // InitSystemRequestContext turns right around and posts a task back |
464 // to the IO thread, so we can't let it run until we know the IO | 490 // to the IO thread, so we can't let it run until we know the IO |
465 // thread has started. | 491 // thread has started. |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
623 new net::HttpNetworkLayer( | 649 new net::HttpNetworkLayer( |
624 new net::HttpNetworkSession(system_params))); | 650 new net::HttpNetworkSession(system_params))); |
625 globals_->system_ftp_transaction_factory.reset( | 651 globals_->system_ftp_transaction_factory.reset( |
626 new net::FtpNetworkLayer(globals_->host_resolver.get())); | 652 new net::FtpNetworkLayer(globals_->host_resolver.get())); |
627 globals_->system_request_context.reset( | 653 globals_->system_request_context.reset( |
628 ConstructSystemRequestContext(globals_, net_log_)); | 654 ConstructSystemRequestContext(globals_, net_log_)); |
629 | 655 |
630 sdch_manager_->set_sdch_fetcher( | 656 sdch_manager_->set_sdch_fetcher( |
631 new SdchDictionaryFetcher(system_url_request_context_getter_.get())); | 657 new SdchDictionaryFetcher(system_url_request_context_getter_.get())); |
632 } | 658 } |
OLD | NEW |