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 #include "chrome/browser/net/http_server_properties_manager.h" | 4 #include "chrome/browser/net/http_server_properties_manager.h" |
5 | 5 |
6 #include "base/bind.h" | 6 #include "base/bind.h" |
7 #include "base/stl_util.h" | 7 #include "base/stl_util.h" |
8 #include "base/values.h" | 8 #include "base/values.h" |
9 #include "chrome/browser/prefs/pref_service.h" | 9 #include "chrome/browser/prefs/pref_service.h" |
10 #include "chrome/common/chrome_notification_types.h" | 10 #include "chrome/common/chrome_notification_types.h" |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 const net::HostPortPair& host_port_pair, | 152 const net::HostPortPair& host_port_pair, |
153 const spdy::SpdySettings& settings) { | 153 const spdy::SpdySettings& settings) { |
154 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 154 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
155 bool persist = http_server_properties_impl_->SetSpdySettings( | 155 bool persist = http_server_properties_impl_->SetSpdySettings( |
156 host_port_pair, settings); | 156 host_port_pair, settings); |
157 if (persist) | 157 if (persist) |
158 ScheduleUpdatePrefsOnIO(); | 158 ScheduleUpdatePrefsOnIO(); |
159 return persist; | 159 return persist; |
160 } | 160 } |
161 | 161 |
| 162 bool HttpServerPropertiesManager::SetSpdySetting( |
| 163 const net::HostPortPair& host_port_pair, |
| 164 const spdy::SpdySetting& setting) { |
| 165 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 166 bool persist = http_server_properties_impl_->SetSpdySetting( |
| 167 host_port_pair, setting); |
| 168 if (persist) |
| 169 ScheduleUpdatePrefsOnIO(); |
| 170 return persist; |
| 171 } |
| 172 |
162 void HttpServerPropertiesManager::ClearSpdySettings() { | 173 void HttpServerPropertiesManager::ClearSpdySettings() { |
163 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 174 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
164 http_server_properties_impl_->ClearSpdySettings(); | 175 http_server_properties_impl_->ClearSpdySettings(); |
165 ScheduleUpdatePrefsOnIO(); | 176 ScheduleUpdatePrefsOnIO(); |
166 } | 177 } |
167 | 178 |
168 const net::SpdySettingsMap& | 179 const net::SpdySettingsMap& |
169 HttpServerPropertiesManager::spdy_settings_map() const { | 180 HttpServerPropertiesManager::spdy_settings_map() const { |
170 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 181 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
171 return http_server_properties_impl_->spdy_settings_map(); | 182 return http_server_properties_impl_->spdy_settings_map(); |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
295 | 306 |
296 int value = 0; | 307 int value = 0; |
297 if (!spdy_setting_dict->GetIntegerWithoutPathExpansion("value", | 308 if (!spdy_setting_dict->GetIntegerWithoutPathExpansion("value", |
298 &value)) { | 309 &value)) { |
299 DVLOG(1) << "Malformed value in SpdySettings for server: " << | 310 DVLOG(1) << "Malformed value in SpdySettings for server: " << |
300 server_str; | 311 server_str; |
301 detected_corrupted_prefs = true; | 312 detected_corrupted_prefs = true; |
302 continue; | 313 continue; |
303 } | 314 } |
304 | 315 |
305 spdy::SettingsFlagsAndId flags_and_id(0); | 316 spdy::SettingsFlagsAndId flags_and_id( |
306 flags_and_id.set_id(id); | 317 spdy::SETTINGS_FLAG_PERSISTED, id); |
307 flags_and_id.set_flags(spdy::SETTINGS_FLAG_PERSISTED); | |
308 | |
309 spdy_settings.push_back(spdy::SpdySetting(flags_and_id, value)); | 318 spdy_settings.push_back(spdy::SpdySetting(flags_and_id, value)); |
310 } | 319 } |
311 | 320 |
312 (*spdy_settings_map)[server] = spdy_settings; | 321 (*spdy_settings_map)[server] = spdy_settings; |
313 } | 322 } |
314 | 323 |
315 int pipeline_capability = net::PIPELINE_UNKNOWN; | 324 int pipeline_capability = net::PIPELINE_UNKNOWN; |
316 if ((server_pref_dict->GetInteger( | 325 if ((server_pref_dict->GetInteger( |
317 "pipeline_capability", &pipeline_capability)) && | 326 "pipeline_capability", &pipeline_capability)) && |
318 pipeline_capability != net::PIPELINE_UNKNOWN) { | 327 pipeline_capability != net::PIPELINE_UNKNOWN) { |
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
622 std::string* pref_name = content::Details<std::string>(details).ptr(); | 631 std::string* pref_name = content::Details<std::string>(details).ptr(); |
623 if (*pref_name == prefs::kHttpServerProperties) { | 632 if (*pref_name == prefs::kHttpServerProperties) { |
624 if (!setting_prefs_) | 633 if (!setting_prefs_) |
625 ScheduleUpdateCacheOnUI(); | 634 ScheduleUpdateCacheOnUI(); |
626 } else { | 635 } else { |
627 NOTREACHED(); | 636 NOTREACHED(); |
628 } | 637 } |
629 } | 638 } |
630 | 639 |
631 } // namespace chrome_browser_net | 640 } // namespace chrome_browser_net |
OLD | NEW |