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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 void SetAlternateProtocolProbabilityThreshold(double threshold) override; | 100 void SetAlternateProtocolProbabilityThreshold(double threshold) override; |
101 const SettingsMap& GetSpdySettings( | 101 const SettingsMap& GetSpdySettings( |
102 const HostPortPair& host_port_pair) override; | 102 const HostPortPair& host_port_pair) override; |
103 bool SetSpdySetting(const HostPortPair& host_port_pair, | 103 bool SetSpdySetting(const HostPortPair& host_port_pair, |
104 SpdySettingsIds id, | 104 SpdySettingsIds id, |
105 SpdySettingsFlags flags, | 105 SpdySettingsFlags flags, |
106 uint32 value) override; | 106 uint32 value) override; |
107 void ClearSpdySettings(const HostPortPair& host_port_pair) override; | 107 void ClearSpdySettings(const HostPortPair& host_port_pair) override; |
108 void ClearAllSpdySettings() override; | 108 void ClearAllSpdySettings() override; |
109 const SpdySettingsMap& spdy_settings_map() const override; | 109 const SpdySettingsMap& spdy_settings_map() const override; |
110 SupportsQuic GetSupportsQuic( | 110 bool GetSupportsQuic(IPAddressNumber* last_address) const override; |
111 const HostPortPair& host_port_pair) const override; | 111 void SetSupportsQuic(bool used_quic, |
112 void SetSupportsQuic(const HostPortPair& host_port_pair, | 112 const IPAddressNumber& last_address) override; |
113 bool used_quic, | |
114 const std::string& address) override; | |
115 const SupportsQuicMap& supports_quic_map() const override; | |
116 void SetServerNetworkStats(const HostPortPair& host_port_pair, | 113 void SetServerNetworkStats(const HostPortPair& host_port_pair, |
117 ServerNetworkStats stats) override; | 114 ServerNetworkStats stats) override; |
118 const ServerNetworkStats* GetServerNetworkStats( | 115 const ServerNetworkStats* GetServerNetworkStats( |
119 const HostPortPair& host_port_pair) override; | 116 const HostPortPair& host_port_pair) override; |
120 const ServerNetworkStatsMap& server_network_stats_map() const override; | 117 const ServerNetworkStatsMap& server_network_stats_map() const override; |
121 | 118 |
122 protected: | 119 protected: |
123 // -------------------- | 120 // -------------------- |
124 // SPDY related methods | 121 // SPDY related methods |
125 | 122 |
(...skipping 11 matching lines...) Expand all Loading... |
137 // UpdateSpdyServersFromPrefsOnNetworkThread() to perform the update on | 134 // UpdateSpdyServersFromPrefsOnNetworkThread() to perform the update on |
138 // network thread. | 135 // network thread. |
139 virtual void UpdateCacheFromPrefsOnPrefThread(); | 136 virtual void UpdateCacheFromPrefsOnPrefThread(); |
140 | 137 |
141 // Starts the update of cached prefs in |http_server_properties_impl_| on the | 138 // Starts the update of cached prefs in |http_server_properties_impl_| on the |
142 // network thread. Protected for testing. | 139 // network thread. Protected for testing. |
143 void UpdateCacheFromPrefsOnNetworkThread( | 140 void UpdateCacheFromPrefsOnNetworkThread( |
144 std::vector<std::string>* spdy_servers, | 141 std::vector<std::string>* spdy_servers, |
145 SpdySettingsMap* spdy_settings_map, | 142 SpdySettingsMap* spdy_settings_map, |
146 AlternateProtocolMap* alternate_protocol_map, | 143 AlternateProtocolMap* alternate_protocol_map, |
147 SupportsQuicMap* supports_quic_map, | 144 IPAddressNumber* last_quic_address, |
148 ServerNetworkStatsMap* server_network_stats_map, | 145 ServerNetworkStatsMap* server_network_stats_map, |
149 bool detected_corrupted_prefs); | 146 bool detected_corrupted_prefs); |
150 | 147 |
151 // These are used to delay updating the preferences when cached data in | 148 // These are used to delay updating the preferences when cached data in |
152 // |http_server_properties_impl_| is changing, and execute only one update per | 149 // |http_server_properties_impl_| is changing, and execute only one update per |
153 // simultaneous spdy_servers or spdy_settings or alternate_protocol changes. | 150 // simultaneous spdy_servers or spdy_settings or alternate_protocol changes. |
154 void ScheduleUpdatePrefsOnNetworkThread(); | 151 void ScheduleUpdatePrefsOnNetworkThread(); |
155 | 152 |
156 // Starts the timers to update the prefs from cache. This are overridden in | 153 // Starts the timers to update the prefs from cache. This are overridden in |
157 // tests to prevent the delay. | 154 // tests to prevent the delay. |
158 virtual void StartPrefsUpdateTimerOnNetworkThread(base::TimeDelta delay); | 155 virtual void StartPrefsUpdateTimerOnNetworkThread(base::TimeDelta delay); |
159 | 156 |
160 // Update prefs::kHttpServerProperties in preferences with the cached data | 157 // Update prefs::kHttpServerProperties in preferences with the cached data |
161 // from |http_server_properties_impl_|. This gets the data on network thread | 158 // from |http_server_properties_impl_|. This gets the data on network thread |
162 // and posts a task (UpdatePrefsOnPrefThread) to update preferences on pref | 159 // and posts a task (UpdatePrefsOnPrefThread) to update preferences on pref |
163 // thread. | 160 // thread. |
164 void UpdatePrefsFromCacheOnNetworkThread(); | 161 void UpdatePrefsFromCacheOnNetworkThread(); |
165 | 162 |
166 // Same as above, but fires an optional |completion| callback on pref thread | 163 // Same as above, but fires an optional |completion| callback on pref thread |
167 // when finished. Virtual for testing. | 164 // when finished. Virtual for testing. |
168 virtual void UpdatePrefsFromCacheOnNetworkThread( | 165 virtual void UpdatePrefsFromCacheOnNetworkThread( |
169 const base::Closure& completion); | 166 const base::Closure& completion); |
170 | 167 |
171 // Update prefs::kHttpServerProperties preferences on pref thread. Executes an | 168 // Update prefs::kHttpServerProperties preferences on pref thread. Executes an |
172 // optional |completion| callback when finished. Protected for testing. | 169 // optional |completion| callback when finished. Protected for testing. |
173 void UpdatePrefsOnPrefThread(base::ListValue* spdy_server_list, | 170 void UpdatePrefsOnPrefThread(base::ListValue* spdy_server_list, |
174 SpdySettingsMap* spdy_settings_map, | 171 SpdySettingsMap* spdy_settings_map, |
175 AlternateProtocolMap* alternate_protocol_map, | 172 AlternateProtocolMap* alternate_protocol_map, |
176 SupportsQuicMap* supports_quic_map, | 173 IPAddressNumber* last_quic_address, |
177 ServerNetworkStatsMap* server_network_stats_map, | 174 ServerNetworkStatsMap* server_network_stats_map, |
178 const base::Closure& completion); | 175 const base::Closure& completion); |
179 | 176 |
180 private: | 177 private: |
181 void OnHttpServerPropertiesChanged(); | 178 void OnHttpServerPropertiesChanged(); |
182 | 179 |
| 180 bool ReadSupportsQuic(const base::DictionaryValue& server_dict, |
| 181 IPAddressNumber* last_quic_address); |
183 void AddToSpdySettingsMap(const HostPortPair& server, | 182 void AddToSpdySettingsMap(const HostPortPair& server, |
184 const base::DictionaryValue& server_dict, | 183 const base::DictionaryValue& server_dict, |
185 SpdySettingsMap* spdy_settings_map); | 184 SpdySettingsMap* spdy_settings_map); |
186 bool AddToAlternateProtocolMap(const HostPortPair& server, | 185 bool AddToAlternateProtocolMap(const HostPortPair& server, |
187 const base::DictionaryValue& server_dict, | 186 const base::DictionaryValue& server_dict, |
188 AlternateProtocolMap* alternate_protocol_map); | 187 AlternateProtocolMap* alternate_protocol_map); |
189 bool AddToSupportsQuicMap(const HostPortPair& server, | |
190 const base::DictionaryValue& server_dict, | |
191 SupportsQuicMap* supports_quic_map); | |
192 bool AddToNetworkStatsMap(const HostPortPair& server, | 188 bool AddToNetworkStatsMap(const HostPortPair& server, |
193 const base::DictionaryValue& server_dict, | 189 const base::DictionaryValue& server_dict, |
194 ServerNetworkStatsMap* network_stats_map); | 190 ServerNetworkStatsMap* network_stats_map); |
195 | 191 |
196 void SaveSpdySettingsToServerPrefs(const SettingsMap* spdy_settings_map, | 192 void SaveSpdySettingsToServerPrefs(const SettingsMap* spdy_settings_map, |
197 base::DictionaryValue* server_pref_dict); | 193 base::DictionaryValue* server_pref_dict); |
198 void SaveAlternateProtocolToServerPrefs( | 194 void SaveAlternateProtocolToServerPrefs( |
199 const AlternateProtocolInfo* port_alternate_protocol, | 195 const AlternateProtocolInfo* port_alternate_protocol, |
200 base::DictionaryValue* server_pref_dict); | 196 base::DictionaryValue* server_pref_dict); |
201 void SaveSupportsQuicToServerPrefs(const SupportsQuic* supports_quic, | |
202 base::DictionaryValue* server_pref_dict); | |
203 void SaveNetworkStatsToServerPrefs( | 197 void SaveNetworkStatsToServerPrefs( |
204 const ServerNetworkStats* server_network_stats, | 198 const ServerNetworkStats* server_network_stats, |
205 base::DictionaryValue* server_pref_dict); | 199 base::DictionaryValue* server_pref_dict); |
206 | 200 |
| 201 void SaveSupportsQuicToPrefs( |
| 202 const IPAddressNumber* last_quic_address, |
| 203 base::DictionaryValue* http_server_properties_dict); |
| 204 |
207 // ----------- | 205 // ----------- |
208 // Pref thread | 206 // Pref thread |
209 // ----------- | 207 // ----------- |
210 | 208 |
211 const scoped_refptr<base::SequencedTaskRunner> pref_task_runner_; | 209 const scoped_refptr<base::SequencedTaskRunner> pref_task_runner_; |
212 | 210 |
213 base::WeakPtr<HttpServerPropertiesManager> pref_weak_ptr_; | 211 base::WeakPtr<HttpServerPropertiesManager> pref_weak_ptr_; |
214 | 212 |
215 // Used to post cache update tasks. | 213 // Used to post cache update tasks. |
216 scoped_ptr<base::OneShotTimer<HttpServerPropertiesManager> > | 214 scoped_ptr<base::OneShotTimer<HttpServerPropertiesManager> > |
(...skipping 24 matching lines...) Expand all Loading... |
241 // Used to get |weak_ptr_| to self on the network thread. | 239 // Used to get |weak_ptr_| to self on the network thread. |
242 scoped_ptr<base::WeakPtrFactory<HttpServerPropertiesManager> > | 240 scoped_ptr<base::WeakPtrFactory<HttpServerPropertiesManager> > |
243 network_weak_ptr_factory_; | 241 network_weak_ptr_factory_; |
244 | 242 |
245 DISALLOW_COPY_AND_ASSIGN(HttpServerPropertiesManager); | 243 DISALLOW_COPY_AND_ASSIGN(HttpServerPropertiesManager); |
246 }; | 244 }; |
247 | 245 |
248 } // namespace net | 246 } // namespace net |
249 | 247 |
250 #endif // NET_HTTP_HTTP_SERVER_PROPERTIES_MANAGER_H_ | 248 #endif // NET_HTTP_HTTP_SERVER_PROPERTIES_MANAGER_H_ |
OLD | NEW |