| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_MANAGER_H_ | 5 #ifndef NET_HTTP_HTTP_SERVER_PROPERTIES_MANAGER_H_ |
| 6 #define NET_HTTP_HTTP_SERVER_PROPERTIES_MANAGER_H_ | 6 #define NET_HTTP_HTTP_SERVER_PROPERTIES_MANAGER_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 const AlternativeService& alternative_service) override; | 94 const AlternativeService& alternative_service) override; |
| 95 void MarkAlternativeServiceRecentlyBroken( | 95 void MarkAlternativeServiceRecentlyBroken( |
| 96 const AlternativeService& alternative_service) override; | 96 const AlternativeService& alternative_service) override; |
| 97 bool IsAlternativeServiceBroken( | 97 bool IsAlternativeServiceBroken( |
| 98 const AlternativeService& alternative_service) override; | 98 const AlternativeService& alternative_service) override; |
| 99 bool WasAlternativeServiceRecentlyBroken( | 99 bool WasAlternativeServiceRecentlyBroken( |
| 100 const AlternativeService& alternative_service) override; | 100 const AlternativeService& alternative_service) override; |
| 101 void ConfirmAlternativeService( | 101 void ConfirmAlternativeService( |
| 102 const AlternativeService& alternative_service) override; | 102 const AlternativeService& alternative_service) override; |
| 103 void ClearAlternativeService(const HostPortPair& origin) override; | 103 void ClearAlternativeService(const HostPortPair& origin) override; |
| 104 const AlternateProtocolMap& alternate_protocol_map() const override; | 104 const AlternativeServiceMap& alternative_service_map() const override; |
| 105 void SetAlternateProtocolProbabilityThreshold(double threshold) override; | 105 void SetAlternateProtocolProbabilityThreshold(double threshold) override; |
| 106 const SettingsMap& GetSpdySettings( | 106 const SettingsMap& GetSpdySettings( |
| 107 const HostPortPair& host_port_pair) override; | 107 const HostPortPair& host_port_pair) override; |
| 108 bool SetSpdySetting(const HostPortPair& host_port_pair, | 108 bool SetSpdySetting(const HostPortPair& host_port_pair, |
| 109 SpdySettingsIds id, | 109 SpdySettingsIds id, |
| 110 SpdySettingsFlags flags, | 110 SpdySettingsFlags flags, |
| 111 uint32 value) override; | 111 uint32 value) override; |
| 112 void ClearSpdySettings(const HostPortPair& host_port_pair) override; | 112 void ClearSpdySettings(const HostPortPair& host_port_pair) override; |
| 113 void ClearAllSpdySettings() override; | 113 void ClearAllSpdySettings() override; |
| 114 const SpdySettingsMap& spdy_settings_map() const override; | 114 const SpdySettingsMap& spdy_settings_map() const override; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 138 // preferences. It gets the data on pref thread and calls | 138 // preferences. It gets the data on pref thread and calls |
| 139 // UpdateSpdyServersFromPrefsOnNetworkThread() to perform the update on | 139 // UpdateSpdyServersFromPrefsOnNetworkThread() to perform the update on |
| 140 // network thread. | 140 // network thread. |
| 141 virtual void UpdateCacheFromPrefsOnPrefThread(); | 141 virtual void UpdateCacheFromPrefsOnPrefThread(); |
| 142 | 142 |
| 143 // Starts the update of cached prefs in |http_server_properties_impl_| on the | 143 // Starts the update of cached prefs in |http_server_properties_impl_| on the |
| 144 // network thread. Protected for testing. | 144 // network thread. Protected for testing. |
| 145 void UpdateCacheFromPrefsOnNetworkThread( | 145 void UpdateCacheFromPrefsOnNetworkThread( |
| 146 std::vector<std::string>* spdy_servers, | 146 std::vector<std::string>* spdy_servers, |
| 147 SpdySettingsMap* spdy_settings_map, | 147 SpdySettingsMap* spdy_settings_map, |
| 148 AlternateProtocolMap* alternate_protocol_map, | 148 AlternativeServiceMap* alternative_service_map, |
| 149 IPAddressNumber* last_quic_address, | 149 IPAddressNumber* last_quic_address, |
| 150 ServerNetworkStatsMap* server_network_stats_map, | 150 ServerNetworkStatsMap* server_network_stats_map, |
| 151 bool detected_corrupted_prefs); | 151 bool detected_corrupted_prefs); |
| 152 | 152 |
| 153 // These are used to delay updating the preferences when cached data in | 153 // These are used to delay updating the preferences when cached data in |
| 154 // |http_server_properties_impl_| is changing, and execute only one update per | 154 // |http_server_properties_impl_| is changing, and execute only one update per |
| 155 // simultaneous spdy_servers or spdy_settings or alternate_protocol changes. | 155 // simultaneous spdy_servers or spdy_settings or alternative_service changes. |
| 156 void ScheduleUpdatePrefsOnNetworkThread(); | 156 void ScheduleUpdatePrefsOnNetworkThread(); |
| 157 | 157 |
| 158 // Starts the timers to update the prefs from cache. This are overridden in | 158 // Starts the timers to update the prefs from cache. This are overridden in |
| 159 // tests to prevent the delay. | 159 // tests to prevent the delay. |
| 160 virtual void StartPrefsUpdateTimerOnNetworkThread(base::TimeDelta delay); | 160 virtual void StartPrefsUpdateTimerOnNetworkThread(base::TimeDelta delay); |
| 161 | 161 |
| 162 // Update prefs::kHttpServerProperties in preferences with the cached data | 162 // Update prefs::kHttpServerProperties in preferences with the cached data |
| 163 // from |http_server_properties_impl_|. This gets the data on network thread | 163 // from |http_server_properties_impl_|. This gets the data on network thread |
| 164 // and posts a task (UpdatePrefsOnPrefThread) to update preferences on pref | 164 // and posts a task (UpdatePrefsOnPrefThread) to update preferences on pref |
| 165 // thread. | 165 // thread. |
| 166 void UpdatePrefsFromCacheOnNetworkThread(); | 166 void UpdatePrefsFromCacheOnNetworkThread(); |
| 167 | 167 |
| 168 // Same as above, but fires an optional |completion| callback on pref thread | 168 // Same as above, but fires an optional |completion| callback on pref thread |
| 169 // when finished. Virtual for testing. | 169 // when finished. Virtual for testing. |
| 170 virtual void UpdatePrefsFromCacheOnNetworkThread( | 170 virtual void UpdatePrefsFromCacheOnNetworkThread( |
| 171 const base::Closure& completion); | 171 const base::Closure& completion); |
| 172 | 172 |
| 173 // Update prefs::kHttpServerProperties preferences on pref thread. Executes an | 173 // Update prefs::kHttpServerProperties preferences on pref thread. Executes an |
| 174 // optional |completion| callback when finished. Protected for testing. | 174 // optional |completion| callback when finished. Protected for testing. |
| 175 void UpdatePrefsOnPrefThread(base::ListValue* spdy_server_list, | 175 void UpdatePrefsOnPrefThread(base::ListValue* spdy_server_list, |
| 176 SpdySettingsMap* spdy_settings_map, | 176 SpdySettingsMap* spdy_settings_map, |
| 177 AlternateProtocolMap* alternate_protocol_map, | 177 AlternativeServiceMap* alternative_service_map, |
| 178 IPAddressNumber* last_quic_address, | 178 IPAddressNumber* last_quic_address, |
| 179 ServerNetworkStatsMap* server_network_stats_map, | 179 ServerNetworkStatsMap* server_network_stats_map, |
| 180 const base::Closure& completion); | 180 const base::Closure& completion); |
| 181 | 181 |
| 182 private: | 182 private: |
| 183 void OnHttpServerPropertiesChanged(); | 183 void OnHttpServerPropertiesChanged(); |
| 184 | 184 |
| 185 bool ReadSupportsQuic(const base::DictionaryValue& server_dict, | 185 bool ReadSupportsQuic(const base::DictionaryValue& server_dict, |
| 186 IPAddressNumber* last_quic_address); | 186 IPAddressNumber* last_quic_address); |
| 187 void AddToSpdySettingsMap(const HostPortPair& server, | 187 void AddToSpdySettingsMap(const HostPortPair& server, |
| 188 const base::DictionaryValue& server_dict, | 188 const base::DictionaryValue& server_dict, |
| 189 SpdySettingsMap* spdy_settings_map); | 189 SpdySettingsMap* spdy_settings_map); |
| 190 AlternateProtocolInfo ParseAlternateProtocolDict( | 190 AlternativeServiceInfo ParseAlternativeServiceDict( |
| 191 const base::DictionaryValue& alternate_protocol_dict, | 191 const base::DictionaryValue& alternative_service_dict, |
| 192 const std::string& server_str); | 192 const std::string& server_str); |
| 193 bool AddToAlternateProtocolMap(const HostPortPair& server, | 193 bool AddToAlternativeServiceMap( |
| 194 const base::DictionaryValue& server_dict, | 194 const HostPortPair& server, |
| 195 AlternateProtocolMap* alternate_protocol_map); | 195 const base::DictionaryValue& server_dict, |
| 196 AlternativeServiceMap* alternative_service_map); |
| 196 bool AddToNetworkStatsMap(const HostPortPair& server, | 197 bool AddToNetworkStatsMap(const HostPortPair& server, |
| 197 const base::DictionaryValue& server_dict, | 198 const base::DictionaryValue& server_dict, |
| 198 ServerNetworkStatsMap* network_stats_map); | 199 ServerNetworkStatsMap* network_stats_map); |
| 199 | 200 |
| 200 void SaveSpdySettingsToServerPrefs(const SettingsMap* spdy_settings_map, | 201 void SaveSpdySettingsToServerPrefs(const SettingsMap* spdy_settings_map, |
| 201 base::DictionaryValue* server_pref_dict); | 202 base::DictionaryValue* server_pref_dict); |
| 202 void SaveAlternateProtocolToServerPrefs( | 203 void SaveAlternativeServiceToServerPrefs( |
| 203 const AlternateProtocolInfo* port_alternate_protocol, | 204 const AlternativeServiceInfo* alternative_service_info, |
| 204 base::DictionaryValue* server_pref_dict); | 205 base::DictionaryValue* server_pref_dict); |
| 205 void SaveNetworkStatsToServerPrefs( | 206 void SaveNetworkStatsToServerPrefs( |
| 206 const ServerNetworkStats* server_network_stats, | 207 const ServerNetworkStats* server_network_stats, |
| 207 base::DictionaryValue* server_pref_dict); | 208 base::DictionaryValue* server_pref_dict); |
| 208 | 209 |
| 209 void SaveSupportsQuicToPrefs( | 210 void SaveSupportsQuicToPrefs( |
| 210 const IPAddressNumber* last_quic_address, | 211 const IPAddressNumber* last_quic_address, |
| 211 base::DictionaryValue* http_server_properties_dict); | 212 base::DictionaryValue* http_server_properties_dict); |
| 212 | 213 |
| 213 // ----------- | 214 // ----------- |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 247 // Used to get |weak_ptr_| to self on the network thread. | 248 // Used to get |weak_ptr_| to self on the network thread. |
| 248 scoped_ptr<base::WeakPtrFactory<HttpServerPropertiesManager> > | 249 scoped_ptr<base::WeakPtrFactory<HttpServerPropertiesManager> > |
| 249 network_weak_ptr_factory_; | 250 network_weak_ptr_factory_; |
| 250 | 251 |
| 251 DISALLOW_COPY_AND_ASSIGN(HttpServerPropertiesManager); | 252 DISALLOW_COPY_AND_ASSIGN(HttpServerPropertiesManager); |
| 252 }; | 253 }; |
| 253 | 254 |
| 254 } // namespace net | 255 } // namespace net |
| 255 | 256 |
| 256 #endif // NET_HTTP_HTTP_SERVER_PROPERTIES_MANAGER_H_ | 257 #endif // NET_HTTP_HTTP_SERVER_PROPERTIES_MANAGER_H_ |
| OLD | NEW |