Commit 6298e996 authored by bnc's avatar bnc Committed by Commit bot

Remove HttpStreamFactoryImpl::Job::MarkAsAlternate.

* Add AlternativeService argument to Job::Job() to signal whether Job is
  alternative;
* remove HttpStreamFactoryImpl::Job::MarkAsAlternate() method;
* add const bool is_spdy_alternative_ and is_quic_alternative members;
* remove Job::IsAlternate() and IsSpdyAlternate() methods;
* s/alternate/alternative/ in comments.

BUG=489280

Review URL: https://codereview.chromium.org/1162893003

Cr-Commit-Position: refs/heads/master@{#332820}
parent 9875f9d7
......@@ -111,7 +111,7 @@ struct NET_EXPORT AlternativeService {
AlternativeService& operator=(const AlternativeService& alternative_service) =
default;
HostPortPair host_port_pair() { return HostPortPair(host, port); }
HostPortPair host_port_pair() const { return HostPortPair(host, port); }
bool operator==(const AlternativeService& other) const {
return protocol == other.protocol && host == other.host &&
......
......@@ -99,22 +99,21 @@ HttpStreamRequest* HttpStreamFactoryImpl::RequestStreamInternal(
// Never share connection with other jobs for FTP requests.
DCHECK(!request_info.url.SchemeIs("ftp"));
Job* alternate_job =
Job* alternative_job =
new Job(this, session_, request_info, priority, server_ssl_config,
proxy_ssl_config, net_log.net_log());
request->AttachJob(alternate_job);
alternate_job->MarkAsAlternate(alternative_service);
proxy_ssl_config, alternative_service, net_log.net_log());
request->AttachJob(alternative_job);
job->WaitFor(alternate_job);
job->WaitFor(alternative_job);
// Make sure to wait until we call WaitFor(), before starting
// |alternate_job|, otherwise |alternate_job| will not notify |job|
// |alternative_job|, otherwise |alternative_job| will not notify |job|
// appropriately.
alternate_job->Start(request);
alternative_job->Start(request);
}
// Even if |alternate_job| has already finished, it won't have notified the
// request yet, since we defer that to the next iteration of the MessageLoop,
// so starting |job| is always safe.
// Even if |alternative_job| has already finished, it will not have notified
// the request yet, since we defer that to the next iteration of the
// MessageLoop, so starting |job| is always safe.
job->Start(request);
return request;
}
......@@ -128,11 +127,9 @@ void HttpStreamFactoryImpl::PreconnectStreams(
DCHECK(!for_websockets_);
AlternativeService alternative_service =
GetAlternativeServiceFor(request_info.url);
Job* job = new Job(this, session_, request_info, priority, server_ssl_config,
proxy_ssl_config, session_->net_log());
if (alternative_service.protocol != UNINITIALIZED_ALTERNATE_PROTOCOL) {
job->MarkAsAlternate(alternative_service);
}
Job* job =
new Job(this, session_, request_info, priority, server_ssl_config,
proxy_ssl_config, alternative_service, session_->net_log());
preconnect_job_set_.insert(job);
job->Preconnect(num_streams);
}
......
This diff is collapsed.
......@@ -36,6 +36,7 @@ class QuicHttpStream;
// created for the StreamFactory.
class HttpStreamFactoryImpl::Job {
public:
// Constructor for non-alternative Job.
Job(HttpStreamFactoryImpl* stream_factory,
HttpNetworkSession* session,
const HttpRequestInfo& request_info,
......@@ -43,6 +44,15 @@ class HttpStreamFactoryImpl::Job {
const SSLConfig& server_ssl_config,
const SSLConfig& proxy_ssl_config,
NetLog* net_log);
// Constructor for alternative Job.
Job(HttpStreamFactoryImpl* stream_factory,
HttpNetworkSession* session,
const HttpRequestInfo& request_info,
RequestPriority priority,
const SSLConfig& server_ssl_config,
const SSLConfig& proxy_ssl_config,
AlternativeService alternative_service,
NetLog* net_log);
~Job();
// Start initiates the process of creating a new HttpStream. |request| will be
......@@ -56,10 +66,6 @@ class HttpStreamFactoryImpl::Job {
int RestartTunnelWithProxyAuth(const AuthCredentials& credentials);
LoadState GetLoadState() const;
// Marks this Job as the "alternate" job, from Alternate-Protocol or Alt-Svc
// using the specified alternate service.
void MarkAsAlternate(AlternativeService alternative_service);
// Tells |this| to wait for |job| to resume it.
void WaitFor(Job* job);
......@@ -146,13 +152,14 @@ class HttpStreamFactoryImpl::Job {
public:
ValidSpdySessionPool(SpdySessionPool* spdy_session_pool,
GURL& origin_url,
bool is_spdy_alternate);
bool is_spdy_alternative);
// Returns OK if a SpdySession was not found (in which case |spdy_session|
// is set to nullptr), or if one was found (in which case |spdy_session| is
// set to it) and it has an associated SSL certificate with is valid for
// |origin_url_|, or if this requirement does not apply because the Job is
// not a SPDY alternate job. Returns the appropriate error code otherwise,
// not a SPDY alternative job. Returns the appropriate error code
// otherwise,
// in which case |spdy_session| should not be used.
int FindAvailableSession(const SpdySessionKey& key,
const BoundNetLog& net_log,
......@@ -160,7 +167,7 @@ class HttpStreamFactoryImpl::Job {
// Creates a SpdySession and sets |spdy_session| to point to it. Returns OK
// if the associated SSL certificate is valid for |origin_url_|, or if this
// requirement does not apply because the Job is not a SPDY alternate job.
// requirement does not apply because the Job is not a SPDY alternative job.
// Returns the appropriate error code otherwise, in which case
// |spdy_session| should not be used.
int CreateAvailableSessionFromSocket(
......@@ -174,14 +181,14 @@ class HttpStreamFactoryImpl::Job {
private:
// Returns OK if |spdy_session| has an associated SSL certificate with is
// valid for |origin_url_|, or if this requirement does not apply because
// the Job is not a SPDY alternate job, or if |spdy_session| is null.
// the Job is not a SPDY alternative job, or if |spdy_session| is null.
// Returns appropriate error code otherwise.
int CheckAlternativeServiceValidityForOrigin(
base::WeakPtr<SpdySession> spdy_session);
SpdySessionPool* const spdy_session_pool_;
const GURL origin_url_;
const bool is_spdy_alternate_;
const bool is_spdy_alternative_;
};
void OnStreamReadyCallback();
......@@ -231,12 +238,9 @@ class HttpStreamFactoryImpl::Job {
bool IsHttpsProxyAndHttpUrl() const;
// Returns true iff this Job is an alternate, that is, iff MarkAsAlternate has
// been called.
bool IsAlternate() const;
// Returns true if this Job is a SPDY alternate job.
bool IsSpdyAlternate() const;
// Is this a SPDY or QUIC alternative Job?
bool IsSpdyAlternative() const;
bool IsQuicAlternative() const;
// Sets several fields of |ssl_config| for |server| based on the proxy info
// and other factors.
......@@ -319,10 +323,10 @@ class HttpStreamFactoryImpl::Job {
// original request when host mapping rules are set-up.
GURL origin_url_;
// AlternateProtocol for this job if this is an alternate job.
AlternativeService alternative_service_;
// AlternativeService for this Job if this is an alternative Job.
const AlternativeService alternative_service_;
// AlternateProtocol for the other job if this is not an alternate job.
// AlternativeService for the other Job if this is not an alternative Job.
AlternativeService other_job_alternative_service_;
// This is the Job we're dependent on. It will notify us if/when it's OK to
......
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