Chromium Code Reviews| Index: net/url_request/url_request_context_builder.cc |
| diff --git a/net/url_request/url_request_context_builder.cc b/net/url_request/url_request_context_builder.cc |
| index fafc21115fd02c357486b0bd28c11538296c922e..8f4cd3e0efce9cddd1e4fe017793d5beb4f633dd 100644 |
| --- a/net/url_request/url_request_context_builder.cc |
| +++ b/net/url_request/url_request_context_builder.cc |
| @@ -26,6 +26,7 @@ |
| #include "net/http/http_network_layer.h" |
| #include "net/http/http_network_session.h" |
| #include "net/http/http_server_properties_impl.h" |
| +#include "net/http/http_server_properties_manager.h" |
| #include "net/http/transport_security_persister.h" |
| #include "net/http/transport_security_state.h" |
| #include "net/ssl/channel_id_service.h" |
| @@ -156,8 +157,20 @@ class BasicURLRequestContext : public URLRequestContext { |
| transport_security_persister = transport_security_persister.Pass(); |
| } |
| + void set_http_server_properties_manager( |
| + scoped_ptr<HttpServerPropertiesManager> http_server_properties_manager) { |
| + http_server_properties_manager_ = http_server_properties_manager.Pass(); |
| + set_http_server_properties(http_server_properties_manager_->GetWeakPtr()); |
| + } |
| + |
| protected: |
| - ~BasicURLRequestContext() override { AssertNoURLRequests(); } |
| + ~BasicURLRequestContext() override { |
| + AssertNoURLRequests(); |
| + // Assuming simple embedders like Cronet uses the network thread as the pref |
| + // thread, shut down the |http_server_properties_manager_| if one is set. |
|
pauljensen
2015/07/01 18:42:22
I don't really like referring to a particular embe
xunjieli
2015/07/06 14:58:02
Done.
|
| + if (http_server_properties_manager_) |
| + http_server_properties_manager_->ShutdownOnPrefThread(); |
| + } |
| private: |
| // The thread should be torn down last. |
| @@ -166,6 +179,7 @@ class BasicURLRequestContext : public URLRequestContext { |
| URLRequestContextStorage storage_; |
| scoped_ptr<TransportSecurityPersister> transport_security_persister_; |
| + scoped_ptr<HttpServerPropertiesManager> http_server_properties_manager_; |
| DISALLOW_COPY_AND_ASSIGN(BasicURLRequestContext); |
| }; |
| @@ -249,6 +263,11 @@ void URLRequestContextBuilder::SetFileTaskRunner( |
| file_task_runner_ = task_runner; |
| } |
| +void URLRequestContextBuilder::SetHttpServerPropertiesManager( |
| + scoped_ptr<HttpServerPropertiesManager> http_server_properties_manager) { |
| + http_server_properties_manager_ = http_server_properties_manager.Pass(); |
| +} |
| + |
| URLRequestContext* URLRequestContextBuilder::Build() { |
| BasicURLRequestContext* context = |
| new BasicURLRequestContext(file_task_runner_); |
| @@ -332,8 +351,14 @@ URLRequestContext* URLRequestContextBuilder::Build() { |
| false))); |
| } |
| - storage->set_http_server_properties( |
| - scoped_ptr<HttpServerProperties>(new HttpServerPropertiesImpl())); |
| + if (http_server_properties_manager_) { |
| + context->set_http_server_properties_manager( |
| + http_server_properties_manager_.Pass()); |
| + } else { |
| + storage->set_http_server_properties( |
| + scoped_ptr<HttpServerProperties>(new HttpServerPropertiesImpl())); |
| + } |
| + |
| storage->set_cert_verifier(CertVerifier::CreateDefault()); |
| if (throttling_enabled_) |