diff options
author | rtenneti@chromium.org <rtenneti@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-18 02:14:42 +0000 |
---|---|---|
committer | rtenneti@chromium.org <rtenneti@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-18 02:14:42 +0000 |
commit | 18b28abfc0a6afc32d44bafeff5caf4db80d0524 (patch) | |
tree | df81aa7b884c28f2494f8e8d98803be44e16ad11 /net | |
parent | 0a798a15c94fd3092ef36d7857ef3a6119e4c7d4 (diff) | |
download | chromium_src-18b28abfc0a6afc32d44bafeff5caf4db80d0524.zip chromium_src-18b28abfc0a6afc32d44bafeff5caf4db80d0524.tar.gz chromium_src-18b28abfc0a6afc32d44bafeff5caf4db80d0524.tar.bz2 |
SPDY - replaced SpdySettings (list) with SettingsMap
CreateSettings accepts SettingsMap which enforces
that there are no duplicate settings.
Deleted unused class SpdySettingsStorage.
In net-internals, log setting's id, flags and value for
SpdySettings.
BUG=119752
R=rch@chromium.org,hkhalil@google.com
TEST=network unit tests
Review URL: http://codereview.chromium.org/10054034
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@132722 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
27 files changed, 198 insertions, 416 deletions
diff --git a/net/base/net_log_event_type_list.h b/net/base/net_log_event_type_list.h index 71e02f0..aa8dfc7 100644 --- a/net/base/net_log_event_type_list.h +++ b/net/base/net_log_event_type_list.h @@ -971,7 +971,7 @@ EVENT_TYPE(SPDY_SESSION_SYN_REPLY) // On sending a SPDY SETTINGS frame. // The following parameters are attached: // { -// "settings": <The list of setting id:value pairs>, +// "settings": <The list of setting id, flags and value>, // } EVENT_TYPE(SPDY_SESSION_SEND_SETTINGS) diff --git a/net/http/http_network_session.h b/net/http/http_network_session.h index 9c53f8b..4ce60f2 100644 --- a/net/http/http_network_session.h +++ b/net/http/http_network_session.h @@ -16,7 +16,6 @@ #include "net/http/http_auth_cache.h" #include "net/http/http_stream_factory.h" #include "net/spdy/spdy_session_pool.h" -#include "net/spdy/spdy_settings_storage.h" namespace base { class Value; diff --git a/net/http/http_proxy_client_socket_pool.cc b/net/http/http_proxy_client_socket_pool.cc index 67018779..249a052 100644 --- a/net/http/http_proxy_client_socket_pool.cc +++ b/net/http/http_proxy_client_socket_pool.cc @@ -23,7 +23,6 @@ #include "net/spdy/spdy_proxy_client_socket.h" #include "net/spdy/spdy_session.h" #include "net/spdy/spdy_session_pool.h" -#include "net/spdy/spdy_settings_storage.h" #include "net/spdy/spdy_stream.h" namespace net { diff --git a/net/net.gyp b/net/net.gyp index 2908194..69122b0 100644 --- a/net/net.gyp +++ b/net/net.gyp @@ -680,8 +680,6 @@ 'spdy/spdy_session.h', 'spdy/spdy_session_pool.cc', 'spdy/spdy_session_pool.h', - 'spdy/spdy_settings_storage.cc', - 'spdy/spdy_settings_storage.h', 'spdy/spdy_stream.cc', 'spdy/spdy_stream.h', 'spdy/spdy_websocket_stream.cc', diff --git a/net/spdy/buffered_spdy_framer.cc b/net/spdy/buffered_spdy_framer.cc index 3160101..a71155f 100644 --- a/net/spdy/buffered_spdy_framer.cc +++ b/net/spdy/buffered_spdy_framer.cc @@ -196,7 +196,7 @@ SpdyRstStreamControlFrame* BufferedSpdyFramer::CreateRstStream( } SpdySettingsControlFrame* BufferedSpdyFramer::CreateSettings( - const SpdySettings& values) const { + const SettingsMap& values) const { return spdy_framer_.CreateSettings(values); } diff --git a/net/spdy/buffered_spdy_framer.h b/net/spdy/buffered_spdy_framer.h index 4c0a9ce..5954f72 100644 --- a/net/spdy/buffered_spdy_framer.h +++ b/net/spdy/buffered_spdy_framer.h @@ -121,7 +121,7 @@ class NET_EXPORT_PRIVATE BufferedSpdyFramer const SpdyHeaderBlock* headers); SpdyRstStreamControlFrame* CreateRstStream(SpdyStreamId stream_id, SpdyStatusCodes status) const; - SpdySettingsControlFrame* CreateSettings(const SpdySettings& values) const; + SpdySettingsControlFrame* CreateSettings(const SettingsMap& values) const; SpdyPingControlFrame* CreatePingFrame(uint32 unique_id) const; SpdyGoAwayControlFrame* CreateGoAway( SpdyStreamId last_accepted_stream_id, diff --git a/net/spdy/buffered_spdy_framer_spdy2_unittest.cc b/net/spdy/buffered_spdy_framer_spdy2_unittest.cc index fbe97ab..950f038 100644 --- a/net/spdy/buffered_spdy_framer_spdy2_unittest.cc +++ b/net/spdy/buffered_spdy_framer_spdy2_unittest.cc @@ -176,9 +176,11 @@ class BufferedSpdyFramerSpdy2Test : public PlatformTest { TEST_F(BufferedSpdyFramerSpdy2Test, OnSetting) { SpdyFramer framer(2); - SpdySettings settings; - settings.push_back(SpdySetting(SettingsFlagsAndId(0, 1), 0x00000002)); - settings.push_back(SpdySetting(SettingsFlagsAndId(0, 1), 0x00000003)); + SettingsMap settings; + settings[SETTINGS_UPLOAD_BANDWIDTH] = + SettingsFlagsAndValue(SETTINGS_FLAG_NONE, 0x00000002); + settings[SETTINGS_DOWNLOAD_BANDWIDTH] = + SettingsFlagsAndValue(SETTINGS_FLAG_NONE, 0x00000003); scoped_ptr<SpdyFrame> control_frame(framer.CreateSettings(settings)); TestBufferedSpdyVisitor visitor; @@ -186,8 +188,8 @@ TEST_F(BufferedSpdyFramerSpdy2Test, OnSetting) { visitor.SimulateInFramer( reinterpret_cast<unsigned char*>(control_frame->data()), control_frame->length() + SpdyControlFrame::kHeaderSize); - EXPECT_EQ(1, visitor.error_count_); - EXPECT_EQ(1, visitor.setting_count_); + EXPECT_EQ(0, visitor.error_count_); + EXPECT_EQ(2, visitor.setting_count_); } TEST_F(BufferedSpdyFramerSpdy2Test, ReadSynStreamHeaderBlock) { diff --git a/net/spdy/buffered_spdy_framer_spdy3_unittest.cc b/net/spdy/buffered_spdy_framer_spdy3_unittest.cc index 933965b..46a87dc 100644 --- a/net/spdy/buffered_spdy_framer_spdy3_unittest.cc +++ b/net/spdy/buffered_spdy_framer_spdy3_unittest.cc @@ -176,9 +176,11 @@ class BufferedSpdyFramerSpdy3Test : public PlatformTest { TEST_F(BufferedSpdyFramerSpdy3Test, OnSetting) { SpdyFramer framer(3); - SpdySettings settings; - settings.push_back(SpdySetting(SettingsFlagsAndId(0, 1), 0x00000002)); - settings.push_back(SpdySetting(SettingsFlagsAndId(0, 1), 0x00000003)); + SettingsMap settings; + settings[SETTINGS_UPLOAD_BANDWIDTH] = + SettingsFlagsAndValue(SETTINGS_FLAG_NONE, 0x00000002); + settings[SETTINGS_DOWNLOAD_BANDWIDTH] = + SettingsFlagsAndValue(SETTINGS_FLAG_NONE, 0x00000003); scoped_ptr<SpdyFrame> control_frame(framer.CreateSettings(settings)); TestBufferedSpdyVisitor visitor; @@ -186,8 +188,8 @@ TEST_F(BufferedSpdyFramerSpdy3Test, OnSetting) { visitor.SimulateInFramer( reinterpret_cast<unsigned char*>(control_frame->data()), control_frame->length() + SpdyControlFrame::kHeaderSize); - EXPECT_EQ(1, visitor.error_count_); - EXPECT_EQ(1, visitor.setting_count_); + EXPECT_EQ(0, visitor.error_count_); + EXPECT_EQ(2, visitor.setting_count_); } TEST_F(BufferedSpdyFramerSpdy3Test, ReadSynStreamHeaderBlock) { diff --git a/net/spdy/spdy_framer.cc b/net/spdy/spdy_framer.cc index a9edcf6..69a0e8b 100644 --- a/net/spdy/spdy_framer.cc +++ b/net/spdy/spdy_framer.cc @@ -1001,7 +1001,7 @@ bool SpdyFramer::ParseHeaderBlockInBuffer(const char* header_data, /* static */ bool SpdyFramer::ParseSettings(const SpdySettingsControlFrame* frame, - SpdySettings* settings) { + SettingsMap* settings) { DCHECK_EQ(frame->type(), SETTINGS); DCHECK(settings); @@ -1016,9 +1016,12 @@ bool SpdyFramer::ParseSettings(const SpdySettingsControlFrame* frame, } if (!parser.ReadUInt32(&value)) return false; - SettingsFlagsAndId id_and_flags = + SettingsFlagsAndId flags_and_id = SettingsFlagsAndId::FromWireFormat(frame->version(), id_and_flags_wire); - settings->insert(settings->end(), std::make_pair(id_and_flags, value)); + SpdySettingsIds id = static_cast<SpdySettingsIds>(flags_and_id.id()); + SpdySettingsFlags flags = + static_cast<SpdySettingsFlags>(flags_and_id.flags()); + settings->insert(std::make_pair(id, SettingsFlagsAndValue(flags, value))); } return true; } @@ -1139,16 +1142,17 @@ SpdyRstStreamControlFrame* SpdyFramer::CreateRstStream( } SpdySettingsControlFrame* SpdyFramer::CreateSettings( - const SpdySettings& values) const { + const SettingsMap& values) const { size_t frame_size = SpdySettingsControlFrame::size() + 8 * values.size(); SpdyFrameBuilder frame(SETTINGS, CONTROL_FLAG_NONE, spdy_version_, frame_size); frame.WriteUInt32(values.size()); - SpdySettings::const_iterator it = values.begin(); + SettingsMap::const_iterator it = values.begin(); while (it != values.end()) { - uint32 id_and_flags_wire = it->first.GetWireFormat(spdy_version_); + SettingsFlagsAndId flags_and_id(it->second.first, it->first); + uint32 id_and_flags_wire = flags_and_id.GetWireFormat(spdy_version_); frame.WriteBytes(&id_and_flags_wire, 4); - frame.WriteUInt32(it->second); + frame.WriteUInt32(it->second.second); ++it; } DCHECK_EQ(static_cast<size_t>(frame.length()), frame_size); diff --git a/net/spdy/spdy_framer.h b/net/spdy/spdy_framer.h index fba04ab..faaf404 100644 --- a/net/spdy/spdy_framer.h +++ b/net/spdy/spdy_framer.h @@ -71,10 +71,7 @@ class NET_EXPORT_PRIVATE SettingsFlagsAndId { uint32 id_; }; -// A datastructure for holding a set of ID/value pairs for a SETTINGS frame. -typedef std::pair<SettingsFlagsAndId, uint32> SpdySetting; -typedef std::list<SpdySetting> SpdySettings; -// SpdySettingsMap has unique (flags, value) pair for give SpdySetting ID. +// SpdySettingsMap has unique (flags, value) pair for given SpdySettingsIds ID. typedef std::pair<SpdySettingsFlags, uint32> SettingsFlagsAndValue; typedef std::map<SpdySettingsIds, SettingsFlagsAndValue> SettingsMap; @@ -303,7 +300,7 @@ class NET_EXPORT_PRIVATE SpdyFramer { // Creates an instance of SpdySettingsControlFrame. The SETTINGS frame is // used to communicate name/value pairs relevant to the communication channel. - SpdySettingsControlFrame* CreateSettings(const SpdySettings& values) const; + SpdySettingsControlFrame* CreateSettings(const SettingsMap& values) const; // Creates an instance of SpdyPingControlFrame. The unique_id is used to // identify the ping request/response. @@ -339,7 +336,7 @@ class NET_EXPORT_PRIVATE SpdyFramer { // Given a SpdySettingsControlFrame, extract the settings. // Returns true on successful parse, false otherwise. static bool ParseSettings(const SpdySettingsControlFrame* frame, - SpdySettings* settings); + SettingsMap* settings); // Given a SpdyCredentialControlFrame's payload, extract the credential. // Returns true on successful parse, false otherwise. diff --git a/net/spdy/spdy_framer_test.cc b/net/spdy/spdy_framer_test.cc index 0040c0b..c4a0a1b 100644 --- a/net/spdy/spdy_framer_test.cc +++ b/net/spdy/spdy_framer_test.cc @@ -501,10 +501,15 @@ class SpdyFramerTest return true; } - SpdySetting SpdySettingFromWireFormat(uint32 key, uint32 value) { - return SpdySetting( - SettingsFlagsAndId::FromWireFormat(spdy_version_, key), - value); + void AddSpdySettingFromWireFormat(SettingsMap* settings, + uint32 key, + uint32 value) { + SettingsFlagsAndId flags_and_id = + SettingsFlagsAndId::FromWireFormat(spdy_version_, key); + SpdySettingsIds id = static_cast<SpdySettingsIds>(flags_and_id.id()); + SpdySettingsFlags flags = + static_cast<SpdySettingsFlags>(flags_and_id.flags()); + settings->insert(std::make_pair(id, SettingsFlagsAndValue(flags, value))); } bool IsSpdy2() { return spdy_version_ < 3; } @@ -1836,16 +1841,14 @@ TEST_P(SpdyFramerTest, CreateSettings) { const char kDescription[] = "Network byte order SETTINGS frame"; uint32 kValue = 0x0a0b0c0d; - uint8 kFlags = 0x04; - uint32 kId = 0x030201; - SettingsFlagsAndId idAndFlags(kFlags, kId); + SpdySettingsFlags kFlags = static_cast<SpdySettingsFlags>(0x04); + SpdySettingsIds kId = static_cast<SpdySettingsIds>(0x030201); - SpdySettings settings; - settings.push_back(SpdySetting(idAndFlags, kValue)); + SettingsMap settings; + settings[kId] = SettingsFlagsAndValue(kFlags, kValue); - EXPECT_EQ(kValue, settings.back().second); - EXPECT_EQ(kFlags, settings.back().first.flags()); - EXPECT_EQ(kId, settings.back().first.id()); + EXPECT_EQ(kFlags, settings[kId].first); + EXPECT_EQ(kValue, settings[kId].second); const unsigned char kFrameDatav2[] = { 0x80, spdy_version_, 0x00, 0x04, @@ -1872,57 +1875,46 @@ TEST_P(SpdyFramerTest, CreateSettings) { SpdyFramer::GetControlFrameStreamId(frame.get())); // Make sure that ParseSettings also works as advertised. - SpdySettings parsed_settings; + SettingsMap parsed_settings; EXPECT_TRUE(framer.ParseSettings(frame.get(), &parsed_settings)); EXPECT_EQ(settings.size(), parsed_settings.size()); - EXPECT_EQ(kFlags, parsed_settings.back().first.flags()); - EXPECT_EQ(kId, parsed_settings.back().first.id()); + EXPECT_EQ(kFlags, parsed_settings[kId].first); + EXPECT_EQ(kValue, parsed_settings[kId].second); } { const char kDescription[] = "Basic SETTINGS frame"; - SpdySettings settings; - settings.push_back( - SpdySettingFromWireFormat(0x00000000, 0x00000000)); // 1st Setting - settings.push_back( - SpdySettingFromWireFormat(0xffffffff, 0x00000001)); // 2nd Setting - settings.push_back( - SpdySettingFromWireFormat(0xff000001, 0x00000002)); // 3rd Setting - - // Duplicates allowed - settings.push_back( - SpdySettingFromWireFormat(0x01000002, 0x00000003)); // 4th Setting - settings.push_back( - SpdySettingFromWireFormat(0x01000002, 0x00000003)); // 5th Setting - - settings.push_back( - SpdySettingFromWireFormat(0x01000003, 0x000000ff)); // 6th Setting - settings.push_back( - SpdySettingFromWireFormat(0x01000004, 0xff000001)); // 7th Setting - settings.push_back( - SpdySettingFromWireFormat(0x01000004, 0xffffffff)); // 8th Setting + SettingsMap settings; + AddSpdySettingFromWireFormat( + &settings, 0x00000000, 0x00000001); // 1st Setting + AddSpdySettingFromWireFormat( + &settings, 0x01000002, 0x00000002); // 2nd Setting + AddSpdySettingFromWireFormat( + &settings, 0x02000003, 0x00000003); // 3rd Setting + AddSpdySettingFromWireFormat( + &settings, 0x03000004, 0xff000004); // 4th Setting + AddSpdySettingFromWireFormat( + &settings, 0xff000005, 0x00000005); // 5th Setting + AddSpdySettingFromWireFormat( + &settings, 0xffffffff, 0x00000006); // 6th Setting const unsigned char kFrameData[] = { 0x80, spdy_version_, 0x00, 0x04, - 0x00, 0x00, 0x00, 0x44, - 0x00, 0x00, 0x00, 0x08, + 0x00, 0x00, 0x00, 0x34, + 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, // 1st Setting - 0x00, 0x00, 0x00, 0x00, - 0xff, 0xff, 0xff, 0xff, // 2nd Setting 0x00, 0x00, 0x00, 0x01, - 0x01, 0x00, 0x00, 0xff, // 3rd Setting + 0x02, 0x00, 0x00, 0x01, // 2nd Setting 0x00, 0x00, 0x00, 0x02, - 0x02, 0x00, 0x00, 0x01, // 4th Setting - 0x00, 0x00, 0x00, 0x03, - 0x02, 0x00, 0x00, 0x01, // 5th Setting + 0x03, 0x00, 0x00, 0x02, // 3rd Setting 0x00, 0x00, 0x00, 0x03, - 0x03, 0x00, 0x00, 0x01, // 6th Setting - 0x00, 0x00, 0x00, 0xff, - 0x04, 0x00, 0x00, 0x01, // 7th Setting - 0xff, 0x00, 0x00, 0x01, - 0x04, 0x00, 0x00, 0x01, // 8th Setting - 0xff, 0xff, 0xff, 0xff, + 0x04, 0x00, 0x00, 0x03, // 4th Setting + 0xff, 0x00, 0x00, 0x04, + 0x05, 0x00, 0x00, 0xff, // 5th Setting + 0x00, 0x00, 0x00, 0x05, + 0xff, 0xff, 0xff, 0xff, // 6th Setting + 0x00, 0x00, 0x00, 0x06, }; scoped_ptr<SpdySettingsControlFrame> frame(framer.CreateSettings(settings)); CompareFrame(kDescription, @@ -1936,7 +1928,7 @@ TEST_P(SpdyFramerTest, CreateSettings) { { const char kDescription[] = "Empty SETTINGS frame"; - SpdySettings settings; + SettingsMap settings; const unsigned char kFrameData[] = { 0x80, spdy_version_, 0x00, 0x04, @@ -2306,7 +2298,7 @@ TEST_P(SpdyFramerTest, ControlFrameSizesAreValidated) { TEST_P(SpdyFramerTest, ReadZeroLenSettingsFrame) { SpdyFramer framer(spdy_version_); - SpdySettings settings; + SettingsMap settings; scoped_ptr<SpdyFrame> control_frame(framer.CreateSettings(settings)); control_frame->set_length(0); TestSpdyVisitor visitor(spdy_version_); @@ -2321,10 +2313,11 @@ TEST_P(SpdyFramerTest, ReadZeroLenSettingsFrame) { // Tests handling of SETTINGS frames with invalid length. TEST_P(SpdyFramerTest, ReadBogusLenSettingsFrame) { SpdyFramer framer(spdy_version_); - SpdySettings settings; + SettingsMap settings; // Add a setting to pad the frame so that we don't get a buffer overflow when // calling SimulateInFramer() below. - settings.push_back(SpdySetting(SettingsFlagsAndId(0, 1), 0x00000002)); + settings[SETTINGS_UPLOAD_BANDWIDTH] = + SettingsFlagsAndValue(SETTINGS_FLAG_NONE, 0x00000002); scoped_ptr<SpdyFrame> control_frame(framer.CreateSettings(settings)); control_frame->set_length(5); TestSpdyVisitor visitor(spdy_version_); @@ -2339,10 +2332,13 @@ TEST_P(SpdyFramerTest, ReadBogusLenSettingsFrame) { // Tests handling of SETTINGS frames larger than the frame buffer size. TEST_P(SpdyFramerTest, ReadLargeSettingsFrame) { SpdyFramer framer(spdy_version_); - SpdySettings settings; - settings.push_back(SpdySetting(SettingsFlagsAndId(0, 1), 0x00000002)); - settings.push_back(SpdySetting(SettingsFlagsAndId(0, 2), 0x00000003)); - settings.push_back(SpdySetting(SettingsFlagsAndId(0, 3), 0x00000004)); + SettingsMap settings; + SpdySettingsFlags flags = SETTINGS_FLAG_NONE; + settings[SETTINGS_UPLOAD_BANDWIDTH] = + SettingsFlagsAndValue(flags, 0x00000002); + settings[SETTINGS_DOWNLOAD_BANDWIDTH] = + SettingsFlagsAndValue(flags, 0x00000003); + settings[SETTINGS_ROUND_TRIP_TIME] = SettingsFlagsAndValue(flags, 0x00000004); scoped_ptr<SpdyFrame> control_frame(framer.CreateSettings(settings)); EXPECT_LT(SpdyFramer::kUncompressedControlFrameBufferInitialSize, control_frame->length() + SpdyControlFrame::kHeaderSize); @@ -2375,46 +2371,6 @@ TEST_P(SpdyFramerTest, ReadLargeSettingsFrame) { EXPECT_EQ(2, visitor.settings_frame_count_); } -// Tests handling of SETTINGS frame with duplicate entries. -TEST_P(SpdyFramerTest, ReadDuplicateSettings) { - SpdyFramer framer(spdy_version_); - SpdySettings settings; - settings.push_back(SpdySetting(SettingsFlagsAndId(0, 1), 0x00000002)); - settings.push_back(SpdySetting(SettingsFlagsAndId(0, 1), 0x00000003)); - // This last setting should not be processed due to error above. - settings.push_back(SpdySetting(SettingsFlagsAndId(0, 3), 0x00000003)); - scoped_ptr<SpdyFrame> control_frame(framer.CreateSettings(settings)); - TestSpdyVisitor visitor(spdy_version_); - visitor.use_compression_ = false; - - visitor.SimulateInFramer( - reinterpret_cast<unsigned char*>(control_frame->data()), - control_frame->length() + SpdyControlFrame::kHeaderSize); - EXPECT_EQ(1, visitor.error_count_); - EXPECT_EQ(1, visitor.setting_count_); - EXPECT_EQ(1, visitor.settings_frame_count_); -} - -// Tests handling of SETTINGS frame with entries out of order. -TEST_P(SpdyFramerTest, ReadOutOfOrderSettings) { - SpdyFramer framer(spdy_version_); - SpdySettings settings; - settings.push_back(SpdySetting(SettingsFlagsAndId(0, 2), 0x00000002)); - settings.push_back(SpdySetting(SettingsFlagsAndId(0, 1), 0x00000003)); - // This last setting should not be processed due to error above. - settings.push_back(SpdySetting(SettingsFlagsAndId(0, 3), 0x00000003)); - scoped_ptr<SpdyFrame> control_frame(framer.CreateSettings(settings)); - TestSpdyVisitor visitor(spdy_version_); - visitor.use_compression_ = false; - - visitor.SimulateInFramer( - reinterpret_cast<unsigned char*>(control_frame->data()), - control_frame->length() + SpdyControlFrame::kHeaderSize); - EXPECT_EQ(1, visitor.error_count_); - EXPECT_EQ(1, visitor.setting_count_); - EXPECT_EQ(1, visitor.settings_frame_count_); -} - TEST_P(SpdyFramerTest, ReadCredentialFrame) { SpdyCredential credential; credential.slot = 3; diff --git a/net/spdy/spdy_network_transaction_spdy2_unittest.cc b/net/spdy/spdy_network_transaction_spdy2_unittest.cc index df30784..810f76e 100644 --- a/net/spdy/spdy_network_transaction_spdy2_unittest.cc +++ b/net/spdy/spdy_network_transaction_spdy2_unittest.cc @@ -933,11 +933,10 @@ TEST_P(SpdyNetworkTransactionSpdy2Test, ThreeGetsWithMaxConcurrent) { scoped_ptr<SpdyFrame> body3(ConstructSpdyBodyFrame(5, false)); scoped_ptr<SpdyFrame> fbody3(ConstructSpdyBodyFrame(5, true)); - SpdySettings settings; - SettingsFlagsAndId id(SETTINGS_FLAG_NONE, SETTINGS_MAX_CONCURRENT_STREAMS); + SettingsMap settings; const size_t max_concurrent_streams = 1; - - settings.push_back(SpdySetting(id, max_concurrent_streams)); + settings[SETTINGS_MAX_CONCURRENT_STREAMS] = + SettingsFlagsAndValue(SETTINGS_FLAG_NONE, max_concurrent_streams); scoped_ptr<SpdyFrame> settings_frame(ConstructSpdySettings(settings)); MockWrite writes[] = { @@ -995,8 +994,8 @@ TEST_P(SpdyNetworkTransactionSpdy2Test, ThreeGetsWithMaxConcurrent) { out.rv = trans1->Start(&httpreq1, callback1.callback(), log); ASSERT_EQ(out.rv, ERR_IO_PENDING); - // run transaction 1 through quickly to force a read of our SETTINGS - // frame + // Run transaction 1 through quickly to force a read of our SETTINGS + // frame. out.rv = callback1.WaitForResult(); ASSERT_EQ(OK, out.rv); @@ -1070,11 +1069,10 @@ TEST_P(SpdyNetworkTransactionSpdy2Test, FourGetsWithMaxConcurrentPriority) { scoped_ptr<SpdyFrame> body3(ConstructSpdyBodyFrame(7, false)); scoped_ptr<SpdyFrame> fbody3(ConstructSpdyBodyFrame(7, true)); - SpdySettings settings; - SettingsFlagsAndId id(SETTINGS_FLAG_NONE, SETTINGS_MAX_CONCURRENT_STREAMS); + SettingsMap settings; const size_t max_concurrent_streams = 1; - - settings.push_back(SpdySetting(id, max_concurrent_streams)); + settings[SETTINGS_MAX_CONCURRENT_STREAMS] = + SettingsFlagsAndValue(SETTINGS_FLAG_NONE, max_concurrent_streams); scoped_ptr<SpdyFrame> settings_frame(ConstructSpdySettings(settings)); MockWrite writes[] = { CreateMockWrite(*req), @@ -1213,11 +1211,10 @@ TEST_P(SpdyNetworkTransactionSpdy2Test, ThreeGetsWithMaxConcurrentDelete) { scoped_ptr<SpdyFrame> body2(ConstructSpdyBodyFrame(3, false)); scoped_ptr<SpdyFrame> fbody2(ConstructSpdyBodyFrame(3, true)); - SpdySettings settings; - SettingsFlagsAndId id(SETTINGS_FLAG_NONE, SETTINGS_MAX_CONCURRENT_STREAMS); + SettingsMap settings; const size_t max_concurrent_streams = 1; - - settings.push_back(SpdySetting(id, max_concurrent_streams)); + settings[SETTINGS_MAX_CONCURRENT_STREAMS] = + SettingsFlagsAndValue(SETTINGS_FLAG_NONE, max_concurrent_streams); scoped_ptr<SpdyFrame> settings_frame(ConstructSpdySettings(settings)); MockWrite writes[] = { CreateMockWrite(*req), @@ -1347,11 +1344,10 @@ TEST_P(SpdyNetworkTransactionSpdy2Test, ThreeGetsWithMaxConcurrentSocketClose) { scoped_ptr<SpdyFrame> req2(ConstructSpdyGet(NULL, 0, false, 3, LOWEST)); scoped_ptr<SpdyFrame> resp2(ConstructSpdyGetSynReply(NULL, 0, 3)); - SpdySettings settings; - SettingsFlagsAndId id(SETTINGS_FLAG_NONE, SETTINGS_MAX_CONCURRENT_STREAMS); + SettingsMap settings; const size_t max_concurrent_streams = 1; - - settings.push_back(SpdySetting(id, max_concurrent_streams)); + settings[SETTINGS_MAX_CONCURRENT_STREAMS] = + SettingsFlagsAndValue(SETTINGS_FLAG_NONE, max_concurrent_streams); scoped_ptr<SpdyFrame> settings_frame(ConstructSpdySettings(settings)); MockWrite writes[] = { CreateMockWrite(*req), @@ -4060,7 +4056,7 @@ TEST_P(SpdyNetworkTransactionSpdy2Test, BufferedCancelled) { } // Test that if the server requests persistence of settings, that we save -// the settings in the SpdySettingsStorage. +// the settings in the HttpServerProperties. TEST_P(SpdyNetworkTransactionSpdy2Test, SettingsSaved) { static const SpdyHeaderInfo kSynReplyInfo = { SYN_REPLY, // Syn Reply @@ -4110,16 +4106,16 @@ TEST_P(SpdyNetworkTransactionSpdy2Test, SettingsSaved) { scoped_ptr<SpdyFrame> settings_frame; { // Construct the SETTINGS frame. - SpdySettings settings; + SettingsMap settings; // First add a persisted setting. - SettingsFlagsAndId setting1(SETTINGS_FLAG_PLEASE_PERSIST, kSampleId1); - settings.push_back(std::make_pair(setting1, kSampleValue1)); + settings[kSampleId1] = + SettingsFlagsAndValue(SETTINGS_FLAG_PLEASE_PERSIST, kSampleValue1); // Next add a non-persisted setting. - SettingsFlagsAndId setting2(SETTINGS_FLAG_NONE, kSampleId2); - settings.push_back(std::make_pair(setting2, kSampleValue2)); + settings[kSampleId2] = + SettingsFlagsAndValue(SETTINGS_FLAG_NONE, kSampleValue2); // Next add another persisted setting. - SettingsFlagsAndId setting3(SETTINGS_FLAG_PLEASE_PERSIST, kSampleId3); - settings.push_back(std::make_pair(setting3, kSampleValue3)); + settings[kSampleId3] = + SettingsFlagsAndValue(SETTINGS_FLAG_PLEASE_PERSIST, kSampleValue3); settings_frame.reset(ConstructSpdySettings(settings)); } @@ -4218,20 +4214,9 @@ TEST_P(SpdyNetworkTransactionSpdy2Test, SettingsPlayback) { host_port_pair).size()); // Construct the SETTINGS frame. - const SettingsMap& settings_map = + const SettingsMap& settings = spdy_session_pool->http_server_properties()->GetSpdySettings( host_port_pair); - - SpdySettings settings; - for (SettingsMap::const_iterator i = settings_map.begin(), - end = settings_map.end(); i != end; ++i) { - const SpdySettingsIds id = i->first; - const SpdySettingsFlags flags = i->second.first; - const uint32 val = i->second.second; - SettingsFlagsAndId flags_and_id(flags, id); - settings.push_back(SpdySetting(flags_and_id, val)); - } - scoped_ptr<SpdyFrame> settings_frame(ConstructSpdySettings(settings)); // Construct the request. diff --git a/net/spdy/spdy_network_transaction_spdy3_unittest.cc b/net/spdy/spdy_network_transaction_spdy3_unittest.cc index 3826ac1..512e4ba 100644 --- a/net/spdy/spdy_network_transaction_spdy3_unittest.cc +++ b/net/spdy/spdy_network_transaction_spdy3_unittest.cc @@ -937,11 +937,10 @@ TEST_P(SpdyNetworkTransactionSpdy3Test, ThreeGetsWithMaxConcurrent) { scoped_ptr<SpdyFrame> body3(ConstructSpdyBodyFrame(5, false)); scoped_ptr<SpdyFrame> fbody3(ConstructSpdyBodyFrame(5, true)); - SpdySettings settings; - SettingsFlagsAndId id(SETTINGS_FLAG_NONE, SETTINGS_MAX_CONCURRENT_STREAMS); + SettingsMap settings; const size_t max_concurrent_streams = 1; - - settings.push_back(SpdySetting(id, max_concurrent_streams)); + settings[SETTINGS_MAX_CONCURRENT_STREAMS] = + SettingsFlagsAndValue(SETTINGS_FLAG_NONE, max_concurrent_streams); scoped_ptr<SpdyFrame> settings_frame(ConstructSpdySettings(settings)); MockWrite writes[] = { @@ -1074,11 +1073,10 @@ TEST_P(SpdyNetworkTransactionSpdy3Test, FourGetsWithMaxConcurrentPriority) { scoped_ptr<SpdyFrame> body3(ConstructSpdyBodyFrame(7, false)); scoped_ptr<SpdyFrame> fbody3(ConstructSpdyBodyFrame(7, true)); - SpdySettings settings; - SettingsFlagsAndId id(SETTINGS_FLAG_NONE, SETTINGS_MAX_CONCURRENT_STREAMS); + SettingsMap settings; const size_t max_concurrent_streams = 1; - - settings.push_back(SpdySetting(id, max_concurrent_streams)); + settings[SETTINGS_MAX_CONCURRENT_STREAMS] = + SettingsFlagsAndValue(SETTINGS_FLAG_NONE, max_concurrent_streams); scoped_ptr<SpdyFrame> settings_frame(ConstructSpdySettings(settings)); MockWrite writes[] = { CreateMockWrite(*req), @@ -1217,11 +1215,10 @@ TEST_P(SpdyNetworkTransactionSpdy3Test, ThreeGetsWithMaxConcurrentDelete) { scoped_ptr<SpdyFrame> body2(ConstructSpdyBodyFrame(3, false)); scoped_ptr<SpdyFrame> fbody2(ConstructSpdyBodyFrame(3, true)); - SpdySettings settings; - SettingsFlagsAndId id(SETTINGS_FLAG_NONE, SETTINGS_MAX_CONCURRENT_STREAMS); + SettingsMap settings; const size_t max_concurrent_streams = 1; - - settings.push_back(SpdySetting(id, max_concurrent_streams)); + settings[SETTINGS_MAX_CONCURRENT_STREAMS] = + SettingsFlagsAndValue(SETTINGS_FLAG_NONE, max_concurrent_streams); scoped_ptr<SpdyFrame> settings_frame(ConstructSpdySettings(settings)); MockWrite writes[] = { CreateMockWrite(*req), @@ -1351,11 +1348,10 @@ TEST_P(SpdyNetworkTransactionSpdy3Test, ThreeGetsWithMaxConcurrentSocketClose) { scoped_ptr<SpdyFrame> req2(ConstructSpdyGet(NULL, 0, false, 3, LOWEST)); scoped_ptr<SpdyFrame> resp2(ConstructSpdyGetSynReply(NULL, 0, 3)); - SpdySettings settings; - SettingsFlagsAndId id(SETTINGS_FLAG_NONE, SETTINGS_MAX_CONCURRENT_STREAMS); + SettingsMap settings; const size_t max_concurrent_streams = 1; - - settings.push_back(SpdySetting(id, max_concurrent_streams)); + settings[SETTINGS_MAX_CONCURRENT_STREAMS] = + SettingsFlagsAndValue(SETTINGS_FLAG_NONE, max_concurrent_streams); scoped_ptr<SpdyFrame> settings_frame(ConstructSpdySettings(settings)); MockWrite writes[] = { CreateMockWrite(*req), @@ -2266,9 +2262,10 @@ TEST_P(SpdyNetworkTransactionSpdy3Test, FlowControlStallResumeAfterSettings) { // Construct read frame for SETTINGS that gives enough space to upload the // rest of the data. - SpdySettings settings; - SettingsFlagsAndId id(0, SETTINGS_INITIAL_WINDOW_SIZE); - settings.push_back(SpdySetting(id, kSpdyStreamInitialWindowSize * 2)); + SettingsMap settings; + settings[SETTINGS_INITIAL_WINDOW_SIZE] = + SettingsFlagsAndValue( + SETTINGS_FLAG_NONE, kSpdyStreamInitialWindowSize * 2); scoped_ptr<SpdyFrame> settings_frame_large(ConstructSpdySettings(settings)); scoped_ptr<SpdyFrame> reply(ConstructSpdyPostSynReply(NULL, 0)); MockRead reads[] = { @@ -2363,9 +2360,10 @@ TEST_P(SpdyNetworkTransactionSpdy3Test, FlowControlNegativeSendWindowSize) { // Construct read frame for SETTINGS that makes the send_window_size // negative. - SpdySettings new_settings; - SettingsFlagsAndId new_id(0, SETTINGS_INITIAL_WINDOW_SIZE); - new_settings.push_back(SpdySetting(new_id, kSpdyStreamInitialWindowSize / 2)); + SettingsMap new_settings; + new_settings[SETTINGS_INITIAL_WINDOW_SIZE] = + SettingsFlagsAndValue( + SETTINGS_FLAG_NONE, kSpdyStreamInitialWindowSize / 2); scoped_ptr<SpdyFrame> settings_frame_small( ConstructSpdySettings(new_settings)); // Construct read frame for WINDOW_UPDATE that makes the send_window_size @@ -4632,7 +4630,7 @@ TEST_P(SpdyNetworkTransactionSpdy3Test, BufferedCancelled) { } // Test that if the server requests persistence of settings, that we save -// the settings in the SpdySettingsStorage. +// the settings in the HttpServerProperties. TEST_P(SpdyNetworkTransactionSpdy3Test, SettingsSaved) { static const SpdyHeaderInfo kSynReplyInfo = { SYN_REPLY, // Syn Reply @@ -4683,16 +4681,16 @@ TEST_P(SpdyNetworkTransactionSpdy3Test, SettingsSaved) { scoped_ptr<SpdyFrame> settings_frame; { // Construct the SETTINGS frame. - SpdySettings settings; + SettingsMap settings; // First add a persisted setting. - SettingsFlagsAndId setting1(SETTINGS_FLAG_PLEASE_PERSIST, kSampleId1); - settings.push_back(std::make_pair(setting1, kSampleValue1)); + settings[kSampleId1] = + SettingsFlagsAndValue(SETTINGS_FLAG_PLEASE_PERSIST, kSampleValue1); // Next add a non-persisted setting. - SettingsFlagsAndId setting2(SETTINGS_FLAG_NONE, kSampleId2); - settings.push_back(std::make_pair(setting2, kSampleValue2)); + settings[kSampleId2] = + SettingsFlagsAndValue(SETTINGS_FLAG_NONE, kSampleValue2); // Next add another persisted setting. - SettingsFlagsAndId setting3(SETTINGS_FLAG_PLEASE_PERSIST, kSampleId3); - settings.push_back(std::make_pair(setting3, kSampleValue3)); + settings[kSampleId3] = + SettingsFlagsAndValue(SETTINGS_FLAG_PLEASE_PERSIST, kSampleValue3); settings_frame.reset(ConstructSpdySettings(settings)); } @@ -4792,20 +4790,9 @@ TEST_P(SpdyNetworkTransactionSpdy3Test, SettingsPlayback) { host_port_pair).size()); // Construct the SETTINGS frame. - const SettingsMap& settings_map = + const SettingsMap& settings = spdy_session_pool->http_server_properties()->GetSpdySettings( host_port_pair); - - SpdySettings settings; - for (SettingsMap::const_iterator i = settings_map.begin(), - end = settings_map.end(); i != end; ++i) { - const SpdySettingsIds id = i->first; - const SpdySettingsFlags flags = i->second.first; - const uint32 val = i->second.second; - SettingsFlagsAndId flags_and_id(flags, id); - settings.push_back(SpdySetting(flags_and_id, val)); - } - scoped_ptr<SpdyFrame> settings_frame(ConstructSpdySettings(settings)); // Construct the request. diff --git a/net/spdy/spdy_protocol_test.cc b/net/spdy/spdy_protocol_test.cc index c955d3b..0ef12ed 100644 --- a/net/spdy/spdy_protocol_test.cc +++ b/net/spdy/spdy_protocol_test.cc @@ -215,7 +215,7 @@ TEST_P(SpdyProtocolTest, TestSpdySettingsFrame) { SpdyFramer framer(spdy_version_); // Create a settings frame with no settings. - SpdySettings settings; + SettingsMap settings; scoped_ptr<SpdySettingsControlFrame> settings_frame( framer.CreateSettings(settings)); EXPECT_EQ(framer.protocol_version(), settings_frame->version()); @@ -229,32 +229,33 @@ TEST_P(SpdyProtocolTest, TestSpdySettingsFrame) { SettingsFlagsAndId::FromWireFormat(spdy_version_, 0x00000000), SettingsFlagsAndId::FromWireFormat(spdy_version_, 0xffffffff), SettingsFlagsAndId::FromWireFormat(spdy_version_, 0xff000001), - SettingsFlagsAndId::FromWireFormat(spdy_version_, 0xffffffff), SettingsFlagsAndId::FromWireFormat(spdy_version_, 0x01000002), - SettingsFlagsAndId(3, 1) + SettingsFlagsAndId(6, 9) }; for (size_t index = 0; index < arraysize(ids); ++index) { - settings.insert(settings.end(), std::make_pair(ids[index], index)); + SettingsFlagsAndId flags_and_id = ids[index]; + SpdySettingsIds id = static_cast<SpdySettingsIds>(flags_and_id.id()); + SpdySettingsFlags flags = + static_cast<SpdySettingsFlags>(flags_and_id.flags()); + settings[id] = SettingsFlagsAndValue(flags, index); settings_frame.reset(framer.CreateSettings(settings)); EXPECT_EQ(framer.protocol_version(), settings_frame->version()); EXPECT_TRUE(settings_frame->is_control_frame()); EXPECT_EQ(SETTINGS, settings_frame->type()); EXPECT_EQ(index + 1, settings_frame->num_entries()); - SpdySettings parsed_settings; + SettingsMap parsed_settings; EXPECT_TRUE(framer.ParseSettings(settings_frame.get(), &parsed_settings)); EXPECT_EQ(settings.size(), parsed_settings.size()); - SpdySettings::const_iterator it = parsed_settings.begin(); - int pos = 0; - while (it != parsed_settings.end()) { - SettingsFlagsAndId parsed = it->first; - uint32 value = it->second; - EXPECT_EQ(ids[pos].flags(), parsed.flags()); - EXPECT_EQ(ids[pos].id(), parsed.id()); - EXPECT_EQ(static_cast<uint32>(pos), value); - ++it; - ++pos; + SettingsMap::const_iterator it, it2; + for (it = parsed_settings.begin(); it != parsed_settings.end(); it++) { + it2 = settings.find(it->first); + EXPECT_EQ(it->first, it2->first); + SettingsFlagsAndValue parsed = it->second; + SettingsFlagsAndValue created = it2->second; + EXPECT_EQ(created.first, parsed.first); + EXPECT_EQ(created.second, parsed.second); } } } diff --git a/net/spdy/spdy_session.cc b/net/spdy/spdy_session.cc index 694d508..f0eedce 100644 --- a/net/spdy/spdy_session.cc +++ b/net/spdy/spdy_session.cc @@ -33,7 +33,6 @@ #include "net/spdy/spdy_http_utils.h" #include "net/spdy/spdy_protocol.h" #include "net/spdy/spdy_session_pool.h" -#include "net/spdy/spdy_settings_storage.h" #include "net/spdy/spdy_stream.h" namespace net { @@ -152,16 +151,19 @@ class NetLogSpdySettingParameter : public NetLog::EventParameters { class NetLogSpdySettingsParameter : public NetLog::EventParameters { public: - explicit NetLogSpdySettingsParameter(const SpdySettings& settings) + explicit NetLogSpdySettingsParameter(const SettingsMap& settings) : settings_(settings) {} virtual Value* ToValue() const { DictionaryValue* dict = new DictionaryValue(); ListValue* settings = new ListValue(); - for (SpdySettings::const_iterator it = settings_.begin(); + for (SettingsMap::const_iterator it = settings_.begin(); it != settings_.end(); ++it) { + const SpdySettingsIds id = it->first; + const SpdySettingsFlags flags = it->second.first; + const uint32 value = it->second.second; settings->Append(new StringValue( - base::StringPrintf("[%u:%u]", it->first.id(), it->second))); + base::StringPrintf("[id:%u flags:%u value:%u]", id, flags, value))); } dict->Set("settings", settings); return dict; @@ -169,7 +171,7 @@ class NetLogSpdySettingsParameter : public NetLog::EventParameters { private: ~NetLogSpdySettingsParameter() {} - const SpdySettings settings_; + const SettingsMap settings_; DISALLOW_COPY_AND_ASSIGN(NetLogSpdySettingsParameter); }; @@ -1721,26 +1723,21 @@ void SpdySession::SendSettings() { const SettingsMap& settings_map_new = http_server_properties_->GetSpdySettings(host_port_pair()); - - SpdySettings settings; for (SettingsMap::const_iterator i = settings_map_new.begin(), end = settings_map_new.end(); i != end; ++i) { const SpdySettingsIds new_id = i->first; - const SpdySettingsFlags new_flags = i->second.first; const uint32 new_val = i->second.second; HandleSetting(new_id, new_val); - SettingsFlagsAndId flags_and_id(new_flags, new_id); - settings.push_back(SpdySetting(flags_and_id, new_val)); } net_log_.AddEvent( NetLog::TYPE_SPDY_SESSION_SEND_SETTINGS, - make_scoped_refptr(new NetLogSpdySettingsParameter(settings))); + make_scoped_refptr(new NetLogSpdySettingsParameter(settings_map_new))); // Create the SETTINGS frame and send it. DCHECK(buffered_spdy_framer_.get()); scoped_ptr<SpdySettingsControlFrame> settings_frame( - buffered_spdy_framer_->CreateSettings(settings)); + buffered_spdy_framer_->CreateSettings(settings_map_new)); sent_settings_ = true; QueueFrame(settings_frame.get(), 0, NULL); } diff --git a/net/spdy/spdy_session_pool.h b/net/spdy/spdy_session_pool.h index 27d1785..c827af4 100644 --- a/net/spdy/spdy_session_pool.h +++ b/net/spdy/spdy_session_pool.h @@ -23,7 +23,6 @@ #include "net/base/ssl_config_service.h" #include "net/proxy/proxy_config.h" #include "net/proxy/proxy_server.h" -#include "net/spdy/spdy_settings_storage.h" namespace net { @@ -112,9 +111,6 @@ class NET_EXPORT SpdySessionPool // responsible for deleting the returned value. base::Value* SpdySessionPoolInfoToValue() const; - SpdySettingsStorage* mutable_spdy_settings() { return &spdy_settings_; } - const SpdySettingsStorage& spdy_settings() const { return spdy_settings_; } - HttpServerProperties* http_server_properties() { return http_server_properties_; } @@ -195,7 +191,6 @@ class NET_EXPORT SpdySessionPool bool RemoveFromSessionList(const scoped_refptr<SpdySession>& session, const HostPortProxyPair& pair); - SpdySettingsStorage spdy_settings_; HttpServerProperties* const http_server_properties_; // This is our weak session pool - one session per domain. diff --git a/net/spdy/spdy_session_spdy2_unittest.cc b/net/spdy/spdy_session_spdy2_unittest.cc index 3fde2b4..8afbed2 100644 --- a/net/spdy/spdy_session_spdy2_unittest.cc +++ b/net/spdy/spdy_session_spdy2_unittest.cc @@ -500,11 +500,11 @@ TEST_F(SpdySessionSpdy2Test, OnSettings) { SpdySessionDependencies session_deps; session_deps.host_resolver->set_synchronous_mode(true); - SpdySettings new_settings; + SettingsMap new_settings; const SpdySettingsIds kSpdySettingsIds1 = SETTINGS_MAX_CONCURRENT_STREAMS; - SettingsFlagsAndId id(SETTINGS_FLAG_NONE, kSpdySettingsIds1); const size_t max_concurrent_streams = 2; - new_settings.push_back(SpdySetting(id, max_concurrent_streams)); + new_settings[kSpdySettingsIds1] = + SettingsFlagsAndValue(SETTINGS_FLAG_NONE, max_concurrent_streams); // Set up the socket so we read a SETTINGS frame that raises max concurrent // streams to 2. @@ -530,7 +530,7 @@ TEST_F(SpdySessionSpdy2Test, OnSettings) { HostPortPair test_host_port_pair(kTestHost, kTestPort); HostPortProxyPair pair(test_host_port_pair, ProxyServer::Direct()); - // Initialize the SpdySettingsStorage with 1 max concurrent streams. + // Initialize the SpdySetting with 1 max concurrent streams. SpdySessionPool* spdy_session_pool(http_session->spdy_session_pool()); spdy_session_pool->http_server_properties()->SetSpdySetting( test_host_port_pair, @@ -613,7 +613,7 @@ TEST_F(SpdySessionSpdy2Test, CancelPendingCreateStream) { HostPortPair test_host_port_pair(kTestHost, kTestPort); HostPortProxyPair pair(test_host_port_pair, ProxyServer::Direct()); - // Initialize the SpdySettingsStorage with 1 max concurrent streams. + // Initialize the SpdySetting with 1 max concurrent streams. SpdySessionPool* spdy_session_pool(http_session->spdy_session_pool()); spdy_session_pool->http_server_properties()->SetSpdySetting( test_host_port_pair, @@ -683,13 +683,13 @@ TEST_F(SpdySessionSpdy2Test, SendSettingsOnNewSession) { // Create the bogus setting that we want to verify is sent out. // Note that it will be marked as SETTINGS_FLAG_PERSISTED when sent out. But - // to set it into the SpdySettingsStorage, we need to mark as + // to persist it into the HttpServerProperties, we need to mark as // SETTINGS_FLAG_PLEASE_PERSIST. - SpdySettings settings; + SettingsMap settings; const SpdySettingsIds kSpdySettingsIds1 = SETTINGS_UPLOAD_BANDWIDTH; const uint32 kBogusSettingValue = 0xCDCD; - SettingsFlagsAndId id(SETTINGS_FLAG_PERSISTED, kSpdySettingsIds1); - settings.push_back(SpdySetting(id, kBogusSettingValue)); + settings[kSpdySettingsIds1] = + SettingsFlagsAndValue(SETTINGS_FLAG_PERSISTED, kBogusSettingValue); MockConnect connect_data(SYNCHRONOUS, OK); scoped_ptr<SpdyFrame> settings_frame(ConstructSpdySettings(settings)); MockWrite writes[] = { @@ -886,23 +886,6 @@ TEST_F(SpdySessionSpdy2Test, IPPoolingCloseCurrentSessions) { IPPoolingTest(true); } -TEST_F(SpdySessionSpdy2Test, ClearSettingsStorage) { - SpdySettingsStorage settings_storage; - const std::string kTestHost("www.foo.com"); - const int kTestPort = 80; - HostPortPair test_host_port_pair(kTestHost, kTestPort); - SpdySettings test_settings; - SettingsFlagsAndId id(SETTINGS_FLAG_PLEASE_PERSIST, - SETTINGS_MAX_CONCURRENT_STREAMS); - const size_t max_concurrent_streams = 2; - test_settings.push_back(SpdySetting(id, max_concurrent_streams)); - - settings_storage.Set(test_host_port_pair, test_settings); - EXPECT_NE(0u, settings_storage.Get(test_host_port_pair).size()); - settings_storage.Clear(); - EXPECT_EQ(0u, settings_storage.Get(test_host_port_pair).size()); -} - TEST_F(SpdySessionSpdy2Test, ClearSettingsStorageOnIPAddressChanged) { const std::string kTestHost("www.foo.com"); const int kTestPort = 80; diff --git a/net/spdy/spdy_session_spdy3_unittest.cc b/net/spdy/spdy_session_spdy3_unittest.cc index e66b309..3e53ab2 100644 --- a/net/spdy/spdy_session_spdy3_unittest.cc +++ b/net/spdy/spdy_session_spdy3_unittest.cc @@ -500,11 +500,11 @@ TEST_F(SpdySessionSpdy3Test, OnSettings) { SpdySessionDependencies session_deps; session_deps.host_resolver->set_synchronous_mode(true); - SpdySettings new_settings; + SettingsMap new_settings; const SpdySettingsIds kSpdySettingsIds1 = SETTINGS_MAX_CONCURRENT_STREAMS; - SettingsFlagsAndId id(SETTINGS_FLAG_NONE, kSpdySettingsIds1); const size_t max_concurrent_streams = 2; - new_settings.push_back(SpdySetting(id, max_concurrent_streams)); + new_settings[kSpdySettingsIds1] = + SettingsFlagsAndValue(SETTINGS_FLAG_NONE, max_concurrent_streams); // Set up the socket so we read a SETTINGS frame that raises max concurrent // streams to 2. @@ -530,7 +530,7 @@ TEST_F(SpdySessionSpdy3Test, OnSettings) { HostPortPair test_host_port_pair(kTestHost, kTestPort); HostPortProxyPair pair(test_host_port_pair, ProxyServer::Direct()); - // Initialize the SpdySettingsStorage with 1 max concurrent streams. + // Initialize the SpdySetting with 1 max concurrent streams. SpdySessionPool* spdy_session_pool(http_session->spdy_session_pool()); spdy_session_pool->http_server_properties()->SetSpdySetting( test_host_port_pair, @@ -613,7 +613,7 @@ TEST_F(SpdySessionSpdy3Test, CancelPendingCreateStream) { HostPortPair test_host_port_pair(kTestHost, kTestPort); HostPortProxyPair pair(test_host_port_pair, ProxyServer::Direct()); - // Initialize the SpdySettingsStorage with 1 max concurrent streams. + // Initialize the SpdySetting with 1 max concurrent streams. SpdySessionPool* spdy_session_pool(http_session->spdy_session_pool()); spdy_session_pool->http_server_properties()->SetSpdySetting( test_host_port_pair, @@ -683,13 +683,13 @@ TEST_F(SpdySessionSpdy3Test, SendSettingsOnNewSession) { // Create the bogus setting that we want to verify is sent out. // Note that it will be marked as SETTINGS_FLAG_PERSISTED when sent out. But - // to set it into the SpdySettingsStorage, we need to mark as + // to persist it into the HttpServerProperties, we need to mark as // SETTINGS_FLAG_PLEASE_PERSIST. - SpdySettings settings; + SettingsMap settings; const SpdySettingsIds kSpdySettingsIds1 = SETTINGS_UPLOAD_BANDWIDTH; const uint32 kBogusSettingValue = 0xCDCD; - SettingsFlagsAndId id(SETTINGS_FLAG_PERSISTED, kSpdySettingsIds1); - settings.push_back(SpdySetting(id, kBogusSettingValue)); + settings[kSpdySettingsIds1] = + SettingsFlagsAndValue(SETTINGS_FLAG_PERSISTED, kBogusSettingValue); MockConnect connect_data(SYNCHRONOUS, OK); scoped_ptr<SpdyFrame> settings_frame(ConstructSpdySettings(settings)); MockWrite writes[] = { @@ -886,23 +886,6 @@ TEST_F(SpdySessionSpdy3Test, IPPoolingCloseCurrentSessions) { IPPoolingTest(true); } -TEST_F(SpdySessionSpdy3Test, ClearSettingsStorage) { - SpdySettingsStorage settings_storage; - const std::string kTestHost("www.foo.com"); - const int kTestPort = 80; - HostPortPair test_host_port_pair(kTestHost, kTestPort); - SpdySettings test_settings; - SettingsFlagsAndId id(SETTINGS_FLAG_PLEASE_PERSIST, - SETTINGS_MAX_CONCURRENT_STREAMS); - const size_t max_concurrent_streams = 2; - test_settings.push_back(SpdySetting(id, max_concurrent_streams)); - - settings_storage.Set(test_host_port_pair, test_settings); - EXPECT_NE(0u, settings_storage.Get(test_host_port_pair).size()); - settings_storage.Clear(); - EXPECT_EQ(0u, settings_storage.Get(test_host_port_pair).size()); -} - TEST_F(SpdySessionSpdy3Test, ClearSettingsStorageOnIPAddressChanged) { const std::string kTestHost("www.foo.com"); const int kTestPort = 80; @@ -999,7 +982,7 @@ TEST_F(SpdySessionSpdy3Test, SendCredentials) { MockRead reads[] = { MockRead(SYNCHRONOUS, ERR_IO_PENDING) // Stall forever. }; - SpdySettings settings; + SettingsMap settings; scoped_ptr<SpdyFrame> settings_frame(ConstructSpdySettings(settings)); MockWrite writes[] = { CreateMockWrite(*settings_frame), @@ -1135,10 +1118,10 @@ TEST_F(SpdySessionSpdy3Test, CloseSessionOnError) { TEST_F(SpdySessionSpdy3Test, UpdateStreamsSendWindowSize) { // Set SETTINGS_INITIAL_WINDOW_SIZE to a small number so that WINDOW_UPDATE // gets sent. - SpdySettings new_settings; - SettingsFlagsAndId id(0, SETTINGS_INITIAL_WINDOW_SIZE); + SettingsMap new_settings; int32 window_size = 1; - new_settings.push_back(SpdySetting(id, window_size)); + new_settings[SETTINGS_INITIAL_WINDOW_SIZE] = + SettingsFlagsAndValue(SETTINGS_FLAG_NONE, window_size); // Set up the socket so we read a SETTINGS frame that sets // INITIAL_WINDOW_SIZE. diff --git a/net/spdy/spdy_settings_storage.cc b/net/spdy/spdy_settings_storage.cc deleted file mode 100644 index 7d187d6..0000000 --- a/net/spdy/spdy_settings_storage.cc +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "net/spdy/spdy_settings_storage.h" - -#include <utility> - -namespace net { - -SpdySettingsStorage::SpdySettingsStorage() { -} - -SpdySettingsStorage::~SpdySettingsStorage() { -} - -const SpdySettings& SpdySettingsStorage::Get( - const HostPortPair& host_port_pair) const { - SettingsMap::const_iterator it = settings_map_.find(host_port_pair); - if (it == settings_map_.end()) { - CR_DEFINE_STATIC_LOCAL(SpdySettings, kEmpty, ()); - return kEmpty; - } - return it->second; -} - -void SpdySettingsStorage::Set(const HostPortPair& host_port_pair, - const SpdySettings& settings) { - SpdySettings persistent_settings; - - // Iterate through the list, and only copy those settings which are marked - // for persistence. - SpdySettings::const_iterator it; - for (it = settings.begin(); it != settings.end(); ++it) { - SettingsFlagsAndId id = it->first; - if (id.flags() & SETTINGS_FLAG_PLEASE_PERSIST) { - SettingsFlagsAndId new_id(SETTINGS_FLAG_PERSISTED, id.id()); - persistent_settings.push_back(std::make_pair(new_id, it->second)); - } - } - - // If we didn't persist anything, then we are done. - if (persistent_settings.empty()) - return; - - settings_map_[host_port_pair] = persistent_settings; -} - -void SpdySettingsStorage::Clear() { - settings_map_.clear(); -} - -} // namespace net - diff --git a/net/spdy/spdy_settings_storage.h b/net/spdy/spdy_settings_storage.h deleted file mode 100644 index f576cd4..0000000 --- a/net/spdy/spdy_settings_storage.h +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef NET_SPDY_SPDY_SETTING_STORAGE_H_ -#define NET_SPDY_SPDY_SETTING_STORAGE_H_ -#pragma once - -#include <map> -#include "base/basictypes.h" -#include "net/base/host_port_pair.h" -#include "net/base/net_export.h" -#include "net/spdy/spdy_framer.h" - -namespace net { - -// SpdySettingsStorage stores SpdySettings which have been transmitted between -// endpoints for the SPDY SETTINGS frame. -class NET_EXPORT_PRIVATE SpdySettingsStorage { - public: - SpdySettingsStorage(); - ~SpdySettingsStorage(); - - // Gets a copy of the SpdySettings stored for a host. - // If no settings are stored, returns an empty set of settings. - // NOTE: Since settings_map_ may be cleared, don't store the address of the - // return value. - const SpdySettings& Get(const HostPortPair& host_port_pair) const; - - // Saves settings for a host. - void Set(const HostPortPair& host_port_pair, - const SpdySettings& settings); - - // Clears out the settings_map_ object. - void Clear(); - - private: - typedef std::map<HostPortPair, SpdySettings> SettingsMap; - - SettingsMap settings_map_; - - DISALLOW_COPY_AND_ASSIGN(SpdySettingsStorage); -}; - -} // namespace net - -#endif // NET_SPDY_SPDY_SETTING_STORAGE_H_ - diff --git a/net/spdy/spdy_test_util_spdy2.cc b/net/spdy/spdy_test_util_spdy2.cc index f67e789..3d43f12 100644 --- a/net/spdy/spdy_test_util_spdy2.cc +++ b/net/spdy/spdy_test_util_spdy2.cc @@ -212,8 +212,7 @@ SpdyFrame* ConstructSpdyPacket(const SpdyHeaderInfo& header_info, // Construct an expected SPDY SETTINGS frame. // |settings| are the settings to set. // Returns the constructed frame. The caller takes ownership of the frame. -SpdyFrame* ConstructSpdySettings( - const SpdySettings& settings) { +SpdyFrame* ConstructSpdySettings(const SettingsMap& settings) { BufferedSpdyFramer framer(2); return framer.CreateSettings(settings); } diff --git a/net/spdy/spdy_test_util_spdy2.h b/net/spdy/spdy_test_util_spdy2.h index 9441c3d..9bd8dd2 100644 --- a/net/spdy/spdy_test_util_spdy2.h +++ b/net/spdy/spdy_test_util_spdy2.h @@ -158,8 +158,7 @@ int ConstructSpdyReplyString(const char* const extra_headers[], // Construct an expected SPDY SETTINGS frame. // |settings| are the settings to set. // Returns the constructed frame. The caller takes ownership of the frame. -SpdyFrame* ConstructSpdySettings( - const SpdySettings& settings); +SpdyFrame* ConstructSpdySettings(const SettingsMap& settings); // Construct an expected SPDY CREDENTIAL frame. // |credential| is the credential to send. diff --git a/net/spdy/spdy_test_util_spdy3.cc b/net/spdy/spdy_test_util_spdy3.cc index 96bfbd9..764f50e 100644 --- a/net/spdy/spdy_test_util_spdy3.cc +++ b/net/spdy/spdy_test_util_spdy3.cc @@ -214,8 +214,7 @@ SpdyFrame* ConstructSpdyPacket(const SpdyHeaderInfo& header_info, // Construct an expected SPDY SETTINGS frame. // |settings| are the settings to set. // Returns the constructed frame. The caller takes ownership of the frame. -SpdyFrame* ConstructSpdySettings( - const SpdySettings& settings) { +SpdyFrame* ConstructSpdySettings(const SettingsMap& settings) { BufferedSpdyFramer framer(3); return framer.CreateSettings(settings); } diff --git a/net/spdy/spdy_test_util_spdy3.h b/net/spdy/spdy_test_util_spdy3.h index c150520..ea41b12 100644 --- a/net/spdy/spdy_test_util_spdy3.h +++ b/net/spdy/spdy_test_util_spdy3.h @@ -159,8 +159,7 @@ int ConstructSpdyReplyString(const char* const extra_headers[], // Construct an expected SPDY SETTINGS frame. // |settings| are the settings to set. // Returns the constructed frame. The caller takes ownership of the frame. -SpdyFrame* ConstructSpdySettings( - const SpdySettings& settings); +SpdyFrame* ConstructSpdySettings(const SettingsMap& settings); // Construct an expected SPDY CREDENTIAL frame. // |credential| is the credential to send. diff --git a/net/spdy/spdy_websocket_stream_spdy2_unittest.cc b/net/spdy/spdy_websocket_stream_spdy2_unittest.cc index 4541cb4..9ce2a3d 100644 --- a/net/spdy/spdy_websocket_stream_spdy2_unittest.cc +++ b/net/spdy/spdy_websocket_stream_spdy2_unittest.cc @@ -196,9 +196,9 @@ class SpdyWebSocketStreamSpdy2Test : public testing::Test { spdy_settings_flags_to_set_ = SETTINGS_FLAG_PLEASE_PERSIST; spdy_settings_value_to_set_ = 1; - SettingsFlagsAndId id1(SETTINGS_FLAG_PERSISTED, spdy_settings_id_to_set_); - spdy_settings_to_send_.push_back( - SpdySetting(id1, spdy_settings_value_to_set_)); + spdy_settings_to_send_[spdy_settings_id_to_set_] = + SettingsFlagsAndValue( + SETTINGS_FLAG_PERSISTED, spdy_settings_value_to_set_); } virtual void TearDown() { @@ -290,7 +290,7 @@ class SpdyWebSocketStreamSpdy2Test : public testing::Test { SpdySettingsIds spdy_settings_id_to_set_; SpdySettingsFlags spdy_settings_flags_to_set_; uint32 spdy_settings_value_to_set_; - SpdySettings spdy_settings_to_send_; + SettingsMap spdy_settings_to_send_; SpdySessionDependencies session_deps_; scoped_ptr<OrderedSocketData> data_; scoped_refptr<HttpNetworkSession> http_session_; diff --git a/net/spdy/spdy_websocket_stream_spdy3_unittest.cc b/net/spdy/spdy_websocket_stream_spdy3_unittest.cc index 522e57a..cecc96b 100644 --- a/net/spdy/spdy_websocket_stream_spdy3_unittest.cc +++ b/net/spdy/spdy_websocket_stream_spdy3_unittest.cc @@ -196,9 +196,9 @@ class SpdyWebSocketStreamSpdy3Test : public testing::Test { spdy_settings_flags_to_set_ = SETTINGS_FLAG_PLEASE_PERSIST; spdy_settings_value_to_set_ = 1; - SettingsFlagsAndId id1(SETTINGS_FLAG_PERSISTED, spdy_settings_id_to_set_); - spdy_settings_to_send_.push_back( - SpdySetting(id1, spdy_settings_value_to_set_)); + spdy_settings_to_send_[spdy_settings_id_to_set_] = + SettingsFlagsAndValue( + SETTINGS_FLAG_PERSISTED, spdy_settings_value_to_set_); } virtual void TearDown() { @@ -290,7 +290,7 @@ class SpdyWebSocketStreamSpdy3Test : public testing::Test { SpdySettingsIds spdy_settings_id_to_set_; SpdySettingsFlags spdy_settings_flags_to_set_; uint32 spdy_settings_value_to_set_; - SpdySettings spdy_settings_to_send_; + SettingsMap spdy_settings_to_send_; SpdySessionDependencies session_deps_; scoped_ptr<OrderedSocketData> data_; scoped_refptr<HttpNetworkSession> http_session_; diff --git a/net/tools/flip_server/spdy_interface.cc b/net/tools/flip_server/spdy_interface.cc index 385cc26..969ea450 100644 --- a/net/tools/flip_server/spdy_interface.cc +++ b/net/tools/flip_server/spdy_interface.cc @@ -293,9 +293,9 @@ void SpdySM::ResetForNewConnection() { // Send a settings frame int SpdySM::PostAcceptHook() { - SpdySettings settings; - SettingsFlagsAndId settings_id(0, SETTINGS_MAX_CONCURRENT_STREAMS); - settings.push_back(SpdySetting(settings_id, 100)); + SettingsMap settings; + settings[SETTINGS_MAX_CONCURRENT_STREAMS] = + SettingsFlagsAndValue(SETTINGS_FLAG_NONE, 100); SpdySettingsControlFrame* settings_frame = buffered_spdy_framer_->CreateSettings(settings); |