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" | |
44 #include "net/ssl/channel_id_service.h" | 42 #include "net/ssl/channel_id_service.h" |
45 #include "net/ssl/default_channel_id_store.h" | 43 #include "net/ssl/default_channel_id_store.h" |
46 #include "net/ssl/ssl_config_service_defaults.h" | 44 #include "net/ssl/ssl_config_service_defaults.h" |
47 #include "net/url_request/data_protocol_handler.h" | 45 #include "net/url_request/data_protocol_handler.h" |
48 #include "net/url_request/static_http_user_agent_settings.h" | 46 #include "net/url_request/static_http_user_agent_settings.h" |
49 #include "net/url_request/url_request_context.h" | 47 #include "net/url_request/url_request_context.h" |
50 #include "net/url_request/url_request_context_storage.h" | 48 #include "net/url_request/url_request_context_storage.h" |
51 #include "net/url_request/url_request_intercepting_job_factory.h" | 49 #include "net/url_request/url_request_intercepting_job_factory.h" |
52 #include "net/url_request/url_request_interceptor.h" | 50 #include "net/url_request/url_request_interceptor.h" |
53 #include "net/url_request/url_request_job_factory_impl.h" | 51 #include "net/url_request/url_request_job_factory_impl.h" |
54 #include "net/url_request/url_request_throttler_manager.h" | 52 #include "net/url_request/url_request_throttler_manager.h" |
55 #include "url/url_constants.h" | 53 #include "url/url_constants.h" |
56 | 54 |
57 #if !BUILDFLAG(DISABLE_FILE_SUPPORT) | 55 #if !BUILDFLAG(DISABLE_FILE_SUPPORT) |
58 #include "net/url_request/file_protocol_handler.h" // nogncheck | 56 #include "net/url_request/file_protocol_handler.h" // nogncheck |
59 #endif | 57 #endif |
60 | 58 |
61 #if !BUILDFLAG(DISABLE_FTP_SUPPORT) | 59 #if !BUILDFLAG(DISABLE_FTP_SUPPORT) |
62 #include "net/ftp/ftp_network_layer.h" // nogncheck | 60 #include "net/ftp/ftp_network_layer.h" // nogncheck |
63 #include "net/url_request/ftp_protocol_handler.h" // nogncheck | 61 #include "net/url_request/ftp_protocol_handler.h" // nogncheck |
64 #endif | 62 #endif |
65 | 63 |
| 64 #if BUILDFLAG(ENABLE_REPORTING) |
| 65 #include "net/reporting/reporting_policy.h" |
| 66 #include "net/reporting/reporting_service.h" |
| 67 #endif // BUILDFLAG(ENABLE_REPORTING) |
| 68 |
66 namespace net { | 69 namespace net { |
67 | 70 |
68 namespace { | 71 namespace { |
69 | 72 |
70 class BasicNetworkDelegate : public NetworkDelegateImpl { | 73 class BasicNetworkDelegate : public NetworkDelegateImpl { |
71 public: | 74 public: |
72 BasicNetworkDelegate() {} | 75 BasicNetworkDelegate() {} |
73 ~BasicNetworkDelegate() override {} | 76 ~BasicNetworkDelegate() override {} |
74 | 77 |
75 private: | 78 private: |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 // is called, ownership of all URLRequestContext components is passed to the | 145 // is called, ownership of all URLRequestContext components is passed to the |
143 // ContainerURLRequestContext. Since this cancels requests in its destructor, | 146 // ContainerURLRequestContext. Since this cancels requests in its destructor, |
144 // it's not safe to subclass this. | 147 // it's not safe to subclass this. |
145 class ContainerURLRequestContext final : public URLRequestContext { | 148 class ContainerURLRequestContext final : public URLRequestContext { |
146 public: | 149 public: |
147 explicit ContainerURLRequestContext( | 150 explicit ContainerURLRequestContext( |
148 const scoped_refptr<base::SingleThreadTaskRunner>& file_task_runner) | 151 const scoped_refptr<base::SingleThreadTaskRunner>& file_task_runner) |
149 : file_task_runner_(file_task_runner), storage_(this) {} | 152 : file_task_runner_(file_task_runner), storage_(this) {} |
150 | 153 |
151 ~ContainerURLRequestContext() override { | 154 ~ContainerURLRequestContext() override { |
| 155 #if BUILDFLAG(ENABLE_REPORTING) |
152 // Destroy the ReportingService before the rest of the URLRequestContext, so | 156 // Destroy the ReportingService before the rest of the URLRequestContext, so |
153 // it cancels any pending requests it may have. | 157 // it cancels any pending requests it may have. |
154 storage_.set_reporting_service(nullptr); | 158 storage_.set_reporting_service(nullptr); |
| 159 #endif // BUILDFLAG(ENABLE_REPORTING) |
155 | 160 |
156 // Shut down the ProxyService, as it may have pending URLRequests using this | 161 // Shut down the ProxyService, as it may have pending URLRequests using this |
157 // context. Since this cancels requests, it's not safe to subclass this, as | 162 // context. Since this cancels requests, it's not safe to subclass this, as |
158 // some parts of the URLRequestContext may then be torn down before this | 163 // some parts of the URLRequestContext may then be torn down before this |
159 // cancels the ProxyService's URLRequests. | 164 // cancels the ProxyService's URLRequests. |
160 proxy_service()->OnShutdown(); | 165 proxy_service()->OnShutdown(); |
161 | 166 |
162 AssertNoURLRequests(); | 167 AssertNoURLRequests(); |
163 } | 168 } |
164 | 169 |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
270 void URLRequestContextBuilder::set_ct_verifier( | 275 void URLRequestContextBuilder::set_ct_verifier( |
271 std::unique_ptr<CTVerifier> ct_verifier) { | 276 std::unique_ptr<CTVerifier> ct_verifier) { |
272 ct_verifier_ = std::move(ct_verifier); | 277 ct_verifier_ = std::move(ct_verifier); |
273 } | 278 } |
274 | 279 |
275 void URLRequestContextBuilder::SetCertVerifier( | 280 void URLRequestContextBuilder::SetCertVerifier( |
276 std::unique_ptr<CertVerifier> cert_verifier) { | 281 std::unique_ptr<CertVerifier> cert_verifier) { |
277 cert_verifier_ = std::move(cert_verifier); | 282 cert_verifier_ = std::move(cert_verifier); |
278 } | 283 } |
279 | 284 |
| 285 #if BUILDFLAG(ENABLE_REPORTING) |
280 void URLRequestContextBuilder::set_reporting_policy( | 286 void URLRequestContextBuilder::set_reporting_policy( |
281 std::unique_ptr<net::ReportingPolicy> reporting_policy) { | 287 std::unique_ptr<net::ReportingPolicy> reporting_policy) { |
282 reporting_policy_ = std::move(reporting_policy); | 288 reporting_policy_ = std::move(reporting_policy); |
283 } | 289 } |
| 290 #endif // BUILDFLAG(ENABLE_REPORTING) |
284 | 291 |
285 void URLRequestContextBuilder::SetInterceptors( | 292 void URLRequestContextBuilder::SetInterceptors( |
286 std::vector<std::unique_ptr<URLRequestInterceptor>> | 293 std::vector<std::unique_ptr<URLRequestInterceptor>> |
287 url_request_interceptors) { | 294 url_request_interceptors) { |
288 url_request_interceptors_ = std::move(url_request_interceptors); | 295 url_request_interceptors_ = std::move(url_request_interceptors); |
289 } | 296 } |
290 | 297 |
291 void URLRequestContextBuilder::SetCookieAndChannelIdStores( | 298 void URLRequestContextBuilder::SetCookieAndChannelIdStores( |
292 std::unique_ptr<CookieStore> cookie_store, | 299 std::unique_ptr<CookieStore> cookie_store, |
293 std::unique_ptr<ChannelIDService> channel_id_service) { | 300 std::unique_ptr<ChannelIDService> channel_id_service) { |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
509 | 516 |
510 for (auto i = url_request_interceptors_.rbegin(); | 517 for (auto i = url_request_interceptors_.rbegin(); |
511 i != url_request_interceptors_.rend(); ++i) { | 518 i != url_request_interceptors_.rend(); ++i) { |
512 top_job_factory.reset(new net::URLRequestInterceptingJobFactory( | 519 top_job_factory.reset(new net::URLRequestInterceptingJobFactory( |
513 std::move(top_job_factory), std::move(*i))); | 520 std::move(top_job_factory), std::move(*i))); |
514 } | 521 } |
515 url_request_interceptors_.clear(); | 522 url_request_interceptors_.clear(); |
516 } | 523 } |
517 storage->set_job_factory(std::move(top_job_factory)); | 524 storage->set_job_factory(std::move(top_job_factory)); |
518 | 525 |
| 526 #if BUILDFLAG(ENABLE_REPORTING) |
519 if (reporting_policy_) { | 527 if (reporting_policy_) { |
520 storage->set_reporting_service( | 528 storage->set_reporting_service( |
521 ReportingService::Create(*reporting_policy_, context.get())); | 529 ReportingService::Create(*reporting_policy_, context.get())); |
522 } | 530 } |
| 531 #endif // BUILDFLAG(ENABLE_REPORTING) |
523 | 532 |
524 return std::move(context); | 533 return std::move(context); |
525 } | 534 } |
526 | 535 |
527 std::unique_ptr<ProxyService> URLRequestContextBuilder::CreateProxyService( | 536 std::unique_ptr<ProxyService> URLRequestContextBuilder::CreateProxyService( |
528 std::unique_ptr<ProxyConfigService> proxy_config_service, | 537 std::unique_ptr<ProxyConfigService> proxy_config_service, |
529 URLRequestContext* url_request_context, | 538 URLRequestContext* url_request_context, |
530 HostResolver* host_resolver, | 539 HostResolver* host_resolver, |
531 NetworkDelegate* network_delegate, | 540 NetworkDelegate* network_delegate, |
532 NetLog* net_log) { | 541 NetLog* net_log) { |
533 return ProxyService::CreateUsingSystemProxyResolver( | 542 return ProxyService::CreateUsingSystemProxyResolver( |
534 std::move(proxy_config_service), net_log); | 543 std::move(proxy_config_service), net_log); |
535 } | 544 } |
536 | 545 |
537 } // namespace net | 546 } // namespace net |
OLD | NEW |