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

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

Issue 266243004: Clang format slam. Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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"
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 SocketStream* stream, 116 SocketStream* stream,
117 const CompletionCallback& callback) OVERRIDE { 117 const CompletionCallback& callback) OVERRIDE {
118 return OK; 118 return OK;
119 } 119 }
120 120
121 DISALLOW_COPY_AND_ASSIGN(BasicNetworkDelegate); 121 DISALLOW_COPY_AND_ASSIGN(BasicNetworkDelegate);
122 }; 122 };
123 123
124 class BasicURLRequestContext : public URLRequestContext { 124 class BasicURLRequestContext : public URLRequestContext {
125 public: 125 public:
126 BasicURLRequestContext() 126 BasicURLRequestContext() : storage_(this) {}
127 : storage_(this) {}
128 127
129 URLRequestContextStorage* storage() { 128 URLRequestContextStorage* storage() { return &storage_; }
130 return &storage_;
131 }
132 129
133 base::Thread* GetCacheThread() { 130 base::Thread* GetCacheThread() {
134 if (!cache_thread_) { 131 if (!cache_thread_) {
135 cache_thread_.reset(new base::Thread("Cache Thread")); 132 cache_thread_.reset(new base::Thread("Cache Thread"));
136 cache_thread_->StartWithOptions( 133 cache_thread_->StartWithOptions(
137 base::Thread::Options(base::MessageLoop::TYPE_IO, 0)); 134 base::Thread::Options(base::MessageLoop::TYPE_IO, 0));
138 } 135 }
139 return cache_thread_.get(); 136 return cache_thread_.get();
140 } 137 }
141 138
(...skipping 12 matching lines...) Expand all
154 private: 151 private:
155 scoped_ptr<base::Thread> cache_thread_; 152 scoped_ptr<base::Thread> cache_thread_;
156 scoped_ptr<base::Thread> file_thread_; 153 scoped_ptr<base::Thread> file_thread_;
157 URLRequestContextStorage storage_; 154 URLRequestContextStorage storage_;
158 DISALLOW_COPY_AND_ASSIGN(BasicURLRequestContext); 155 DISALLOW_COPY_AND_ASSIGN(BasicURLRequestContext);
159 }; 156 };
160 157
161 } // namespace 158 } // namespace
162 159
163 URLRequestContextBuilder::HttpCacheParams::HttpCacheParams() 160 URLRequestContextBuilder::HttpCacheParams::HttpCacheParams()
164 : type(IN_MEMORY), 161 : type(IN_MEMORY), max_size(0) {
165 max_size(0) {} 162 }
166 URLRequestContextBuilder::HttpCacheParams::~HttpCacheParams() {} 163 URLRequestContextBuilder::HttpCacheParams::~HttpCacheParams() {
164 }
167 165
168 URLRequestContextBuilder::HttpNetworkSessionParams::HttpNetworkSessionParams() 166 URLRequestContextBuilder::HttpNetworkSessionParams::HttpNetworkSessionParams()
169 : ignore_certificate_errors(false), 167 : ignore_certificate_errors(false),
170 host_mapping_rules(NULL), 168 host_mapping_rules(NULL),
171 http_pipelining_enabled(false), 169 http_pipelining_enabled(false),
172 testing_fixed_http_port(0), 170 testing_fixed_http_port(0),
173 testing_fixed_https_port(0), 171 testing_fixed_https_port(0),
174 trusted_spdy_proxy() {} 172 trusted_spdy_proxy() {
173 }
175 174
176 URLRequestContextBuilder::HttpNetworkSessionParams::~HttpNetworkSessionParams() 175 URLRequestContextBuilder::HttpNetworkSessionParams::
177 {} 176 ~HttpNetworkSessionParams() {
177 }
178 178
179 URLRequestContextBuilder::SchemeFactory::SchemeFactory( 179 URLRequestContextBuilder::SchemeFactory::SchemeFactory(
180 const std::string& auth_scheme, 180 const std::string& auth_scheme,
181 net::HttpAuthHandlerFactory* auth_handler_factory) 181 net::HttpAuthHandlerFactory* auth_handler_factory)
182 : scheme(auth_scheme), factory(auth_handler_factory) { 182 : scheme(auth_scheme), factory(auth_handler_factory) {
183 } 183 }
184 184
185 URLRequestContextBuilder::SchemeFactory::~SchemeFactory() { 185 URLRequestContextBuilder::SchemeFactory::~SchemeFactory() {
186 } 186 }
187 187
188 URLRequestContextBuilder::URLRequestContextBuilder() 188 URLRequestContextBuilder::URLRequestContextBuilder()
189 : data_enabled_(false), 189 : data_enabled_(false),
190 file_enabled_(false), 190 file_enabled_(false),
191 #if !defined(DISABLE_FTP_SUPPORT) 191 #if !defined(DISABLE_FTP_SUPPORT)
192 ftp_enabled_(false), 192 ftp_enabled_(false),
193 #endif 193 #endif
194 http_cache_enabled_(true) { 194 http_cache_enabled_(true) {
195 } 195 }
196 196
197 URLRequestContextBuilder::~URLRequestContextBuilder() {} 197 URLRequestContextBuilder::~URLRequestContextBuilder() {
198 }
198 199
199 void URLRequestContextBuilder::set_proxy_config_service( 200 void URLRequestContextBuilder::set_proxy_config_service(
200 ProxyConfigService* proxy_config_service) { 201 ProxyConfigService* proxy_config_service) {
201 proxy_config_service_.reset(proxy_config_service); 202 proxy_config_service_.reset(proxy_config_service);
202 } 203 }
203 204
204 URLRequestContext* URLRequestContextBuilder::Build() { 205 URLRequestContext* URLRequestContextBuilder::Build() {
205 BasicURLRequestContext* context = new BasicURLRequestContext; 206 BasicURLRequestContext* context = new BasicURLRequestContext;
206 URLRequestContextStorage* storage = context->storage(); 207 URLRequestContextStorage* storage = context->storage();
207 208
208 storage->set_http_user_agent_settings(new StaticHttpUserAgentSettings( 209 storage->set_http_user_agent_settings(
209 accept_language_, user_agent_)); 210 new StaticHttpUserAgentSettings(accept_language_, user_agent_));
210 211
211 if (!network_delegate_) 212 if (!network_delegate_)
212 network_delegate_.reset(new BasicNetworkDelegate); 213 network_delegate_.reset(new BasicNetworkDelegate);
213 NetworkDelegate* network_delegate = network_delegate_.release(); 214 NetworkDelegate* network_delegate = network_delegate_.release();
214 storage->set_network_delegate(network_delegate); 215 storage->set_network_delegate(network_delegate);
215 216
216 if (!host_resolver_) 217 if (!host_resolver_)
217 host_resolver_ = net::HostResolver::CreateDefaultResolver(NULL); 218 host_resolver_ = net::HostResolver::CreateDefaultResolver(NULL);
218 storage->set_host_resolver(host_resolver_.Pass()); 219 storage->set_host_resolver(host_resolver_.Pass());
219 220
220 storage->set_net_log(new net::NetLog); 221 storage->set_net_log(new net::NetLog);
221 222
222 // TODO(willchan): Switch to using this code when 223 // TODO(willchan): Switch to using this code when
223 // ProxyService::CreateSystemProxyConfigService()'s signature doesn't suck. 224 // ProxyService::CreateSystemProxyConfigService()'s signature doesn't suck.
224 #if defined(OS_LINUX) || defined(OS_ANDROID) 225 #if defined(OS_LINUX) || defined(OS_ANDROID)
225 ProxyConfigService* proxy_config_service = proxy_config_service_.release(); 226 ProxyConfigService* proxy_config_service = proxy_config_service_.release();
226 #else 227 #else
227 ProxyConfigService* proxy_config_service = NULL; 228 ProxyConfigService* proxy_config_service = NULL;
228 if (proxy_config_service_) { 229 if (proxy_config_service_) {
229 proxy_config_service = proxy_config_service_.release(); 230 proxy_config_service = proxy_config_service_.release();
230 } else { 231 } else {
231 proxy_config_service = 232 proxy_config_service = ProxyService::CreateSystemProxyConfigService(
232 ProxyService::CreateSystemProxyConfigService( 233 base::ThreadTaskRunnerHandle::Get().get(),
233 base::ThreadTaskRunnerHandle::Get().get(), 234 context->GetFileThread()->message_loop());
234 context->GetFileThread()->message_loop());
235 } 235 }
236 #endif // defined(OS_LINUX) || defined(OS_ANDROID) 236 #endif // defined(OS_LINUX) || defined(OS_ANDROID)
237 storage->set_proxy_service( 237 storage->set_proxy_service(ProxyService::CreateUsingSystemProxyResolver(
238 ProxyService::CreateUsingSystemProxyResolver( 238 proxy_config_service,
239 proxy_config_service, 239 4, // TODO(willchan): Find a better constant somewhere.
240 4, // TODO(willchan): Find a better constant somewhere. 240 context->net_log()));
241 context->net_log()));
242 storage->set_ssl_config_service(new net::SSLConfigServiceDefaults); 241 storage->set_ssl_config_service(new net::SSLConfigServiceDefaults);
243 HttpAuthHandlerRegistryFactory* http_auth_handler_registry_factory = 242 HttpAuthHandlerRegistryFactory* http_auth_handler_registry_factory =
244 net::HttpAuthHandlerRegistryFactory::CreateDefault( 243 net::HttpAuthHandlerRegistryFactory::CreateDefault(
245 context->host_resolver()); 244 context->host_resolver());
246 for (size_t i = 0; i < extra_http_auth_handlers_.size(); ++i) { 245 for (size_t i = 0; i < extra_http_auth_handlers_.size(); ++i) {
247 http_auth_handler_registry_factory->RegisterSchemeFactory( 246 http_auth_handler_registry_factory->RegisterSchemeFactory(
248 extra_http_auth_handlers_[i].scheme, 247 extra_http_auth_handlers_[i].scheme,
249 extra_http_auth_handlers_[i].factory); 248 extra_http_auth_handlers_[i].factory);
250 } 249 }
251 storage->set_http_auth_handler_factory(http_auth_handler_registry_factory); 250 storage->set_http_auth_handler_factory(http_auth_handler_registry_factory);
252 storage->set_cookie_store(new CookieMonster(NULL, NULL)); 251 storage->set_cookie_store(new CookieMonster(NULL, NULL));
253 storage->set_transport_security_state(new net::TransportSecurityState()); 252 storage->set_transport_security_state(new net::TransportSecurityState());
254 storage->set_http_server_properties( 253 storage->set_http_server_properties(scoped_ptr<net::HttpServerProperties>(
255 scoped_ptr<net::HttpServerProperties>( 254 new net::HttpServerPropertiesImpl()));
256 new net::HttpServerPropertiesImpl()));
257 storage->set_cert_verifier(CertVerifier::CreateDefault()); 255 storage->set_cert_verifier(CertVerifier::CreateDefault());
258 256
259 net::HttpNetworkSession::Params network_session_params; 257 net::HttpNetworkSession::Params network_session_params;
260 network_session_params.host_resolver = context->host_resolver(); 258 network_session_params.host_resolver = context->host_resolver();
261 network_session_params.cert_verifier = context->cert_verifier(); 259 network_session_params.cert_verifier = context->cert_verifier();
262 network_session_params.transport_security_state = 260 network_session_params.transport_security_state =
263 context->transport_security_state(); 261 context->transport_security_state();
264 network_session_params.proxy_service = context->proxy_service(); 262 network_session_params.proxy_service = context->proxy_service();
265 network_session_params.ssl_config_service = 263 network_session_params.ssl_config_service = context->ssl_config_service();
266 context->ssl_config_service();
267 network_session_params.http_auth_handler_factory = 264 network_session_params.http_auth_handler_factory =
268 context->http_auth_handler_factory(); 265 context->http_auth_handler_factory();
269 network_session_params.network_delegate = network_delegate; 266 network_session_params.network_delegate = network_delegate;
270 network_session_params.http_server_properties = 267 network_session_params.http_server_properties =
271 context->http_server_properties(); 268 context->http_server_properties();
272 network_session_params.net_log = context->net_log(); 269 network_session_params.net_log = context->net_log();
273 network_session_params.ignore_certificate_errors = 270 network_session_params.ignore_certificate_errors =
274 http_network_session_params_.ignore_certificate_errors; 271 http_network_session_params_.ignore_certificate_errors;
275 network_session_params.host_mapping_rules = 272 network_session_params.host_mapping_rules =
276 http_network_session_params_.host_mapping_rules; 273 http_network_session_params_.host_mapping_rules;
(...skipping 16 matching lines...) Expand all
293 DISK_CACHE, 290 DISK_CACHE,
294 net::CACHE_BACKEND_DEFAULT, 291 net::CACHE_BACKEND_DEFAULT,
295 http_cache_params_.path, 292 http_cache_params_.path,
296 http_cache_params_.max_size, 293 http_cache_params_.max_size,
297 context->GetCacheThread()->message_loop_proxy().get()); 294 context->GetCacheThread()->message_loop_proxy().get());
298 } else { 295 } else {
299 http_cache_backend = 296 http_cache_backend =
300 HttpCache::DefaultBackend::InMemory(http_cache_params_.max_size); 297 HttpCache::DefaultBackend::InMemory(http_cache_params_.max_size);
301 } 298 }
302 299
303 http_transaction_factory = new HttpCache( 300 http_transaction_factory =
304 network_session_params, http_cache_backend); 301 new HttpCache(network_session_params, http_cache_backend);
305 } else { 302 } else {
306 scoped_refptr<net::HttpNetworkSession> network_session( 303 scoped_refptr<net::HttpNetworkSession> network_session(
307 new net::HttpNetworkSession(network_session_params)); 304 new net::HttpNetworkSession(network_session_params));
308 305
309 http_transaction_factory = new HttpNetworkLayer(network_session.get()); 306 http_transaction_factory = new HttpNetworkLayer(network_session.get());
310 } 307 }
311 storage->set_http_transaction_factory(http_transaction_factory); 308 storage->set_http_transaction_factory(http_transaction_factory);
312 309
313 URLRequestJobFactoryImpl* job_factory = new URLRequestJobFactoryImpl; 310 URLRequestJobFactoryImpl* job_factory = new URLRequestJobFactoryImpl;
314 if (data_enabled_) 311 if (data_enabled_)
315 job_factory->SetProtocolHandler("data", new DataProtocolHandler); 312 job_factory->SetProtocolHandler("data", new DataProtocolHandler);
316 if (file_enabled_) { 313 if (file_enabled_) {
317 job_factory->SetProtocolHandler( 314 job_factory->SetProtocolHandler(
318 "file", 315 "file",
319 new FileProtocolHandler(context->GetFileThread()->message_loop_proxy())); 316 new FileProtocolHandler(
317 context->GetFileThread()->message_loop_proxy()));
320 } 318 }
321 #if !defined(DISABLE_FTP_SUPPORT) 319 #if !defined(DISABLE_FTP_SUPPORT)
322 if (ftp_enabled_) { 320 if (ftp_enabled_) {
323 ftp_transaction_factory_.reset( 321 ftp_transaction_factory_.reset(
324 new FtpNetworkLayer(context->host_resolver())); 322 new FtpNetworkLayer(context->host_resolver()));
325 job_factory->SetProtocolHandler("ftp", 323 job_factory->SetProtocolHandler(
326 new FtpProtocolHandler(ftp_transaction_factory_.get())); 324 "ftp", new FtpProtocolHandler(ftp_transaction_factory_.get()));
327 } 325 }
328 #endif 326 #endif
329 storage->set_job_factory(job_factory); 327 storage->set_job_factory(job_factory);
330 328
331 // TODO(willchan): Support sdch. 329 // TODO(willchan): Support sdch.
332 330
333 return context; 331 return context;
334 } 332 }
335 333
336 } // namespace net 334 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698