Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(385)

Side by Side Diff: net/http/http_server_properties_impl.cc

Issue 9802003: SPDY - persist SPDY settings. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 #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"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 alternate_protocol_map_.swap(*alternate_protocol_map); 45 alternate_protocol_map_.swap(*alternate_protocol_map);
46 for (AlternateProtocolMap::const_iterator it = 46 for (AlternateProtocolMap::const_iterator it =
47 alternate_protocol_map->begin(); 47 alternate_protocol_map->begin();
48 it != alternate_protocol_map->end(); ++it) { 48 it != alternate_protocol_map->end(); ++it) {
49 if (it->second.protocol == ALTERNATE_PROTOCOL_BROKEN) 49 if (it->second.protocol == ALTERNATE_PROTOCOL_BROKEN)
50 alternate_protocol_map_[it->first] = it->second; 50 alternate_protocol_map_[it->first] = it->second;
51 } 51 }
52 } 52 }
53 53
54 void HttpServerPropertiesImpl::InitializeSpdySettingsServers( 54 void HttpServerPropertiesImpl::InitializeSpdySettingsServers(
55 std::map<HostPortPair, SpdySettings>* spdy_settings_map) { 55 SpdySettingsMap* spdy_settings_map) {
56 spdy_settings_map_.swap(*spdy_settings_map); 56 spdy_settings_map_.swap(*spdy_settings_map);
57 } 57 }
58 58
59 void HttpServerPropertiesImpl::InitializePipelineCapabilities( 59 void HttpServerPropertiesImpl::InitializePipelineCapabilities(
60 const PipelineCapabilityMap* pipeline_capability_map) { 60 const PipelineCapabilityMap* pipeline_capability_map) {
61 PipelineCapabilityMap::const_iterator it; 61 PipelineCapabilityMap::const_iterator it;
62 pipeline_capability_map_->Clear(); 62 pipeline_capability_map_->Clear();
63 for (it = pipeline_capability_map->begin(); 63 for (it = pipeline_capability_map->begin();
64 it != pipeline_capability_map->end(); ++it) { 64 it != pipeline_capability_map->end(); ++it) {
65 pipeline_capability_map_->Put(it->first, it->second); 65 pipeline_capability_map_->Put(it->first, it->second);
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 void HttpServerPropertiesImpl::SetBrokenAlternateProtocol( 213 void HttpServerPropertiesImpl::SetBrokenAlternateProtocol(
214 const HostPortPair& server) { 214 const HostPortPair& server) {
215 alternate_protocol_map_[server].protocol = ALTERNATE_PROTOCOL_BROKEN; 215 alternate_protocol_map_[server].protocol = ALTERNATE_PROTOCOL_BROKEN;
216 } 216 }
217 217
218 const AlternateProtocolMap& 218 const AlternateProtocolMap&
219 HttpServerPropertiesImpl::alternate_protocol_map() const { 219 HttpServerPropertiesImpl::alternate_protocol_map() const {
220 return alternate_protocol_map_; 220 return alternate_protocol_map_;
221 } 221 }
222 222
223 const SpdySettings& HttpServerPropertiesImpl::GetSpdySettings( 223 const SettingsMap& HttpServerPropertiesImpl::GetSpdySettings(
224 const HostPortPair& host_port_pair) const { 224 const HostPortPair& host_port_pair) const {
225 SpdySettingsMap::const_iterator it = spdy_settings_map_.find(host_port_pair); 225 SpdySettingsMap::const_iterator it = spdy_settings_map_.find(host_port_pair);
226 if (it == spdy_settings_map_.end()) { 226 if (it == spdy_settings_map_.end()) {
227 CR_DEFINE_STATIC_LOCAL(SpdySettings, kEmptySpdySettings, ()); 227 CR_DEFINE_STATIC_LOCAL(SettingsMap, kEmptySettingsMap, ());
228 return kEmptySpdySettings; 228 return kEmptySettingsMap;
229 } 229 }
230 return it->second; 230 return it->second;
231 } 231 }
232 232
233 bool HttpServerPropertiesImpl::SetSpdySettings( 233 bool HttpServerPropertiesImpl::SetSpdySetting(
234 const HostPortPair& host_port_pair, 234 const HostPortPair& host_port_pair,
235 const SpdySettings& settings) { 235 SpdySettingsIds id,
236 SpdySettings persistent_settings; 236 SpdySettingsFlags flags,
237 uint32 value) {
238 if (!(flags & SETTINGS_FLAG_PLEASE_PERSIST))
239 return false;
237 240
238 // Iterate through the list, and only copy those settings which are marked 241 SettingsMap& settings_map = spdy_settings_map_[host_port_pair];
239 // for persistence. 242 SettingsFlagsAndValue flags_and_value(SETTINGS_FLAG_PERSISTED, value);
240 SpdySettings::const_iterator it; 243 settings_map[id] = flags_and_value;
241 for (it = settings.begin(); it != settings.end(); ++it) {
242 SettingsFlagsAndId id = it->first;
243 if (id.flags() & SETTINGS_FLAG_PLEASE_PERSIST) {
244 SettingsFlagsAndId new_id(SETTINGS_FLAG_PERSISTED, id.id());
245 persistent_settings.push_back(std::make_pair(new_id, it->second));
246 }
247 }
248
249 // If we didn't persist anything, then we are done.
250 if (persistent_settings.empty())
251 return false;
252
253 spdy_settings_map_[host_port_pair] = persistent_settings;
254 return true; 244 return true;
255 } 245 }
256 246
257 bool HttpServerPropertiesImpl::SetSpdySetting(
258 const HostPortPair& host_port_pair,
259 const SpdySetting& setting) {
260
261 SettingsFlagsAndId id = setting.first;
262 if (!(id.flags() & SETTINGS_FLAG_PLEASE_PERSIST))
263 return false;
264
265 SpdySettingsMap::const_iterator it = spdy_settings_map_.find(host_port_pair);
266 SpdySettings persistent_settings;
267 if (it != spdy_settings_map_.end()) {
268 persistent_settings = it->second;
269 }
270
271 SettingsFlagsAndId new_id(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
278 void HttpServerPropertiesImpl::ClearSpdySettings() { 247 void HttpServerPropertiesImpl::ClearSpdySettings() {
279 spdy_settings_map_.clear(); 248 spdy_settings_map_.clear();
280 } 249 }
281 250
282 const SpdySettingsMap& 251 const SpdySettingsMap&
283 HttpServerPropertiesImpl::spdy_settings_map() const { 252 HttpServerPropertiesImpl::spdy_settings_map() const {
284 return spdy_settings_map_; 253 return spdy_settings_map_;
285 } 254 }
286 255
287 HttpPipelinedHostCapability HttpServerPropertiesImpl::GetPipelineCapability( 256 HttpPipelinedHostCapability HttpServerPropertiesImpl::GetPipelineCapability(
(...skipping 27 matching lines...) Expand all
315 PipelineCapabilityMap result; 284 PipelineCapabilityMap result;
316 CachedPipelineCapabilityMap::const_iterator it; 285 CachedPipelineCapabilityMap::const_iterator it;
317 for (it = pipeline_capability_map_->begin(); 286 for (it = pipeline_capability_map_->begin();
318 it != pipeline_capability_map_->end(); ++it) { 287 it != pipeline_capability_map_->end(); ++it) {
319 result[it->first] = it->second; 288 result[it->first] = it->second;
320 } 289 }
321 return result; 290 return result;
322 } 291 }
323 292
324 } // namespace net 293 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_server_properties_impl.h ('k') | net/http/http_server_properties_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698