OLD | NEW |
---|---|
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 15 matching lines...) Expand all Loading... | |
26 #include "net/http/http_server_properties_impl.h" | 26 #include "net/http/http_server_properties_impl.h" |
27 #include "net/http/transport_security_persister.h" | 27 #include "net/http/transport_security_persister.h" |
28 #include "net/http/transport_security_state.h" | 28 #include "net/http/transport_security_state.h" |
29 #include "net/ssl/channel_id_service.h" | 29 #include "net/ssl/channel_id_service.h" |
30 #include "net/ssl/default_channel_id_store.h" | 30 #include "net/ssl/default_channel_id_store.h" |
31 #include "net/ssl/ssl_config_service_defaults.h" | 31 #include "net/ssl/ssl_config_service_defaults.h" |
32 #include "net/url_request/data_protocol_handler.h" | 32 #include "net/url_request/data_protocol_handler.h" |
33 #include "net/url_request/static_http_user_agent_settings.h" | 33 #include "net/url_request/static_http_user_agent_settings.h" |
34 #include "net/url_request/url_request_context.h" | 34 #include "net/url_request/url_request_context.h" |
35 #include "net/url_request/url_request_context_storage.h" | 35 #include "net/url_request/url_request_context_storage.h" |
36 #include "net/url_request/url_request_intercepting_job_factory.h" | |
37 #include "net/url_request/url_request_interceptor.h" | |
36 #include "net/url_request/url_request_job_factory_impl.h" | 38 #include "net/url_request/url_request_job_factory_impl.h" |
37 #include "net/url_request/url_request_throttler_manager.h" | 39 #include "net/url_request/url_request_throttler_manager.h" |
38 | 40 |
39 #if !defined(DISABLE_FILE_SUPPORT) | 41 #if !defined(DISABLE_FILE_SUPPORT) |
40 #include "net/url_request/file_protocol_handler.h" | 42 #include "net/url_request/file_protocol_handler.h" |
41 #endif | 43 #endif |
42 | 44 |
43 #if !defined(DISABLE_FTP_SUPPORT) | 45 #if !defined(DISABLE_FTP_SUPPORT) |
44 #include "net/url_request/ftp_protocol_handler.h" | 46 #include "net/url_request/ftp_protocol_handler.h" |
45 #endif | 47 #endif |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
224 http_cache_params_ = HttpCacheParams(); | 226 http_cache_params_ = HttpCacheParams(); |
225 } | 227 } |
226 | 228 |
227 void URLRequestContextBuilder::SetSpdyAndQuicEnabled(bool spdy_enabled, | 229 void URLRequestContextBuilder::SetSpdyAndQuicEnabled(bool spdy_enabled, |
228 bool quic_enabled) { | 230 bool quic_enabled) { |
229 http_network_session_params_.next_protos = | 231 http_network_session_params_.next_protos = |
230 NextProtosWithSpdyAndQuic(spdy_enabled, quic_enabled); | 232 NextProtosWithSpdyAndQuic(spdy_enabled, quic_enabled); |
231 http_network_session_params_.enable_quic = quic_enabled; | 233 http_network_session_params_.enable_quic = quic_enabled; |
232 } | 234 } |
233 | 235 |
236 void URLRequestContextBuilder::SetInterceptors( | |
237 URLRequestInterceptors url_request_interceptors) { | |
238 url_request_interceptors_ = url_request_interceptors.Pass(); | |
239 } | |
240 | |
234 void URLRequestContextBuilder::SetCookieAndChannelIdStores( | 241 void URLRequestContextBuilder::SetCookieAndChannelIdStores( |
235 const scoped_refptr<CookieStore>& cookie_store, | 242 const scoped_refptr<CookieStore>& cookie_store, |
236 scoped_ptr<ChannelIDService> channel_id_service) { | 243 scoped_ptr<ChannelIDService> channel_id_service) { |
237 DCHECK(cookie_store); | 244 DCHECK(cookie_store); |
238 cookie_store_ = cookie_store; | 245 cookie_store_ = cookie_store; |
239 channel_id_service_ = channel_id_service.Pass(); | 246 channel_id_service_ = channel_id_service.Pass(); |
240 } | 247 } |
241 | 248 |
242 URLRequestContext* URLRequestContextBuilder::Build() { | 249 URLRequestContext* URLRequestContextBuilder::Build() { |
243 BasicURLRequestContext* context = new BasicURLRequestContext; | 250 BasicURLRequestContext* context = new BasicURLRequestContext; |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
402 | 409 |
403 #if !defined(DISABLE_FTP_SUPPORT) | 410 #if !defined(DISABLE_FTP_SUPPORT) |
404 if (ftp_enabled_) { | 411 if (ftp_enabled_) { |
405 ftp_transaction_factory_.reset( | 412 ftp_transaction_factory_.reset( |
406 new FtpNetworkLayer(context->host_resolver())); | 413 new FtpNetworkLayer(context->host_resolver())); |
407 job_factory->SetProtocolHandler("ftp", | 414 job_factory->SetProtocolHandler("ftp", |
408 new FtpProtocolHandler(ftp_transaction_factory_.get())); | 415 new FtpProtocolHandler(ftp_transaction_factory_.get())); |
409 } | 416 } |
410 #endif // !defined(DISABLE_FTP_SUPPORT) | 417 #endif // !defined(DISABLE_FTP_SUPPORT) |
411 | 418 |
412 storage->set_job_factory(job_factory); | 419 if (!url_request_interceptors_.empty()) { |
413 | 420 // Set up interceptors in the reverse order. |
421 scoped_ptr<net::URLRequestJobFactory> top_job_factory = | |
422 make_scoped_ptr(job_factory); | |
mmenke
2015/03/13 18:16:48
make_scoped_ptr not needed.
bengr
2015/03/19 01:03:51
Done.
| |
423 for (URLRequestInterceptors::reverse_iterator i = | |
424 url_request_interceptors_.rbegin(); | |
425 i != url_request_interceptors_.rend(); ++i) { | |
426 top_job_factory.reset(new net::URLRequestInterceptingJobFactory( | |
427 top_job_factory.Pass(), make_scoped_ptr(*i))); | |
428 } | |
429 url_request_interceptors_.weak_clear(); | |
430 storage->set_job_factory(top_job_factory.release()); | |
431 } else { | |
432 storage->set_job_factory(job_factory); | |
433 } | |
mmenke
2015/03/13 18:16:48
optional: Think this would be a little simpler wi
bengr
2015/03/19 01:03:51
Done.
| |
414 // TODO(willchan): Support sdch. | 434 // TODO(willchan): Support sdch. |
415 | 435 |
416 return context; | 436 return context; |
417 } | 437 } |
418 | 438 |
419 } // namespace net | 439 } // namespace net |
OLD | NEW |