| 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 "net/base/cookie_monster.h" | 7 #include "net/base/cookie_monster.h" |
| 8 #include "net/base/host_resolver.h" |
| 8 #include "net/proxy/proxy_service.h" | 9 #include "net/proxy/proxy_service.h" |
| 9 #include "webkit/glue/webkit_glue.h" | 10 #include "webkit/glue/webkit_glue.h" |
| 10 | 11 |
| 11 TestShellRequestContext::TestShellRequestContext() { | 12 TestShellRequestContext::TestShellRequestContext() { |
| 12 Init(std::wstring(), net::HttpCache::NORMAL, false); | 13 Init(std::wstring(), net::HttpCache::NORMAL, false); |
| 13 } | 14 } |
| 14 | 15 |
| 15 TestShellRequestContext::TestShellRequestContext( | 16 TestShellRequestContext::TestShellRequestContext( |
| 16 const std::wstring& cache_path, | 17 const std::wstring& cache_path, |
| 17 net::HttpCache::Mode cache_mode, | 18 net::HttpCache::Mode cache_mode, |
| (...skipping 16 matching lines...) Expand all Loading... |
| 34 // Force no_proxy to true so as to use a fixed proxy configuration | 35 // Force no_proxy to true so as to use a fixed proxy configuration |
| 35 // and bypass ProxyConfigServiceLinux. Enabling use of the | 36 // and bypass ProxyConfigServiceLinux. Enabling use of the |
| 36 // ProxyConfigServiceLinux requires: | 37 // ProxyConfigServiceLinux requires: |
| 37 // -Calling from a thread with a TYPE_UI MessageLoop, | 38 // -Calling from a thread with a TYPE_UI MessageLoop, |
| 38 // -If at all possible, passing in a pointer to the IO thread's MessageLoop, | 39 // -If at all possible, passing in a pointer to the IO thread's MessageLoop, |
| 39 // -Keep in mind that proxy auto configuration is also | 40 // -Keep in mind that proxy auto configuration is also |
| 40 // non-functional on linux in this context because of v8 threading | 41 // non-functional on linux in this context because of v8 threading |
| 41 // issues. | 42 // issues. |
| 42 no_proxy = true; | 43 no_proxy = true; |
| 43 #endif | 44 #endif |
| 45 host_resolver_ = new net::HostResolver(); |
| 44 proxy_service_ = net::ProxyService::Create(no_proxy ? &proxy_config : NULL, | 46 proxy_service_ = net::ProxyService::Create(no_proxy ? &proxy_config : NULL, |
| 45 false, NULL, NULL); | 47 false, NULL, NULL); |
| 46 | 48 |
| 47 net::HttpCache *cache; | 49 net::HttpCache *cache; |
| 48 if (cache_path.empty()) { | 50 if (cache_path.empty()) { |
| 49 cache = new net::HttpCache(proxy_service_, 0); | 51 cache = new net::HttpCache(host_resolver_, proxy_service_, 0); |
| 50 } else { | 52 } else { |
| 51 cache = new net::HttpCache(proxy_service_, cache_path, 0); | 53 cache = new net::HttpCache(host_resolver_, proxy_service_, cache_path, 0); |
| 52 } | 54 } |
| 53 cache->set_mode(cache_mode); | 55 cache->set_mode(cache_mode); |
| 54 http_transaction_factory_ = cache; | 56 http_transaction_factory_ = cache; |
| 55 } | 57 } |
| 56 | 58 |
| 57 TestShellRequestContext::~TestShellRequestContext() { | 59 TestShellRequestContext::~TestShellRequestContext() { |
| 58 delete cookie_store_; | 60 delete cookie_store_; |
| 59 delete http_transaction_factory_; | 61 delete http_transaction_factory_; |
| 60 delete proxy_service_; | 62 delete proxy_service_; |
| 63 delete host_resolver_; |
| 61 } | 64 } |
| 62 | 65 |
| 63 const std::string& TestShellRequestContext::GetUserAgent( | 66 const std::string& TestShellRequestContext::GetUserAgent( |
| 64 const GURL& url) const { | 67 const GURL& url) const { |
| 65 return webkit_glue::GetUserAgent(url); | 68 return webkit_glue::GetUserAgent(url); |
| 66 } | 69 } |
| OLD | NEW |