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

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: Address erikwright's second round of comments. Created 8 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
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"
(...skipping 16 matching lines...) Expand all
27 #include "third_party/WebKit/Source/WebKit/chromium/public/WebKit.h" 27 #include "third_party/WebKit/Source/WebKit/chromium/public/WebKit.h"
28 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebKitPlatfo rmSupport.h" 28 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebKitPlatfo rmSupport.h"
29 #include "webkit/blob/blob_storage_controller.h" 29 #include "webkit/blob/blob_storage_controller.h"
30 #include "webkit/blob/blob_url_request_job_factory.h" 30 #include "webkit/blob/blob_url_request_job_factory.h"
31 #include "webkit/fileapi/file_system_context.h" 31 #include "webkit/fileapi/file_system_context.h"
32 #include "webkit/fileapi/file_system_url_request_job_factory.h" 32 #include "webkit/fileapi/file_system_url_request_job_factory.h"
33 #include "webkit/tools/test_shell/simple_file_system.h" 33 #include "webkit/tools/test_shell/simple_file_system.h"
34 #include "webkit/tools/test_shell/simple_resource_loader_bridge.h" 34 #include "webkit/tools/test_shell/simple_resource_loader_bridge.h"
35 #include "webkit/user_agent/user_agent.h" 35 #include "webkit/user_agent/user_agent.h"
36 36
37 class TestShellHttpUserAgentSettings
38 : public net::ConstHttpAcceptLanguageAndCharset {
mmenke 2012/09/26 16:28:20 4-space indent
39 public:
40 TestShellHttpUserAgentSettings()
41 // hard-code A-L and A-C for test shells
42 : ConstHttpAcceptLanguageAndCharset("en-us,en", "iso-8859-1,*,utf-8") {}
43 virtual ~TestShellHttpUserAgentSettings() {}
44
45 virtual const std::string& GetUserAgent(const GURL& url) OVERRIDE {
46 return webkit_glue::GetUserAgent(url);
47 }
48
49 private:
50 DISALLOW_COPY_AND_ASSIGN(TestShellHttpUserAgentSettings);
51 };
52
37 TestShellRequestContext::TestShellRequestContext() 53 TestShellRequestContext::TestShellRequestContext()
38 : ALLOW_THIS_IN_INITIALIZER_LIST(storage_(this)) { 54 : ALLOW_THIS_IN_INITIALIZER_LIST(storage_(this)) {
39 Init(FilePath(), net::HttpCache::NORMAL, false); 55 Init(FilePath(), net::HttpCache::NORMAL, false);
40 } 56 }
41 57
42 TestShellRequestContext::TestShellRequestContext( 58 TestShellRequestContext::TestShellRequestContext(
43 const FilePath& cache_path, 59 const FilePath& cache_path,
44 net::HttpCache::Mode cache_mode, 60 net::HttpCache::Mode cache_mode,
45 bool no_proxy) 61 bool no_proxy)
46 : ALLOW_THIS_IN_INITIALIZER_LIST(storage_(this)) { 62 : ALLOW_THIS_IN_INITIALIZER_LIST(storage_(this)) {
47 Init(cache_path, cache_mode, no_proxy); 63 Init(cache_path, cache_mode, no_proxy);
48 } 64 }
49 65
50 void TestShellRequestContext::Init( 66 void TestShellRequestContext::Init(
51 const FilePath& cache_path, 67 const FilePath& cache_path,
52 net::HttpCache::Mode cache_mode, 68 net::HttpCache::Mode cache_mode,
53 bool no_proxy) { 69 bool no_proxy) {
54 storage_.set_cookie_store(new net::CookieMonster(NULL, NULL)); 70 storage_.set_cookie_store(new net::CookieMonster(NULL, NULL));
55 storage_.set_server_bound_cert_service(new net::ServerBoundCertService( 71 storage_.set_server_bound_cert_service(new net::ServerBoundCertService(
56 new net::DefaultServerBoundCertStore(NULL), 72 new net::DefaultServerBoundCertStore(NULL),
57 base::WorkerPool::GetTaskRunner(true))); 73 base::WorkerPool::GetTaskRunner(true)));
58 74
59 // hard-code A-L and A-C for test shells 75 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 76
63 #if defined(OS_POSIX) && !defined(OS_MACOSX) 77 #if defined(OS_POSIX) && !defined(OS_MACOSX)
64 // Use no proxy to avoid ProxyConfigServiceLinux. 78 // Use no proxy to avoid ProxyConfigServiceLinux.
65 // Enabling use of the ProxyConfigServiceLinux requires: 79 // Enabling use of the ProxyConfigServiceLinux requires:
66 // -Calling from a thread with a TYPE_UI MessageLoop, 80 // -Calling from a thread with a TYPE_UI MessageLoop,
67 // -If at all possible, passing in a pointer to the IO thread's MessageLoop, 81 // -If at all possible, passing in a pointer to the IO thread's MessageLoop,
68 // -Keep in mind that proxy auto configuration is also 82 // -Keep in mind that proxy auto configuration is also
69 // non-functional on linux in this context because of v8 threading 83 // non-functional on linux in this context because of v8 threading
70 // issues. 84 // issues.
71 // TODO(port): rename "linux" to some nonspecific unix. 85 // TODO(port): rename "linux" to some nonspecific unix.
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 blob_storage_controller_.get(), 141 blob_storage_controller_.get(),
128 SimpleResourceLoaderBridge::GetIoThread())); 142 SimpleResourceLoaderBridge::GetIoThread()));
129 job_factory->SetProtocolHandler( 143 job_factory->SetProtocolHandler(
130 "filesystem", 144 "filesystem",
131 fileapi::CreateFileSystemProtocolHandler(file_system_context_.get())); 145 fileapi::CreateFileSystemProtocolHandler(file_system_context_.get()));
132 storage_.set_job_factory(job_factory); 146 storage_.set_job_factory(job_factory);
133 } 147 }
134 148
135 TestShellRequestContext::~TestShellRequestContext() { 149 TestShellRequestContext::~TestShellRequestContext() {
136 } 150 }
137
138 const std::string& TestShellRequestContext::GetUserAgent(
139 const GURL& url) const {
140 return webkit_glue::GetUserAgent(url);
141 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698