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

Side by Side Diff: net/disk_cache/entry_unittest.cc

Issue 341006: Don't hang during DiskCacheEntryTest.CancelSparseIO on infinitely fast disks.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 1 month 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 | « no previous file | no next file » | 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) 2006-2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-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 "base/basictypes.h" 5 #include "base/basictypes.h"
6 #include "base/platform_thread.h" 6 #include "base/platform_thread.h"
7 #include "base/timer.h" 7 #include "base/timer.h"
8 #include "base/string_util.h" 8 #include "base/string_util.h"
9 #include "net/base/io_buffer.h" 9 #include "net/base/io_buffer.h"
10 #include "net/base/net_errors.h" 10 #include "net/base/net_errors.h"
(...skipping 1338 matching lines...) Expand 10 before | Expand all | Expand 10 after
1349 std::string key("the first key"); 1349 std::string key("the first key");
1350 disk_cache::Entry* entry; 1350 disk_cache::Entry* entry;
1351 ASSERT_TRUE(cache_->CreateEntry(key, &entry)); 1351 ASSERT_TRUE(cache_->CreateEntry(key, &entry));
1352 1352
1353 const int kSize = 40 * 1024; 1353 const int kSize = 40 * 1024;
1354 scoped_refptr<net::IOBuffer> buf = new net::IOBuffer(kSize); 1354 scoped_refptr<net::IOBuffer> buf = new net::IOBuffer(kSize);
1355 CacheTestFillBuffer(buf->data(), kSize, false); 1355 CacheTestFillBuffer(buf->data(), kSize, false);
1356 1356
1357 SimpleCallbackTest cb1, cb2, cb3, cb4; 1357 SimpleCallbackTest cb1, cb2, cb3, cb4;
1358 int64 offset = 0; 1358 int64 offset = 0;
1359 for (int ret = 0; ret != net::ERR_IO_PENDING; offset += kSize * 4) 1359 int tries = 0;
1360 const int maxtries = 1000; // Avoid hang on infinitely fast disks
rvargas (doing something else) 2009/10/27 23:04:58 Are you sure you want to have a number that high?
1361 for (int ret = 0; ret != net::ERR_IO_PENDING; offset += kSize * 4) {
1360 ret = entry->WriteSparseData(offset, buf, kSize, &cb1); 1362 ret = entry->WriteSparseData(offset, buf, kSize, &cb1);
1363 if (++tries > maxtries) {
1364 LOG(ERROR) << "Data writes never come back PENDING; skipping test";
1365 entry->Close();
1366 return;
1367 }
1368 }
1361 1369
1362 // Cannot use the entry at this point. 1370 // Cannot use the entry at this point.
1363 offset = 0; 1371 offset = 0;
1364 EXPECT_EQ(net::ERR_CACHE_OPERATION_NOT_SUPPORTED, 1372 EXPECT_EQ(net::ERR_CACHE_OPERATION_NOT_SUPPORTED,
1365 entry->GetAvailableRange(offset, kSize, &offset)); 1373 entry->GetAvailableRange(offset, kSize, &offset));
1366 EXPECT_EQ(net::OK, entry->ReadyForSparseIO(&cb2)); 1374 EXPECT_EQ(net::OK, entry->ReadyForSparseIO(&cb2));
1367 1375
1368 // We cancel the pending operation, and register multiple notifications. 1376 // We cancel the pending operation, and register multiple notifications.
1369 entry->CancelSparseIO(); 1377 entry->CancelSparseIO();
1370 EXPECT_EQ(net::ERR_IO_PENDING, entry->ReadyForSparseIO(&cb2)); 1378 EXPECT_EQ(net::ERR_IO_PENDING, entry->ReadyForSparseIO(&cb2));
(...skipping 12 matching lines...) Expand all
1383 // Now see if we receive all notifications. 1391 // Now see if we receive all notifications.
1384 EXPECT_EQ(kSize, cb1.GetResult(net::ERR_IO_PENDING)); 1392 EXPECT_EQ(kSize, cb1.GetResult(net::ERR_IO_PENDING));
1385 EXPECT_EQ(net::OK, cb2.GetResult(net::ERR_IO_PENDING)); 1393 EXPECT_EQ(net::OK, cb2.GetResult(net::ERR_IO_PENDING));
1386 EXPECT_EQ(net::OK, cb3.GetResult(net::ERR_IO_PENDING)); 1394 EXPECT_EQ(net::OK, cb3.GetResult(net::ERR_IO_PENDING));
1387 EXPECT_EQ(net::OK, cb4.GetResult(net::ERR_IO_PENDING)); 1395 EXPECT_EQ(net::OK, cb4.GetResult(net::ERR_IO_PENDING));
1388 1396
1389 EXPECT_EQ(kSize, entry->GetAvailableRange(offset, kSize, &offset)); 1397 EXPECT_EQ(kSize, entry->GetAvailableRange(offset, kSize, &offset));
1390 EXPECT_EQ(net::OK, entry->ReadyForSparseIO(&cb2)); 1398 EXPECT_EQ(net::OK, entry->ReadyForSparseIO(&cb2));
1391 entry->Close(); 1399 entry->Close();
1392 } 1400 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698