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

Unified Diff: net/http/http_server_properties_impl.h

Issue 2898983006: Fix and refactor HttpServerPropertiesImpl's alternative services brokenness expiration behavior (Closed)
Patch Set: Fixed some mistakes in unit-test code Created 3 years, 7 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
Index: net/http/http_server_properties_impl.h
diff --git a/net/http/http_server_properties_impl.h b/net/http/http_server_properties_impl.h
index b483bb296b1f73898f5bf47b536a5f13f064f917..4bdad57bdcb1c3d919b88ad570a61153dffeca32 100644
--- a/net/http/http_server_properties_impl.h
+++ b/net/http/http_server_properties_impl.h
@@ -22,6 +22,7 @@
#include "net/base/ip_address.h"
#include "net/base/linked_hash_map.h"
#include "net/base/net_export.h"
+#include "net/http/broken_alternative_services.h"
#include "net/http/http_server_properties.h"
namespace base {
@@ -30,18 +31,14 @@ class ListValue;
namespace net {
-struct AlternativeServiceHash {
- size_t operator()(const net::AlternativeService& entry) const {
- return entry.protocol ^ std::hash<std::string>()(entry.host) ^ entry.port;
- }
-};
-
// The implementation for setting/retrieving the HTTP server properties.
class NET_EXPORT HttpServerPropertiesImpl
: public HttpServerProperties,
+ public BrokenAlternativeServices::Delegate,
NON_EXPORTED_BASE(public base::NonThreadSafe) {
public:
HttpServerPropertiesImpl();
+ explicit HttpServerPropertiesImpl(BrokenAlternativeServices::Clock* clock);
~HttpServerPropertiesImpl() override;
// Sets |spdy_servers_map_| with the servers (host/port) from
@@ -122,7 +119,13 @@ class NET_EXPORT HttpServerPropertiesImpl
size_t max_server_configs_stored_in_properties) override;
bool IsInitialized() const override;
+ // BrokenAlternativeServices::Delegate method
+ void OnExpireBrokenAlternativeService(
+ const AlternativeService& expired_alternative_service) override;
+
private:
+ // TODO (wangyix): modify HttpServerPropertiesImpl unit tests so this
+ // friendness is no longer required.
friend class HttpServerPropertiesImplPeer;
// |spdy_servers_map_| has flattened representation of servers
@@ -132,14 +135,6 @@ class NET_EXPORT HttpServerPropertiesImpl
typedef std::vector<std::string> CanonicalSufficList;
typedef std::set<HostPortPair> Http11ServerHostPortSet;
- // Linked hash map from AlternativeService to expiration time. This container
- // is a queue with O(1) enqueue and dequeue, and a hash_map with O(1) lookup
- // at the same time.
- typedef linked_hash_map<AlternativeService,
- base::TimeTicks,
- AlternativeServiceHash>
- BrokenAlternativeServices;
-
// Return the iterator for |server|, or for its canonical host, or end.
AlternativeServiceMap::const_iterator GetAlternateProtocolIterator(
const url::SchemeHostPort& server);
@@ -150,17 +145,13 @@ class NET_EXPORT HttpServerPropertiesImpl
// Remove the cononical host for |server|.
void RemoveCanonicalHost(const url::SchemeHostPort& server);
- void ExpireBrokenAlternateProtocolMappings();
- void ScheduleBrokenAlternateProtocolMappingsExpiration();
+
+ BrokenAlternativeServices broken_alternative_services_;
SpdyServersMap spdy_servers_map_;
Http11ServerHostPortSet http11_servers_;
AlternativeServiceMap alternative_service_map_;
- BrokenAlternativeServices broken_alternative_services_;
- // Class invariant: Every alternative service in broken_alternative_services_
- // must also be in recently_broken_alternative_services_.
- RecentlyBrokenAlternativeServices recently_broken_alternative_services_;
IPAddress last_quic_address_;
ServerNetworkStatsMap server_network_stats_map_;
@@ -175,8 +166,6 @@ class NET_EXPORT HttpServerPropertiesImpl
QuicServerInfoMap quic_server_info_map_;
size_t max_server_configs_stored_in_properties_;
- base::WeakPtrFactory<HttpServerPropertiesImpl> weak_ptr_factory_;
-
DISALLOW_COPY_AND_ASSIGN(HttpServerPropertiesImpl);
};

Powered by Google App Engine
This is Rietveld 408576698