Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / net / http / http_stream_factory_impl.cc
index 991e469..8304694 100644 (file)
@@ -12,9 +12,6 @@
 #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"
@@ -25,10 +22,6 @@ namespace net {
 
 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
@@ -45,15 +38,11 @@ GURL UpgradeUrlToHttps(const GURL& original_url, int port) {
 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_);
@@ -118,7 +107,7 @@ HttpStreamRequest* HttpStreamFactoryImpl::RequestStreamInternal(
                                  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) {
@@ -162,7 +151,7 @@ void HttpStreamFactoryImpl::PreconnectStreams(
     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) {
@@ -179,18 +168,17 @@ void HttpStreamFactoryImpl::PreconnectStreams(
   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"))
@@ -204,10 +192,12 @@ PortAlternateProtocolPair HttpStreamFactoryImpl::GetAlternateProtocolRequestFor(
   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();
@@ -229,20 +219,18 @@ PortAlternateProtocolPair HttpStreamFactoryImpl::GetAlternateProtocolRequestFor(
   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
@@ -317,40 +305,4 @@ void HttpStreamFactoryImpl::OnPreconnectsComplete(const Job* job) {
   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