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 20 matching lines...) Expand all Loading... |
31 #include "net/http/http_auth_handler_factory.h" | 31 #include "net/http/http_auth_handler_factory.h" |
32 #include "net/http/http_cache.h" | 32 #include "net/http/http_cache.h" |
33 #include "net/http/http_network_layer.h" | 33 #include "net/http/http_network_layer.h" |
34 #include "net/http/http_server_properties_impl.h" | 34 #include "net/http/http_server_properties_impl.h" |
35 #include "net/http/http_server_properties_manager.h" | 35 #include "net/http/http_server_properties_manager.h" |
36 #include "net/http/transport_security_persister.h" | 36 #include "net/http/transport_security_persister.h" |
37 #include "net/http/transport_security_state.h" | 37 #include "net/http/transport_security_state.h" |
38 #include "net/net_features.h" | 38 #include "net/net_features.h" |
39 #include "net/nqe/network_quality_estimator.h" | 39 #include "net/nqe/network_quality_estimator.h" |
40 #include "net/quic/chromium/quic_stream_factory.h" | 40 #include "net/quic/chromium/quic_stream_factory.h" |
41 #include "net/reporting/reporting_policy.h" | |
42 #include "net/reporting/reporting_service.h" | |
43 #include "net/ssl/channel_id_service.h" | 41 #include "net/ssl/channel_id_service.h" |
44 #include "net/ssl/default_channel_id_store.h" | 42 #include "net/ssl/default_channel_id_store.h" |
45 #include "net/ssl/ssl_config_service_defaults.h" | 43 #include "net/ssl/ssl_config_service_defaults.h" |
46 #include "net/url_request/data_protocol_handler.h" | 44 #include "net/url_request/data_protocol_handler.h" |
47 #include "net/url_request/static_http_user_agent_settings.h" | 45 #include "net/url_request/static_http_user_agent_settings.h" |
48 #include "net/url_request/url_request_context.h" | 46 #include "net/url_request/url_request_context.h" |
49 #include "net/url_request/url_request_context_storage.h" | 47 #include "net/url_request/url_request_context_storage.h" |
50 #include "net/url_request/url_request_intercepting_job_factory.h" | 48 #include "net/url_request/url_request_intercepting_job_factory.h" |
51 #include "net/url_request/url_request_interceptor.h" | 49 #include "net/url_request/url_request_interceptor.h" |
52 #include "net/url_request/url_request_job_factory_impl.h" | 50 #include "net/url_request/url_request_job_factory_impl.h" |
53 #include "net/url_request/url_request_throttler_manager.h" | 51 #include "net/url_request/url_request_throttler_manager.h" |
54 #include "url/url_constants.h" | 52 #include "url/url_constants.h" |
55 | 53 |
56 #if !BUILDFLAG(DISABLE_FILE_SUPPORT) | 54 #if !BUILDFLAG(DISABLE_FILE_SUPPORT) |
57 #include "net/url_request/file_protocol_handler.h" // nogncheck | 55 #include "net/url_request/file_protocol_handler.h" // nogncheck |
58 #endif | 56 #endif |
59 | 57 |
60 #if !BUILDFLAG(DISABLE_FTP_SUPPORT) | 58 #if !BUILDFLAG(DISABLE_FTP_SUPPORT) |
61 #include "net/ftp/ftp_network_layer.h" // nogncheck | 59 #include "net/ftp/ftp_network_layer.h" // nogncheck |
62 #include "net/url_request/ftp_protocol_handler.h" // nogncheck | 60 #include "net/url_request/ftp_protocol_handler.h" // nogncheck |
63 #endif | 61 #endif |
64 | 62 |
| 63 #if BUILDFLAG(ENABLE_REPORTING) |
| 64 #include "net/reporting/reporting_policy.h" |
| 65 #include "net/reporting/reporting_service.h" |
| 66 #endif // BUILDFLAG(ENABLE_REPORTING) |
| 67 |
65 namespace net { | 68 namespace net { |
66 | 69 |
67 namespace { | 70 namespace { |
68 | 71 |
69 class BasicNetworkDelegate : public NetworkDelegateImpl { | 72 class BasicNetworkDelegate : public NetworkDelegateImpl { |
70 public: | 73 public: |
71 BasicNetworkDelegate() {} | 74 BasicNetworkDelegate() {} |
72 ~BasicNetworkDelegate() override {} | 75 ~BasicNetworkDelegate() override {} |
73 | 76 |
74 private: | 77 private: |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 // A URLRequestContext subclass that owns most of its components | 142 // A URLRequestContext subclass that owns most of its components |
140 // via a UrlRequestContextStorage object. When URLRequestContextBuilder::Build() | 143 // via a UrlRequestContextStorage object. When URLRequestContextBuilder::Build() |
141 // is called, ownership of all URLRequestContext components is passed to the | 144 // is called, ownership of all URLRequestContext components is passed to the |
142 // ContainerURLRequestContext. Since this cancels requests in its destructor, | 145 // ContainerURLRequestContext. Since this cancels requests in its destructor, |
143 // it's not safe to subclass this. | 146 // it's not safe to subclass this. |
144 class ContainerURLRequestContext final : public URLRequestContext { | 147 class ContainerURLRequestContext final : public URLRequestContext { |
145 public: | 148 public: |
146 ContainerURLRequestContext() : storage_(this) {} | 149 ContainerURLRequestContext() : storage_(this) {} |
147 | 150 |
148 ~ContainerURLRequestContext() override { | 151 ~ContainerURLRequestContext() override { |
| 152 #if BUILDFLAG(ENABLE_REPORTING) |
149 // Destroy the ReportingService before the rest of the URLRequestContext, so | 153 // Destroy the ReportingService before the rest of the URLRequestContext, so |
150 // it cancels any pending requests it may have. | 154 // it cancels any pending requests it may have. |
151 storage_.set_reporting_service(nullptr); | 155 storage_.set_reporting_service(nullptr); |
| 156 #endif // BUILDFLAG(ENABLE_REPORTING) |
152 | 157 |
153 // Shut down the ProxyService, as it may have pending URLRequests using this | 158 // Shut down the ProxyService, as it may have pending URLRequests using this |
154 // context. Since this cancels requests, it's not safe to subclass this, as | 159 // context. Since this cancels requests, it's not safe to subclass this, as |
155 // some parts of the URLRequestContext may then be torn down before this | 160 // some parts of the URLRequestContext may then be torn down before this |
156 // cancels the ProxyService's URLRequests. | 161 // cancels the ProxyService's URLRequests. |
157 proxy_service()->OnShutdown(); | 162 proxy_service()->OnShutdown(); |
158 | 163 |
159 AssertNoURLRequests(); | 164 AssertNoURLRequests(); |
160 } | 165 } |
161 | 166 |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
251 void URLRequestContextBuilder::set_ct_verifier( | 256 void URLRequestContextBuilder::set_ct_verifier( |
252 std::unique_ptr<CTVerifier> ct_verifier) { | 257 std::unique_ptr<CTVerifier> ct_verifier) { |
253 ct_verifier_ = std::move(ct_verifier); | 258 ct_verifier_ = std::move(ct_verifier); |
254 } | 259 } |
255 | 260 |
256 void URLRequestContextBuilder::SetCertVerifier( | 261 void URLRequestContextBuilder::SetCertVerifier( |
257 std::unique_ptr<CertVerifier> cert_verifier) { | 262 std::unique_ptr<CertVerifier> cert_verifier) { |
258 cert_verifier_ = std::move(cert_verifier); | 263 cert_verifier_ = std::move(cert_verifier); |
259 } | 264 } |
260 | 265 |
| 266 #if BUILDFLAG(ENABLE_REPORTING) |
261 void URLRequestContextBuilder::set_reporting_policy( | 267 void URLRequestContextBuilder::set_reporting_policy( |
262 std::unique_ptr<net::ReportingPolicy> reporting_policy) { | 268 std::unique_ptr<net::ReportingPolicy> reporting_policy) { |
263 reporting_policy_ = std::move(reporting_policy); | 269 reporting_policy_ = std::move(reporting_policy); |
264 } | 270 } |
| 271 #endif // BUILDFLAG(ENABLE_REPORTING) |
265 | 272 |
266 void URLRequestContextBuilder::SetInterceptors( | 273 void URLRequestContextBuilder::SetInterceptors( |
267 std::vector<std::unique_ptr<URLRequestInterceptor>> | 274 std::vector<std::unique_ptr<URLRequestInterceptor>> |
268 url_request_interceptors) { | 275 url_request_interceptors) { |
269 url_request_interceptors_ = std::move(url_request_interceptors); | 276 url_request_interceptors_ = std::move(url_request_interceptors); |
270 } | 277 } |
271 | 278 |
272 void URLRequestContextBuilder::SetCookieAndChannelIdStores( | 279 void URLRequestContextBuilder::SetCookieAndChannelIdStores( |
273 std::unique_ptr<CookieStore> cookie_store, | 280 std::unique_ptr<CookieStore> cookie_store, |
274 std::unique_ptr<ChannelIDService> channel_id_service) { | 281 std::unique_ptr<ChannelIDService> channel_id_service) { |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
502 | 509 |
503 for (auto i = url_request_interceptors_.rbegin(); | 510 for (auto i = url_request_interceptors_.rbegin(); |
504 i != url_request_interceptors_.rend(); ++i) { | 511 i != url_request_interceptors_.rend(); ++i) { |
505 top_job_factory.reset(new net::URLRequestInterceptingJobFactory( | 512 top_job_factory.reset(new net::URLRequestInterceptingJobFactory( |
506 std::move(top_job_factory), std::move(*i))); | 513 std::move(top_job_factory), std::move(*i))); |
507 } | 514 } |
508 url_request_interceptors_.clear(); | 515 url_request_interceptors_.clear(); |
509 } | 516 } |
510 storage->set_job_factory(std::move(top_job_factory)); | 517 storage->set_job_factory(std::move(top_job_factory)); |
511 | 518 |
| 519 #if BUILDFLAG(ENABLE_REPORTING) |
512 if (reporting_policy_) { | 520 if (reporting_policy_) { |
513 storage->set_reporting_service( | 521 storage->set_reporting_service( |
514 ReportingService::Create(*reporting_policy_, context.get())); | 522 ReportingService::Create(*reporting_policy_, context.get())); |
515 } | 523 } |
| 524 #endif // BUILDFLAG(ENABLE_REPORTING) |
516 | 525 |
517 return std::move(context); | 526 return std::move(context); |
518 } | 527 } |
519 | 528 |
520 std::unique_ptr<ProxyService> URLRequestContextBuilder::CreateProxyService( | 529 std::unique_ptr<ProxyService> URLRequestContextBuilder::CreateProxyService( |
521 std::unique_ptr<ProxyConfigService> proxy_config_service, | 530 std::unique_ptr<ProxyConfigService> proxy_config_service, |
522 URLRequestContext* url_request_context, | 531 URLRequestContext* url_request_context, |
523 HostResolver* host_resolver, | 532 HostResolver* host_resolver, |
524 NetworkDelegate* network_delegate, | 533 NetworkDelegate* network_delegate, |
525 NetLog* net_log) { | 534 NetLog* net_log) { |
(...skipping 18 matching lines...) Expand all Loading... |
544 | 553 |
545 scoped_refptr<base::SingleThreadTaskRunner> | 554 scoped_refptr<base::SingleThreadTaskRunner> |
546 URLRequestContextBuilder::GetFileSingleThreadTaskRunner( | 555 URLRequestContextBuilder::GetFileSingleThreadTaskRunner( |
547 const base::TaskTraits& traits) { | 556 const base::TaskTraits& traits) { |
548 if (file_task_runner_) | 557 if (file_task_runner_) |
549 return file_task_runner_; | 558 return file_task_runner_; |
550 return base::CreateSingleThreadTaskRunnerWithTraits(traits); | 559 return base::CreateSingleThreadTaskRunnerWithTraits(traits); |
551 } | 560 } |
552 | 561 |
553 } // namespace net | 562 } // namespace net |
OLD | NEW |