Handle nullptr in RequestConextGetter

This commit is contained in:
Cheng Zhao 2016-03-10 14:39:07 +09:00
parent f70ece1669
commit 5ce6592e1c

View file

@ -200,6 +200,7 @@ URLRequestContextGetter::URLRequestContextGetter(
// Must first be created on the UI thread.
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
if (protocol_handlers)
std::swap(protocol_handlers_, *protocol_handlers);
// We must create the proxy config service on the UI loop on Linux because it
@ -231,8 +232,10 @@ net::URLRequestContext* URLRequestContextGetter::GetURLRequestContext() {
#endif
// --log-net-log
if (net_log_) {
net_log_->StartLogging(url_request_context_.get());
url_request_context_->set_net_log(net_log_);
}
network_delegate_.reset(delegate_->CreateNetworkDelegate());
url_request_context_->set_network_delegate(network_delegate_.get());
@ -365,12 +368,20 @@ net::URLRequestContext* URLRequestContextGetter::GetURLRequestContext() {
} else {
backend.reset(delegate_->CreateHttpCacheBackendFactory(base_path_));
}
if (controller_) {
storage_->set_http_transaction_factory(make_scoped_ptr(
new net::HttpCache(
make_scoped_ptr(new DevToolsNetworkTransactionFactory(
controller_, http_network_session_.get())),
std::move(backend),
false)));
} else {
storage_->set_http_transaction_factory(make_scoped_ptr(
new net::HttpCache(http_network_session_.get(),
std::move(backend),
false)));
}
storage_->set_job_factory(delegate_->CreateURLRequestJobFactory(
&protocol_handlers_, &protocol_interceptors_));