| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef NET_HTTP_HTTP_SERVER_PROPERTIES_IMPL_H_ | 5 #ifndef NET_HTTP_HTTP_SERVER_PROPERTIES_IMPL_H_ |
| 6 #define NET_HTTP_HTTP_SERVER_PROPERTIES_IMPL_H_ | 6 #define NET_HTTP_HTTP_SERVER_PROPERTIES_IMPL_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 } | 23 } |
| 24 | 24 |
| 25 namespace net { | 25 namespace net { |
| 26 | 26 |
| 27 // The implementation for setting/retrieving the HTTP server properties. | 27 // The implementation for setting/retrieving the HTTP server properties. |
| 28 class NET_EXPORT HttpServerPropertiesImpl | 28 class NET_EXPORT HttpServerPropertiesImpl |
| 29 : public HttpServerProperties, | 29 : public HttpServerProperties, |
| 30 NON_EXPORTED_BASE(public base::NonThreadSafe) { | 30 NON_EXPORTED_BASE(public base::NonThreadSafe) { |
| 31 public: | 31 public: |
| 32 HttpServerPropertiesImpl(); | 32 HttpServerPropertiesImpl(); |
| 33 virtual ~HttpServerPropertiesImpl(); | 33 ~HttpServerPropertiesImpl() override; |
| 34 | 34 |
| 35 // Initializes |spdy_servers_map_| with the servers (host/port) from | 35 // Initializes |spdy_servers_map_| with the servers (host/port) from |
| 36 // |spdy_servers| that either support SPDY or not. | 36 // |spdy_servers| that either support SPDY or not. |
| 37 void InitializeSpdyServers(std::vector<std::string>* spdy_servers, | 37 void InitializeSpdyServers(std::vector<std::string>* spdy_servers, |
| 38 bool support_spdy); | 38 bool support_spdy); |
| 39 | 39 |
| 40 void InitializeAlternateProtocolServers( | 40 void InitializeAlternateProtocolServers( |
| 41 AlternateProtocolMap* alternate_protocol_servers); | 41 AlternateProtocolMap* alternate_protocol_servers); |
| 42 | 42 |
| 43 void InitializeSpdySettingsServers(SpdySettingsMap* spdy_settings_map); | 43 void InitializeSpdySettingsServers(SpdySettingsMap* spdy_settings_map); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 62 | 62 |
| 63 // Returns the canonical host suffix for |server|, or std::string() if none | 63 // Returns the canonical host suffix for |server|, or std::string() if none |
| 64 // exists. | 64 // exists. |
| 65 std::string GetCanonicalSuffix(const net::HostPortPair& server); | 65 std::string GetCanonicalSuffix(const net::HostPortPair& server); |
| 66 | 66 |
| 67 // ----------------------------- | 67 // ----------------------------- |
| 68 // HttpServerProperties methods: | 68 // HttpServerProperties methods: |
| 69 // ----------------------------- | 69 // ----------------------------- |
| 70 | 70 |
| 71 // Gets a weak pointer for this object. | 71 // Gets a weak pointer for this object. |
| 72 virtual base::WeakPtr<HttpServerProperties> GetWeakPtr() override; | 72 base::WeakPtr<HttpServerProperties> GetWeakPtr() override; |
| 73 | 73 |
| 74 // Deletes all data. | 74 // Deletes all data. |
| 75 virtual void Clear() override; | 75 void Clear() override; |
| 76 | 76 |
| 77 // Returns true if |server| supports SPDY. | 77 // Returns true if |server| supports SPDY. |
| 78 virtual bool SupportsSpdy(const HostPortPair& server) override; | 78 bool SupportsSpdy(const HostPortPair& server) override; |
| 79 | 79 |
| 80 // Add |server| into the persistent store. | 80 // Add |server| into the persistent store. |
| 81 virtual void SetSupportsSpdy(const HostPortPair& server, | 81 void SetSupportsSpdy(const HostPortPair& server, bool support_spdy) override; |
| 82 bool support_spdy) override; | |
| 83 | 82 |
| 84 // Returns true if |server| has an Alternate-Protocol header. | 83 // Returns true if |server| has an Alternate-Protocol header. |
| 85 virtual bool HasAlternateProtocol(const HostPortPair& server) override; | 84 bool HasAlternateProtocol(const HostPortPair& server) override; |
| 86 | 85 |
| 87 // Returns the Alternate-Protocol and port for |server|. | 86 // Returns the Alternate-Protocol and port for |server|. |
| 88 // HasAlternateProtocol(server) must be true. | 87 // HasAlternateProtocol(server) must be true. |
| 89 virtual AlternateProtocolInfo GetAlternateProtocol( | 88 AlternateProtocolInfo GetAlternateProtocol( |
| 90 const HostPortPair& server) override; | 89 const HostPortPair& server) override; |
| 91 | 90 |
| 92 // Sets the Alternate-Protocol for |server|. | 91 // Sets the Alternate-Protocol for |server|. |
| 93 virtual void SetAlternateProtocol( | 92 void SetAlternateProtocol(const HostPortPair& server, |
| 94 const HostPortPair& server, | 93 uint16 alternate_port, |
| 95 uint16 alternate_port, | 94 AlternateProtocol alternate_protocol, |
| 96 AlternateProtocol alternate_protocol, | 95 double probability) override; |
| 97 double probability) override; | |
| 98 | 96 |
| 99 // Sets the Alternate-Protocol for |server| to be BROKEN. | 97 // Sets the Alternate-Protocol for |server| to be BROKEN. |
| 100 virtual void SetBrokenAlternateProtocol(const HostPortPair& server) override; | 98 void SetBrokenAlternateProtocol(const HostPortPair& server) override; |
| 101 | 99 |
| 102 // Returns true if Alternate-Protocol for |server| was recently BROKEN. | 100 // Returns true if Alternate-Protocol for |server| was recently BROKEN. |
| 103 virtual bool WasAlternateProtocolRecentlyBroken( | 101 bool WasAlternateProtocolRecentlyBroken(const HostPortPair& server) override; |
| 104 const HostPortPair& server) override; | |
| 105 | 102 |
| 106 // Confirms that Alternate-Protocol for |server| is working. | 103 // Confirms that Alternate-Protocol for |server| is working. |
| 107 virtual void ConfirmAlternateProtocol(const HostPortPair& server) override; | 104 void ConfirmAlternateProtocol(const HostPortPair& server) override; |
| 108 | 105 |
| 109 // Clears the Alternate-Protocol for |server|. | 106 // Clears the Alternate-Protocol for |server|. |
| 110 virtual void ClearAlternateProtocol(const HostPortPair& server) override; | 107 void ClearAlternateProtocol(const HostPortPair& server) override; |
| 111 | 108 |
| 112 // Returns all Alternate-Protocol mappings. | 109 // Returns all Alternate-Protocol mappings. |
| 113 virtual const AlternateProtocolMap& alternate_protocol_map() const override; | 110 const AlternateProtocolMap& alternate_protocol_map() const override; |
| 114 | 111 |
| 115 virtual void SetAlternateProtocolExperiment( | 112 void SetAlternateProtocolExperiment( |
| 116 AlternateProtocolExperiment experiment) override; | 113 AlternateProtocolExperiment experiment) override; |
| 117 | 114 |
| 118 virtual void SetAlternateProtocolProbabilityThreshold( | 115 void SetAlternateProtocolProbabilityThreshold(double threshold) override; |
| 119 double threshold) override; | |
| 120 | 116 |
| 121 virtual AlternateProtocolExperiment GetAlternateProtocolExperiment() | 117 AlternateProtocolExperiment GetAlternateProtocolExperiment() const override; |
| 122 const override; | |
| 123 | 118 |
| 124 // Gets a reference to the SettingsMap stored for a host. | 119 // Gets a reference to the SettingsMap stored for a host. |
| 125 // If no settings are stored, returns an empty SettingsMap. | 120 // If no settings are stored, returns an empty SettingsMap. |
| 126 virtual const SettingsMap& GetSpdySettings( | 121 const SettingsMap& GetSpdySettings( |
| 127 const HostPortPair& host_port_pair) override; | 122 const HostPortPair& host_port_pair) override; |
| 128 | 123 |
| 129 // Saves an individual SPDY setting for a host. Returns true if SPDY setting | 124 // Saves an individual SPDY setting for a host. Returns true if SPDY setting |
| 130 // is to be persisted. | 125 // is to be persisted. |
| 131 virtual bool SetSpdySetting(const HostPortPair& host_port_pair, | 126 bool SetSpdySetting(const HostPortPair& host_port_pair, |
| 132 SpdySettingsIds id, | 127 SpdySettingsIds id, |
| 133 SpdySettingsFlags flags, | 128 SpdySettingsFlags flags, |
| 134 uint32 value) override; | 129 uint32 value) override; |
| 135 | 130 |
| 136 // Clears all entries in |spdy_settings_map_| for a host. | 131 // Clears all entries in |spdy_settings_map_| for a host. |
| 137 virtual void ClearSpdySettings(const HostPortPair& host_port_pair) override; | 132 void ClearSpdySettings(const HostPortPair& host_port_pair) override; |
| 138 | 133 |
| 139 // Clears all entries in |spdy_settings_map_|. | 134 // Clears all entries in |spdy_settings_map_|. |
| 140 virtual void ClearAllSpdySettings() override; | 135 void ClearAllSpdySettings() override; |
| 141 | 136 |
| 142 // Returns all persistent SPDY settings. | 137 // Returns all persistent SPDY settings. |
| 143 virtual const SpdySettingsMap& spdy_settings_map() const override; | 138 const SpdySettingsMap& spdy_settings_map() const override; |
| 144 | 139 |
| 145 // Methods for SupportsQuic. | 140 // Methods for SupportsQuic. |
| 146 virtual SupportsQuic GetSupportsQuic( | 141 SupportsQuic GetSupportsQuic( |
| 147 const HostPortPair& host_port_pair) const override; | 142 const HostPortPair& host_port_pair) const override; |
| 148 | 143 |
| 149 virtual void SetSupportsQuic(const HostPortPair& host_port_pair, | 144 void SetSupportsQuic(const HostPortPair& host_port_pair, |
| 150 bool used_quic, | 145 bool used_quic, |
| 151 const std::string& address) override; | 146 const std::string& address) override; |
| 152 | 147 |
| 153 virtual const SupportsQuicMap& supports_quic_map() const override; | 148 const SupportsQuicMap& supports_quic_map() const override; |
| 154 | 149 |
| 155 // Methods for NetworkStats. | 150 // Methods for NetworkStats. |
| 156 virtual void SetServerNetworkStats(const HostPortPair& host_port_pair, | 151 void SetServerNetworkStats(const HostPortPair& host_port_pair, |
| 157 NetworkStats stats) override; | 152 NetworkStats stats) override; |
| 158 | 153 |
| 159 virtual const NetworkStats* GetServerNetworkStats( | 154 const NetworkStats* GetServerNetworkStats( |
| 160 const HostPortPair& host_port_pair) const override; | 155 const HostPortPair& host_port_pair) const override; |
| 161 | 156 |
| 162 private: | 157 private: |
| 163 // |spdy_servers_map_| has flattened representation of servers (host, port) | 158 // |spdy_servers_map_| has flattened representation of servers (host, port) |
| 164 // that either support or not support SPDY protocol. | 159 // that either support or not support SPDY protocol. |
| 165 typedef base::MRUCache<std::string, bool> SpdyServerHostPortMap; | 160 typedef base::MRUCache<std::string, bool> SpdyServerHostPortMap; |
| 166 typedef std::map<HostPortPair, NetworkStats> ServerNetworkStatsMap; | 161 typedef std::map<HostPortPair, NetworkStats> ServerNetworkStatsMap; |
| 167 typedef std::map<HostPortPair, HostPortPair> CanonicalHostMap; | 162 typedef std::map<HostPortPair, HostPortPair> CanonicalHostMap; |
| 168 typedef std::vector<std::string> CanonicalSufficList; | 163 typedef std::vector<std::string> CanonicalSufficList; |
| 169 // List of broken host:ports and the times when they can be expired. | 164 // List of broken host:ports and the times when they can be expired. |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 double alternate_protocol_probability_threshold_; | 200 double alternate_protocol_probability_threshold_; |
| 206 | 201 |
| 207 base::WeakPtrFactory<HttpServerPropertiesImpl> weak_ptr_factory_; | 202 base::WeakPtrFactory<HttpServerPropertiesImpl> weak_ptr_factory_; |
| 208 | 203 |
| 209 DISALLOW_COPY_AND_ASSIGN(HttpServerPropertiesImpl); | 204 DISALLOW_COPY_AND_ASSIGN(HttpServerPropertiesImpl); |
| 210 }; | 205 }; |
| 211 | 206 |
| 212 } // namespace net | 207 } // namespace net |
| 213 | 208 |
| 214 #endif // NET_HTTP_HTTP_SERVER_PROPERTIES_IMPL_H_ | 209 #endif // NET_HTTP_HTTP_SERVER_PROPERTIES_IMPL_H_ |
| OLD | NEW |