| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "webkit/tools/test_shell/test_shell_request_context.h" | 5 #include "webkit/tools/test_shell/test_shell_request_context.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | |
| 8 #include "net/base/cookie_monster.h" | 7 #include "net/base/cookie_monster.h" |
| 9 #include "net/base/host_resolver.h" | 8 #include "net/base/host_resolver.h" |
| 10 #include "net/ftp/ftp_network_layer.h" | 9 #include "net/ftp/ftp_network_layer.h" |
| 11 #include "net/proxy/proxy_service.h" | 10 #include "net/proxy/proxy_service.h" |
| 12 #include "webkit/glue/webkit_glue.h" | 11 #include "webkit/glue/webkit_glue.h" |
| 13 #include "webkit/tools/test_shell/test_shell_switches.h" | |
| 14 | 12 |
| 15 TestShellRequestContext::TestShellRequestContext() { | 13 TestShellRequestContext::TestShellRequestContext() { |
| 16 Init(std::wstring(), net::HttpCache::NORMAL, false); | 14 Init(std::wstring(), net::HttpCache::NORMAL, false); |
| 17 } | 15 } |
| 18 | 16 |
| 19 TestShellRequestContext::TestShellRequestContext( | 17 TestShellRequestContext::TestShellRequestContext( |
| 20 const std::wstring& cache_path, | 18 const std::wstring& cache_path, |
| 21 net::HttpCache::Mode cache_mode, | 19 net::HttpCache::Mode cache_mode, |
| 22 bool no_proxy) { | 20 bool no_proxy) { |
| 23 Init(cache_path, cache_mode, no_proxy); | 21 Init(cache_path, cache_mode, no_proxy); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 51 | 49 |
| 52 net::HttpCache *cache; | 50 net::HttpCache *cache; |
| 53 if (cache_path.empty()) { | 51 if (cache_path.empty()) { |
| 54 cache = new net::HttpCache(host_resolver_, proxy_service_, 0); | 52 cache = new net::HttpCache(host_resolver_, proxy_service_, 0); |
| 55 } else { | 53 } else { |
| 56 cache = new net::HttpCache(host_resolver_, proxy_service_, cache_path, 0); | 54 cache = new net::HttpCache(host_resolver_, proxy_service_, cache_path, 0); |
| 57 } | 55 } |
| 58 cache->set_mode(cache_mode); | 56 cache->set_mode(cache_mode); |
| 59 http_transaction_factory_ = cache; | 57 http_transaction_factory_ = cache; |
| 60 | 58 |
| 61 // The kNewFtp switch is Windows specific only because we have multiple FTP | |
| 62 // implementations on Windows. | |
| 63 #if defined(OS_WIN) | |
| 64 if (CommandLine::ForCurrentProcess()->HasSwitch(test_shell::kNewFtp)) | |
| 65 ftp_transaction_factory_ = new net::FtpNetworkLayer(host_resolver_); | |
| 66 #else | |
| 67 ftp_transaction_factory_ = new net::FtpNetworkLayer(host_resolver_); | 59 ftp_transaction_factory_ = new net::FtpNetworkLayer(host_resolver_); |
| 68 #endif | |
| 69 } | 60 } |
| 70 | 61 |
| 71 TestShellRequestContext::~TestShellRequestContext() { | 62 TestShellRequestContext::~TestShellRequestContext() { |
| 72 delete cookie_store_; | 63 delete cookie_store_; |
| 73 delete ftp_transaction_factory_; | 64 delete ftp_transaction_factory_; |
| 74 delete http_transaction_factory_; | 65 delete http_transaction_factory_; |
| 75 delete proxy_service_; | 66 delete proxy_service_; |
| 76 } | 67 } |
| 77 | 68 |
| 78 const std::string& TestShellRequestContext::GetUserAgent( | 69 const std::string& TestShellRequestContext::GetUserAgent( |
| 79 const GURL& url) const { | 70 const GURL& url) const { |
| 80 return webkit_glue::GetUserAgent(url); | 71 return webkit_glue::GetUserAgent(url); |
| 81 } | 72 } |
| OLD | NEW |