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

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

Issue 6402002: Simplify HttpCache/HttpNetworkLayer/HttpNetworkSession interaction. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix CF tests. 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"
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 274
275 context->set_proxy_service( 275 context->set_proxy_service(
276 CreateProxyService(io_thread()->net_log(), 276 CreateProxyService(io_thread()->net_log(),
277 io_thread_globals->proxy_script_fetcher_context.get(), 277 io_thread_globals->proxy_script_fetcher_context.get(),
278 proxy_config_service_.release(), 278 proxy_config_service_.release(),
279 command_line)); 279 command_line));
280 280
281 net::HttpCache::DefaultBackend* backend = new net::HttpCache::DefaultBackend( 281 net::HttpCache::DefaultBackend* backend = new net::HttpCache::DefaultBackend(
282 net::DISK_CACHE, disk_cache_path_, cache_size_, 282 net::DISK_CACHE, disk_cache_path_, cache_size_,
283 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::CACHE)); 283 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::CACHE));
284 net::HttpCache* cache = 284 net::HttpCache* cache = new net::HttpCache(
285 new net::HttpCache(context->host_resolver(), 285 context->host_resolver(),
286 context->cert_verifier(), 286 context->cert_verifier(),
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()->net_log(), 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_));
304 cache->set_mode( 304 cache->set_mode(
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 static_cast<ChromeCookiePolicy*>(main_context->cookie_policy())); 484 static_cast<ChromeCookiePolicy*>(main_context->cookie_policy()));
485 485
486 // Create a media cache with default size. 486 // Create a media cache with default size.
487 // TODO(hclam): make the maximum size of media cache configurable. 487 // TODO(hclam): make the maximum size of media cache configurable.
488 net::HttpCache::DefaultBackend* backend = new net::HttpCache::DefaultBackend( 488 net::HttpCache::DefaultBackend* backend = new net::HttpCache::DefaultBackend(
489 net::MEDIA_CACHE, disk_cache_path_, cache_size_, 489 net::MEDIA_CACHE, disk_cache_path_, cache_size_,
490 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::CACHE)); 490 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::CACHE));
491 491
492 net::HttpCache* main_cache = 492 net::HttpCache* main_cache =
493 main_context->http_transaction_factory()->GetCache(); 493 main_context->http_transaction_factory()->GetCache();
494 net::HttpCache* cache; 494 net::HttpNetworkSession* network_session = main_cache->GetSession();
wtc 2011/01/28 01:51:23 IMPORTANT: Why do we not need the null check for '
willchan no longer on Chromium 2011/01/28 06:12:07 I will doublecheck with eroman tomorrow to make su
495 if (main_cache) { 495 net::HttpCache* cache = new net::HttpCache(network_session, backend);
496 // Try to reuse HttpNetworkSession in the main context, assuming that
497 // HttpTransactionFactory (network_layer()) of HttpCache is implemented
498 // by HttpNetworkLayer so we can reuse HttpNetworkSession within it. This
499 // assumption will be invalid if the original HttpCache is constructed with
500 // HttpCache(HttpTransactionFactory*, BackendFactory*) constructor.
501 net::HttpNetworkLayer* main_network_layer =
502 static_cast<net::HttpNetworkLayer*>(main_cache->network_layer());
503 cache = new net::HttpCache(main_network_layer->GetSession(), backend);
504 // TODO(eroman): Since this is poaching the session from the main
505 // context, it should hold a reference to that context preventing the
506 // session from getting deleted.
507 } else {
508 // If original HttpCache doesn't exist, simply construct one with a whole
509 // new set of network stack.
510 cache = new net::HttpCache(
511 io_thread_globals->host_resolver.get(),
512 io_thread_globals->cert_verifier.get(),
513 io_thread_globals->dnsrr_resolver.get(),
514 NULL /* dns_cert_checker */,
515 main_context->proxy_service(),
516 main_context->ssl_config_service(),
517 io_thread_globals->http_auth_handler_factory.get(),
518 &io_thread_globals->network_delegate,
519 io_thread()->net_log(),
520 backend);
521 }
522
523 context->set_http_transaction_factory(cache); 496 context->set_http_transaction_factory(cache);
524 context->set_net_log(io_thread()->net_log()); 497 context->set_net_log(io_thread()->net_log());
525 498
526 return context; 499 return context;
527 } 500 }
528 501
529 } // namespace 502 } // namespace
530 503
531 // ---------------------------------------------------------------------------- 504 // ----------------------------------------------------------------------------
532 // ChromeURLRequestContextGetter 505 // ChromeURLRequestContextGetter
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after
907 context->set_transport_security_state( 880 context->set_transport_security_state(
908 transport_security_state_); 881 transport_security_state_);
909 context->set_ssl_config_service(ssl_config_service_); 882 context->set_ssl_config_service(ssl_config_service_);
910 context->set_appcache_service(appcache_service_); 883 context->set_appcache_service(appcache_service_);
911 context->set_database_tracker(database_tracker_); 884 context->set_database_tracker(database_tracker_);
912 context->set_blob_storage_context(blob_storage_context_); 885 context->set_blob_storage_context(blob_storage_context_);
913 context->set_file_system_context(file_system_context_); 886 context->set_file_system_context(file_system_context_);
914 context->set_extension_info_map(extension_info_map_); 887 context->set_extension_info_map(extension_info_map_);
915 context->set_prerender_manager(prerender_manager_); 888 context->set_prerender_manager(prerender_manager_);
916 } 889 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698