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 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
266 context->set_http_auth_handler_factory( | 266 context->set_http_auth_handler_factory( |
267 io_thread_globals->http_auth_handler_factory.get()); | 267 io_thread_globals->http_auth_handler_factory.get()); |
268 | 268 |
269 context->set_dns_cert_checker( | 269 context->set_dns_cert_checker( |
270 CreateDnsCertProvenanceChecker(io_thread_globals->dnsrr_resolver.get(), | 270 CreateDnsCertProvenanceChecker(io_thread_globals->dnsrr_resolver.get(), |
271 context)); | 271 context)); |
272 | 272 |
273 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 273 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
274 | 274 |
275 context->set_proxy_service( | 275 context->set_proxy_service( |
276 CreateProxyService(io_thread_globals->net_log.get(), | 276 CreateProxyService(io_thread()->net_log(), |
277 context, | 277 context, |
278 proxy_config_service_.release(), | 278 proxy_config_service_.release(), |
279 command_line, | 279 command_line, |
280 io_thread())); | 280 io_thread())); |
281 | 281 |
282 net::HttpCache::DefaultBackend* backend = new net::HttpCache::DefaultBackend( | 282 net::HttpCache::DefaultBackend* backend = new net::HttpCache::DefaultBackend( |
283 net::DISK_CACHE, disk_cache_path_, cache_size_, | 283 net::DISK_CACHE, disk_cache_path_, cache_size_, |
284 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::CACHE)); | 284 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::CACHE)); |
285 net::HttpCache* cache = | 285 net::HttpCache* cache = |
286 new net::HttpCache(context->host_resolver(), | 286 new net::HttpCache(context->host_resolver(), |
287 context->dnsrr_resolver(), | 287 context->dnsrr_resolver(), |
288 context->dns_cert_checker(), | 288 context->dns_cert_checker(), |
289 context->proxy_service(), | 289 context->proxy_service(), |
290 context->ssl_config_service(), | 290 context->ssl_config_service(), |
291 context->http_auth_handler_factory(), | 291 context->http_auth_handler_factory(), |
292 &io_thread_globals->network_delegate, | 292 &io_thread_globals->network_delegate, |
293 io_thread_globals->net_log.get(), | 293 io_thread()->net_log(), |
294 backend); | 294 backend); |
295 | 295 |
296 bool record_mode = chrome::kRecordModeEnabled && | 296 bool record_mode = chrome::kRecordModeEnabled && |
297 command_line.HasSwitch(switches::kRecordMode); | 297 command_line.HasSwitch(switches::kRecordMode); |
298 bool playback_mode = command_line.HasSwitch(switches::kPlaybackMode); | 298 bool playback_mode = command_line.HasSwitch(switches::kPlaybackMode); |
299 | 299 |
300 if (record_mode || playback_mode) { | 300 if (record_mode || playback_mode) { |
301 // Don't use existing cookies and use an in-memory store. | 301 // Don't use existing cookies and use an in-memory store. |
302 context->set_cookie_store(new net::CookieMonster(NULL, | 302 context->set_cookie_store(new net::CookieMonster(NULL, |
303 cookie_monster_delegate_)); | 303 cookie_monster_delegate_)); |
(...skipping 13 matching lines...) Expand all Loading... |
317 new SQLitePersistentCookieStore(cookie_store_path_); | 317 new SQLitePersistentCookieStore(cookie_store_path_); |
318 context->set_cookie_store(new net::CookieMonster(cookie_db.get(), | 318 context->set_cookie_store(new net::CookieMonster(cookie_db.get(), |
319 cookie_monster_delegate_)); | 319 cookie_monster_delegate_)); |
320 } | 320 } |
321 | 321 |
322 context->set_cookie_policy( | 322 context->set_cookie_policy( |
323 new ChromeCookiePolicy(host_content_settings_map_)); | 323 new ChromeCookiePolicy(host_content_settings_map_)); |
324 | 324 |
325 appcache_service_->set_request_context(context); | 325 appcache_service_->set_request_context(context); |
326 | 326 |
327 context->set_net_log(io_thread_globals->net_log.get()); | 327 context->set_net_log(io_thread()->net_log()); |
328 return context; | 328 return context; |
329 } | 329 } |
330 | 330 |
331 // Factory that creates the ChromeURLRequestContext for extensions. | 331 // Factory that creates the ChromeURLRequestContext for extensions. |
332 class FactoryForExtensions : public ChromeURLRequestContextFactory { | 332 class FactoryForExtensions : public ChromeURLRequestContextFactory { |
333 public: | 333 public: |
334 FactoryForExtensions(Profile* profile, const FilePath& cookie_store_path, | 334 FactoryForExtensions(Profile* profile, const FilePath& cookie_store_path, |
335 bool incognito) | 335 bool incognito) |
336 : ChromeURLRequestContextFactory(profile), | 336 : ChromeURLRequestContextFactory(profile), |
337 cookie_store_path_(cookie_store_path), | 337 cookie_store_path_(cookie_store_path), |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
410 net::HttpCache::DefaultBackend::InMemory(0); | 410 net::HttpCache::DefaultBackend::InMemory(0); |
411 | 411 |
412 net::HttpCache* cache = | 412 net::HttpCache* cache = |
413 new net::HttpCache(context->host_resolver(), | 413 new net::HttpCache(context->host_resolver(), |
414 context->dnsrr_resolver(), | 414 context->dnsrr_resolver(), |
415 NULL /* dns_cert_checker */, | 415 NULL /* dns_cert_checker */, |
416 context->proxy_service(), | 416 context->proxy_service(), |
417 context->ssl_config_service(), | 417 context->ssl_config_service(), |
418 context->http_auth_handler_factory(), | 418 context->http_auth_handler_factory(), |
419 &io_thread_globals->network_delegate, | 419 &io_thread_globals->network_delegate, |
420 io_thread_globals->net_log.get(), | 420 io_thread()->net_log(), |
421 backend); | 421 backend); |
422 context->set_cookie_store(new net::CookieMonster(NULL, | 422 context->set_cookie_store(new net::CookieMonster(NULL, |
423 cookie_monster_delegate_)); | 423 cookie_monster_delegate_)); |
424 context->set_cookie_policy( | 424 context->set_cookie_policy( |
425 new ChromeCookiePolicy(host_content_settings_map_)); | 425 new ChromeCookiePolicy(host_content_settings_map_)); |
426 context->set_http_transaction_factory(cache); | 426 context->set_http_transaction_factory(cache); |
427 | 427 |
428 context->set_ftp_transaction_factory( | 428 context->set_ftp_transaction_factory( |
429 new net::FtpNetworkLayer(context->host_resolver())); | 429 new net::FtpNetworkLayer(context->host_resolver())); |
430 | 430 |
431 appcache_service_->set_request_context(context); | 431 appcache_service_->set_request_context(context); |
432 | 432 |
433 context->set_net_log(io_thread_globals->net_log.get()); | 433 context->set_net_log(io_thread()->net_log()); |
434 return context; | 434 return context; |
435 } | 435 } |
436 | 436 |
437 // Factory that creates the ChromeURLRequestContext for media. | 437 // Factory that creates the ChromeURLRequestContext for media. |
438 class FactoryForMedia : public ChromeURLRequestContextFactory { | 438 class FactoryForMedia : public ChromeURLRequestContextFactory { |
439 public: | 439 public: |
440 FactoryForMedia(Profile* profile, | 440 FactoryForMedia(Profile* profile, |
441 const FilePath& disk_cache_path, | 441 const FilePath& disk_cache_path, |
442 int cache_size, | 442 int cache_size, |
443 bool off_the_record) | 443 bool off_the_record) |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
503 } else { | 503 } else { |
504 // If original HttpCache doesn't exist, simply construct one with a whole | 504 // If original HttpCache doesn't exist, simply construct one with a whole |
505 // new set of network stack. | 505 // new set of network stack. |
506 cache = new net::HttpCache(main_context->host_resolver(), | 506 cache = new net::HttpCache(main_context->host_resolver(), |
507 main_context->dnsrr_resolver(), | 507 main_context->dnsrr_resolver(), |
508 NULL /* dns_cert_checker */, | 508 NULL /* dns_cert_checker */, |
509 main_context->proxy_service(), | 509 main_context->proxy_service(), |
510 main_context->ssl_config_service(), | 510 main_context->ssl_config_service(), |
511 main_context->http_auth_handler_factory(), | 511 main_context->http_auth_handler_factory(), |
512 &io_thread_globals->network_delegate, | 512 &io_thread_globals->network_delegate, |
513 io_thread_globals->net_log.get(), | 513 io_thread()->net_log(), |
514 backend); | 514 backend); |
515 } | 515 } |
516 | 516 |
517 context->set_http_transaction_factory(cache); | 517 context->set_http_transaction_factory(cache); |
518 context->set_net_log(io_thread_globals->net_log.get()); | 518 context->set_net_log(io_thread()->net_log()); |
519 | 519 |
520 return context; | 520 return context; |
521 } | 521 } |
522 | 522 |
523 } // namespace | 523 } // namespace |
524 | 524 |
525 // ---------------------------------------------------------------------------- | 525 // ---------------------------------------------------------------------------- |
526 // ChromeURLRequestContextGetter | 526 // ChromeURLRequestContextGetter |
527 // ---------------------------------------------------------------------------- | 527 // ---------------------------------------------------------------------------- |
528 | 528 |
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
932 context->set_host_zoom_map(host_zoom_map_); | 932 context->set_host_zoom_map(host_zoom_map_); |
933 context->set_transport_security_state( | 933 context->set_transport_security_state( |
934 transport_security_state_); | 934 transport_security_state_); |
935 context->set_ssl_config_service(ssl_config_service_); | 935 context->set_ssl_config_service(ssl_config_service_); |
936 context->set_appcache_service(appcache_service_); | 936 context->set_appcache_service(appcache_service_); |
937 context->set_database_tracker(database_tracker_); | 937 context->set_database_tracker(database_tracker_); |
938 context->set_blob_storage_context(blob_storage_context_); | 938 context->set_blob_storage_context(blob_storage_context_); |
939 context->set_browser_file_system_context(browser_file_system_context_); | 939 context->set_browser_file_system_context(browser_file_system_context_); |
940 context->set_extension_info_map(extension_info_map_); | 940 context->set_extension_info_map(extension_info_map_); |
941 } | 941 } |
OLD | NEW |