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

Unified Diff: net/http/http_alternate_protocols.cc

Issue 3195015: Add option to simulate alternate protocol always being present.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 10 years, 4 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_alternate_protocols.h ('k') | net/http/http_alternate_protocols_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/http/http_alternate_protocols.cc
===================================================================
--- net/http/http_alternate_protocols.cc (revision 57015)
+++ net/http/http_alternate_protocols.cc (working copy)
@@ -15,12 +15,17 @@
"npn-spdy/2",
};
+// static
+HttpAlternateProtocols::PortProtocolPair*
+ HttpAlternateProtocols::forced_alternate_protocol_ = NULL;
+
HttpAlternateProtocols::HttpAlternateProtocols() {}
HttpAlternateProtocols::~HttpAlternateProtocols() {}
bool HttpAlternateProtocols::HasAlternateProtocolFor(
const HostPortPair& http_host_port_pair) const {
- return ContainsKey(protocol_map_, http_host_port_pair);
+ return ContainsKey(protocol_map_, http_host_port_pair) ||
+ forced_alternate_protocol_;
}
bool HttpAlternateProtocols::HasAlternateProtocolFor(
@@ -32,8 +37,16 @@
HttpAlternateProtocols::PortProtocolPair
HttpAlternateProtocols::GetAlternateProtocolFor(
const HostPortPair& http_host_port_pair) const {
- DCHECK(ContainsKey(protocol_map_, http_host_port_pair));
- return protocol_map_.find(http_host_port_pair)->second;
+ DCHECK(HasAlternateProtocolFor(http_host_port_pair));
+
+ // First check the map.
+ ProtocolMap::const_iterator it = protocol_map_.find(http_host_port_pair);
+ if (it != protocol_map_.end())
+ return it->second;
+
+ // We must be forcing an alternate.
+ DCHECK(forced_alternate_protocol_);
+ return *forced_alternate_protocol_;
}
HttpAlternateProtocols::PortProtocolPair
@@ -83,4 +96,17 @@
protocol_map_[http_host_port_pair].protocol = BROKEN;
}
+// static
+void HttpAlternateProtocols::ForceAlternateProtocol(
+ const PortProtocolPair& pair) {
+ // Note: we're going to leak this.
willchan no longer on Chromium 2010/08/22 16:27:33 Call delete forced_alternate_protocol_ here, in ca
+ forced_alternate_protocol_ = new PortProtocolPair(pair);
+}
+
+// static
+void HttpAlternateProtocols::DisableForcedAlternateProtocol() {
+ delete forced_alternate_protocol_;
+ forced_alternate_protocol_ = NULL;
+}
+
} // namespace net
« no previous file with comments | « net/http/http_alternate_protocols.h ('k') | net/http/http_alternate_protocols_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698