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