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

Unified Diff: net/http/http_stream_factory.cc

Issue 25956002: [SPDY] Remove references to obsolete SPDY versions SPDY/1 and SPDY/2.1 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix unit test Created 7 years, 2 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.cc » ('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 a55ed075bb51d8f000617c27567d51d1c42a8a0c..31d102fde0ba143468713d3b061baa6574a9b89d 100644
--- a/net/http/http_stream_factory.cc
+++ b/net/http/http_stream_factory.cc
@@ -19,7 +19,7 @@ namespace net {
// static
std::vector<std::string>* HttpStreamFactory::next_protos_ = NULL;
// static
-bool HttpStreamFactory::enabled_protocols_[NUM_ALTERNATE_PROTOCOLS];
+bool HttpStreamFactory::enabled_protocols_[NUM_VALID_ALTERNATE_PROTOCOLS];
// static
bool HttpStreamFactory::spdy_enabled_ = true;
// static
@@ -34,6 +34,28 @@ std::list<HostPortPair>* HttpStreamFactory::forced_spdy_exclusions_ = NULL;
HttpStreamFactory::~HttpStreamFactory() {}
// static
+bool HttpStreamFactory::IsProtocolEnabled(AlternateProtocol protocol) {
+ DCHECK(IsAlternateProtocolValid(protocol));
+ return enabled_protocols_[
+ protocol - ALTERNATE_PROTOCOL_MINIMUM_VALID_VERSION];
+}
+
+// static
+void HttpStreamFactory::SetProtocolEnabled(AlternateProtocol protocol) {
+ DCHECK(IsAlternateProtocolValid(protocol));
+ enabled_protocols_[
+ protocol - ALTERNATE_PROTOCOL_MINIMUM_VALID_VERSION] = true;
+}
+
+// static
+void HttpStreamFactory::ResetEnabledProtocols() {
+ for (int i = ALTERNATE_PROTOCOL_MINIMUM_VALID_VERSION;
+ i <= ALTERNATE_PROTOCOL_MAXIMUM_VALID_VERSION; ++i) {
+ enabled_protocols_[i - ALTERNATE_PROTOCOL_MINIMUM_VALID_VERSION] = false;
+ }
+}
+
+// static
void HttpStreamFactory::ResetStaticSettingsToInit() {
// WARNING: These must match the initializers above.
delete next_protos_;
@@ -44,8 +66,7 @@ void HttpStreamFactory::ResetStaticSettingsToInit() {
force_spdy_over_ssl_ = true;
force_spdy_always_ = false;
forced_spdy_exclusions_ = NULL;
- for (int i = 0; i < NUM_ALTERNATE_PROTOCOLS; ++i)
- enabled_protocols_[i] = false;
+ ResetEnabledProtocols();
}
void HttpStreamFactory::ProcessAlternateProtocol(
@@ -72,11 +93,11 @@ void HttpStreamFactory::ProcessAlternateProtocol(
AlternateProtocol protocol =
AlternateProtocolFromString(port_protocol_vector[1]);
- if (protocol < NUM_ALTERNATE_PROTOCOLS && !enabled_protocols_[protocol])
+ if (IsAlternateProtocolValid(protocol) && !IsProtocolEnabled(protocol)) {
protocol = ALTERNATE_PROTOCOL_BROKEN;
+ }
if (protocol == ALTERNATE_PROTOCOL_BROKEN) {
- // Currently, we only recognize the npn-spdy protocol.
DLOG(WARNING) << kAlternateProtocolHeader
<< " header has unrecognized protocol: "
<< port_protocol_vector[1];
@@ -212,8 +233,7 @@ void HttpStreamFactory::SetNextProtos(const std::vector<NextProto>& value) {
next_protos_->clear();
- for (uint32 i = 0; i < NUM_ALTERNATE_PROTOCOLS; ++i)
- enabled_protocols_[i] = false;
+ ResetEnabledProtocols();
// TODO(rtenneti): bug 116575 - consider combining the NextProto and
// AlternateProtocol.
@@ -229,11 +249,11 @@ void HttpStreamFactory::SetNextProtos(const std::vector<NextProto>& value) {
// which has not corresponding alternative.
if (proto != kProtoHTTP11) {
AlternateProtocol alternate = AlternateProtocolFromNextProto(proto);
- if (alternate == UNINITIALIZED_ALTERNATE_PROTOCOL) {
+ if (!IsAlternateProtocolValid(alternate)) {
NOTREACHED() << "Invalid next proto: " << proto;
continue;
}
- enabled_protocols_[alternate] = true;
+ SetProtocolEnabled(alternate);
}
}
}
« no previous file with comments | « net/http/http_stream_factory.h ('k') | net/http/http_stream_factory_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698