OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 25 matching lines...) Expand all Loading... |
36 // those don't get persisted. | 36 // those don't get persisted. |
37 alternate_protocol_map_.swap(*alternate_protocol_map); | 37 alternate_protocol_map_.swap(*alternate_protocol_map); |
38 for (AlternateProtocolMap::const_iterator it = | 38 for (AlternateProtocolMap::const_iterator it = |
39 alternate_protocol_map->begin(); | 39 alternate_protocol_map->begin(); |
40 it != alternate_protocol_map->end(); ++it) { | 40 it != alternate_protocol_map->end(); ++it) { |
41 if (it->second.protocol == ALTERNATE_PROTOCOL_BROKEN) | 41 if (it->second.protocol == ALTERNATE_PROTOCOL_BROKEN) |
42 alternate_protocol_map_[it->first] = it->second; | 42 alternate_protocol_map_[it->first] = it->second; |
43 } | 43 } |
44 } | 44 } |
45 | 45 |
| 46 void HttpServerPropertiesImpl::InitializeSpdySettingsServers( |
| 47 std::map<HostPortPair, spdy::SpdySettings>* spdy_settings_map) { |
| 48 spdy_settings_map_.swap(*spdy_settings_map); |
| 49 } |
| 50 |
46 void HttpServerPropertiesImpl::GetSpdyServerList( | 51 void HttpServerPropertiesImpl::GetSpdyServerList( |
47 base::ListValue* spdy_server_list) const { | 52 base::ListValue* spdy_server_list) const { |
48 DCHECK(CalledOnValidThread()); | 53 DCHECK(CalledOnValidThread()); |
49 DCHECK(spdy_server_list); | 54 DCHECK(spdy_server_list); |
50 spdy_server_list->Clear(); | 55 spdy_server_list->Clear(); |
51 // Get the list of servers (host/port) that support SPDY. | 56 // Get the list of servers (host/port) that support SPDY. |
52 for (SpdyServerHostPortTable::const_iterator it = spdy_servers_table_.begin(); | 57 for (SpdyServerHostPortTable::const_iterator it = spdy_servers_table_.begin(); |
53 it != spdy_servers_table_.end(); ++it) { | 58 it != spdy_servers_table_.end(); ++it) { |
54 const std::string spdy_server_host_port = it->first; | 59 const std::string spdy_server_host_port = it->first; |
55 if (it->second) | 60 if (it->second) |
(...skipping 25 matching lines...) Expand all Loading... |
81 // static | 86 // static |
82 void HttpServerPropertiesImpl::DisableForcedAlternateProtocol() { | 87 void HttpServerPropertiesImpl::DisableForcedAlternateProtocol() { |
83 delete g_forced_alternate_protocol; | 88 delete g_forced_alternate_protocol; |
84 g_forced_alternate_protocol = NULL; | 89 g_forced_alternate_protocol = NULL; |
85 } | 90 } |
86 | 91 |
87 void HttpServerPropertiesImpl::Clear() { | 92 void HttpServerPropertiesImpl::Clear() { |
88 DCHECK(CalledOnValidThread()); | 93 DCHECK(CalledOnValidThread()); |
89 spdy_servers_table_.clear(); | 94 spdy_servers_table_.clear(); |
90 alternate_protocol_map_.clear(); | 95 alternate_protocol_map_.clear(); |
| 96 spdy_settings_map_.clear(); |
91 } | 97 } |
92 | 98 |
93 bool HttpServerPropertiesImpl::SupportsSpdy( | 99 bool HttpServerPropertiesImpl::SupportsSpdy( |
94 const net::HostPortPair& host_port_pair) const { | 100 const net::HostPortPair& host_port_pair) const { |
95 DCHECK(CalledOnValidThread()); | 101 DCHECK(CalledOnValidThread()); |
96 if (host_port_pair.host().empty()) | 102 if (host_port_pair.host().empty()) |
97 return false; | 103 return false; |
98 std::string spdy_server = GetFlattenedSpdyServer(host_port_pair); | 104 std::string spdy_server = GetFlattenedSpdyServer(host_port_pair); |
99 | 105 |
100 SpdyServerHostPortTable::const_iterator spdy_host_port = | 106 SpdyServerHostPortTable::const_iterator spdy_host_port = |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 void HttpServerPropertiesImpl::SetBrokenAlternateProtocol( | 189 void HttpServerPropertiesImpl::SetBrokenAlternateProtocol( |
184 const HostPortPair& server) { | 190 const HostPortPair& server) { |
185 alternate_protocol_map_[server].protocol = ALTERNATE_PROTOCOL_BROKEN; | 191 alternate_protocol_map_[server].protocol = ALTERNATE_PROTOCOL_BROKEN; |
186 } | 192 } |
187 | 193 |
188 const AlternateProtocolMap& | 194 const AlternateProtocolMap& |
189 HttpServerPropertiesImpl::alternate_protocol_map() const { | 195 HttpServerPropertiesImpl::alternate_protocol_map() const { |
190 return alternate_protocol_map_; | 196 return alternate_protocol_map_; |
191 } | 197 } |
192 | 198 |
| 199 const spdy::SpdySettings& HttpServerPropertiesImpl::GetSpdySettings( |
| 200 const HostPortPair& host_port_pair) const { |
| 201 SpdySettingsMap::const_iterator it = spdy_settings_map_.find(host_port_pair); |
| 202 if (it == spdy_settings_map_.end()) { |
| 203 CR_DEFINE_STATIC_LOCAL(spdy::SpdySettings, kEmptySpdySettings, ()); |
| 204 return kEmptySpdySettings; |
| 205 } |
| 206 return it->second; |
| 207 } |
| 208 |
| 209 bool HttpServerPropertiesImpl::SetSpdySettings( |
| 210 const HostPortPair& host_port_pair, |
| 211 const spdy::SpdySettings& settings) { |
| 212 spdy::SpdySettings persistent_settings; |
| 213 |
| 214 // Iterate through the list, and only copy those settings which are marked |
| 215 // for persistence. |
| 216 spdy::SpdySettings::const_iterator it; |
| 217 for (it = settings.begin(); it != settings.end(); ++it) { |
| 218 spdy::SettingsFlagsAndId id = it->first; |
| 219 if (id.flags() & spdy::SETTINGS_FLAG_PLEASE_PERSIST) { |
| 220 id.set_flags(spdy::SETTINGS_FLAG_PERSISTED); |
| 221 persistent_settings.push_back(std::make_pair(id, it->second)); |
| 222 } |
| 223 } |
| 224 |
| 225 // If we didn't persist anything, then we are done. |
| 226 if (persistent_settings.empty()) |
| 227 return false; |
| 228 |
| 229 spdy_settings_map_[host_port_pair] = persistent_settings; |
| 230 return true; |
| 231 } |
| 232 |
| 233 void HttpServerPropertiesImpl::ClearSpdySettings() { |
| 234 spdy_settings_map_.clear(); |
| 235 } |
| 236 |
| 237 const SpdySettingsMap& |
| 238 HttpServerPropertiesImpl::spdy_settings_map() const { |
| 239 return spdy_settings_map_; |
| 240 } |
| 241 |
193 } // namespace net | 242 } // namespace net |
OLD | NEW |