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

Side by Side Diff: net/spdy/spdy_network_transaction_unittest.cc

Issue 1535363003: Switch to standard integer types in net/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: stddef Created 5 years 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
« no previous file with comments | « net/spdy/spdy_http_stream.h ('k') | net/spdy/spdy_pinnable_buffer_piece.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <string> 5 #include <string>
6 #include <vector> 6 #include <vector>
7 7
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/bind_helpers.h" 9 #include "base/bind_helpers.h"
10 #include "base/files/file_util.h" 10 #include "base/files/file_util.h"
(...skipping 1108 matching lines...) Expand 10 before | Expand all | Expand 10 after
1119 scoped_ptr<SpdyFrame> fbody2(spdy_util_.ConstructSpdyBodyFrame(3, true)); 1119 scoped_ptr<SpdyFrame> fbody2(spdy_util_.ConstructSpdyBodyFrame(3, true));
1120 spdy_util_.UpdateWithStreamDestruction(3); 1120 spdy_util_.UpdateWithStreamDestruction(3);
1121 1121
1122 scoped_ptr<SpdyFrame> req3( 1122 scoped_ptr<SpdyFrame> req3(
1123 spdy_util_.ConstructSpdyGet(NULL, 0, false, 5, LOWEST, true)); 1123 spdy_util_.ConstructSpdyGet(NULL, 0, false, 5, LOWEST, true));
1124 scoped_ptr<SpdyFrame> resp3(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 5)); 1124 scoped_ptr<SpdyFrame> resp3(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 5));
1125 scoped_ptr<SpdyFrame> body3(spdy_util_.ConstructSpdyBodyFrame(5, false)); 1125 scoped_ptr<SpdyFrame> body3(spdy_util_.ConstructSpdyBodyFrame(5, false));
1126 scoped_ptr<SpdyFrame> fbody3(spdy_util_.ConstructSpdyBodyFrame(5, true)); 1126 scoped_ptr<SpdyFrame> fbody3(spdy_util_.ConstructSpdyBodyFrame(5, true));
1127 1127
1128 SettingsMap settings; 1128 SettingsMap settings;
1129 const uint32 max_concurrent_streams = 1; 1129 const uint32_t max_concurrent_streams = 1;
1130 settings[SETTINGS_MAX_CONCURRENT_STREAMS] = 1130 settings[SETTINGS_MAX_CONCURRENT_STREAMS] =
1131 SettingsFlagsAndValue(SETTINGS_FLAG_NONE, max_concurrent_streams); 1131 SettingsFlagsAndValue(SETTINGS_FLAG_NONE, max_concurrent_streams);
1132 scoped_ptr<SpdyFrame> settings_frame( 1132 scoped_ptr<SpdyFrame> settings_frame(
1133 spdy_util_.ConstructSpdySettings(settings)); 1133 spdy_util_.ConstructSpdySettings(settings));
1134 scoped_ptr<SpdyFrame> settings_ack(spdy_util_.ConstructSpdySettingsAck()); 1134 scoped_ptr<SpdyFrame> settings_ack(spdy_util_.ConstructSpdySettingsAck());
1135 1135
1136 MockWrite writes[] = { 1136 MockWrite writes[] = {
1137 CreateMockWrite(*req, 0), 1137 CreateMockWrite(*req, 0),
1138 CreateMockWrite(*settings_ack, 5), 1138 CreateMockWrite(*settings_ack, 5),
1139 CreateMockWrite(*req2, 6), 1139 CreateMockWrite(*req2, 6),
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
1255 scoped_ptr<SpdyFrame> fbody4(spdy_util_.ConstructSpdyBodyFrame(5, true)); 1255 scoped_ptr<SpdyFrame> fbody4(spdy_util_.ConstructSpdyBodyFrame(5, true));
1256 spdy_util_.UpdateWithStreamDestruction(5); 1256 spdy_util_.UpdateWithStreamDestruction(5);
1257 1257
1258 scoped_ptr<SpdyFrame> req3( 1258 scoped_ptr<SpdyFrame> req3(
1259 spdy_util_.ConstructSpdyGet(NULL, 0, false, 7, LOWEST, true)); 1259 spdy_util_.ConstructSpdyGet(NULL, 0, false, 7, LOWEST, true));
1260 scoped_ptr<SpdyFrame> resp3(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 7)); 1260 scoped_ptr<SpdyFrame> resp3(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 7));
1261 scoped_ptr<SpdyFrame> body3(spdy_util_.ConstructSpdyBodyFrame(7, false)); 1261 scoped_ptr<SpdyFrame> body3(spdy_util_.ConstructSpdyBodyFrame(7, false));
1262 scoped_ptr<SpdyFrame> fbody3(spdy_util_.ConstructSpdyBodyFrame(7, true)); 1262 scoped_ptr<SpdyFrame> fbody3(spdy_util_.ConstructSpdyBodyFrame(7, true));
1263 1263
1264 SettingsMap settings; 1264 SettingsMap settings;
1265 const uint32 max_concurrent_streams = 1; 1265 const uint32_t max_concurrent_streams = 1;
1266 settings[SETTINGS_MAX_CONCURRENT_STREAMS] = 1266 settings[SETTINGS_MAX_CONCURRENT_STREAMS] =
1267 SettingsFlagsAndValue(SETTINGS_FLAG_NONE, max_concurrent_streams); 1267 SettingsFlagsAndValue(SETTINGS_FLAG_NONE, max_concurrent_streams);
1268 scoped_ptr<SpdyFrame> settings_frame( 1268 scoped_ptr<SpdyFrame> settings_frame(
1269 spdy_util_.ConstructSpdySettings(settings)); 1269 spdy_util_.ConstructSpdySettings(settings));
1270 scoped_ptr<SpdyFrame> settings_ack(spdy_util_.ConstructSpdySettingsAck()); 1270 scoped_ptr<SpdyFrame> settings_ack(spdy_util_.ConstructSpdySettingsAck());
1271 MockWrite writes[] = { 1271 MockWrite writes[] = {
1272 CreateMockWrite(*req, 0), 1272 CreateMockWrite(*req, 0),
1273 CreateMockWrite(*settings_ack, 5), 1273 CreateMockWrite(*settings_ack, 5),
1274 // By making these synchronous, it guarantees that they are not *started* 1274 // By making these synchronous, it guarantees that they are not *started*
1275 // before their sequence number, which in turn verifies that only a single 1275 // before their sequence number, which in turn verifies that only a single
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
1394 scoped_ptr<SpdyFrame> fbody(spdy_util_.ConstructSpdyBodyFrame(1, true)); 1394 scoped_ptr<SpdyFrame> fbody(spdy_util_.ConstructSpdyBodyFrame(1, true));
1395 spdy_util_.UpdateWithStreamDestruction(1); 1395 spdy_util_.UpdateWithStreamDestruction(1);
1396 1396
1397 scoped_ptr<SpdyFrame> req2( 1397 scoped_ptr<SpdyFrame> req2(
1398 spdy_util_.ConstructSpdyGet(NULL, 0, false, 3, LOWEST, true)); 1398 spdy_util_.ConstructSpdyGet(NULL, 0, false, 3, LOWEST, true));
1399 scoped_ptr<SpdyFrame> resp2(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 3)); 1399 scoped_ptr<SpdyFrame> resp2(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 3));
1400 scoped_ptr<SpdyFrame> body2(spdy_util_.ConstructSpdyBodyFrame(3, false)); 1400 scoped_ptr<SpdyFrame> body2(spdy_util_.ConstructSpdyBodyFrame(3, false));
1401 scoped_ptr<SpdyFrame> fbody2(spdy_util_.ConstructSpdyBodyFrame(3, true)); 1401 scoped_ptr<SpdyFrame> fbody2(spdy_util_.ConstructSpdyBodyFrame(3, true));
1402 1402
1403 SettingsMap settings; 1403 SettingsMap settings;
1404 const uint32 max_concurrent_streams = 1; 1404 const uint32_t max_concurrent_streams = 1;
1405 settings[SETTINGS_MAX_CONCURRENT_STREAMS] = 1405 settings[SETTINGS_MAX_CONCURRENT_STREAMS] =
1406 SettingsFlagsAndValue(SETTINGS_FLAG_NONE, max_concurrent_streams); 1406 SettingsFlagsAndValue(SETTINGS_FLAG_NONE, max_concurrent_streams);
1407 scoped_ptr<SpdyFrame> settings_frame( 1407 scoped_ptr<SpdyFrame> settings_frame(
1408 spdy_util_.ConstructSpdySettings(settings)); 1408 spdy_util_.ConstructSpdySettings(settings));
1409 scoped_ptr<SpdyFrame> settings_ack(spdy_util_.ConstructSpdySettingsAck()); 1409 scoped_ptr<SpdyFrame> settings_ack(spdy_util_.ConstructSpdySettingsAck());
1410 1410
1411 MockWrite writes[] = { 1411 MockWrite writes[] = {
1412 CreateMockWrite(*req, 0), 1412 CreateMockWrite(*req, 0),
1413 CreateMockWrite(*settings_ack, 5), 1413 CreateMockWrite(*settings_ack, 5),
1414 CreateMockWrite(*req2, 6), 1414 CreateMockWrite(*req2, 6),
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
1524 scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); 1524 scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1));
1525 scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(1, false)); 1525 scoped_ptr<SpdyFrame> body(spdy_util_.ConstructSpdyBodyFrame(1, false));
1526 scoped_ptr<SpdyFrame> fin_body(spdy_util_.ConstructSpdyBodyFrame(1, true)); 1526 scoped_ptr<SpdyFrame> fin_body(spdy_util_.ConstructSpdyBodyFrame(1, true));
1527 spdy_util_.UpdateWithStreamDestruction(1); 1527 spdy_util_.UpdateWithStreamDestruction(1);
1528 1528
1529 scoped_ptr<SpdyFrame> req2( 1529 scoped_ptr<SpdyFrame> req2(
1530 spdy_util_.ConstructSpdyGet(NULL, 0, false, 3, LOWEST, true)); 1530 spdy_util_.ConstructSpdyGet(NULL, 0, false, 3, LOWEST, true));
1531 scoped_ptr<SpdyFrame> resp2(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 3)); 1531 scoped_ptr<SpdyFrame> resp2(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 3));
1532 1532
1533 SettingsMap settings; 1533 SettingsMap settings;
1534 const uint32 max_concurrent_streams = 1; 1534 const uint32_t max_concurrent_streams = 1;
1535 settings[SETTINGS_MAX_CONCURRENT_STREAMS] = 1535 settings[SETTINGS_MAX_CONCURRENT_STREAMS] =
1536 SettingsFlagsAndValue(SETTINGS_FLAG_NONE, max_concurrent_streams); 1536 SettingsFlagsAndValue(SETTINGS_FLAG_NONE, max_concurrent_streams);
1537 scoped_ptr<SpdyFrame> settings_frame( 1537 scoped_ptr<SpdyFrame> settings_frame(
1538 spdy_util_.ConstructSpdySettings(settings)); 1538 spdy_util_.ConstructSpdySettings(settings));
1539 scoped_ptr<SpdyFrame> settings_ack(spdy_util_.ConstructSpdySettingsAck()); 1539 scoped_ptr<SpdyFrame> settings_ack(spdy_util_.ConstructSpdySettingsAck());
1540 1540
1541 MockWrite writes[] = { 1541 MockWrite writes[] = {
1542 CreateMockWrite(*req, 0), 1542 CreateMockWrite(*req, 0),
1543 CreateMockWrite(*settings_ack, 5), 1543 CreateMockWrite(*settings_ack, 5),
1544 CreateMockWrite(*req2, 6), 1544 CreateMockWrite(*req2, 6),
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after
1908 // Create an empty UploadDataStream. 1908 // Create an empty UploadDataStream.
1909 std::vector<scoped_ptr<UploadElementReader>> element_readers; 1909 std::vector<scoped_ptr<UploadElementReader>> element_readers;
1910 ElementsUploadDataStream stream(std::move(element_readers), 0); 1910 ElementsUploadDataStream stream(std::move(element_readers), 0);
1911 1911
1912 // Setup the request 1912 // Setup the request
1913 HttpRequestInfo request; 1913 HttpRequestInfo request;
1914 request.method = "POST"; 1914 request.method = "POST";
1915 request.url = GURL(GetDefaultUrl()); 1915 request.url = GURL(GetDefaultUrl());
1916 request.upload_data_stream = &stream; 1916 request.upload_data_stream = &stream;
1917 1917
1918 const uint64 kContentLength = 0; 1918 const uint64_t kContentLength = 0;
1919 1919
1920 scoped_ptr<SpdyHeaderBlock> req_block( 1920 scoped_ptr<SpdyHeaderBlock> req_block(
1921 spdy_util_.ConstructPostHeaderBlock(GetDefaultUrl(), kContentLength)); 1921 spdy_util_.ConstructPostHeaderBlock(GetDefaultUrl(), kContentLength));
1922 scoped_ptr<SpdyFrame> req( 1922 scoped_ptr<SpdyFrame> req(
1923 spdy_util_.ConstructSpdySyn(1, *req_block, LOWEST, false, true)); 1923 spdy_util_.ConstructSpdySyn(1, *req_block, LOWEST, false, true));
1924 1924
1925 MockWrite writes[] = { 1925 MockWrite writes[] = {
1926 CreateMockWrite(*req, 0), 1926 CreateMockWrite(*req, 0),
1927 }; 1927 };
1928 1928
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after
2248 // http://crbug.com/47455 2248 // http://crbug.com/47455
2249 TEST_P(SpdyNetworkTransactionTest, StartTransactionOnReadCallback) { 2249 TEST_P(SpdyNetworkTransactionTest, StartTransactionOnReadCallback) {
2250 scoped_ptr<SpdyFrame> req( 2250 scoped_ptr<SpdyFrame> req(
2251 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true)); 2251 spdy_util_.ConstructSpdyGet(NULL, 0, false, 1, LOWEST, true));
2252 MockWrite writes[] = {CreateMockWrite(*req)}; 2252 MockWrite writes[] = {CreateMockWrite(*req)};
2253 MockWrite writes2[] = {CreateMockWrite(*req, 0)}; 2253 MockWrite writes2[] = {CreateMockWrite(*req, 0)};
2254 2254
2255 // The indicated length of this frame is longer than its actual length. When 2255 // The indicated length of this frame is longer than its actual length. When
2256 // the session receives an empty frame after this one, it shuts down the 2256 // the session receives an empty frame after this one, it shuts down the
2257 // session, and calls the read callback with the incomplete data. 2257 // session, and calls the read callback with the incomplete data.
2258 const uint8 kGetBodyFrame2[] = { 2258 const uint8_t kGetBodyFrame2[] = {
2259 0x00, 0x00, 0x00, 0x01, 2259 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00,
2260 0x01, 0x00, 0x00, 0x07, 2260 0x07, 'h', 'e', 'l', 'l', 'o', '!',
2261 'h', 'e', 'l', 'l', 'o', '!',
2262 }; 2261 };
2263 2262
2264 scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1)); 2263 scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyGetSynReply(NULL, 0, 1));
2265 MockRead reads[] = { 2264 MockRead reads[] = {
2266 CreateMockRead(*resp, 1), 2265 CreateMockRead(*resp, 1),
2267 MockRead(ASYNC, ERR_IO_PENDING, 2), // Force a pause 2266 MockRead(ASYNC, ERR_IO_PENDING, 2), // Force a pause
2268 MockRead(ASYNC, reinterpret_cast<const char*>(kGetBodyFrame2), 2267 MockRead(ASYNC, reinterpret_cast<const char*>(kGetBodyFrame2),
2269 arraysize(kGetBodyFrame2), 3), 2268 arraysize(kGetBodyFrame2), 3),
2270 MockRead(ASYNC, ERR_IO_PENDING, 4), // Force a pause 2269 MockRead(ASYNC, ERR_IO_PENDING, 4), // Force a pause
2271 MockRead(ASYNC, 0, 0, 5), // EOF 2270 MockRead(ASYNC, 0, 0, 5), // EOF
(...skipping 3473 matching lines...) Expand 10 before | Expand all | Expand 10 after
5745 scoped_ptr<SpdyFrame> body_end( 5744 scoped_ptr<SpdyFrame> body_end(
5746 spdy_util_.ConstructSpdyBodyFrame( 5745 spdy_util_.ConstructSpdyBodyFrame(
5747 1, content->c_str(), content->size(), true)); 5746 1, content->c_str(), content->size(), true));
5748 5747
5749 MockWrite writes[] = { 5748 MockWrite writes[] = {
5750 CreateMockWrite(*req, 0), 5749 CreateMockWrite(*req, 0),
5751 CreateMockWrite(*body, 1), 5750 CreateMockWrite(*body, 1),
5752 CreateMockWrite(*body_end, 2), 5751 CreateMockWrite(*body_end, 2),
5753 }; 5752 };
5754 5753
5755 static const int32 kDeltaWindowSize = 0xff; 5754 static const int32_t kDeltaWindowSize = 0xff;
5756 static const int kDeltaCount = 4; 5755 static const int kDeltaCount = 4;
5757 scoped_ptr<SpdyFrame> window_update( 5756 scoped_ptr<SpdyFrame> window_update(
5758 spdy_util_.ConstructSpdyWindowUpdate(1, kDeltaWindowSize)); 5757 spdy_util_.ConstructSpdyWindowUpdate(1, kDeltaWindowSize));
5759 scoped_ptr<SpdyFrame> window_update_dummy( 5758 scoped_ptr<SpdyFrame> window_update_dummy(
5760 spdy_util_.ConstructSpdyWindowUpdate(2, kDeltaWindowSize)); 5759 spdy_util_.ConstructSpdyWindowUpdate(2, kDeltaWindowSize));
5761 scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyPostSynReply(NULL, 0)); 5760 scoped_ptr<SpdyFrame> resp(spdy_util_.ConstructSpdyPostSynReply(NULL, 0));
5762 MockRead reads[] = { 5761 MockRead reads[] = {
5763 CreateMockRead(*window_update_dummy, 3), 5762 CreateMockRead(*window_update_dummy, 3),
5764 CreateMockRead(*window_update_dummy, 4), 5763 CreateMockRead(*window_update_dummy, 4),
5765 CreateMockRead(*window_update_dummy, 5), 5764 CreateMockRead(*window_update_dummy, 5),
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
5815 5814
5816 rv = callback.WaitForResult(); 5815 rv = callback.WaitForResult();
5817 EXPECT_EQ(OK, rv); 5816 EXPECT_EQ(OK, rv);
5818 5817
5819 helper.VerifyDataConsumed(); 5818 helper.VerifyDataConsumed();
5820 } 5819 }
5821 5820
5822 // Test that received data frames and sent WINDOW_UPDATE frames change 5821 // Test that received data frames and sent WINDOW_UPDATE frames change
5823 // the recv_window_size_ correctly. 5822 // the recv_window_size_ correctly.
5824 TEST_P(SpdyNetworkTransactionTest, WindowUpdateSent) { 5823 TEST_P(SpdyNetworkTransactionTest, WindowUpdateSent) {
5825 const int32 default_initial_window_size = 5824 const int32_t default_initial_window_size =
5826 SpdySession::GetDefaultInitialWindowSize(GetParam().protocol); 5825 SpdySession::GetDefaultInitialWindowSize(GetParam().protocol);
5827 // Session level maximum window size that is more than twice the default 5826 // Session level maximum window size that is more than twice the default
5828 // initial window size so that an initial window update is sent. 5827 // initial window size so that an initial window update is sent.
5829 const int32 session_max_recv_window_size = 5 * 64 * 1024; 5828 const int32_t session_max_recv_window_size = 5 * 64 * 1024;
5830 ASSERT_LT(2 * default_initial_window_size, session_max_recv_window_size); 5829 ASSERT_LT(2 * default_initial_window_size, session_max_recv_window_size);
5831 // Stream level maximum window size that is less than the session level 5830 // Stream level maximum window size that is less than the session level
5832 // maximum window size so that we test for confusion between the two. 5831 // maximum window size so that we test for confusion between the two.
5833 const int32 stream_max_recv_window_size = 4 * 64 * 1024; 5832 const int32_t stream_max_recv_window_size = 4 * 64 * 1024;
5834 ASSERT_GT(session_max_recv_window_size, stream_max_recv_window_size); 5833 ASSERT_GT(session_max_recv_window_size, stream_max_recv_window_size);
5835 // Size of body to be sent. Has to be less than or equal to both window sizes 5834 // Size of body to be sent. Has to be less than or equal to both window sizes
5836 // so that we do not run out of receiving window. Also has to be greater than 5835 // so that we do not run out of receiving window. Also has to be greater than
5837 // half of them so that it triggers both a session level and a stream level 5836 // half of them so that it triggers both a session level and a stream level
5838 // window update frame. 5837 // window update frame.
5839 const int32 kTargetSize = 3 * 64 * 1024; 5838 const int32_t kTargetSize = 3 * 64 * 1024;
5840 ASSERT_GE(session_max_recv_window_size, kTargetSize); 5839 ASSERT_GE(session_max_recv_window_size, kTargetSize);
5841 ASSERT_GE(stream_max_recv_window_size, kTargetSize); 5840 ASSERT_GE(stream_max_recv_window_size, kTargetSize);
5842 ASSERT_LT(session_max_recv_window_size / 2, kTargetSize); 5841 ASSERT_LT(session_max_recv_window_size / 2, kTargetSize);
5843 ASSERT_LT(stream_max_recv_window_size / 2, kTargetSize); 5842 ASSERT_LT(stream_max_recv_window_size / 2, kTargetSize);
5844 // Size of each DATA frame. 5843 // Size of each DATA frame.
5845 const int32 kChunkSize = 4096; 5844 const int32_t kChunkSize = 4096;
5846 // Size of window updates. 5845 // Size of window updates.
5847 ASSERT_EQ(0, session_max_recv_window_size / 2 % kChunkSize); 5846 ASSERT_EQ(0, session_max_recv_window_size / 2 % kChunkSize);
5848 const int32 session_window_update_delta = 5847 const int32_t session_window_update_delta =
5849 session_max_recv_window_size / 2 + kChunkSize; 5848 session_max_recv_window_size / 2 + kChunkSize;
5850 ASSERT_EQ(0, stream_max_recv_window_size / 2 % kChunkSize); 5849 ASSERT_EQ(0, stream_max_recv_window_size / 2 % kChunkSize);
5851 const int32 stream_window_update_delta = 5850 const int32_t stream_window_update_delta =
5852 stream_max_recv_window_size / 2 + kChunkSize; 5851 stream_max_recv_window_size / 2 + kChunkSize;
5853 5852
5854 SettingsMap initial_settings; 5853 SettingsMap initial_settings;
5855 initial_settings[SETTINGS_MAX_CONCURRENT_STREAMS] = 5854 initial_settings[SETTINGS_MAX_CONCURRENT_STREAMS] =
5856 SettingsFlagsAndValue(SETTINGS_FLAG_NONE, kMaxConcurrentPushedStreams); 5855 SettingsFlagsAndValue(SETTINGS_FLAG_NONE, kMaxConcurrentPushedStreams);
5857 initial_settings[SETTINGS_INITIAL_WINDOW_SIZE] = 5856 initial_settings[SETTINGS_INITIAL_WINDOW_SIZE] =
5858 SettingsFlagsAndValue(SETTINGS_FLAG_NONE, stream_max_recv_window_size); 5857 SettingsFlagsAndValue(SETTINGS_FLAG_NONE, stream_max_recv_window_size);
5859 scoped_ptr<SpdyFrame> initial_settings_frame( 5858 scoped_ptr<SpdyFrame> initial_settings_frame(
5860 spdy_util_.ConstructSpdySettings(initial_settings)); 5859 spdy_util_.ConstructSpdySettings(initial_settings));
5861 scoped_ptr<SpdyFrame> initial_window_update( 5860 scoped_ptr<SpdyFrame> initial_window_update(
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
5971 spdy_util_.ConstructSpdyRstStream(1, RST_STREAM_FLOW_CONTROL_ERROR)); 5970 spdy_util_.ConstructSpdyRstStream(1, RST_STREAM_FLOW_CONTROL_ERROR));
5972 5971
5973 // We're not going to write a data frame with FIN, we'll receive a bad 5972 // We're not going to write a data frame with FIN, we'll receive a bad
5974 // WINDOW_UPDATE while sending a request and will send a RST_STREAM frame. 5973 // WINDOW_UPDATE while sending a request and will send a RST_STREAM frame.
5975 MockWrite writes[] = { 5974 MockWrite writes[] = {
5976 CreateMockWrite(*req, 0), 5975 CreateMockWrite(*req, 0),
5977 CreateMockWrite(*body, 2), 5976 CreateMockWrite(*body, 2),
5978 CreateMockWrite(*rst, 3), 5977 CreateMockWrite(*rst, 3),
5979 }; 5978 };
5980 5979
5981 static const int32 kDeltaWindowSize = 0x7fffffff; // cause an overflow 5980 static const int32_t kDeltaWindowSize = 0x7fffffff; // cause an overflow
5982 scoped_ptr<SpdyFrame> window_update( 5981 scoped_ptr<SpdyFrame> window_update(
5983 spdy_util_.ConstructSpdyWindowUpdate(1, kDeltaWindowSize)); 5982 spdy_util_.ConstructSpdyWindowUpdate(1, kDeltaWindowSize));
5984 MockRead reads[] = { 5983 MockRead reads[] = {
5985 CreateMockRead(*window_update, 1), 5984 CreateMockRead(*window_update, 1),
5986 MockRead(ASYNC, 0, 4) // EOF 5985 MockRead(ASYNC, 0, 4) // EOF
5987 }; 5986 };
5988 5987
5989 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes)); 5988 SequencedSocketData data(reads, arraysize(reads), writes, arraysize(writes));
5990 5989
5991 std::vector<scoped_ptr<UploadElementReader>> element_readers; 5990 std::vector<scoped_ptr<UploadElementReader>> element_readers;
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
6026 // also contains a FIN flag. SequencedSocketData is used to enforce all 6025 // also contains a FIN flag. SequencedSocketData is used to enforce all
6027 // writes, save the last, go through before a read could happen. The last frame 6026 // writes, save the last, go through before a read could happen. The last frame
6028 // ("hello!") is not permitted to go through since by the time its turn 6027 // ("hello!") is not permitted to go through since by the time its turn
6029 // arrives, window size is 0. At this point MessageLoop::Run() called via 6028 // arrives, window size is 0. At this point MessageLoop::Run() called via
6030 // callback would block. Therefore we call MessageLoop::RunUntilIdle() 6029 // callback would block. Therefore we call MessageLoop::RunUntilIdle()
6031 // which returns after performing all possible writes. We use DCHECKS to 6030 // which returns after performing all possible writes. We use DCHECKS to
6032 // ensure that last data frame is still there and stream has stalled. 6031 // ensure that last data frame is still there and stream has stalled.
6033 // After that, next read is artifically enforced, which causes a 6032 // After that, next read is artifically enforced, which causes a
6034 // WINDOW_UPDATE to be read and I/O process resumes. 6033 // WINDOW_UPDATE to be read and I/O process resumes.
6035 TEST_P(SpdyNetworkTransactionTest, FlowControlStallResume) { 6034 TEST_P(SpdyNetworkTransactionTest, FlowControlStallResume) {
6036 const int32 initial_window_size = 6035 const int32_t initial_window_size =
6037 SpdySession::GetDefaultInitialWindowSize(GetParam().protocol); 6036 SpdySession::GetDefaultInitialWindowSize(GetParam().protocol);
6038 // Number of frames we need to send to zero out the window size: data 6037 // Number of frames we need to send to zero out the window size: data
6039 // frames plus SYN_STREAM plus the last data frame; also we need another 6038 // frames plus SYN_STREAM plus the last data frame; also we need another
6040 // data frame that we will send once the WINDOW_UPDATE is received, 6039 // data frame that we will send once the WINDOW_UPDATE is received,
6041 // therefore +3. 6040 // therefore +3.
6042 size_t num_writes = initial_window_size / kMaxSpdyFrameChunkSize + 3; 6041 size_t num_writes = initial_window_size / kMaxSpdyFrameChunkSize + 3;
6043 6042
6044 // Calculate last frame's size; 0 size data frame is legal. 6043 // Calculate last frame's size; 0 size data frame is legal.
6045 size_t last_frame_size = initial_window_size % kMaxSpdyFrameChunkSize; 6044 size_t last_frame_size = initial_window_size % kMaxSpdyFrameChunkSize;
6046 6045
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
6132 EXPECT_TRUE(stream->stream()->send_stalled_by_flow_control()); 6131 EXPECT_TRUE(stream->stream()->send_stalled_by_flow_control());
6133 6132
6134 data.Resume(); // Read in WINDOW_UPDATE frame. 6133 data.Resume(); // Read in WINDOW_UPDATE frame.
6135 rv = callback.WaitForResult(); 6134 rv = callback.WaitForResult();
6136 helper.VerifyDataConsumed(); 6135 helper.VerifyDataConsumed();
6137 } 6136 }
6138 6137
6139 // Test we correctly handle the case where the SETTINGS frame results in 6138 // Test we correctly handle the case where the SETTINGS frame results in
6140 // unstalling the send window. 6139 // unstalling the send window.
6141 TEST_P(SpdyNetworkTransactionTest, FlowControlStallResumeAfterSettings) { 6140 TEST_P(SpdyNetworkTransactionTest, FlowControlStallResumeAfterSettings) {
6142 const int32 initial_window_size = 6141 const int32_t initial_window_size =
6143 SpdySession::GetDefaultInitialWindowSize(GetParam().protocol); 6142 SpdySession::GetDefaultInitialWindowSize(GetParam().protocol);
6144 6143
6145 // Number of frames we need to send to zero out the window size: data 6144 // Number of frames we need to send to zero out the window size: data
6146 // frames plus SYN_STREAM plus the last data frame; also we need another 6145 // frames plus SYN_STREAM plus the last data frame; also we need another
6147 // data frame that we will send once the SETTING is received, therefore +3. 6146 // data frame that we will send once the SETTING is received, therefore +3.
6148 size_t num_writes = initial_window_size / kMaxSpdyFrameChunkSize + 3; 6147 size_t num_writes = initial_window_size / kMaxSpdyFrameChunkSize + 3;
6149 6148
6150 // Calculate last frame's size; 0 size data frame is legal. 6149 // Calculate last frame's size; 0 size data frame is legal.
6151 size_t last_frame_size = initial_window_size % kMaxSpdyFrameChunkSize; 6150 size_t last_frame_size = initial_window_size % kMaxSpdyFrameChunkSize;
6152 6151
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
6256 6255
6257 rv = callback.WaitForResult(); 6256 rv = callback.WaitForResult();
6258 helper.VerifyDataConsumed(); 6257 helper.VerifyDataConsumed();
6259 // If stream is NULL, that means it was unstalled and closed. 6258 // If stream is NULL, that means it was unstalled and closed.
6260 EXPECT_TRUE(stream->stream() == NULL); 6259 EXPECT_TRUE(stream->stream() == NULL);
6261 } 6260 }
6262 6261
6263 // Test we correctly handle the case where the SETTINGS frame results in a 6262 // Test we correctly handle the case where the SETTINGS frame results in a
6264 // negative send window size. 6263 // negative send window size.
6265 TEST_P(SpdyNetworkTransactionTest, FlowControlNegativeSendWindowSize) { 6264 TEST_P(SpdyNetworkTransactionTest, FlowControlNegativeSendWindowSize) {
6266 const int32 initial_window_size = 6265 const int32_t initial_window_size =
6267 SpdySession::GetDefaultInitialWindowSize(GetParam().protocol); 6266 SpdySession::GetDefaultInitialWindowSize(GetParam().protocol);
6268 // Number of frames we need to send to zero out the window size: data 6267 // Number of frames we need to send to zero out the window size: data
6269 // frames plus SYN_STREAM plus the last data frame; also we need another 6268 // frames plus SYN_STREAM plus the last data frame; also we need another
6270 // data frame that we will send once the SETTING is received, therefore +3. 6269 // data frame that we will send once the SETTING is received, therefore +3.
6271 size_t num_writes = initial_window_size / kMaxSpdyFrameChunkSize + 3; 6270 size_t num_writes = initial_window_size / kMaxSpdyFrameChunkSize + 3;
6272 6271
6273 // Calculate last frame's size; 0 size data frame is legal. 6272 // Calculate last frame's size; 0 size data frame is legal.
6274 size_t last_frame_size = initial_window_size % kMaxSpdyFrameChunkSize; 6273 size_t last_frame_size = initial_window_size % kMaxSpdyFrameChunkSize;
6275 6274
6276 // Construct content for a data frame of maximum size. 6275 // Construct content for a data frame of maximum size.
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after
6589 TEST_P(SpdyNetworkTransactionTLSUsageCheckTest, TLSCipherSuiteSucky) { 6588 TEST_P(SpdyNetworkTransactionTLSUsageCheckTest, TLSCipherSuiteSucky) {
6590 scoped_ptr<SSLSocketDataProvider> ssl_provider( 6589 scoped_ptr<SSLSocketDataProvider> ssl_provider(
6591 new SSLSocketDataProvider(ASYNC, OK)); 6590 new SSLSocketDataProvider(ASYNC, OK));
6592 // Set to TLS_RSA_WITH_NULL_MD5 6591 // Set to TLS_RSA_WITH_NULL_MD5
6593 SSLConnectionStatusSetCipherSuite(0x1, &ssl_provider->connection_status); 6592 SSLConnectionStatusSetCipherSuite(0x1, &ssl_provider->connection_status);
6594 6593
6595 RunTLSUsageCheckTest(ssl_provider.Pass()); 6594 RunTLSUsageCheckTest(ssl_provider.Pass());
6596 } 6595 }
6597 6596
6598 } // namespace net 6597 } // namespace net
OLDNEW
« no previous file with comments | « net/spdy/spdy_http_stream.h ('k') | net/spdy/spdy_pinnable_buffer_piece.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698