Skip to content

Commit

Permalink
[Chromecast] Initialize QuicContext in URLRequestContextFactory
Browse files Browse the repository at this point in the history
QuicContext needs to be provided for every URLRequestContext. Otherwise,
a crash occurs.

Bug: internal b/144527786
Test: CQ
Change-Id: Ideac2eeefe6b12450906a47b711ebd9afda90e31
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1923032
Reviewed-by: Yuchen Liu <yucliu@chromium.org>
Commit-Queue: Sean Topping <seantopping@chromium.org>
Cr-Commit-Position: refs/heads/master@{#716412}
  • Loading branch information
Sean Topping authored and Commit Bot committed Nov 19, 2019
1 parent 2aab1d0 commit 7e9567e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
5 changes: 5 additions & 0 deletions chromecast/browser/url_request_context_factory.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
#include "net/http/http_server_properties.h"
#include "net/http/http_stream_factory.h"
#include "net/proxy_resolution/proxy_resolution_service.h"
#include "net/quic/quic_context.h"
#include "net/ssl/ssl_config_service_defaults.h"
#include "net/url_request/url_request_context.h"
#include "net/url_request/url_request_context_builder.h"
Expand Down Expand Up @@ -232,6 +233,8 @@ void URLRequestContextFactory::InitializeSystemContextDependencies() {
system_host_resolver_ =
net::HostResolver::CreateResolver(host_resolver_manager_.get());

quic_context_ = std::make_unique<net::QuicContext>();

system_dependencies_initialized_ = true;
}

Expand Down Expand Up @@ -344,6 +347,7 @@ net::URLRequestContext* URLRequestContextFactory::CreateMediaRequestContext() {
DCHECK(main_getter_.get())
<< "Getting MediaRequestContext before MainRequestContext";

InitializeSystemContextDependencies();
InitializeMediaContextDependencies();

// Reuse main context dependencies except HostResolver and
Expand Down Expand Up @@ -403,6 +407,7 @@ void URLRequestContextFactory::ConfigureURLRequestContext(
context->set_http_server_properties(http_server_properties_.get());
context->set_http_user_agent_settings(http_user_agent_settings_.get());
context->set_net_log(net_log_);
context->set_quic_context(quic_context_.get());

// settings from the caller
context->set_job_factory(job_factory.get());
Expand Down
2 changes: 2 additions & 0 deletions chromecast/browser/url_request_context_factory.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class HttpTransactionFactory;
class HttpUserAgentSettings;
class NetLog;
class ProxyConfigService;
class QuicContext;
class URLRequestContextGetter;
class URLRequestJobFactory;
} // namespace net
Expand Down Expand Up @@ -130,6 +131,7 @@ class URLRequestContextFactory {
std::unique_ptr<net::CookieStore> system_cookie_store_;
std::unique_ptr<net::URLRequestJobFactory> system_job_factory_;
std::unique_ptr<net::HostResolver> system_host_resolver_;
std::unique_ptr<net::QuicContext> quic_context_;

bool main_dependencies_initialized_;
std::unique_ptr<net::HttpNetworkSession> main_network_session_;
Expand Down

0 comments on commit 7e9567e

Please sign in to comment.