OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #ifndef NET_SPDY_SPDY_SETTING_STORAGE_H_ | 5 #ifndef NET_SPDY_SPDY_SETTING_STORAGE_H_ |
6 #define NET_SPDY_SPDY_SETTING_STORAGE_H_ | 6 #define NET_SPDY_SPDY_SETTING_STORAGE_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <map> | 9 #include <map> |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "net/base/host_port_pair.h" | 11 #include "net/base/host_port_pair.h" |
12 #include "net/spdy/spdy_framer.h" | 12 #include "net/spdy/spdy_framer.h" |
13 | 13 |
14 namespace net { | 14 namespace net { |
15 | 15 |
16 // SpdySettingsStorage stores SpdySettings which have been transmitted between | 16 // SpdySettingsStorage stores SpdySettings which have been transmitted between |
17 // endpoints for the SPDY SETTINGS frame. | 17 // endpoints for the SPDY SETTINGS frame. |
18 class SpdySettingsStorage { | 18 class SpdySettingsStorage { |
19 public: | 19 public: |
20 SpdySettingsStorage(); | 20 SpdySettingsStorage(); |
21 ~SpdySettingsStorage(); | 21 ~SpdySettingsStorage(); |
22 | 22 |
23 // Get a copy of the SpdySettings stored for a host. | 23 // Gets a copy of the SpdySettings stored for a host. |
24 // If no settings are stored, returns an empty set of settings. | 24 // If no settings are stored, returns an empty set of settings. |
| 25 // NOTE: Since settings_map_ may be cleared, don't store the address of the |
| 26 // return value. |
25 const spdy::SpdySettings& Get(const HostPortPair& host_port_pair) const; | 27 const spdy::SpdySettings& Get(const HostPortPair& host_port_pair) const; |
26 | 28 |
27 // Save settings for a host. | 29 // Saves settings for a host. |
28 void Set(const HostPortPair& host_port_pair, | 30 void Set(const HostPortPair& host_port_pair, |
29 const spdy::SpdySettings& settings); | 31 const spdy::SpdySettings& settings); |
30 | 32 |
| 33 // Clears out the settings_map_ object. |
| 34 void Clear(); |
| 35 |
31 private: | 36 private: |
32 typedef std::map<HostPortPair, spdy::SpdySettings> SettingsMap; | 37 typedef std::map<HostPortPair, spdy::SpdySettings> SettingsMap; |
33 | 38 |
34 SettingsMap settings_map_; | 39 SettingsMap settings_map_; |
35 | 40 |
36 DISALLOW_COPY_AND_ASSIGN(SpdySettingsStorage); | 41 DISALLOW_COPY_AND_ASSIGN(SpdySettingsStorage); |
37 }; | 42 }; |
38 | 43 |
39 } // namespace net | 44 } // namespace net |
40 | 45 |
41 #endif // NET_SPDY_SPDY_SETTING_STORAGE_H_ | 46 #endif // NET_SPDY_SPDY_SETTING_STORAGE_H_ |
42 | 47 |
OLD | NEW |