| 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/string_util.h" | 9 #include "base/string_util.h" |
| 10 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 245 proxy_config_service_.release(), | 245 proxy_config_service_.release(), |
| 246 command_line, | 246 command_line, |
| 247 MessageLoop::current() /*io_loop*/)); | 247 MessageLoop::current() /*io_loop*/)); |
| 248 | 248 |
| 249 net::HttpCache* cache = | 249 net::HttpCache* cache = |
| 250 new net::HttpCache(io_thread()->globals()->network_change_notifier.get(), | 250 new net::HttpCache(io_thread()->globals()->network_change_notifier.get(), |
| 251 context->host_resolver(), | 251 context->host_resolver(), |
| 252 context->proxy_service(), | 252 context->proxy_service(), |
| 253 context->ssl_config_service(), | 253 context->ssl_config_service(), |
| 254 context->http_auth_handler_factory(), | 254 context->http_auth_handler_factory(), |
| 255 disk_cache_path_, cache_size_); | 255 disk_cache_path_, NULL, cache_size_); |
| 256 | 256 |
| 257 if (command_line.HasSwitch(switches::kDisableByteRangeSupport)) | 257 if (command_line.HasSwitch(switches::kDisableByteRangeSupport)) |
| 258 cache->set_enable_range_support(false); | 258 cache->set_enable_range_support(false); |
| 259 | 259 |
| 260 bool record_mode = chrome::kRecordModeEnabled && | 260 bool record_mode = chrome::kRecordModeEnabled && |
| 261 command_line.HasSwitch(switches::kRecordMode); | 261 command_line.HasSwitch(switches::kRecordMode); |
| 262 bool playback_mode = command_line.HasSwitch(switches::kPlaybackMode); | 262 bool playback_mode = command_line.HasSwitch(switches::kPlaybackMode); |
| 263 | 263 |
| 264 if (record_mode || playback_mode) { | 264 if (record_mode || playback_mode) { |
| 265 // Don't use existing cookies and use an in-memory store. | 265 // Don't use existing cookies and use an in-memory store. |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 444 net::HttpCache* cache; | 444 net::HttpCache* cache; |
| 445 if (main_cache) { | 445 if (main_cache) { |
| 446 // Try to reuse HttpNetworkSession in the main context, assuming that | 446 // Try to reuse HttpNetworkSession in the main context, assuming that |
| 447 // HttpTransactionFactory (network_layer()) of HttpCache is implemented | 447 // HttpTransactionFactory (network_layer()) of HttpCache is implemented |
| 448 // by HttpNetworkLayer so we can reuse HttpNetworkSession within it. This | 448 // by HttpNetworkLayer so we can reuse HttpNetworkSession within it. This |
| 449 // assumption will be invalid if the original HttpCache is constructed with | 449 // assumption will be invalid if the original HttpCache is constructed with |
| 450 // HttpCache(HttpTransactionFactory*, disk_cache::Backend*) constructor. | 450 // HttpCache(HttpTransactionFactory*, disk_cache::Backend*) constructor. |
| 451 net::HttpNetworkLayer* main_network_layer = | 451 net::HttpNetworkLayer* main_network_layer = |
| 452 static_cast<net::HttpNetworkLayer*>(main_cache->network_layer()); | 452 static_cast<net::HttpNetworkLayer*>(main_cache->network_layer()); |
| 453 cache = new net::HttpCache(main_network_layer->GetSession(), | 453 cache = new net::HttpCache(main_network_layer->GetSession(), |
| 454 disk_cache_path_, cache_size_); | 454 disk_cache_path_, NULL, cache_size_); |
| 455 // TODO(eroman): Since this is poaching the session from the main | 455 // TODO(eroman): Since this is poaching the session from the main |
| 456 // context, it should hold a reference to that context preventing the | 456 // context, it should hold a reference to that context preventing the |
| 457 // session from getting deleted. | 457 // session from getting deleted. |
| 458 } else { | 458 } else { |
| 459 // If original HttpCache doesn't exist, simply construct one with a whole | 459 // If original HttpCache doesn't exist, simply construct one with a whole |
| 460 // new set of network stack. | 460 // new set of network stack. |
| 461 cache = new net::HttpCache( | 461 cache = new net::HttpCache( |
| 462 io_thread()->globals()->network_change_notifier.get(), | 462 io_thread()->globals()->network_change_notifier.get(), |
| 463 main_context->host_resolver(), | 463 main_context->host_resolver(), |
| 464 main_context->proxy_service(), | 464 main_context->proxy_service(), |
| 465 main_context->ssl_config_service(), | 465 main_context->ssl_config_service(), |
| 466 main_context->http_auth_handler_factory(), | 466 main_context->http_auth_handler_factory(), |
| 467 disk_cache_path_, cache_size_); | 467 disk_cache_path_, NULL, cache_size_); |
| 468 } | 468 } |
| 469 | 469 |
| 470 if (CommandLine::ForCurrentProcess()->HasSwitch( | 470 if (CommandLine::ForCurrentProcess()->HasSwitch( |
| 471 switches::kDisableByteRangeSupport)) | 471 switches::kDisableByteRangeSupport)) |
| 472 cache->set_enable_range_support(false); | 472 cache->set_enable_range_support(false); |
| 473 | 473 |
| 474 cache->set_type(net::MEDIA_CACHE); | 474 cache->set_type(net::MEDIA_CACHE); |
| 475 context->set_http_transaction_factory(cache); | 475 context->set_http_transaction_factory(cache); |
| 476 | 476 |
| 477 // Use the same appcache service as the profile's main context. | 477 // Use the same appcache service as the profile's main context. |
| (...skipping 554 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1032 } | 1032 } |
| 1033 | 1033 |
| 1034 if (command_line.HasSwitch(switches::kProxyBypassList)) { | 1034 if (command_line.HasSwitch(switches::kProxyBypassList)) { |
| 1035 proxy_config->proxy_rules().bypass_rules.ParseFromString( | 1035 proxy_config->proxy_rules().bypass_rules.ParseFromString( |
| 1036 WideToASCII(command_line.GetSwitchValue( | 1036 WideToASCII(command_line.GetSwitchValue( |
| 1037 switches::kProxyBypassList))); | 1037 switches::kProxyBypassList))); |
| 1038 } | 1038 } |
| 1039 | 1039 |
| 1040 return proxy_config; | 1040 return proxy_config; |
| 1041 } | 1041 } |
| OLD | NEW |