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

Unified Diff: net/http/http_stream_factory.cc

Issue 377063002: Revert of Add a probability to Alternate-Protocol support. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 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.h ('k') | net/http/http_stream_factory_impl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/http/http_stream_factory.cc
diff --git a/net/http/http_stream_factory.cc b/net/http/http_stream_factory.cc
index e86d8f89b071a9216854512694d174aaa85475a2..b60df85ed7ecbe8961b6ace2bb087bfbe8784df8 100644
--- a/net/http/http_stream_factory.cc
+++ b/net/http/http_stream_factory.cc
@@ -7,7 +7,6 @@
#include "base/logging.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_split.h"
-#include "base/strings/string_util.h"
#include "net/base/host_mapping_rules.h"
#include "net/base/host_port_pair.h"
#include "net/http/http_network_session.h"
@@ -30,60 +29,40 @@
void HttpStreamFactory::ProcessAlternateProtocol(
const base::WeakPtr<HttpServerProperties>& http_server_properties,
- const std::vector<std::string>& alternate_protocol_values,
+ const std::string& alternate_protocol_str,
const HostPortPair& http_host_port_pair,
const HttpNetworkSession& session) {
- AlternateProtocol protocol = UNINITIALIZED_ALTERNATE_PROTOCOL;
- int port = 0;
- double probability = 1;
- for (size_t i = 0; i < alternate_protocol_values.size(); ++i) {
- const std::string& alternate_protocol_str = alternate_protocol_values[i];
- if (StartsWithASCII(alternate_protocol_str, "p=", true)) {
- if (!base::StringToDouble(alternate_protocol_str.substr(2),
- &probability) ||
- probability < 0 || probability > 1) {
- DVLOG(1) << kAlternateProtocolHeader
- << " header has unrecognizable probability: "
- << alternate_protocol_values[i];
- return;
- }
- continue;
- }
-
- std::vector<std::string> port_protocol_vector;
- base::SplitString(alternate_protocol_str, ':', &port_protocol_vector);
- if (port_protocol_vector.size() != 2) {
- DVLOG(1) << kAlternateProtocolHeader
- << " header has too many tokens: "
- << alternate_protocol_str;
- return;
- }
-
- if (!base::StringToInt(port_protocol_vector[0], &port) ||
- port <= 0 || port >= 1 << 16) {
- DVLOG(1) << kAlternateProtocolHeader
- << " header has unrecognizable port: "
- << port_protocol_vector[0];
- return;
- }
-
- protocol =
- AlternateProtocolFromString(port_protocol_vector[1]);
- if (IsAlternateProtocolValid(protocol) &&
- !session.IsProtocolEnabled(protocol)) {
- protocol = ALTERNATE_PROTOCOL_BROKEN;
- }
-
- if (protocol == ALTERNATE_PROTOCOL_BROKEN) {
- DVLOG(1) << kAlternateProtocolHeader
- << " header has unrecognized protocol: "
- << port_protocol_vector[1];
- return;
- }
+ std::vector<std::string> port_protocol_vector;
+ base::SplitString(alternate_protocol_str, ':', &port_protocol_vector);
+ if (port_protocol_vector.size() != 2) {
+ DVLOG(1) << kAlternateProtocolHeader
+ << " header has too many tokens: "
+ << alternate_protocol_str;
+ return;
}
- if (protocol == UNINITIALIZED_ALTERNATE_PROTOCOL)
+ int port;
+ if (!base::StringToInt(port_protocol_vector[0], &port) ||
+ port <= 0 || port >= 1 << 16) {
+ DVLOG(1) << kAlternateProtocolHeader
+ << " header has unrecognizable port: "
+ << port_protocol_vector[0];
return;
+ }
+
+ AlternateProtocol protocol =
+ AlternateProtocolFromString(port_protocol_vector[1]);
+ if (IsAlternateProtocolValid(protocol) &&
+ !session.IsProtocolEnabled(protocol)) {
+ protocol = ALTERNATE_PROTOCOL_BROKEN;
+ }
+
+ if (protocol == ALTERNATE_PROTOCOL_BROKEN) {
+ DVLOG(1) << kAlternateProtocolHeader
+ << " header has unrecognized protocol: "
+ << port_protocol_vector[1];
+ return;
+ }
HostPortPair host_port(http_host_port_pair);
const HostMappingRules* mapping_rules = GetHostMappingRules();
@@ -91,15 +70,14 @@
mapping_rules->RewriteHost(&host_port);
if (http_server_properties->HasAlternateProtocol(host_port)) {
- const AlternateProtocolInfo existing_alternate =
+ const PortAlternateProtocolPair existing_alternate =
http_server_properties->GetAlternateProtocol(host_port);
// If we think the alternate protocol is broken, don't change it.
if (existing_alternate.protocol == ALTERNATE_PROTOCOL_BROKEN)
return;
}
- http_server_properties->SetAlternateProtocol(host_port, port, protocol,
- probability);
+ http_server_properties->SetAlternateProtocol(host_port, port, protocol);
}
GURL HttpStreamFactory::ApplyHostMappingRules(const GURL& url,
« no previous file with comments | « net/http/http_stream_factory.h ('k') | net/http/http_stream_factory_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698