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 #include <utility> | 8 #include <utility> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 21 matching lines...) Expand all Loading... |
32 #include "net/http/http_auth_handler_factory.h" | 32 #include "net/http/http_auth_handler_factory.h" |
33 #include "net/http/http_cache.h" | 33 #include "net/http/http_cache.h" |
34 #include "net/http/http_network_layer.h" | 34 #include "net/http/http_network_layer.h" |
35 #include "net/http/http_server_properties_impl.h" | 35 #include "net/http/http_server_properties_impl.h" |
36 #include "net/http/http_server_properties_manager.h" | 36 #include "net/http/http_server_properties_manager.h" |
37 #include "net/http/transport_security_persister.h" | 37 #include "net/http/transport_security_persister.h" |
38 #include "net/http/transport_security_state.h" | 38 #include "net/http/transport_security_state.h" |
39 #include "net/net_features.h" | 39 #include "net/net_features.h" |
40 #include "net/nqe/network_quality_estimator.h" | 40 #include "net/nqe/network_quality_estimator.h" |
41 #include "net/quic/chromium/quic_stream_factory.h" | 41 #include "net/quic/chromium/quic_stream_factory.h" |
| 42 #include "net/reporting/reporting_policy.h" |
| 43 #include "net/reporting/reporting_service.h" |
42 #include "net/ssl/channel_id_service.h" | 44 #include "net/ssl/channel_id_service.h" |
43 #include "net/ssl/default_channel_id_store.h" | 45 #include "net/ssl/default_channel_id_store.h" |
44 #include "net/ssl/ssl_config_service_defaults.h" | 46 #include "net/ssl/ssl_config_service_defaults.h" |
45 #include "net/url_request/data_protocol_handler.h" | 47 #include "net/url_request/data_protocol_handler.h" |
46 #include "net/url_request/static_http_user_agent_settings.h" | 48 #include "net/url_request/static_http_user_agent_settings.h" |
47 #include "net/url_request/url_request_context.h" | 49 #include "net/url_request/url_request_context.h" |
48 #include "net/url_request/url_request_context_storage.h" | 50 #include "net/url_request/url_request_context_storage.h" |
49 #include "net/url_request/url_request_intercepting_job_factory.h" | 51 #include "net/url_request/url_request_intercepting_job_factory.h" |
50 #include "net/url_request/url_request_interceptor.h" | 52 #include "net/url_request/url_request_interceptor.h" |
51 #include "net/url_request/url_request_job_factory_impl.h" | 53 #include "net/url_request/url_request_job_factory_impl.h" |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 // Define a context class that can self-manage the ownership of its components | 139 // Define a context class that can self-manage the ownership of its components |
138 // via a UrlRequestContextStorage object. Since it cancels requests in its | 140 // via a UrlRequestContextStorage object. Since it cancels requests in its |
139 // destructor, it's not safe to subclass this. | 141 // destructor, it's not safe to subclass this. |
140 class ContainerURLRequestContext final : public URLRequestContext { | 142 class ContainerURLRequestContext final : public URLRequestContext { |
141 public: | 143 public: |
142 explicit ContainerURLRequestContext( | 144 explicit ContainerURLRequestContext( |
143 const scoped_refptr<base::SingleThreadTaskRunner>& file_task_runner) | 145 const scoped_refptr<base::SingleThreadTaskRunner>& file_task_runner) |
144 : file_task_runner_(file_task_runner), storage_(this) {} | 146 : file_task_runner_(file_task_runner), storage_(this) {} |
145 | 147 |
146 ~ContainerURLRequestContext() override { | 148 ~ContainerURLRequestContext() override { |
| 149 // Destroy the ReportingService before the rest of the URLRequestContext, so |
| 150 // it cancels any pending requests it may have. |
| 151 storage_.set_reporting_service(nullptr); |
| 152 |
147 // Shut down the ProxyService, as it may have pending URLRequests using this | 153 // Shut down the ProxyService, as it may have pending URLRequests using this |
148 // context. Since this cancels requests, it's not safe to subclass this, as | 154 // context. Since this cancels requests, it's not safe to subclass this, as |
149 // some parts of the URLRequestContext may then be torn down before this | 155 // some parts of the URLRequestContext may then be torn down before this |
150 // cancels the ProxyService's URLRequests. | 156 // cancels the ProxyService's URLRequests. |
151 proxy_service()->OnShutdown(); | 157 proxy_service()->OnShutdown(); |
152 | 158 |
153 AssertNoURLRequests(); | 159 AssertNoURLRequests(); |
154 } | 160 } |
155 | 161 |
156 URLRequestContextStorage* storage() { | 162 URLRequestContextStorage* storage() { |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
261 void URLRequestContextBuilder::set_ct_verifier( | 267 void URLRequestContextBuilder::set_ct_verifier( |
262 std::unique_ptr<CTVerifier> ct_verifier) { | 268 std::unique_ptr<CTVerifier> ct_verifier) { |
263 ct_verifier_ = std::move(ct_verifier); | 269 ct_verifier_ = std::move(ct_verifier); |
264 } | 270 } |
265 | 271 |
266 void URLRequestContextBuilder::SetCertVerifier( | 272 void URLRequestContextBuilder::SetCertVerifier( |
267 std::unique_ptr<CertVerifier> cert_verifier) { | 273 std::unique_ptr<CertVerifier> cert_verifier) { |
268 cert_verifier_ = std::move(cert_verifier); | 274 cert_verifier_ = std::move(cert_verifier); |
269 } | 275 } |
270 | 276 |
| 277 void URLRequestContextBuilder::set_reporting_policy( |
| 278 std::unique_ptr<net::ReportingPolicy> reporting_policy) { |
| 279 reporting_policy_ = std::move(reporting_policy); |
| 280 } |
| 281 |
271 void URLRequestContextBuilder::SetInterceptors( | 282 void URLRequestContextBuilder::SetInterceptors( |
272 std::vector<std::unique_ptr<URLRequestInterceptor>> | 283 std::vector<std::unique_ptr<URLRequestInterceptor>> |
273 url_request_interceptors) { | 284 url_request_interceptors) { |
274 url_request_interceptors_ = std::move(url_request_interceptors); | 285 url_request_interceptors_ = std::move(url_request_interceptors); |
275 } | 286 } |
276 | 287 |
277 void URLRequestContextBuilder::SetCookieAndChannelIdStores( | 288 void URLRequestContextBuilder::SetCookieAndChannelIdStores( |
278 std::unique_ptr<CookieStore> cookie_store, | 289 std::unique_ptr<CookieStore> cookie_store, |
279 std::unique_ptr<ChannelIDService> channel_id_service) { | 290 std::unique_ptr<ChannelIDService> channel_id_service) { |
280 cookie_store_set_by_client_ = true; | 291 cookie_store_set_by_client_ = true; |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
489 // Set up interceptors in the reverse order. | 500 // Set up interceptors in the reverse order. |
490 | 501 |
491 for (auto i = url_request_interceptors_.rbegin(); | 502 for (auto i = url_request_interceptors_.rbegin(); |
492 i != url_request_interceptors_.rend(); ++i) { | 503 i != url_request_interceptors_.rend(); ++i) { |
493 top_job_factory.reset(new net::URLRequestInterceptingJobFactory( | 504 top_job_factory.reset(new net::URLRequestInterceptingJobFactory( |
494 std::move(top_job_factory), std::move(*i))); | 505 std::move(top_job_factory), std::move(*i))); |
495 } | 506 } |
496 url_request_interceptors_.clear(); | 507 url_request_interceptors_.clear(); |
497 } | 508 } |
498 storage->set_job_factory(std::move(top_job_factory)); | 509 storage->set_job_factory(std::move(top_job_factory)); |
499 // TODO(willchan): Support sdch. | 510 |
| 511 if (reporting_policy_) { |
| 512 storage->set_reporting_service( |
| 513 ReportingService::Create(*reporting_policy_, context.get())); |
| 514 } |
500 | 515 |
501 return std::move(context); | 516 return std::move(context); |
502 } | 517 } |
503 | 518 |
504 std::unique_ptr<ProxyService> URLRequestContextBuilder::CreateProxyService( | 519 std::unique_ptr<ProxyService> URLRequestContextBuilder::CreateProxyService( |
505 std::unique_ptr<ProxyConfigService> proxy_config_service, | 520 std::unique_ptr<ProxyConfigService> proxy_config_service, |
506 URLRequestContext* url_request_context, | 521 URLRequestContext* url_request_context, |
507 HostResolver* host_resolver, | 522 HostResolver* host_resolver, |
508 NetworkDelegate* network_delegate, | 523 NetworkDelegate* network_delegate, |
509 NetLog* net_log) { | 524 NetLog* net_log) { |
510 return ProxyService::CreateUsingSystemProxyResolver( | 525 return ProxyService::CreateUsingSystemProxyResolver( |
511 std::move(proxy_config_service), net_log); | 526 std::move(proxy_config_service), net_log); |
512 } | 527 } |
513 | 528 |
514 } // namespace net | 529 } // namespace net |
OLD | NEW |