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

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, spdy::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 spdy::SpdySettings& HttpServerPropertiesImpl::GetSpdySettings( 223 const spdy::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 =
226 spdy_settings_map_.find(host_port_pair);
Ryan Hamilton 2012/03/21 16:24:41 can this all fit on one line? (Looks like it did
ramant (doing other things) 2012/03/23 04:11:25 Done.
226 if (it == spdy_settings_map_.end()) { 227 if (it == spdy_settings_map_.end()) {
227 CR_DEFINE_STATIC_LOCAL(spdy::SpdySettings, kEmptySpdySettings, ()); 228 CR_DEFINE_STATIC_LOCAL(spdy::SettingsMap, kEmptySettingsMap, ());
228 return kEmptySpdySettings; 229 return kEmptySettingsMap;
229 } 230 }
230 return it->second; 231 return it->second;
231 } 232 }
232 233
233 bool HttpServerPropertiesImpl::SetSpdySettings( 234 bool HttpServerPropertiesImpl::SetSpdySetting(
234 const HostPortPair& host_port_pair, 235 const HostPortPair& host_port_pair,
235 const spdy::SpdySettings& settings) { 236 uint32 id,
236 spdy::SpdySettings persistent_settings; 237 const spdy::SettingsFlagsAndValue& flags_and_value) {
238 if (!(flags_and_value.first & spdy::SETTINGS_FLAG_PLEASE_PERSIST))
239 return false;
237 240
238 // Iterate through the list, and only copy those settings which are marked 241 spdy::SettingsMap& settings_map = spdy_settings_map_[host_port_pair];
239 // for persistence. 242 spdy::SettingsFlagsAndValue new_flags_and_value(
240 spdy::SpdySettings::const_iterator it; 243 spdy::SETTINGS_FLAG_PERSISTED, flags_and_value.second);
241 for (it = settings.begin(); it != settings.end(); ++it) { 244 settings_map[id] = new_flags_and_value;
Ryan Hamilton 2012/03/21 16:24:41 So much cleaner! Obviously correct, too :>
ramant (doing other things) 2012/03/23 04:11:25 Thanks.
242 spdy::SettingsFlagsAndId id = it->first;
243 if (id.flags() & spdy::SETTINGS_FLAG_PLEASE_PERSIST) {
244 spdy::SettingsFlagsAndId new_id(spdy::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; 245 return true;
255 } 246 }
256 247
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
278 void HttpServerPropertiesImpl::ClearSpdySettings() { 248 void HttpServerPropertiesImpl::ClearSpdySettings() {
279 spdy_settings_map_.clear(); 249 spdy_settings_map_.clear();
280 } 250 }
281 251
282 const SpdySettingsMap& 252 const SpdySettingsMap&
283 HttpServerPropertiesImpl::spdy_settings_map() const { 253 HttpServerPropertiesImpl::spdy_settings_map() const {
284 return spdy_settings_map_; 254 return spdy_settings_map_;
285 } 255 }
286 256
287 HttpPipelinedHostCapability HttpServerPropertiesImpl::GetPipelineCapability( 257 HttpPipelinedHostCapability HttpServerPropertiesImpl::GetPipelineCapability(
(...skipping 27 matching lines...) Expand all
315 PipelineCapabilityMap result; 285 PipelineCapabilityMap result;
316 CachedPipelineCapabilityMap::const_iterator it; 286 CachedPipelineCapabilityMap::const_iterator it;
317 for (it = pipeline_capability_map_->begin(); 287 for (it = pipeline_capability_map_->begin();
318 it != pipeline_capability_map_->end(); ++it) { 288 it != pipeline_capability_map_->end(); ++it) {
319 result[it->first] = it->second; 289 result[it->first] = it->second;
320 } 290 }
321 return result; 291 return result;
322 } 292 }
323 293
324 } // namespace net 294 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698