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

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

Issue 10918279: Provide mutable members of UrlRequestContext via pure-virtual interface (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Disable test for chrome_frame_net_tests Created 8 years, 1 month 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 | « webkit/tools/test_shell/test_shell_request_context.h ('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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/file_path.h" 10 #include "base/file_path.h"
11 #include "base/thread_task_runner_handle.h" 11 #include "base/thread_task_runner_handle.h"
12 #include "base/threading/worker_pool.h" 12 #include "base/threading/worker_pool.h"
13 #include "net/base/cert_verifier.h" 13 #include "net/base/cert_verifier.h"
14 #include "net/base/default_server_bound_cert_store.h" 14 #include "net/base/default_server_bound_cert_store.h"
15 #include "net/base/host_resolver.h" 15 #include "net/base/host_resolver.h"
16 #include "net/base/server_bound_cert_service.h" 16 #include "net/base/server_bound_cert_service.h"
17 #include "net/base/ssl_config_service_defaults.h" 17 #include "net/base/ssl_config_service_defaults.h"
18 #include "net/cookies/cookie_monster.h" 18 #include "net/cookies/cookie_monster.h"
19 #include "net/ftp/ftp_network_layer.h" 19 #include "net/ftp/ftp_network_layer.h"
20 #include "net/http/http_auth_handler_factory.h" 20 #include "net/http/http_auth_handler_factory.h"
21 #include "net/http/http_network_session.h" 21 #include "net/http/http_network_session.h"
22 #include "net/http/http_server_properties_impl.h" 22 #include "net/http/http_server_properties_impl.h"
23 #include "net/proxy/proxy_config_service.h" 23 #include "net/proxy/proxy_config_service.h"
24 #include "net/proxy/proxy_config_service_fixed.h" 24 #include "net/proxy/proxy_config_service_fixed.h"
25 #include "net/proxy/proxy_service.h" 25 #include "net/proxy/proxy_service.h"
26 #include "net/url_request/http_user_agent_settings.h"
26 #include "net/url_request/url_request_job_factory_impl.h" 27 #include "net/url_request/url_request_job_factory_impl.h"
27 #include "third_party/WebKit/Source/WebKit/chromium/public/WebKit.h" 28 #include "third_party/WebKit/Source/WebKit/chromium/public/WebKit.h"
28 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebKitPlatfo rmSupport.h" 29 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebKitPlatfo rmSupport.h"
29 #include "webkit/blob/blob_storage_controller.h" 30 #include "webkit/blob/blob_storage_controller.h"
30 #include "webkit/blob/blob_url_request_job_factory.h" 31 #include "webkit/blob/blob_url_request_job_factory.h"
31 #include "webkit/fileapi/file_system_context.h" 32 #include "webkit/fileapi/file_system_context.h"
32 #include "webkit/fileapi/file_system_url_request_job_factory.h" 33 #include "webkit/fileapi/file_system_url_request_job_factory.h"
33 #include "webkit/tools/test_shell/simple_file_system.h" 34 #include "webkit/tools/test_shell/simple_file_system.h"
34 #include "webkit/tools/test_shell/simple_resource_loader_bridge.h" 35 #include "webkit/tools/test_shell/simple_resource_loader_bridge.h"
35 #include "webkit/user_agent/user_agent.h" 36 #include "webkit/user_agent/user_agent.h"
36 37
38 class TestShellHttpUserAgentSettings : public net::HttpUserAgentSettings {
39 public:
40 TestShellHttpUserAgentSettings() {}
41 virtual ~TestShellHttpUserAgentSettings() {}
42
43 // hard-code A-L and A-C for test shells
44 virtual std::string GetAcceptLanguage() const OVERRIDE {
45 return "en-us,en";
46 }
47 virtual std::string GetAcceptCharset() const OVERRIDE {
48 return "iso-8859-1,*,utf-8";
49 }
50
51 virtual std::string GetUserAgent(const GURL& url) const OVERRIDE {
52 return webkit_glue::GetUserAgent(url);
53 }
54
55 private:
56 DISALLOW_COPY_AND_ASSIGN(TestShellHttpUserAgentSettings);
57 };
58
37 TestShellRequestContext::TestShellRequestContext() 59 TestShellRequestContext::TestShellRequestContext()
38 : ALLOW_THIS_IN_INITIALIZER_LIST(storage_(this)) { 60 : ALLOW_THIS_IN_INITIALIZER_LIST(storage_(this)) {
39 Init(FilePath(), net::HttpCache::NORMAL, false); 61 Init(FilePath(), net::HttpCache::NORMAL, false);
40 } 62 }
41 63
42 TestShellRequestContext::TestShellRequestContext( 64 TestShellRequestContext::TestShellRequestContext(
43 const FilePath& cache_path, 65 const FilePath& cache_path,
44 net::HttpCache::Mode cache_mode, 66 net::HttpCache::Mode cache_mode,
45 bool no_proxy) 67 bool no_proxy)
46 : ALLOW_THIS_IN_INITIALIZER_LIST(storage_(this)) { 68 : ALLOW_THIS_IN_INITIALIZER_LIST(storage_(this)) {
47 Init(cache_path, cache_mode, no_proxy); 69 Init(cache_path, cache_mode, no_proxy);
48 } 70 }
49 71
50 void TestShellRequestContext::Init( 72 void TestShellRequestContext::Init(
51 const FilePath& cache_path, 73 const FilePath& cache_path,
52 net::HttpCache::Mode cache_mode, 74 net::HttpCache::Mode cache_mode,
53 bool no_proxy) { 75 bool no_proxy) {
54 storage_.set_cookie_store(new net::CookieMonster(NULL, NULL)); 76 storage_.set_cookie_store(new net::CookieMonster(NULL, NULL));
55 storage_.set_server_bound_cert_service(new net::ServerBoundCertService( 77 storage_.set_server_bound_cert_service(new net::ServerBoundCertService(
56 new net::DefaultServerBoundCertStore(NULL), 78 new net::DefaultServerBoundCertStore(NULL),
57 base::WorkerPool::GetTaskRunner(true))); 79 base::WorkerPool::GetTaskRunner(true)));
58 80
59 // hard-code A-L and A-C for test shells 81 storage_.set_http_user_agent_settings(new TestShellHttpUserAgentSettings);
60 set_accept_language("en-us,en");
61 set_accept_charset("iso-8859-1,*,utf-8");
62 82
63 #if defined(OS_POSIX) && !defined(OS_MACOSX) 83 #if defined(OS_POSIX) && !defined(OS_MACOSX)
64 // Use no proxy to avoid ProxyConfigServiceLinux. 84 // Use no proxy to avoid ProxyConfigServiceLinux.
65 // Enabling use of the ProxyConfigServiceLinux requires: 85 // Enabling use of the ProxyConfigServiceLinux requires:
66 // -Calling from a thread with a TYPE_UI MessageLoop, 86 // -Calling from a thread with a TYPE_UI MessageLoop,
67 // -If at all possible, passing in a pointer to the IO thread's MessageLoop, 87 // -If at all possible, passing in a pointer to the IO thread's MessageLoop,
68 // -Keep in mind that proxy auto configuration is also 88 // -Keep in mind that proxy auto configuration is also
69 // non-functional on linux in this context because of v8 threading 89 // non-functional on linux in this context because of v8 threading
70 // issues. 90 // issues.
71 // TODO(port): rename "linux" to some nonspecific unix. 91 // TODO(port): rename "linux" to some nonspecific unix.
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 file_system_context_, 145 file_system_context_,
126 SimpleResourceLoaderBridge::GetIoThread())); 146 SimpleResourceLoaderBridge::GetIoThread()));
127 job_factory->SetProtocolHandler( 147 job_factory->SetProtocolHandler(
128 "filesystem", 148 "filesystem",
129 fileapi::CreateFileSystemProtocolHandler(file_system_context_.get())); 149 fileapi::CreateFileSystemProtocolHandler(file_system_context_.get()));
130 storage_.set_job_factory(job_factory); 150 storage_.set_job_factory(job_factory);
131 } 151 }
132 152
133 TestShellRequestContext::~TestShellRequestContext() { 153 TestShellRequestContext::~TestShellRequestContext() {
134 } 154 }
135
136 const std::string& TestShellRequestContext::GetUserAgent(
137 const GURL& url) const {
138 return webkit_glue::GetUserAgent(url);
139 }
OLDNEW
« no previous file with comments | « webkit/tools/test_shell/test_shell_request_context.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698