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

Side by Side Diff: net/url_request/url_request_context_builder.cc

Issue 10918279: Provide mutable members of UrlRequestContext via pure-virtual interface (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Change to returning strings by value 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 "net/url_request/url_request_context_builder.h" 5 #include "net/url_request/url_request_context_builder.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/string_util.h"
12 #include "base/threading/thread.h" 13 #include "base/threading/thread.h"
13 #include "base/thread_task_runner_handle.h" 14 #include "base/thread_task_runner_handle.h"
14 #include "net/base/cert_verifier.h" 15 #include "net/base/cert_verifier.h"
15 #include "net/base/host_resolver.h" 16 #include "net/base/host_resolver.h"
16 #include "net/base/net_errors.h" 17 #include "net/base/net_errors.h"
17 #include "net/base/network_delegate.h" 18 #include "net/base/network_delegate.h"
18 #include "net/base/ssl_config_service_defaults.h" 19 #include "net/base/ssl_config_service_defaults.h"
19 #include "net/base/transport_security_state.h" 20 #include "net/base/transport_security_state.h"
20 #include "net/cookies/cookie_monster.h" 21 #include "net/cookies/cookie_monster.h"
21 #include "net/ftp/ftp_network_layer.h" 22 #include "net/ftp/ftp_network_layer.h"
22 #include "net/http/http_auth_handler_factory.h" 23 #include "net/http/http_auth_handler_factory.h"
23 #include "net/http/http_cache.h" 24 #include "net/http/http_cache.h"
24 #include "net/http/http_network_layer.h" 25 #include "net/http/http_network_layer.h"
25 #include "net/http/http_network_session.h" 26 #include "net/http/http_network_session.h"
26 #include "net/http/http_server_properties_impl.h" 27 #include "net/http/http_server_properties_impl.h"
27 #include "net/proxy/proxy_service.h" 28 #include "net/proxy/proxy_service.h"
29 #include "net/url_request/const_http_user_agent_settings.h"
28 #include "net/url_request/url_request_context.h" 30 #include "net/url_request/url_request_context.h"
29 #include "net/url_request/url_request_context_storage.h" 31 #include "net/url_request/url_request_context_storage.h"
30 32
31 namespace net { 33 namespace net {
32 34
33 namespace { 35 namespace {
34 36
35 class BasicNetworkDelegate : public NetworkDelegate { 37 class BasicNetworkDelegate : public NetworkDelegate {
36 public: 38 public:
37 BasicNetworkDelegate() {} 39 BasicNetworkDelegate() {}
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 : cache_thread_("Cache Thread"), 126 : cache_thread_("Cache Thread"),
125 file_thread_("File Thread"), 127 file_thread_("File Thread"),
126 ALLOW_THIS_IN_INITIALIZER_LIST(storage_(this)) {} 128 ALLOW_THIS_IN_INITIALIZER_LIST(storage_(this)) {}
127 129
128 URLRequestContextStorage* storage() { 130 URLRequestContextStorage* storage() {
129 return &storage_; 131 return &storage_;
130 } 132 }
131 133
132 void set_user_agent(const std::string& user_agent) { 134 void set_user_agent(const std::string& user_agent) {
133 user_agent_ = user_agent; 135 user_agent_ = user_agent;
134 } 136 }
mmenke 2012/10/05 20:08:51 Remove this.
135 137
136 void StartCacheThread() { 138 void StartCacheThread() {
137 cache_thread_.StartWithOptions( 139 cache_thread_.StartWithOptions(
138 base::Thread::Options(MessageLoop::TYPE_IO, 0)); 140 base::Thread::Options(MessageLoop::TYPE_IO, 0));
139 } 141 }
140 142
141 scoped_refptr<base::MessageLoopProxy> cache_message_loop_proxy() { 143 scoped_refptr<base::MessageLoopProxy> cache_message_loop_proxy() {
142 DCHECK(cache_thread_.IsRunning()); 144 DCHECK(cache_thread_.IsRunning());
143 return cache_thread_.message_loop_proxy(); 145 return cache_thread_.message_loop_proxy();
144 } 146 }
145 147
146 void StartFileThread() { 148 void StartFileThread() {
147 file_thread_.StartWithOptions( 149 file_thread_.StartWithOptions(
148 base::Thread::Options(MessageLoop::TYPE_DEFAULT, 0)); 150 base::Thread::Options(MessageLoop::TYPE_DEFAULT, 0));
149 } 151 }
150 152
151 MessageLoop* file_message_loop() { 153 MessageLoop* file_message_loop() {
152 DCHECK(file_thread_.IsRunning()); 154 DCHECK(file_thread_.IsRunning());
153 return file_thread_.message_loop(); 155 return file_thread_.message_loop();
154 } 156 }
155 157
156 virtual const std::string& GetUserAgent(
157 const GURL& /* url */) const OVERRIDE {
158 return user_agent_;
159 }
160
161 protected: 158 protected:
162 virtual ~BasicURLRequestContext() {} 159 virtual ~BasicURLRequestContext() {}
163 160
164 private: 161 private:
165 std::string user_agent_; 162 std::string user_agent_;
mmenke 2012/10/05 20:08:51 Remove this.
166 base::Thread cache_thread_; 163 base::Thread cache_thread_;
167 base::Thread file_thread_; 164 base::Thread file_thread_;
168 URLRequestContextStorage storage_; 165 URLRequestContextStorage storage_;
169 DISALLOW_COPY_AND_ASSIGN(BasicURLRequestContext); 166 DISALLOW_COPY_AND_ASSIGN(BasicURLRequestContext);
170 }; 167 };
171 168
172 } // namespace 169 } // namespace
173 170
174 URLRequestContextBuilder::HostResolverParams::HostResolverParams() 171 URLRequestContextBuilder::HostResolverParams::HostResolverParams()
175 : parallelism(HostResolver::kDefaultParallelism), 172 : parallelism(HostResolver::kDefaultParallelism),
(...skipping 25 matching lines...) Expand all
201 void URLRequestContextBuilder::set_proxy_config_service( 198 void URLRequestContextBuilder::set_proxy_config_service(
202 ProxyConfigService* proxy_config_service) { 199 ProxyConfigService* proxy_config_service) {
203 proxy_config_service_.reset(proxy_config_service); 200 proxy_config_service_.reset(proxy_config_service);
204 } 201 }
205 #endif // defined(OS_LINUX) 202 #endif // defined(OS_LINUX)
206 203
207 URLRequestContext* URLRequestContextBuilder::Build() { 204 URLRequestContext* URLRequestContextBuilder::Build() {
208 BasicURLRequestContext* context = new BasicURLRequestContext; 205 BasicURLRequestContext* context = new BasicURLRequestContext;
209 URLRequestContextStorage* storage = context->storage(); 206 URLRequestContextStorage* storage = context->storage();
210 207
211 context->set_user_agent(user_agent_); 208 storage->set_http_user_agent_settings(new ConstHttpUserAgentSettings(
209 EmptyString(), EmptyString(), user_agent_));
212 210
213 BasicNetworkDelegate* network_delegate = new BasicNetworkDelegate; 211 BasicNetworkDelegate* network_delegate = new BasicNetworkDelegate;
214 storage->set_network_delegate(network_delegate); 212 storage->set_network_delegate(network_delegate);
215 213
216 net::HostResolver* host_resolver = net::CreateSystemHostResolver( 214 net::HostResolver* host_resolver = net::CreateSystemHostResolver(
217 host_resolver_params_.parallelism, 215 host_resolver_params_.parallelism,
218 host_resolver_params_.retry_attempts, 216 host_resolver_params_.retry_attempts,
219 NULL /* no NetLog */); 217 NULL /* no NetLog */);
220 storage->set_host_resolver(host_resolver); 218 storage->set_host_resolver(host_resolver);
221 219
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 http_transaction_factory = new HttpNetworkLayer(network_session); 300 http_transaction_factory = new HttpNetworkLayer(network_session);
303 } 301 }
304 storage->set_http_transaction_factory(http_transaction_factory); 302 storage->set_http_transaction_factory(http_transaction_factory);
305 303
306 // TODO(willchan): Support sdch. 304 // TODO(willchan): Support sdch.
307 305
308 return context; 306 return context;
309 } 307 }
310 308
311 } // namespace net 309 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698