summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbnc <bnc@chromium.org>2015-02-05 10:58:00 -0800
committerCommit bot <commit-bot@chromium.org>2015-02-05 18:58:58 +0000
commit9f2a7c417364a965f99c3e1948fd948d07b316cd (patch)
tree8812871f0095d2d445c15214324bee8a9b2daac0
parentdd1e6a18b17c3aba5740c2f2d78cc48dd62da81c (diff)
downloadchromium_src-9f2a7c417364a965f99c3e1948fd948d07b316cd.zip
chromium_src-9f2a7c417364a965f99c3e1948fd948d07b316cd.tar.gz
chromium_src-9f2a7c417364a965f99c3e1948fd948d07b316cd.tar.bz2
Add AlternateProtocol to broken_altproto_list_ and map_.
Add AlternateProtocol (port and protocol) to HttpServerPropertiesImpl::broken_alternate_protocol_list_ and HttpServerPropertiesImpl::broken_alternate_protocol_list_ in preparation for supporting multiple AlternateProtocols per host. See draft at https://crrev.com/665083009 for how this fits into a larger picture. BUG=392575 Review URL: https://codereview.chromium.org/888943003 Cr-Commit-Position: refs/heads/master@{#314843}
-rw-r--r--net/http/http_server_properties_impl.cc31
-rw-r--r--net/http/http_server_properties_impl.h43
2 files changed, 60 insertions, 14 deletions
diff --git a/net/http/http_server_properties_impl.cc b/net/http/http_server_properties_impl.cc
index a18a3fe..9f17afc 100644
--- a/net/http/http_server_properties_impl.cc
+++ b/net/http/http_server_properties_impl.cc
@@ -318,13 +318,14 @@ void HttpServerPropertiesImpl::SetBrokenAlternateProtocol(
it = alternate_protocol_map_.Put(server, alternate);
}
it->second.is_broken = true;
- int count = ++broken_alternate_protocol_map_[server];
+ const BrokenAlternateProtocolEntry entry(server, alternate.port,
+ alternate.protocol);
+ int count = ++broken_alternate_protocol_map_[entry];
base::TimeDelta delay =
base::TimeDelta::FromSeconds(kBrokenAlternateProtocolDelaySecs);
- BrokenAlternateProtocolEntry entry;
- entry.server = server;
- entry.when = base::TimeTicks::Now() + delay * (1 << (count - 1));
- broken_alternate_protocol_list_.push_back(entry);
+ base::TimeTicks when = base::TimeTicks::Now() + delay * (1 << (count - 1));
+ broken_alternate_protocol_list_.push_back(
+ BrokenAlternateProtocolEntryWithTime(entry, when));
// Do not leave this host as canonical so that we don't infer the other
// hosts are also broken without testing them first.
@@ -339,12 +340,22 @@ void HttpServerPropertiesImpl::SetBrokenAlternateProtocol(
bool HttpServerPropertiesImpl::WasAlternateProtocolRecentlyBroken(
const HostPortPair& server) {
- return ContainsKey(broken_alternate_protocol_map_, server);
+ const AlternateProtocolInfo alternate_protocol = GetAlternateProtocol(server);
+ if (alternate_protocol.protocol == UNINITIALIZED_ALTERNATE_PROTOCOL)
+ return false;
+ const BrokenAlternateProtocolEntry entry(server, alternate_protocol.port,
+ alternate_protocol.protocol);
+ return ContainsKey(broken_alternate_protocol_map_, entry);
}
void HttpServerPropertiesImpl::ConfirmAlternateProtocol(
const HostPortPair& server) {
- broken_alternate_protocol_map_.erase(server);
+ const AlternateProtocolInfo alternate_protocol = GetAlternateProtocol(server);
+ if (alternate_protocol.protocol == UNINITIALIZED_ALTERNATE_PROTOCOL)
+ return;
+ const BrokenAlternateProtocolEntry entry(server, alternate_protocol.port,
+ alternate_protocol.protocol);
+ broken_alternate_protocol_map_.erase(entry);
}
void HttpServerPropertiesImpl::ClearAlternateProtocol(
@@ -494,12 +505,14 @@ void HttpServerPropertiesImpl::RemoveCanonicalHost(
void HttpServerPropertiesImpl::ExpireBrokenAlternateProtocolMappings() {
base::TimeTicks now = base::TimeTicks::Now();
while (!broken_alternate_protocol_list_.empty()) {
- BrokenAlternateProtocolEntry entry =
+ BrokenAlternateProtocolEntryWithTime entry_with_time =
broken_alternate_protocol_list_.front();
- if (now < entry.when) {
+ if (now < entry_with_time.when) {
break;
}
+ const BrokenAlternateProtocolEntry& entry =
+ entry_with_time.broken_alternate_protocol_entry;
ClearAlternateProtocol(entry.server);
broken_alternate_protocol_list_.pop_front();
}
diff --git a/net/http/http_server_properties_impl.h b/net/http/http_server_properties_impl.h
index 0af32db..5c84226 100644
--- a/net/http/http_server_properties_impl.h
+++ b/net/http/http_server_properties_impl.h
@@ -5,6 +5,7 @@
#ifndef NET_HTTP_HTTP_SERVER_PROPERTIES_IMPL_H_
#define NET_HTTP_HTTP_SERVER_PROPERTIES_IMPL_H_
+#include <deque>
#include <map>
#include <set>
#include <string>
@@ -115,16 +116,48 @@ class NET_EXPORT HttpServerPropertiesImpl
typedef std::map<HostPortPair, HostPortPair> CanonicalHostMap;
typedef std::vector<std::string> CanonicalSufficList;
typedef std::set<HostPortPair> Http11ServerHostPortSet;
- // List of broken host:ports and the times when they can be expired.
+
+ // Server, port, and AlternateProtocol: an entity that can be broken. (Once
+ // we use AlternativeService, the same AltSvc can be broken for one server but
+ // not for another depending on what certificate it can offer.)
struct BrokenAlternateProtocolEntry {
+ BrokenAlternateProtocolEntry(const BrokenAlternateProtocolEntry&) = default;
+ BrokenAlternateProtocolEntry(const HostPortPair& server,
+ uint16 port,
+ AlternateProtocol protocol)
+ : server(server), port(port), protocol(protocol) {}
+
+ bool operator<(const BrokenAlternateProtocolEntry& other) const {
+ if (!server.Equals(other.server))
+ return server < other.server;
+ if (port != other.port)
+ return port < other.port;
+ return protocol < other.protocol;
+ }
+
HostPortPair server;
+ uint16 port;
+ AlternateProtocol protocol;
+ };
+ // BrokenAlternateProtocolEntry with expiration time.
+ struct BrokenAlternateProtocolEntryWithTime {
+ BrokenAlternateProtocolEntryWithTime(
+ const BrokenAlternateProtocolEntry& broken_alternate_protocol_entry,
+ base::TimeTicks when)
+ : broken_alternate_protocol_entry(broken_alternate_protocol_entry),
+ when(when) {}
+
+ BrokenAlternateProtocolEntry broken_alternate_protocol_entry;
base::TimeTicks when;
};
- typedef std::list<BrokenAlternateProtocolEntry>
+ // Deque of BrokenAlternateProtocolEntryWithTime items, ordered by expiration
+ // time.
+ typedef std::deque<BrokenAlternateProtocolEntryWithTime>
BrokenAlternateProtocolList;
- // Map from host:port to the number of times alternate protocol has
- // been marked broken.
- typedef std::map<HostPortPair, int> BrokenAlternateProtocolMap;
+ // Map from (server, alternate protocol and port) to the number of
+ // times that alternate protocol has been marked broken for that server.
+ typedef std::map<BrokenAlternateProtocolEntry, int>
+ BrokenAlternateProtocolMap;
// Return the iterator for |server|, or for its canonical host, or end.
AlternateProtocolMap::const_iterator GetAlternateProtocolIterator(