| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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" |
| (...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 261 | 261 |
| 262 // Global host resolver for the context. | 262 // Global host resolver for the context. |
| 263 context->set_host_resolver(io_thread_globals->host_resolver.get()); | 263 context->set_host_resolver(io_thread_globals->host_resolver.get()); |
| 264 context->set_dnsrr_resolver(io_thread_globals->dnsrr_resolver.get()); | 264 context->set_dnsrr_resolver(io_thread_globals->dnsrr_resolver.get()); |
| 265 context->set_http_auth_handler_factory( | 265 context->set_http_auth_handler_factory( |
| 266 io_thread_globals->http_auth_handler_factory.get()); | 266 io_thread_globals->http_auth_handler_factory.get()); |
| 267 | 267 |
| 268 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 268 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
| 269 | 269 |
| 270 context->set_proxy_service( | 270 context->set_proxy_service( |
| 271 CreateProxyService(io_thread_globals->net_log.get(), | 271 CreateProxyService(io_thread()->net_log(), |
| 272 context, | 272 context, |
| 273 proxy_config_service_.release(), | 273 proxy_config_service_.release(), |
| 274 command_line, | 274 command_line, |
| 275 io_thread())); | 275 io_thread())); |
| 276 | 276 |
| 277 net::HttpCache::DefaultBackend* backend = new net::HttpCache::DefaultBackend( | 277 net::HttpCache::DefaultBackend* backend = new net::HttpCache::DefaultBackend( |
| 278 net::DISK_CACHE, disk_cache_path_, cache_size_, | 278 net::DISK_CACHE, disk_cache_path_, cache_size_, |
| 279 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::CACHE)); | 279 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::CACHE)); |
| 280 net::HttpCache* cache = | 280 net::HttpCache* cache = |
| 281 new net::HttpCache(context->host_resolver(), | 281 new net::HttpCache(context->host_resolver(), |
| 282 context->dnsrr_resolver(), | 282 context->dnsrr_resolver(), |
| 283 context->proxy_service(), | 283 context->proxy_service(), |
| 284 context->ssl_config_service(), | 284 context->ssl_config_service(), |
| 285 context->http_auth_handler_factory(), | 285 context->http_auth_handler_factory(), |
| 286 &io_thread_globals->network_delegate, | 286 &io_thread_globals->network_delegate, |
| 287 io_thread_globals->net_log.get(), | 287 io_thread()->net_log(), |
| 288 backend); | 288 backend); |
| 289 | 289 |
| 290 bool record_mode = chrome::kRecordModeEnabled && | 290 bool record_mode = chrome::kRecordModeEnabled && |
| 291 command_line.HasSwitch(switches::kRecordMode); | 291 command_line.HasSwitch(switches::kRecordMode); |
| 292 bool playback_mode = command_line.HasSwitch(switches::kPlaybackMode); | 292 bool playback_mode = command_line.HasSwitch(switches::kPlaybackMode); |
| 293 | 293 |
| 294 if (record_mode || playback_mode) { | 294 if (record_mode || playback_mode) { |
| 295 // Don't use existing cookies and use an in-memory store. | 295 // Don't use existing cookies and use an in-memory store. |
| 296 context->set_cookie_store(new net::CookieMonster(NULL, | 296 context->set_cookie_store(new net::CookieMonster(NULL, |
| 297 cookie_monster_delegate_)); | 297 cookie_monster_delegate_)); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 311 new SQLitePersistentCookieStore(cookie_store_path_); | 311 new SQLitePersistentCookieStore(cookie_store_path_); |
| 312 context->set_cookie_store(new net::CookieMonster(cookie_db.get(), | 312 context->set_cookie_store(new net::CookieMonster(cookie_db.get(), |
| 313 cookie_monster_delegate_)); | 313 cookie_monster_delegate_)); |
| 314 } | 314 } |
| 315 | 315 |
| 316 context->set_cookie_policy( | 316 context->set_cookie_policy( |
| 317 new ChromeCookiePolicy(host_content_settings_map_)); | 317 new ChromeCookiePolicy(host_content_settings_map_)); |
| 318 | 318 |
| 319 appcache_service_->set_request_context(context); | 319 appcache_service_->set_request_context(context); |
| 320 | 320 |
| 321 context->set_net_log(io_thread_globals->net_log.get()); | 321 context->set_net_log(io_thread()->net_log()); |
| 322 return context; | 322 return context; |
| 323 } | 323 } |
| 324 | 324 |
| 325 // Factory that creates the ChromeURLRequestContext for extensions. | 325 // Factory that creates the ChromeURLRequestContext for extensions. |
| 326 class FactoryForExtensions : public ChromeURLRequestContextFactory { | 326 class FactoryForExtensions : public ChromeURLRequestContextFactory { |
| 327 public: | 327 public: |
| 328 FactoryForExtensions(Profile* profile, const FilePath& cookie_store_path, | 328 FactoryForExtensions(Profile* profile, const FilePath& cookie_store_path, |
| 329 bool incognito) | 329 bool incognito) |
| 330 : ChromeURLRequestContextFactory(profile), | 330 : ChromeURLRequestContextFactory(profile), |
| 331 cookie_store_path_(cookie_store_path), | 331 cookie_store_path_(cookie_store_path), |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 403 net::HttpCache::BackendFactory* backend = | 403 net::HttpCache::BackendFactory* backend = |
| 404 net::HttpCache::DefaultBackend::InMemory(0); | 404 net::HttpCache::DefaultBackend::InMemory(0); |
| 405 | 405 |
| 406 net::HttpCache* cache = | 406 net::HttpCache* cache = |
| 407 new net::HttpCache(context->host_resolver(), | 407 new net::HttpCache(context->host_resolver(), |
| 408 context->dnsrr_resolver(), | 408 context->dnsrr_resolver(), |
| 409 context->proxy_service(), | 409 context->proxy_service(), |
| 410 context->ssl_config_service(), | 410 context->ssl_config_service(), |
| 411 context->http_auth_handler_factory(), | 411 context->http_auth_handler_factory(), |
| 412 &io_thread_globals->network_delegate, | 412 &io_thread_globals->network_delegate, |
| 413 io_thread_globals->net_log.get(), | 413 io_thread()->net_log(), |
| 414 backend); | 414 backend); |
| 415 context->set_cookie_store(new net::CookieMonster(NULL, | 415 context->set_cookie_store(new net::CookieMonster(NULL, |
| 416 cookie_monster_delegate_)); | 416 cookie_monster_delegate_)); |
| 417 context->set_cookie_policy( | 417 context->set_cookie_policy( |
| 418 new ChromeCookiePolicy(host_content_settings_map_)); | 418 new ChromeCookiePolicy(host_content_settings_map_)); |
| 419 context->set_http_transaction_factory(cache); | 419 context->set_http_transaction_factory(cache); |
| 420 | 420 |
| 421 context->set_ftp_transaction_factory( | 421 context->set_ftp_transaction_factory( |
| 422 new net::FtpNetworkLayer(context->host_resolver())); | 422 new net::FtpNetworkLayer(context->host_resolver())); |
| 423 | 423 |
| 424 appcache_service_->set_request_context(context); | 424 appcache_service_->set_request_context(context); |
| 425 | 425 |
| 426 context->set_net_log(io_thread_globals->net_log.get()); | 426 context->set_net_log(io_thread()->net_log()); |
| 427 return context; | 427 return context; |
| 428 } | 428 } |
| 429 | 429 |
| 430 // Factory that creates the ChromeURLRequestContext for media. | 430 // Factory that creates the ChromeURLRequestContext for media. |
| 431 class FactoryForMedia : public ChromeURLRequestContextFactory { | 431 class FactoryForMedia : public ChromeURLRequestContextFactory { |
| 432 public: | 432 public: |
| 433 FactoryForMedia(Profile* profile, | 433 FactoryForMedia(Profile* profile, |
| 434 const FilePath& disk_cache_path, | 434 const FilePath& disk_cache_path, |
| 435 int cache_size, | 435 int cache_size, |
| 436 bool off_the_record) | 436 bool off_the_record) |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 495 // session from getting deleted. | 495 // session from getting deleted. |
| 496 } else { | 496 } else { |
| 497 // If original HttpCache doesn't exist, simply construct one with a whole | 497 // If original HttpCache doesn't exist, simply construct one with a whole |
| 498 // new set of network stack. | 498 // new set of network stack. |
| 499 cache = new net::HttpCache(main_context->host_resolver(), | 499 cache = new net::HttpCache(main_context->host_resolver(), |
| 500 main_context->dnsrr_resolver(), | 500 main_context->dnsrr_resolver(), |
| 501 main_context->proxy_service(), | 501 main_context->proxy_service(), |
| 502 main_context->ssl_config_service(), | 502 main_context->ssl_config_service(), |
| 503 main_context->http_auth_handler_factory(), | 503 main_context->http_auth_handler_factory(), |
| 504 &io_thread_globals->network_delegate, | 504 &io_thread_globals->network_delegate, |
| 505 io_thread_globals->net_log.get(), | 505 io_thread()->net_log(), |
| 506 backend); | 506 backend); |
| 507 } | 507 } |
| 508 | 508 |
| 509 context->set_http_transaction_factory(cache); | 509 context->set_http_transaction_factory(cache); |
| 510 context->set_net_log(io_thread_globals->net_log.get()); | 510 context->set_net_log(io_thread()->net_log()); |
| 511 | 511 |
| 512 return context; | 512 return context; |
| 513 } | 513 } |
| 514 | 514 |
| 515 } // namespace | 515 } // namespace |
| 516 | 516 |
| 517 // ---------------------------------------------------------------------------- | 517 // ---------------------------------------------------------------------------- |
| 518 // ChromeURLRequestContextGetter | 518 // ChromeURLRequestContextGetter |
| 519 // ---------------------------------------------------------------------------- | 519 // ---------------------------------------------------------------------------- |
| 520 | 520 |
| (...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 972 prefs::kProxyAutoDetect)); | 972 prefs::kProxyAutoDetect)); |
| 973 | 973 |
| 974 if (pref_service->HasPrefPath(prefs::kProxyBypassList)) { | 974 if (pref_service->HasPrefPath(prefs::kProxyBypassList)) { |
| 975 std::string proxy_bypass = | 975 std::string proxy_bypass = |
| 976 pref_service->GetString(prefs::kProxyBypassList); | 976 pref_service->GetString(prefs::kProxyBypassList); |
| 977 proxy_config->proxy_rules().bypass_rules.ParseFromString(proxy_bypass); | 977 proxy_config->proxy_rules().bypass_rules.ParseFromString(proxy_bypass); |
| 978 } | 978 } |
| 979 | 979 |
| 980 return proxy_config; | 980 return proxy_config; |
| 981 } | 981 } |
| OLD | NEW |