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

Side by Side Diff: webkit/tools/test_shell/test_shell_request_context.cc

Issue 258008: Move initialization of ChromeURLRequestContexts to the IO thread. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: sync again, just in case Created 11 years, 2 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
« no previous file with comments | « net/proxy/proxy_service.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "build/build_config.h" 7 #include "build/build_config.h"
8 8
9 #include "base/file_path.h" 9 #include "base/file_path.h"
10 #include "net/base/cookie_monster.h" 10 #include "net/base/cookie_monster.h"
11 #include "net/base/host_resolver.h" 11 #include "net/base/host_resolver.h"
12 #include "net/base/ssl_config_service.h" 12 #include "net/base/ssl_config_service.h"
13 #include "net/ftp/ftp_network_layer.h" 13 #include "net/ftp/ftp_network_layer.h"
14 #include "net/proxy/proxy_config_service.h"
15 #include "net/proxy/proxy_config_service_fixed.h"
14 #include "net/proxy/proxy_service.h" 16 #include "net/proxy/proxy_service.h"
15 #include "webkit/glue/webkit_glue.h" 17 #include "webkit/glue/webkit_glue.h"
16 18
17 TestShellRequestContext::TestShellRequestContext() { 19 TestShellRequestContext::TestShellRequestContext() {
18 Init(FilePath(), net::HttpCache::NORMAL, false); 20 Init(FilePath(), net::HttpCache::NORMAL, false);
19 } 21 }
20 22
21 TestShellRequestContext::TestShellRequestContext( 23 TestShellRequestContext::TestShellRequestContext(
22 const FilePath& cache_path, 24 const FilePath& cache_path,
23 net::HttpCache::Mode cache_mode, 25 net::HttpCache::Mode cache_mode,
24 bool no_proxy) { 26 bool no_proxy) {
25 Init(cache_path, cache_mode, no_proxy); 27 Init(cache_path, cache_mode, no_proxy);
26 } 28 }
27 29
28 void TestShellRequestContext::Init( 30 void TestShellRequestContext::Init(
29 const FilePath& cache_path, 31 const FilePath& cache_path,
30 net::HttpCache::Mode cache_mode, 32 net::HttpCache::Mode cache_mode,
31 bool no_proxy) { 33 bool no_proxy) {
32 cookie_store_ = new net::CookieMonster(); 34 cookie_store_ = new net::CookieMonster();
33 35
34 // hard-code A-L and A-C for test shells 36 // hard-code A-L and A-C for test shells
35 accept_language_ = "en-us,en"; 37 accept_language_ = "en-us,en";
36 accept_charset_ = "iso-8859-1,*,utf-8"; 38 accept_charset_ = "iso-8859-1,*,utf-8";
37 39
38 net::ProxyConfig proxy_config;
39 #if defined(OS_LINUX) 40 #if defined(OS_LINUX)
40 // Force no_proxy to true so as to use a fixed proxy configuration 41 // Use no proxy to avoid ProxyConfigServiceLinux.
41 // and bypass ProxyConfigServiceLinux. Enabling use of the 42 // Enabling use of the ProxyConfigServiceLinux requires:
42 // ProxyConfigServiceLinux requires:
43 // -Calling from a thread with a TYPE_UI MessageLoop, 43 // -Calling from a thread with a TYPE_UI MessageLoop,
44 // -If at all possible, passing in a pointer to the IO thread's MessageLoop, 44 // -If at all possible, passing in a pointer to the IO thread's MessageLoop,
45 // -Keep in mind that proxy auto configuration is also 45 // -Keep in mind that proxy auto configuration is also
46 // non-functional on linux in this context because of v8 threading 46 // non-functional on linux in this context because of v8 threading
47 // issues. 47 // issues.
48 no_proxy = true; 48 scoped_ptr<net::ProxyConfigService> proxy_config_service(
49 new net::ProxyConfigServiceFixed(net::ProxyConfig()));
50 #else
51 // Use the system proxy settings.
52 scoped_ptr<net::ProxyConfigService> proxy_config_service(
53 net::ProxyService::CreateSystemProxyConfigService(NULL, NULL));
49 #endif 54 #endif
50 host_resolver_ = net::CreateSystemHostResolver(); 55 host_resolver_ = net::CreateSystemHostResolver();
51 proxy_service_ = net::ProxyService::Create(no_proxy ? &proxy_config : NULL, 56 proxy_service_ = net::ProxyService::Create(proxy_config_service.release(),
52 false, NULL, NULL, NULL); 57 false, NULL, NULL);
53 ssl_config_service_ = net::SSLConfigService::CreateSystemSSLConfigService(); 58 ssl_config_service_ = net::SSLConfigService::CreateSystemSSLConfigService();
54 59
55 net::HttpCache *cache; 60 net::HttpCache *cache;
56 if (cache_path.empty()) { 61 if (cache_path.empty()) {
57 cache = new net::HttpCache(host_resolver_, proxy_service_, 62 cache = new net::HttpCache(host_resolver_, proxy_service_,
58 ssl_config_service_, 0); 63 ssl_config_service_, 0);
59 } else { 64 } else {
60 cache = new net::HttpCache(host_resolver_, proxy_service_, 65 cache = new net::HttpCache(host_resolver_, proxy_service_,
61 ssl_config_service_, cache_path, 0); 66 ssl_config_service_, cache_path, 0);
62 } 67 }
63 cache->set_mode(cache_mode); 68 cache->set_mode(cache_mode);
64 http_transaction_factory_ = cache; 69 http_transaction_factory_ = cache;
65 70
66 ftp_transaction_factory_ = new net::FtpNetworkLayer(host_resolver_); 71 ftp_transaction_factory_ = new net::FtpNetworkLayer(host_resolver_);
67 } 72 }
68 73
69 TestShellRequestContext::~TestShellRequestContext() { 74 TestShellRequestContext::~TestShellRequestContext() {
70 delete ftp_transaction_factory_; 75 delete ftp_transaction_factory_;
71 delete http_transaction_factory_; 76 delete http_transaction_factory_;
72 } 77 }
73 78
74 const std::string& TestShellRequestContext::GetUserAgent( 79 const std::string& TestShellRequestContext::GetUserAgent(
75 const GURL& url) const { 80 const GURL& url) const {
76 return webkit_glue::GetUserAgent(url); 81 return webkit_glue::GetUserAgent(url);
77 } 82 }
OLDNEW
« no previous file with comments | « net/proxy/proxy_service.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698