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

Side by Side Diff: chrome/browser/net/chrome_url_request_context.cc

Issue 6292017: Extended: Add "system" URLRequestContext (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Cleanup Created 9 years, 10 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/net/chrome_url_request_context.h" 5 #include "chrome/browser/net/chrome_url_request_context.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/message_loop.h" 8 #include "base/message_loop.h"
9 #include "base/message_loop_proxy.h" 9 #include "base/message_loop_proxy.h"
10 #include "base/string_number_conversions.h" 10 #include "base/string_number_conversions.h"
11 #include "base/string_util.h" 11 #include "base/string_util.h"
12 #include "chrome/browser/browser_process.h" 12 #include "chrome/browser/browser_process.h"
13 #include "chrome/browser/browser_thread.h" 13 #include "chrome/browser/browser_thread.h"
14 #include "chrome/browser/dom_ui/chrome_url_data_manager_backend.h" 14 #include "chrome/browser/dom_ui/chrome_url_data_manager_backend.h"
15 #include "chrome/browser/extensions/extension_service.h" 15 #include "chrome/browser/extensions/extension_service.h"
16 #include "chrome/browser/extensions/user_script_master.h" 16 #include "chrome/browser/extensions/user_script_master.h"
17 #include "chrome/browser/io_thread.h" 17 #include "chrome/browser/io_thread.h"
18 #include "chrome/browser/net/chrome_cookie_notification_details.h" 18 #include "chrome/browser/net/chrome_cookie_notification_details.h"
19 #include "chrome/browser/net/chrome_net_log.h" 19 #include "chrome/browser/net/chrome_net_log.h"
20 #include "chrome/browser/net/chrome_dns_cert_provenance_checker_factory.h" 20 #include "chrome/browser/net/chrome_dns_cert_provenance_checker_factory.h"
21 #include "chrome/browser/net/sqlite_persistent_cookie_store.h" 21 #include "chrome/browser/net/sqlite_persistent_cookie_store.h"
22 #include "chrome/browser/net/predictor_api.h" 22 #include "chrome/browser/net/predictor_api.h"
23 #include "chrome/browser/net/pref_proxy_config_service.h" 23 #include "chrome/browser/net/pref_proxy_config_service.h"
24 #include "chrome/browser/net/proxy_service_factory.h"
24 #include "chrome/browser/profiles/profile.h" 25 #include "chrome/browser/profiles/profile.h"
25 #include "chrome/browser/profiles/profile_io_data.h" 26 #include "chrome/browser/profiles/profile_io_data.h"
26 #include "chrome/common/chrome_constants.h" 27 #include "chrome/common/chrome_constants.h"
27 #include "chrome/common/chrome_switches.h" 28 #include "chrome/common/chrome_switches.h"
28 #include "chrome/common/extensions/extension.h" 29 #include "chrome/common/extensions/extension.h"
29 #include "chrome/common/notification_service.h" 30 #include "chrome/common/notification_service.h"
30 #include "chrome/common/pref_names.h" 31 #include "chrome/common/pref_names.h"
31 #include "chrome/common/url_constants.h" 32 #include "chrome/common/url_constants.h"
32 #include "net/base/static_cookie_policy.h" 33 #include "net/base/static_cookie_policy.h"
33 #include "net/ftp/ftp_network_layer.h" 34 #include "net/ftp/ftp_network_layer.h"
(...skipping 28 matching lines...) Expand all
62 63
63 void CheckCurrentlyOnMainThread() { 64 void CheckCurrentlyOnMainThread() {
64 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 65 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
65 } 66 }
66 67
67 // ---------------------------------------------------------------------------- 68 // ----------------------------------------------------------------------------
68 // Helper methods to initialize proxy 69 // Helper methods to initialize proxy
69 // ---------------------------------------------------------------------------- 70 // ----------------------------------------------------------------------------
70 71
71 net::ProxyConfigService* CreateProxyConfigService(Profile* profile) { 72 net::ProxyConfigService* CreateProxyConfigService(Profile* profile) {
72 // The linux gconf-based proxy settings getter relies on being initialized 73 return ProxyServiceFactory::CreateProxyConfigService(
73 // from the UI thread.
74 CheckCurrentlyOnMainThread();
75
76 // Create a baseline service that provides proxy configuration in case nothing
77 // is configured through prefs (Note: prefs include command line and
78 // configuration policy).
79 net::ProxyConfigService* base_service = NULL;
80
81 // TODO(port): the IO and FILE message loops are only used by Linux. Can
82 // that code be moved to chrome/browser instead of being in net, so that it
83 // can use BrowserThread instead of raw MessageLoop pointers? See bug 25354.
84 #if defined(OS_CHROMEOS)
85 base_service = new chromeos::ProxyConfigService(
86 profile->GetChromeOSProxyConfigServiceImpl());
87 #else
88 base_service = net::ProxyService::CreateSystemProxyConfigService(
89 g_browser_process->io_thread()->message_loop(), 74 g_browser_process->io_thread()->message_loop(),
90 g_browser_process->file_thread()->message_loop()); 75 g_browser_process->file_thread()->message_loop(),
91 #endif // defined(OS_CHROMEOS) 76 profile->GetProxyConfigTracker());
92
93 return new PrefProxyConfigService(profile->GetProxyConfigTracker(),
94 base_service);
95 } 77 }
96 78
97 // Create a proxy service according to the options on command line. 79 // Create a proxy service according to the options on command line.
98 net::ProxyService* CreateProxyService( 80 net::ProxyService* CreateProxyService(
99 net::NetLog* net_log, 81 net::NetLog* net_log,
100 net::URLRequestContext* context, 82 net::URLRequestContext* context,
101 net::ProxyConfigService* proxy_config_service, 83 net::ProxyConfigService* proxy_config_service,
102 const CommandLine& command_line) { 84 const CommandLine& command_line) {
103 CheckCurrentlyOnIOThread(); 85 CheckCurrentlyOnIOThread();
104 86
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 IOThread::Globals* io_thread_globals = io_thread()->globals(); 250 IOThread::Globals* io_thread_globals = io_thread()->globals();
269 const ProfileIOData::LazyParams& params = profile_io_data_->lazy_params(); 251 const ProfileIOData::LazyParams& params = profile_io_data_->lazy_params();
270 252
271 context->set_dns_cert_checker( 253 context->set_dns_cert_checker(
272 CreateDnsCertProvenanceChecker(io_thread_globals->dnsrr_resolver.get(), 254 CreateDnsCertProvenanceChecker(io_thread_globals->dnsrr_resolver.get(),
273 context)); 255 context));
274 256
275 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); 257 const CommandLine& command_line = *CommandLine::ForCurrentProcess();
276 258
277 context->set_proxy_service( 259 context->set_proxy_service(
278 CreateProxyService(io_thread()->net_log(), 260 ProxyServiceFactory::CreateProxyService(
279 io_thread_globals->proxy_script_fetcher_context.get(), 261 io_thread()->net_log(),
280 proxy_config_service_.release(), 262 io_thread_globals->proxy_script_fetcher_context.get(),
281 command_line)); 263 proxy_config_service_.release(),
264 command_line));
282 265
283 net::HttpCache::DefaultBackend* backend = new net::HttpCache::DefaultBackend( 266 net::HttpCache::DefaultBackend* backend = new net::HttpCache::DefaultBackend(
284 net::DISK_CACHE, params.cache_path, params.cache_max_size, 267 net::DISK_CACHE, params.cache_path, params.cache_max_size,
285 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::CACHE)); 268 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::CACHE));
286 net::HttpCache* cache = new net::HttpCache( 269 net::HttpCache* cache = new net::HttpCache(
287 context->host_resolver(), 270 context->host_resolver(),
288 context->cert_verifier(), 271 context->cert_verifier(),
289 context->dnsrr_resolver(), 272 context->dnsrr_resolver(),
290 context->dns_cert_checker(), 273 context->dns_cert_checker(),
291 context->proxy_service(), 274 context->proxy_service(),
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 390
408 IOThread::Globals* io_thread_globals = io_thread()->globals(); 391 IOThread::Globals* io_thread_globals = io_thread()->globals();
409 context->set_host_resolver(io_thread_globals->host_resolver.get()); 392 context->set_host_resolver(io_thread_globals->host_resolver.get());
410 context->set_cert_verifier(io_thread_globals->cert_verifier.get()); 393 context->set_cert_verifier(io_thread_globals->cert_verifier.get());
411 context->set_http_auth_handler_factory( 394 context->set_http_auth_handler_factory(
412 io_thread_globals->http_auth_handler_factory.get()); 395 io_thread_globals->http_auth_handler_factory.get());
413 context->set_network_delegate(&io_thread_globals->network_delegate); 396 context->set_network_delegate(&io_thread_globals->network_delegate);
414 397
415 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); 398 const CommandLine& command_line = *CommandLine::ForCurrentProcess();
416 context->set_proxy_service( 399 context->set_proxy_service(
417 CreateProxyService(io_thread()->net_log(), 400 ProxyServiceFactory::CreateProxyService(
418 io_thread_globals->proxy_script_fetcher_context.get(), 401 io_thread()->net_log(),
419 proxy_config_service_.release(), 402 io_thread_globals->proxy_script_fetcher_context.get(),
420 command_line)); 403 proxy_config_service_.release(),
404 command_line));
421 405
422 net::HttpCache::BackendFactory* backend = 406 net::HttpCache::BackendFactory* backend =
423 net::HttpCache::DefaultBackend::InMemory(0); 407 net::HttpCache::DefaultBackend::InMemory(0);
424 408
425 net::HttpCache* cache = 409 net::HttpCache* cache =
426 new net::HttpCache(io_thread_globals->host_resolver.get(), 410 new net::HttpCache(io_thread_globals->host_resolver.get(),
427 io_thread_globals->cert_verifier.get(), 411 io_thread_globals->cert_verifier.get(),
428 context->dnsrr_resolver(), 412 context->dnsrr_resolver(),
429 NULL /* dns_cert_checker */, 413 NULL /* dns_cert_checker */,
430 context->proxy_service(), 414 context->proxy_service(),
(...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after
872 transport_security_state_); 856 transport_security_state_);
873 context->set_ssl_config_service(ssl_config_service_); 857 context->set_ssl_config_service(ssl_config_service_);
874 context->set_appcache_service(appcache_service_); 858 context->set_appcache_service(appcache_service_);
875 context->set_database_tracker(database_tracker_); 859 context->set_database_tracker(database_tracker_);
876 context->set_blob_storage_context(blob_storage_context_); 860 context->set_blob_storage_context(blob_storage_context_);
877 context->set_file_system_context(file_system_context_); 861 context->set_file_system_context(file_system_context_);
878 context->set_extension_info_map(extension_info_map_); 862 context->set_extension_info_map(extension_info_map_);
879 context->set_extension_io_event_router(extension_io_event_router_); 863 context->set_extension_io_event_router(extension_io_event_router_);
880 context->set_prerender_manager(prerender_manager_); 864 context->set_prerender_manager(prerender_manager_);
881 } 865 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698