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..e55fd6f7d2cc04643ff51898bf76283eac979ee5 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,23 @@ class BasicURLRequestContext : public URLRequestContext { |
transport_security_persister = transport_security_persister.Pass(); |
} |
+ // Sets a HttpServerPropertiesManager. Note that the manager must be |
+ // initialized prior to this call. |
+ 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(); |
+ // Shut down the |http_server_properties_manager_| if there is one, since |
+ // this is the only place in BasicURLRequestContext to do so. |
+ // Note that the shutdown is performed on the network thread. |
+ if (http_server_properties_manager_) |
+ http_server_properties_manager_->ShutdownOnPrefThread(); |
+ } |
private: |
// The thread should be torn down last. |
@@ -166,6 +182,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 +266,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 +354,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_) |