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

Side by Side Diff: net/socket/transport_client_socket_unittest.cc

Issue 7255002: Revert 90373 - Warmth of a connection (cwnd) is estimated by the amount of data written to the so... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/socket/transport_client_socket_pool_unittest.cc ('k') | net/spdy/spdy_http_stream.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:mergeinfo
OLDNEW
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/socket/tcp_client_socket.h" 5 #include "net/socket/tcp_client_socket.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "net/base/address_list.h" 8 #include "net/base/address_list.h"
9 #include "net/base/host_resolver.h" 9 #include "net/base/host_resolver.h"
10 #include "net/base/io_buffer.h" 10 #include "net/base/io_buffer.h"
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 scoped_refptr<IOBuffer> buf(new IOBuffer(4096)); 270 scoped_refptr<IOBuffer> buf(new IOBuffer(4096));
271 uint32 bytes_read = DrainClientSocket(buf, 4096, arraysize(kServerReply) - 1, 271 uint32 bytes_read = DrainClientSocket(buf, 4096, arraysize(kServerReply) - 1,
272 &callback); 272 &callback);
273 ASSERT_EQ(bytes_read, arraysize(kServerReply) - 1); 273 ASSERT_EQ(bytes_read, arraysize(kServerReply) - 1);
274 274
275 // All data has been read now. Read once more to force an ERR_IO_PENDING, and 275 // All data has been read now. Read once more to force an ERR_IO_PENDING, and
276 // then close the server socket, and note the close. 276 // then close the server socket, and note the close.
277 277
278 rv = sock_->Read(buf, 4096, &callback); 278 rv = sock_->Read(buf, 4096, &callback);
279 ASSERT_EQ(ERR_IO_PENDING, rv); 279 ASSERT_EQ(ERR_IO_PENDING, rv);
280 EXPECT_EQ(static_cast<int64>(std::string(kServerReply).size()),
281 sock_->NumBytesRead());
282 CloseServerSocket(); 280 CloseServerSocket();
283 EXPECT_EQ(0, callback.WaitForResult()); 281 EXPECT_EQ(0, callback.WaitForResult());
284 } 282 }
285 283
286 TEST_P(TransportClientSocketTest, Read_SmallChunks) { 284 TEST_P(TransportClientSocketTest, Read_SmallChunks) {
287 TestCompletionCallback callback; 285 TestCompletionCallback callback;
288 int rv = sock_->Connect(&callback); 286 int rv = sock_->Connect(&callback);
289 if (rv != OK) { 287 if (rv != OK) {
290 ASSERT_EQ(rv, ERR_IO_PENDING); 288 ASSERT_EQ(rv, ERR_IO_PENDING);
291 289
(...skipping 12 matching lines...) Expand all
304 rv = callback.WaitForResult(); 302 rv = callback.WaitForResult();
305 303
306 ASSERT_EQ(1, rv); 304 ASSERT_EQ(1, rv);
307 bytes_read += rv; 305 bytes_read += rv;
308 } 306 }
309 307
310 // All data has been read now. Read once more to force an ERR_IO_PENDING, and 308 // All data has been read now. Read once more to force an ERR_IO_PENDING, and
311 // then close the server socket, and note the close. 309 // then close the server socket, and note the close.
312 310
313 rv = sock_->Read(buf, 1, &callback); 311 rv = sock_->Read(buf, 1, &callback);
314 EXPECT_EQ(static_cast<int64>(std::string(kServerReply).size()),
315 sock_->NumBytesRead());
316 ASSERT_EQ(ERR_IO_PENDING, rv); 312 ASSERT_EQ(ERR_IO_PENDING, rv);
317 CloseServerSocket(); 313 CloseServerSocket();
318 EXPECT_EQ(0, callback.WaitForResult()); 314 EXPECT_EQ(0, callback.WaitForResult());
319 } 315 }
320 316
321 TEST_P(TransportClientSocketTest, Read_Interrupted) { 317 TEST_P(TransportClientSocketTest, Read_Interrupted) {
322 TestCompletionCallback callback; 318 TestCompletionCallback callback;
323 int rv = sock_->Connect(&callback); 319 int rv = sock_->Connect(&callback);
324 if (rv != OK) { 320 if (rv != OK) {
325 ASSERT_EQ(ERR_IO_PENDING, rv); 321 ASSERT_EQ(ERR_IO_PENDING, rv);
326 322
327 rv = callback.WaitForResult(); 323 rv = callback.WaitForResult();
328 EXPECT_EQ(rv, OK); 324 EXPECT_EQ(rv, OK);
329 } 325 }
330 SendClientRequest(); 326 SendClientRequest();
331 327
332 // Do a partial read and then exit. This test should not crash! 328 // Do a partial read and then exit. This test should not crash!
333 scoped_refptr<IOBuffer> buf(new IOBuffer(16)); 329 scoped_refptr<IOBuffer> buf(new IOBuffer(16));
334 rv = sock_->Read(buf, 16, &callback); 330 rv = sock_->Read(buf, 16, &callback);
335 EXPECT_TRUE(rv >= 0 || rv == ERR_IO_PENDING); 331 EXPECT_TRUE(rv >= 0 || rv == ERR_IO_PENDING);
336 EXPECT_EQ(0, sock_->NumBytesRead());
337 332
338 if (rv == ERR_IO_PENDING) { 333 if (rv == ERR_IO_PENDING)
339 rv = callback.WaitForResult(); 334 rv = callback.WaitForResult();
340 EXPECT_EQ(16, sock_->NumBytesRead());
341 }
342 335
343 EXPECT_NE(0, rv); 336 EXPECT_NE(0, rv);
344 } 337 }
345 338
346 TEST_P(TransportClientSocketTest, DISABLED_FullDuplex_ReadFirst) { 339 TEST_P(TransportClientSocketTest, DISABLED_FullDuplex_ReadFirst) {
347 TestCompletionCallback callback; 340 TestCompletionCallback callback;
348 int rv = sock_->Connect(&callback); 341 int rv = sock_->Connect(&callback);
349 if (rv != OK) { 342 if (rv != OK) {
350 ASSERT_EQ(rv, ERR_IO_PENDING); 343 ASSERT_EQ(rv, ERR_IO_PENDING);
351 344
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
434 // Close the server socket, so there will at least be a 0-byte read. 427 // Close the server socket, so there will at least be a 0-byte read.
435 CloseServerSocket(); 428 CloseServerSocket();
436 429
437 rv = callback.WaitForResult(); 430 rv = callback.WaitForResult();
438 EXPECT_GE(rv, 0); 431 EXPECT_GE(rv, 0);
439 } 432 }
440 433
441 } // namespace 434 } // namespace
442 435
443 } // namespace net 436 } // namespace net
OLDNEW
« no previous file with comments | « net/socket/transport_client_socket_pool_unittest.cc ('k') | net/spdy/spdy_http_stream.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698