Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(113)

Unified Diff: net/http/http_stream_factory_impl.cc

Issue 1054413002: Remove the "alternate_url" outparam from (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix preconnect Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/http/http_stream_factory_impl.h ('k') | net/http/http_stream_factory_impl_job.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/http/http_stream_factory_impl.cc
diff --git a/net/http/http_stream_factory_impl.cc b/net/http/http_stream_factory_impl.cc
index 47d8f03a7fdec78707996764ab1a17a28458ab1f..dab8bc80c4a29ae9d02c9baa5037290e6b4cfe13 100644
--- a/net/http/http_stream_factory_impl.cc
+++ b/net/http/http_stream_factory_impl.cc
@@ -8,7 +8,6 @@
#include "base/logging.h"
#include "base/stl_util.h"
-#include "base/strings/string_number_conversions.h"
#include "net/base/net_util.h"
#include "net/http/http_network_session.h"
#include "net/http/http_server_properties.h"
@@ -20,20 +19,6 @@
namespace net {
-namespace {
-
-GURL UpgradeUrlToHttps(const GURL& original_url, int port) {
- GURL::Replacements replacements;
- // new_port needs to be in scope here because GURL::Replacements references
- // the memory contained by it directly.
- const std::string new_port = base::IntToString(port);
- replacements.SetSchemeStr("https");
- replacements.SetPortStr(new_port);
- return original_url.ReplaceComponents(replacements);
-}
-
-} // namespace
-
HttpStreamFactoryImpl::HttpStreamFactoryImpl(HttpNetworkSession* session,
bool for_websockets)
: session_(session),
@@ -104,29 +89,22 @@ HttpStreamRequest* HttpStreamFactoryImpl::RequestStreamInternal(
delegate,
websocket_handshake_stream_create_helper,
net_log);
+ Job* job = new Job(this, session_, request_info, priority, server_ssl_config,
+ proxy_ssl_config, net_log.net_log());
+ request->AttachJob(job);
- // TODO(bnc): Get rid of |alternate_url|.
- GURL alternate_url;
AlternativeService alternative_service =
- GetAlternativeServiceRequestFor(request_info.url, &alternate_url);
- Job* alternate_job = NULL;
+ GetAlternativeServiceFor(request_info.url);
if (alternative_service.protocol != UNINITIALIZED_ALTERNATE_PROTOCOL) {
// Never share connection with other jobs for FTP requests.
DCHECK(!request_info.url.SchemeIs("ftp"));
- HttpRequestInfo alternate_request_info = request_info;
- alternate_request_info.url = alternate_url;
- alternate_job =
- new Job(this, session_, alternate_request_info, priority,
- server_ssl_config, proxy_ssl_config, net_log.net_log());
+ Job* alternate_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(request_info.url, alternative_service);
- }
+ alternate_job->MarkAsAlternate(alternative_service);
- Job* job = new Job(this, session_, request_info, priority,
- server_ssl_config, proxy_ssl_config, net_log.net_log());
- request->AttachJob(job);
- if (alternate_job) {
// Never share connection with other jobs for FTP requests.
DCHECK(!request_info.url.SchemeIs("ftp"));
@@ -136,6 +114,7 @@ HttpStreamRequest* HttpStreamFactoryImpl::RequestStreamInternal(
// appropriately.
alternate_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.
@@ -150,19 +129,12 @@ void HttpStreamFactoryImpl::PreconnectStreams(
const SSLConfig& server_ssl_config,
const SSLConfig& proxy_ssl_config) {
DCHECK(!for_websockets_);
- GURL alternate_url;
AlternativeService alternative_service =
- GetAlternativeServiceRequestFor(request_info.url, &alternate_url);
- Job* job = NULL;
+ 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) {
- HttpRequestInfo alternate_request_info = request_info;
- alternate_request_info.url = alternate_url;
- job = new Job(this, session_, alternate_request_info, priority,
- server_ssl_config, proxy_ssl_config, session_->net_log());
- job->MarkAsAlternate(request_info.url, alternative_service);
- } else {
- job = new Job(this, session_, request_info, priority,
- server_ssl_config, proxy_ssl_config, session_->net_log());
+ job->MarkAsAlternate(alternative_service);
}
preconnect_job_set_.insert(job);
job->Preconnect(num_streams);
@@ -172,9 +144,8 @@ const HostMappingRules* HttpStreamFactoryImpl::GetHostMappingRules() const {
return session_->params().host_mapping_rules;
}
-AlternativeService HttpStreamFactoryImpl::GetAlternativeServiceRequestFor(
- const GURL& original_url,
- GURL* alternate_url) {
+AlternativeService HttpStreamFactoryImpl::GetAlternativeServiceFor(
+ const GURL& original_url) {
const AlternativeService kNoAlternativeService;
if (!session_->params().use_alternate_protocols)
@@ -226,21 +197,16 @@ AlternativeService HttpStreamFactoryImpl::GetAlternativeServiceRequestFor(
if (session_->HasSpdyExclusion(origin))
return kNoAlternativeService;
- *alternate_url = UpgradeUrlToHttps(original_url, alternative_service.port);
- } else {
- DCHECK_EQ(QUIC, alternative_service.protocol);
- if (!session_->params().enable_quic)
- return kNoAlternativeService;
+ return alternative_service;
+ }
- if (session_->quic_stream_factory()->IsQuicDisabled(origin.port()))
- return kNoAlternativeService;
+ DCHECK_EQ(QUIC, alternative_service.protocol);
+ if (!session_->params().enable_quic)
+ return kNoAlternativeService;
+
+ if (session_->quic_stream_factory()->IsQuicDisabled(origin.port()))
+ return kNoAlternativeService;
- // 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
- // the alternate request will be going via UDP to a different port.
- *alternate_url = original_url;
- }
return alternative_service;
}
« no previous file with comments | « net/http/http_stream_factory_impl.h ('k') | net/http/http_stream_factory_impl_job.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698