OLD | NEW |
1 // Copyright (c) 2011 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 #include "net/http/http_server_properties_impl.h" | 5 #include "net/http/http_server_properties_impl.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
10 #include "base/stringprintf.h" | 10 #include "base/stringprintf.h" |
11 #include "net/http/http_pipelined_host_capability.h" | 11 #include "net/http/http_pipelined_host_capability.h" |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 const HostPortPair& host_port_pair, | 234 const HostPortPair& host_port_pair, |
235 const spdy::SpdySettings& settings) { | 235 const spdy::SpdySettings& settings) { |
236 spdy::SpdySettings persistent_settings; | 236 spdy::SpdySettings persistent_settings; |
237 | 237 |
238 // Iterate through the list, and only copy those settings which are marked | 238 // Iterate through the list, and only copy those settings which are marked |
239 // for persistence. | 239 // for persistence. |
240 spdy::SpdySettings::const_iterator it; | 240 spdy::SpdySettings::const_iterator it; |
241 for (it = settings.begin(); it != settings.end(); ++it) { | 241 for (it = settings.begin(); it != settings.end(); ++it) { |
242 spdy::SettingsFlagsAndId id = it->first; | 242 spdy::SettingsFlagsAndId id = it->first; |
243 if (id.flags() & spdy::SETTINGS_FLAG_PLEASE_PERSIST) { | 243 if (id.flags() & spdy::SETTINGS_FLAG_PLEASE_PERSIST) { |
244 id.set_flags(spdy::SETTINGS_FLAG_PERSISTED); | 244 spdy::SettingsFlagsAndId new_id(spdy::SETTINGS_FLAG_PERSISTED, id.id()); |
245 persistent_settings.push_back(std::make_pair(id, it->second)); | 245 persistent_settings.push_back(std::make_pair(new_id, it->second)); |
246 } | 246 } |
247 } | 247 } |
248 | 248 |
249 // If we didn't persist anything, then we are done. | 249 // If we didn't persist anything, then we are done. |
250 if (persistent_settings.empty()) | 250 if (persistent_settings.empty()) |
251 return false; | 251 return false; |
252 | 252 |
253 spdy_settings_map_[host_port_pair] = persistent_settings; | 253 spdy_settings_map_[host_port_pair] = persistent_settings; |
254 return true; | 254 return true; |
255 } | 255 } |
256 | 256 |
| 257 bool HttpServerPropertiesImpl::SetSpdySetting( |
| 258 const HostPortPair& host_port_pair, |
| 259 const spdy::SpdySetting& setting) { |
| 260 |
| 261 spdy::SettingsFlagsAndId id = setting.first; |
| 262 if (!(id.flags() & spdy::SETTINGS_FLAG_PLEASE_PERSIST)) |
| 263 return false; |
| 264 |
| 265 SpdySettingsMap::const_iterator it = spdy_settings_map_.find(host_port_pair); |
| 266 spdy::SpdySettings persistent_settings; |
| 267 if (it != spdy_settings_map_.end()) { |
| 268 persistent_settings = it->second; |
| 269 } |
| 270 |
| 271 spdy::SettingsFlagsAndId new_id(spdy::SETTINGS_FLAG_PERSISTED, id.id()); |
| 272 persistent_settings.push_back(std::make_pair(new_id, setting.second)); |
| 273 spdy_settings_map_[host_port_pair] = persistent_settings; |
| 274 |
| 275 return true; |
| 276 } |
| 277 |
257 void HttpServerPropertiesImpl::ClearSpdySettings() { | 278 void HttpServerPropertiesImpl::ClearSpdySettings() { |
258 spdy_settings_map_.clear(); | 279 spdy_settings_map_.clear(); |
259 } | 280 } |
260 | 281 |
261 const SpdySettingsMap& | 282 const SpdySettingsMap& |
262 HttpServerPropertiesImpl::spdy_settings_map() const { | 283 HttpServerPropertiesImpl::spdy_settings_map() const { |
263 return spdy_settings_map_; | 284 return spdy_settings_map_; |
264 } | 285 } |
265 | 286 |
266 HttpPipelinedHostCapability HttpServerPropertiesImpl::GetPipelineCapability( | 287 HttpPipelinedHostCapability HttpServerPropertiesImpl::GetPipelineCapability( |
(...skipping 27 matching lines...) Expand all Loading... |
294 PipelineCapabilityMap result; | 315 PipelineCapabilityMap result; |
295 CachedPipelineCapabilityMap::const_iterator it; | 316 CachedPipelineCapabilityMap::const_iterator it; |
296 for (it = pipeline_capability_map_->begin(); | 317 for (it = pipeline_capability_map_->begin(); |
297 it != pipeline_capability_map_->end(); ++it) { | 318 it != pipeline_capability_map_->end(); ++it) { |
298 result[it->first] = it->second; | 319 result[it->first] = it->second; |
299 } | 320 } |
300 return result; | 321 return result; |
301 } | 322 } |
302 | 323 |
303 } // namespace net | 324 } // namespace net |
OLD | NEW |