#include "net/base/net_log.h"
#include "net/base/net_util.h"
#include "net/http/http_network_session.h"
-#include "net/http/http_pipelined_connection.h"
-#include "net/http/http_pipelined_host.h"
-#include "net/http/http_pipelined_stream.h"
#include "net/http/http_server_properties.h"
#include "net/http/http_stream_factory_impl_job.h"
#include "net/http/http_stream_factory_impl_request.h"
namespace {
-const PortAlternateProtocolPair kNoAlternateProtocol = {
- 0, UNINITIALIZED_ALTERNATE_PROTOCOL
-};
-
GURL UpgradeUrlToHttps(const GURL& original_url, int port) {
GURL::Replacements replacements;
// new_sheme and new_port need to be in scope here because GURL::Replacements
HttpStreamFactoryImpl::HttpStreamFactoryImpl(HttpNetworkSession* session,
bool for_websockets)
: session_(session),
- http_pipelined_host_pool_(this, NULL,
- session_->http_server_properties(),
- session_->force_http_pipelining()),
for_websockets_(for_websockets) {}
HttpStreamFactoryImpl::~HttpStreamFactoryImpl() {
DCHECK(request_map_.empty());
DCHECK(spdy_session_request_map_.empty());
- DCHECK(http_pipelining_request_map_.empty());
std::set<const Job*> tmp_job_set;
tmp_job_set.swap(orphaned_job_set_);
net_log);
GURL alternate_url;
- PortAlternateProtocolPair alternate =
+ AlternateProtocolInfo alternate =
GetAlternateProtocolRequestFor(request_info.url, &alternate_url);
Job* alternate_job = NULL;
if (alternate.protocol != UNINITIALIZED_ALTERNATE_PROTOCOL) {
const SSLConfig& proxy_ssl_config) {
DCHECK(!for_websockets_);
GURL alternate_url;
- PortAlternateProtocolPair alternate =
+ AlternateProtocolInfo alternate =
GetAlternateProtocolRequestFor(request_info.url, &alternate_url);
Job* job = NULL;
if (alternate.protocol != UNINITIALIZED_ALTERNATE_PROTOCOL) {
job->Preconnect(num_streams);
}
-base::Value* HttpStreamFactoryImpl::PipelineInfoToValue() const {
- return http_pipelined_host_pool_.PipelineInfoToValue();
-}
-
const HostMappingRules* HttpStreamFactoryImpl::GetHostMappingRules() const {
return session_->params().host_mapping_rules;
}
-PortAlternateProtocolPair HttpStreamFactoryImpl::GetAlternateProtocolRequestFor(
+AlternateProtocolInfo HttpStreamFactoryImpl::GetAlternateProtocolRequestFor(
const GURL& original_url,
GURL* alternate_url) {
- if (!use_alternate_protocols())
+ const AlternateProtocolInfo kNoAlternateProtocol =
+ AlternateProtocolInfo(0, UNINITIALIZED_ALTERNATE_PROTOCOL, 0);
+
+ if (!session_->params().use_alternate_protocols)
return kNoAlternateProtocol;
if (original_url.SchemeIs("ftp"))
if (!http_server_properties.HasAlternateProtocol(origin))
return kNoAlternateProtocol;
- PortAlternateProtocolPair alternate =
+ AlternateProtocolInfo alternate =
http_server_properties.GetAlternateProtocol(origin);
- if (alternate.protocol == ALTERNATE_PROTOCOL_BROKEN)
+ if (alternate.is_broken) {
+ HistogramAlternateProtocolUsage(ALTERNATE_PROTOCOL_USAGE_BROKEN);
return kNoAlternateProtocol;
+ }
if (!IsAlternateProtocolValid(alternate.protocol)) {
NOTREACHED();
origin.set_port(alternate.port);
if (alternate.protocol >= NPN_SPDY_MINIMUM_VERSION &&
alternate.protocol <= NPN_SPDY_MAXIMUM_VERSION) {
- if (!spdy_enabled())
+ if (!HttpStreamFactory::spdy_enabled())
return kNoAlternateProtocol;
- if (HttpStreamFactory::HasSpdyExclusion(origin))
+ if (session_->HasSpdyExclusion(origin))
return kNoAlternateProtocol;
*alternate_url = UpgradeUrlToHttps(original_url, alternate.port);
} else {
DCHECK_EQ(QUIC, alternate.protocol);
- if (!session_->params().enable_quic ||
- !(original_url.SchemeIs("http") ||
- session_->params().enable_quic_https)) {
+ if (!session_->params().enable_quic)
return kNoAlternateProtocol;
- }
+
// TODO(rch): Figure out how to make QUIC iteract with PAC
// scripts. By not re-writing the URL, we will query the PAC script
// for the proxy to use to reach the original URL via TCP. But
OnPreconnectsCompleteInternal();
}
-void HttpStreamFactoryImpl::OnHttpPipelinedHostHasAdditionalCapacity(
- HttpPipelinedHost* host) {
- while (ContainsKey(http_pipelining_request_map_, host->GetKey())) {
- HttpPipelinedStream* stream =
- http_pipelined_host_pool_.CreateStreamOnExistingPipeline(
- host->GetKey());
- if (!stream) {
- break;
- }
-
- Request* request = *http_pipelining_request_map_[host->GetKey()].begin();
- request->Complete(stream->was_npn_negotiated(),
- stream->protocol_negotiated(),
- false, // not using_spdy
- stream->net_log());
- request->OnStreamReady(NULL,
- stream->used_ssl_config(),
- stream->used_proxy_info(),
- stream);
- }
-}
-
-void HttpStreamFactoryImpl::AbortPipelinedRequestsWithKey(
- const Job* job, const HttpPipelinedHost::Key& key, int status,
- const SSLConfig& used_ssl_config) {
- RequestVector requests_to_fail = http_pipelining_request_map_[key];
- for (RequestVector::const_iterator it = requests_to_fail.begin();
- it != requests_to_fail.end(); ++it) {
- Request* request = *it;
- if (request == request_map_[job]) {
- continue;
- }
- request->OnStreamFailed(NULL, status, used_ssl_config);
- }
-}
-
} // namespace net