Commit 014df383 authored by Ryan Hamilton's avatar Ryan Hamilton Committed by Commit Bot

Clean up HttpStreamFactory::Job by removing an unused method, and factoring...

Clean up HttpStreamFactory::Job by removing an unused method, and factoring out a large block of code into asmaller stand-alone method.

Change-Id: I307b284b29ebe7113e90a9afda2d0f47123939f8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1881225
Commit-Queue: Ryan Hamilton <rch@chromium.org>
Reviewed-by: default avatarZhongyi Shi <zhongyi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#709689}
parent f0b3bcb8
......@@ -728,53 +728,8 @@ int HttpStreamFactory::Job::DoInitConnectionImpl() {
server_ssl_config_.renego_allowed_for_protos.push_back(kProtoHTTP11);
}
if (using_quic_) {
HostPortPair destination;
SSLConfig* ssl_config;
GURL url(request_info_.url);
if (proxy_info_.is_quic()) {
// A proxy's certificate is expected to be valid for the proxy hostname.
destination = proxy_info_.proxy_server().host_port_pair();
ssl_config = &proxy_ssl_config_;
GURL::Replacements replacements;
replacements.SetSchemeStr(url::kHttpsScheme);
replacements.SetHostStr(destination.host());
const std::string new_port = base::NumberToString(destination.port());
replacements.SetPortStr(new_port);
replacements.ClearUsername();
replacements.ClearPassword();
replacements.ClearPath();
replacements.ClearQuery();
replacements.ClearRef();
url = url.ReplaceComponents(replacements);
} else {
DCHECK(using_ssl_);
// The certificate of a QUIC alternative server is expected to be valid
// for the origin of the request (in addition to being valid for the
// server itself).
destination = destination_;
ssl_config = &server_ssl_config_;
}
int rv = quic_request_.Request(
destination, quic_version_, request_info_.privacy_mode, priority_,
request_info_.socket_tag, request_info_.network_isolation_key,
request_info_.disable_secure_dns, ssl_config->GetCertVerifyFlags(), url,
net_log_, &net_error_details_,
base::BindOnce(&Job::OnFailedOnDefaultNetwork,
ptr_factory_.GetWeakPtr()),
io_callback_);
if (rv == OK) {
using_existing_quic_session_ = true;
} else if (rv == ERR_IO_PENDING) {
// There's no available QUIC session. Inform the delegate how long to
// delay the main job.
delegate_->MaybeSetWaitTimeForMainJob(
quic_request_.GetTimeDelayForWaitingJob());
expect_on_quic_host_resolution_ = quic_request_.WaitForHostResolution(
base::BindOnce(&Job::OnQuicHostResolution, base::Unretained(this)));
}
return rv;
}
if (using_quic_)
return DoInitConnectionImplQuic();
// Check first if there is a pushed stream matching the request, or an HTTP/2
// connection this request can pool to. If so, then go straight to using
......@@ -891,6 +846,53 @@ int HttpStreamFactory::Job::DoInitConnectionImpl() {
connection_.get(), io_callback_, proxy_auth_callback);
}
int HttpStreamFactory::Job::DoInitConnectionImplQuic() {
HostPortPair destination;
SSLConfig* ssl_config;
GURL url(request_info_.url);
if (proxy_info_.is_quic()) {
// A proxy's certificate is expected to be valid for the proxy hostname.
destination = proxy_info_.proxy_server().host_port_pair();
ssl_config = &proxy_ssl_config_;
GURL::Replacements replacements;
replacements.SetSchemeStr(url::kHttpsScheme);
replacements.SetHostStr(destination.host());
const std::string new_port = base::NumberToString(destination.port());
replacements.SetPortStr(new_port);
replacements.ClearUsername();
replacements.ClearPassword();
replacements.ClearPath();
replacements.ClearQuery();
replacements.ClearRef();
url = url.ReplaceComponents(replacements);
} else {
DCHECK(using_ssl_);
// The certificate of a QUIC alternative server is expected to be valid
// for the origin of the request (in addition to being valid for the
// server itself).
destination = destination_;
ssl_config = &server_ssl_config_;
}
int rv = quic_request_.Request(
destination, quic_version_, request_info_.privacy_mode, priority_,
request_info_.socket_tag, request_info_.network_isolation_key,
request_info_.disable_secure_dns, ssl_config->GetCertVerifyFlags(), url,
net_log_, &net_error_details_,
base::BindOnce(&Job::OnFailedOnDefaultNetwork, ptr_factory_.GetWeakPtr()),
io_callback_);
if (rv == OK) {
using_existing_quic_session_ = true;
} else if (rv == ERR_IO_PENDING) {
// There's no available QUIC session. Inform the delegate how long to
// delay the main job.
delegate_->MaybeSetWaitTimeForMainJob(
quic_request_.GetTimeDelayForWaitingJob());
expect_on_quic_host_resolution_ = quic_request_.WaitForHostResolution(
base::BindOnce(&Job::OnQuicHostResolution, base::Unretained(this)));
}
return rv;
}
void HttpStreamFactory::Job::OnQuicHostResolution(int result) {
DCHECK(expect_on_quic_host_resolution_);
expect_on_quic_host_resolution_ = false;
......@@ -1181,17 +1183,6 @@ int HttpStreamFactory::Job::DoCreateStreamComplete(int result) {
return OK;
}
void HttpStreamFactory::Job::ReturnToStateInitConnection(
bool close_connection) {
if (close_connection && connection_->socket())
connection_->socket()->Disconnect();
connection_->Reset();
spdy_session_request_.reset();
next_state_ = STATE_INIT_CONNECTION;
}
void HttpStreamFactory::Job::OnSpdySessionAvailable(
base::WeakPtr<SpdySession> spdy_session) {
DCHECK(spdy_session);
......
......@@ -282,6 +282,7 @@ class HttpStreamFactory::Job
int DoLoop(int result);
int StartInternal();
int DoInitConnectionImpl();
int DoInitConnectionImplQuic();
// If this is a QUIC alt job, then this function is called when host
// resolution completes. It's called with the next result after host
......@@ -312,9 +313,6 @@ class HttpStreamFactory::Job
int SetSpdyHttpStreamOrBidirectionalStreamImpl(
base::WeakPtr<SpdySession> session);
// Returns to STATE_INIT_CONNECTION and resets some state.
void ReturnToStateInitConnection(bool close_connection);
// SpdySessionPool::SpdySessionRequest::Delegate implementation:
void OnSpdySessionAvailable(base::WeakPtr<SpdySession> spdy_session) override;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment