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

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

Issue 257044: This is a second attempt at submitting this changelist. The original one was... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 2 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
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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/socket_test_util.h" 5 #include "net/socket/socket_test_util.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 // static 327 // static
328 const int ClientSocketPoolTest::kRequestNotFound = -2; 328 const int ClientSocketPoolTest::kRequestNotFound = -2;
329 329
330 void ClientSocketPoolTest::SetUp() { 330 void ClientSocketPoolTest::SetUp() {
331 completion_count_ = 0; 331 completion_count_ = 0;
332 } 332 }
333 333
334 void ClientSocketPoolTest::TearDown() { 334 void ClientSocketPoolTest::TearDown() {
335 // The tests often call Reset() on handles at the end which may post 335 // The tests often call Reset() on handles at the end which may post
336 // DoReleaseSocket() tasks. 336 // DoReleaseSocket() tasks.
337 // Pending tasks created by client_socket_pool_base_unittest.cc are
338 // posted two milliseconds into the future and thus won't become
339 // scheduled until that time.
340 // We wait a few milliseconds to make sure that all such future tasks
341 // are ready to run, before calling RunAllPending(). This will work
342 // correctly even if Sleep() finishes late (and it should never finish
343 // early), as all we have to ensure is that actual wall-time has progressed
344 // past the scheduled starting time of the pending task.
345 PlatformThread::Sleep(10);
337 MessageLoop::current()->RunAllPending(); 346 MessageLoop::current()->RunAllPending();
338 } 347 }
339 348
340 int ClientSocketPoolTest::GetOrderOfRequest(size_t index) { 349 int ClientSocketPoolTest::GetOrderOfRequest(size_t index) {
341 index--; 350 index--;
342 if (index >= requests_.size()) 351 if (index >= requests_.size())
343 return kIndexOutOfBounds; 352 return kIndexOutOfBounds;
344 353
345 for (size_t i = 0; i < request_order_.size(); i++) 354 for (size_t i = 0; i < request_order_.size(); i++)
346 if (requests_[index] == request_order_[i]) 355 if (requests_[index] == request_order_[i])
(...skipping 17 matching lines...) Expand all
364 } 373 }
365 374
366 void ClientSocketPoolTest::ReleaseAllConnections(KeepAlive keep_alive) { 375 void ClientSocketPoolTest::ReleaseAllConnections(KeepAlive keep_alive) {
367 bool released_one; 376 bool released_one;
368 do { 377 do {
369 released_one = ReleaseOneConnection(keep_alive); 378 released_one = ReleaseOneConnection(keep_alive);
370 } while (released_one); 379 } while (released_one);
371 } 380 }
372 381
373 } // namespace net 382 } // namespace net
OLDNEW
« no previous file with comments | « net/socket/client_socket_pool_base_unittest.cc ('k') | net/socket/tcp_client_socket_pool_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698