| OLD | NEW |
| 1 // Copyright (c) 2006-2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2010 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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 EXPECT_EQ(1500, entry1->ReadData(1, 5000, buffer2, kSize2, NULL)); | 75 EXPECT_EQ(1500, entry1->ReadData(1, 5000, buffer2, kSize2, NULL)); |
| 76 | 76 |
| 77 EXPECT_EQ(0, entry1->ReadData(1, 6500, buffer2, kSize2, NULL)); | 77 EXPECT_EQ(0, entry1->ReadData(1, 6500, buffer2, kSize2, NULL)); |
| 78 EXPECT_EQ(6500, entry1->ReadData(1, 0, buffer3, kSize3, NULL)); | 78 EXPECT_EQ(6500, entry1->ReadData(1, 0, buffer3, kSize3, NULL)); |
| 79 EXPECT_EQ(8192, entry1->WriteData(1, 0, buffer3, 8192, NULL, false)); | 79 EXPECT_EQ(8192, entry1->WriteData(1, 0, buffer3, 8192, NULL, false)); |
| 80 EXPECT_EQ(8192, entry1->ReadData(1, 0, buffer3, kSize3, NULL)); | 80 EXPECT_EQ(8192, entry1->ReadData(1, 0, buffer3, kSize3, NULL)); |
| 81 EXPECT_EQ(8192, entry1->GetDataSize(1)); | 81 EXPECT_EQ(8192, entry1->GetDataSize(1)); |
| 82 | 82 |
| 83 entry1->Doom(); | 83 entry1->Doom(); |
| 84 entry1->Close(); | 84 entry1->Close(); |
| 85 FlushQueueForTest(); | |
| 86 EXPECT_EQ(0, cache_->GetEntryCount()); | 85 EXPECT_EQ(0, cache_->GetEntryCount()); |
| 87 } | 86 } |
| 88 | 87 |
| 89 TEST_F(DiskCacheEntryTest, InternalSyncIO) { | 88 TEST_F(DiskCacheEntryTest, InternalSyncIO) { |
| 90 SetDirectMode(); | |
| 91 InitCache(); | 89 InitCache(); |
| 92 InternalSyncIO(); | 90 InternalSyncIO(); |
| 93 } | 91 } |
| 94 | 92 |
| 95 TEST_F(DiskCacheEntryTest, MemoryOnlyInternalSyncIO) { | 93 TEST_F(DiskCacheEntryTest, MemoryOnlyInternalSyncIO) { |
| 96 SetMemoryOnlyMode(); | 94 SetMemoryOnlyMode(); |
| 97 InitCache(); | 95 InitCache(); |
| 98 InternalSyncIO(); | 96 InternalSyncIO(); |
| 99 } | 97 } |
| 100 | 98 |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 if (net::ERR_IO_PENDING == ret) | 216 if (net::ERR_IO_PENDING == ret) |
| 219 expected++; | 217 expected++; |
| 220 | 218 |
| 221 EXPECT_TRUE(helper.WaitUntilCacheIoFinished(expected)); | 219 EXPECT_TRUE(helper.WaitUntilCacheIoFinished(expected)); |
| 222 | 220 |
| 223 EXPECT_FALSE(g_cache_tests_error); | 221 EXPECT_FALSE(g_cache_tests_error); |
| 224 EXPECT_EQ(expected, g_cache_tests_received); | 222 EXPECT_EQ(expected, g_cache_tests_received); |
| 225 | 223 |
| 226 entry1->Doom(); | 224 entry1->Doom(); |
| 227 entry1->Close(); | 225 entry1->Close(); |
| 228 FlushQueueForTest(); | |
| 229 EXPECT_EQ(0, cache_->GetEntryCount()); | 226 EXPECT_EQ(0, cache_->GetEntryCount()); |
| 230 } | 227 } |
| 231 | 228 |
| 232 TEST_F(DiskCacheEntryTest, InternalAsyncIO) { | 229 TEST_F(DiskCacheEntryTest, InternalAsyncIO) { |
| 233 SetDirectMode(); | |
| 234 InitCache(); | 230 InitCache(); |
| 235 InternalAsyncIO(); | 231 InternalAsyncIO(); |
| 236 } | 232 } |
| 237 | 233 |
| 238 TEST_F(DiskCacheEntryTest, MemoryOnlyInternalAsyncIO) { | 234 TEST_F(DiskCacheEntryTest, MemoryOnlyInternalAsyncIO) { |
| 239 SetMemoryOnlyMode(); | 235 SetMemoryOnlyMode(); |
| 240 InitCache(); | 236 InitCache(); |
| 241 InternalAsyncIO(); | 237 InternalAsyncIO(); |
| 242 } | 238 } |
| 243 | 239 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 266 EXPECT_EQ(0, memcmp(buffer2->data(), buffer2->data(), 10000)); | 262 EXPECT_EQ(0, memcmp(buffer2->data(), buffer2->data(), 10000)); |
| 267 EXPECT_EQ(5000, entry1->ReadData(1, 30000, buffer2, kSize2, NULL)); | 263 EXPECT_EQ(5000, entry1->ReadData(1, 30000, buffer2, kSize2, NULL)); |
| 268 | 264 |
| 269 EXPECT_EQ(0, entry1->ReadData(1, 35000, buffer2, kSize2, NULL)); | 265 EXPECT_EQ(0, entry1->ReadData(1, 35000, buffer2, kSize2, NULL)); |
| 270 EXPECT_EQ(17000, entry1->ReadData(1, 0, buffer1, kSize1, NULL)); | 266 EXPECT_EQ(17000, entry1->ReadData(1, 0, buffer1, kSize1, NULL)); |
| 271 EXPECT_EQ(17000, entry1->WriteData(1, 20000, buffer1, kSize1, NULL, false)); | 267 EXPECT_EQ(17000, entry1->WriteData(1, 20000, buffer1, kSize1, NULL, false)); |
| 272 EXPECT_EQ(37000, entry1->GetDataSize(1)); | 268 EXPECT_EQ(37000, entry1->GetDataSize(1)); |
| 273 | 269 |
| 274 entry1->Doom(); | 270 entry1->Doom(); |
| 275 entry1->Close(); | 271 entry1->Close(); |
| 276 FlushQueueForTest(); | |
| 277 EXPECT_EQ(0, cache_->GetEntryCount()); | 272 EXPECT_EQ(0, cache_->GetEntryCount()); |
| 278 } | 273 } |
| 279 | 274 |
| 280 TEST_F(DiskCacheEntryTest, ExternalSyncIO) { | 275 TEST_F(DiskCacheEntryTest, ExternalSyncIO) { |
| 281 SetDirectMode(); | |
| 282 InitCache(); | 276 InitCache(); |
| 283 ExternalSyncIO(); | 277 ExternalSyncIO(); |
| 284 } | 278 } |
| 285 | 279 |
| 286 TEST_F(DiskCacheEntryTest, MemoryOnlyExternalSyncIO) { | 280 TEST_F(DiskCacheEntryTest, MemoryOnlyExternalSyncIO) { |
| 287 SetMemoryOnlyMode(); | 281 SetMemoryOnlyMode(); |
| 288 InitCache(); | 282 InitCache(); |
| 289 ExternalSyncIO(); | 283 ExternalSyncIO(); |
| 290 } | 284 } |
| 291 | 285 |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 366 | 360 |
| 367 EXPECT_EQ(0, entry1->ReadData(1, 35000, buffer2, kSize2, &callback7)); | 361 EXPECT_EQ(0, entry1->ReadData(1, 35000, buffer2, kSize2, &callback7)); |
| 368 ret = entry1->ReadData(1, 0, buffer1, kSize1, &callback8); | 362 ret = entry1->ReadData(1, 0, buffer1, kSize1, &callback8); |
| 369 EXPECT_TRUE(17000 == ret || net::ERR_IO_PENDING == ret); | 363 EXPECT_TRUE(17000 == ret || net::ERR_IO_PENDING == ret); |
| 370 if (net::ERR_IO_PENDING == ret) | 364 if (net::ERR_IO_PENDING == ret) |
| 371 expected++; | 365 expected++; |
| 372 ret = entry1->WriteData(1, 20000, buffer1, kSize1, &callback9, false); | 366 ret = entry1->WriteData(1, 20000, buffer1, kSize1, &callback9, false); |
| 373 EXPECT_TRUE(17000 == ret || net::ERR_IO_PENDING == ret); | 367 EXPECT_TRUE(17000 == ret || net::ERR_IO_PENDING == ret); |
| 374 if (net::ERR_IO_PENDING == ret) | 368 if (net::ERR_IO_PENDING == ret) |
| 375 expected++; | 369 expected++; |
| 370 EXPECT_EQ(37000, entry1->GetDataSize(1)); |
| 376 | 371 |
| 377 EXPECT_TRUE(helper.WaitUntilCacheIoFinished(expected)); | 372 EXPECT_TRUE(helper.WaitUntilCacheIoFinished(expected)); |
| 378 EXPECT_EQ(37000, entry1->GetDataSize(1)); | |
| 379 | 373 |
| 380 EXPECT_FALSE(g_cache_tests_error); | 374 EXPECT_FALSE(g_cache_tests_error); |
| 381 EXPECT_EQ(expected, g_cache_tests_received); | 375 EXPECT_EQ(expected, g_cache_tests_received); |
| 382 | 376 |
| 383 entry1->Doom(); | 377 entry1->Doom(); |
| 384 entry1->Close(); | 378 entry1->Close(); |
| 385 FlushQueueForTest(); | |
| 386 EXPECT_EQ(0, cache_->GetEntryCount()); | 379 EXPECT_EQ(0, cache_->GetEntryCount()); |
| 387 } | 380 } |
| 388 | 381 |
| 389 TEST_F(DiskCacheEntryTest, ExternalAsyncIO) { | 382 TEST_F(DiskCacheEntryTest, ExternalAsyncIO) { |
| 390 SetDirectMode(); | |
| 391 InitCache(); | 383 InitCache(); |
| 392 ExternalAsyncIO(); | 384 ExternalAsyncIO(); |
| 393 } | 385 } |
| 394 | 386 |
| 395 TEST_F(DiskCacheEntryTest, MemoryOnlyExternalAsyncIO) { | 387 TEST_F(DiskCacheEntryTest, MemoryOnlyExternalAsyncIO) { |
| 396 SetMemoryOnlyMode(); | 388 SetMemoryOnlyMode(); |
| 397 InitCache(); | 389 InitCache(); |
| 398 ExternalAsyncIO(); | 390 ExternalAsyncIO(); |
| 399 } | 391 } |
| 400 | 392 |
| (...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 789 CacheTestFillBuffer(buffer->data(), kSize, true); | 781 CacheTestFillBuffer(buffer->data(), kSize, true); |
| 790 buffer->data()[19999] = '\0'; | 782 buffer->data()[19999] = '\0'; |
| 791 | 783 |
| 792 key1 = buffer->data(); | 784 key1 = buffer->data(); |
| 793 ASSERT_EQ(net::OK, CreateEntry(key1, &entry1)); | 785 ASSERT_EQ(net::OK, CreateEntry(key1, &entry1)); |
| 794 EXPECT_EQ(20000, entry1->WriteData(0, 0, buffer, kSize, NULL, false)); | 786 EXPECT_EQ(20000, entry1->WriteData(0, 0, buffer, kSize, NULL, false)); |
| 795 EXPECT_EQ(20000, entry1->WriteData(1, 0, buffer, kSize, NULL, false)); | 787 EXPECT_EQ(20000, entry1->WriteData(1, 0, buffer, kSize, NULL, false)); |
| 796 entry1->Doom(); | 788 entry1->Doom(); |
| 797 entry1->Close(); | 789 entry1->Close(); |
| 798 | 790 |
| 799 FlushQueueForTest(); | |
| 800 EXPECT_EQ(0, cache_->GetEntryCount()); | 791 EXPECT_EQ(0, cache_->GetEntryCount()); |
| 801 } | 792 } |
| 802 | 793 |
| 803 TEST_F(DiskCacheEntryTest, DoomEntry) { | 794 TEST_F(DiskCacheEntryTest, DoomEntry) { |
| 804 SetDirectMode(); | |
| 805 InitCache(); | 795 InitCache(); |
| 806 DoomNormalEntry(); | 796 DoomNormalEntry(); |
| 807 } | 797 } |
| 808 | 798 |
| 809 TEST_F(DiskCacheEntryTest, MemoryOnlyDoomEntry) { | 799 TEST_F(DiskCacheEntryTest, MemoryOnlyDoomEntry) { |
| 810 SetMemoryOnlyMode(); | 800 SetMemoryOnlyMode(); |
| 811 InitCache(); | 801 InitCache(); |
| 812 DoomNormalEntry(); | 802 DoomNormalEntry(); |
| 813 } | 803 } |
| 814 | 804 |
| 815 // Verify that basic operations work as expected with doomed entries. | 805 // Verify that basic operations work as expected with doomed entries. |
| 816 void DiskCacheEntryTest::DoomedEntry() { | 806 void DiskCacheEntryTest::DoomedEntry() { |
| 817 std::string key("the first key"); | 807 std::string key("the first key"); |
| 818 disk_cache::Entry *entry; | 808 disk_cache::Entry *entry; |
| 819 ASSERT_EQ(net::OK, CreateEntry(key, &entry)); | 809 ASSERT_EQ(net::OK, CreateEntry(key, &entry)); |
| 820 entry->Doom(); | 810 entry->Doom(); |
| 821 | 811 |
| 822 FlushQueueForTest(); | |
| 823 EXPECT_EQ(0, cache_->GetEntryCount()); | 812 EXPECT_EQ(0, cache_->GetEntryCount()); |
| 824 Time initial = Time::Now(); | 813 Time initial = Time::Now(); |
| 825 PlatformThread::Sleep(20); | 814 PlatformThread::Sleep(20); |
| 826 | 815 |
| 827 const int kSize1 = 2000; | 816 const int kSize1 = 2000; |
| 828 const int kSize2 = 2000; | 817 const int kSize2 = 2000; |
| 829 scoped_refptr<net::IOBuffer> buffer1 = new net::IOBuffer(kSize1); | 818 scoped_refptr<net::IOBuffer> buffer1 = new net::IOBuffer(kSize1); |
| 830 scoped_refptr<net::IOBuffer> buffer2 = new net::IOBuffer(kSize2); | 819 scoped_refptr<net::IOBuffer> buffer2 = new net::IOBuffer(kSize2); |
| 831 CacheTestFillBuffer(buffer1->data(), kSize1, false); | 820 CacheTestFillBuffer(buffer1->data(), kSize1, false); |
| 832 memset(buffer2->data(), 0, kSize2); | 821 memset(buffer2->data(), 0, kSize2); |
| 833 | 822 |
| 834 EXPECT_EQ(2000, entry->WriteData(0, 0, buffer1, 2000, NULL, false)); | 823 EXPECT_EQ(2000, entry->WriteData(0, 0, buffer1, 2000, NULL, false)); |
| 835 EXPECT_EQ(2000, entry->ReadData(0, 0, buffer2, 2000, NULL)); | 824 EXPECT_EQ(2000, entry->ReadData(0, 0, buffer2, 2000, NULL)); |
| 836 EXPECT_EQ(0, memcmp(buffer1->data(), buffer2->data(), kSize1)); | 825 EXPECT_EQ(0, memcmp(buffer1->data(), buffer2->data(), kSize1)); |
| 837 EXPECT_EQ(key, entry->GetKey()); | 826 EXPECT_EQ(key, entry->GetKey()); |
| 838 EXPECT_TRUE(initial < entry->GetLastModified()); | 827 EXPECT_TRUE(initial < entry->GetLastModified()); |
| 839 EXPECT_TRUE(initial < entry->GetLastUsed()); | 828 EXPECT_TRUE(initial < entry->GetLastUsed()); |
| 840 | 829 |
| 841 entry->Close(); | 830 entry->Close(); |
| 842 } | 831 } |
| 843 | 832 |
| 844 TEST_F(DiskCacheEntryTest, DoomedEntry) { | 833 TEST_F(DiskCacheEntryTest, DoomedEntry) { |
| 845 SetDirectMode(); | |
| 846 InitCache(); | 834 InitCache(); |
| 847 DoomedEntry(); | 835 DoomedEntry(); |
| 848 } | 836 } |
| 849 | 837 |
| 850 TEST_F(DiskCacheEntryTest, MemoryOnlyDoomedEntry) { | 838 TEST_F(DiskCacheEntryTest, MemoryOnlyDoomedEntry) { |
| 851 SetMemoryOnlyMode(); | 839 SetMemoryOnlyMode(); |
| 852 InitCache(); | 840 InitCache(); |
| 853 DoomedEntry(); | 841 DoomedEntry(); |
| 854 } | 842 } |
| 855 | 843 |
| (...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1268 // (it's always async on Posix so it is easy to miss). Unfortunately we | 1256 // (it's always async on Posix so it is easy to miss). Unfortunately we |
| 1269 // don't have any signal to watch for so we can only wait. | 1257 // don't have any signal to watch for so we can only wait. |
| 1270 PlatformThread::Sleep(500); | 1258 PlatformThread::Sleep(500); |
| 1271 MessageLoop::current()->RunAllPending(); | 1259 MessageLoop::current()->RunAllPending(); |
| 1272 } | 1260 } |
| 1273 EXPECT_EQ(0, cache_->GetEntryCount()); | 1261 EXPECT_EQ(0, cache_->GetEntryCount()); |
| 1274 } | 1262 } |
| 1275 } | 1263 } |
| 1276 | 1264 |
| 1277 TEST_F(DiskCacheEntryTest, DoomSparseEntry) { | 1265 TEST_F(DiskCacheEntryTest, DoomSparseEntry) { |
| 1278 SetDirectMode(); | |
| 1279 UseCurrentThread(); | |
| 1280 InitCache(); | 1266 InitCache(); |
| 1281 DoomSparseEntry(); | 1267 DoomSparseEntry(); |
| 1282 } | 1268 } |
| 1283 | 1269 |
| 1284 TEST_F(DiskCacheEntryTest, MemoryOnlyDoomSparseEntry) { | 1270 TEST_F(DiskCacheEntryTest, MemoryOnlyDoomSparseEntry) { |
| 1285 SetMemoryOnlyMode(); | 1271 SetMemoryOnlyMode(); |
| 1286 InitCache(); | 1272 InitCache(); |
| 1287 DoomSparseEntry(); | 1273 DoomSparseEntry(); |
| 1288 } | 1274 } |
| 1289 | 1275 |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1428 | 1414 |
| 1429 // We never touched this one. | 1415 // We never touched this one. |
| 1430 EXPECT_EQ(kSize, entry->ReadSparseData(8192, buf1, kSize, NULL)); | 1416 EXPECT_EQ(kSize, entry->ReadSparseData(8192, buf1, kSize, NULL)); |
| 1431 entry->Close(); | 1417 entry->Close(); |
| 1432 | 1418 |
| 1433 // We re-created one of the corrupt children. | 1419 // We re-created one of the corrupt children. |
| 1434 EXPECT_EQ(3, cache_->GetEntryCount()); | 1420 EXPECT_EQ(3, cache_->GetEntryCount()); |
| 1435 } | 1421 } |
| 1436 | 1422 |
| 1437 TEST_F(DiskCacheEntryTest, CancelSparseIO) { | 1423 TEST_F(DiskCacheEntryTest, CancelSparseIO) { |
| 1438 UseCurrentThread(); | |
| 1439 InitCache(); | 1424 InitCache(); |
| 1440 std::string key("the first key"); | 1425 std::string key("the first key"); |
| 1441 disk_cache::Entry* entry; | 1426 disk_cache::Entry* entry; |
| 1442 ASSERT_EQ(net::OK, CreateEntry(key, &entry)); | 1427 ASSERT_EQ(net::OK, CreateEntry(key, &entry)); |
| 1443 | 1428 |
| 1444 const int kSize = 40 * 1024; | 1429 const int kSize = 40 * 1024; |
| 1445 scoped_refptr<net::IOBuffer> buf = new net::IOBuffer(kSize); | 1430 scoped_refptr<net::IOBuffer> buf = new net::IOBuffer(kSize); |
| 1446 CacheTestFillBuffer(buf->data(), kSize, false); | 1431 CacheTestFillBuffer(buf->data(), kSize, false); |
| 1447 | 1432 |
| 1448 // This will open and write two "real" entries. | |
| 1449 TestCompletionCallback cb1, cb2, cb3, cb4, cb5; | 1433 TestCompletionCallback cb1, cb2, cb3, cb4, cb5; |
| 1450 int rv = entry->WriteSparseData(1024 * 1024 - 4096, buf, kSize, &cb1); | 1434 int64 offset = 0; |
| 1451 EXPECT_EQ(net::ERR_IO_PENDING, rv); | 1435 int tries = 0; |
| 1436 const int maxtries = 100; // Avoid hang on infinitely fast disks. |
| 1437 for (int ret = 0; ret != net::ERR_IO_PENDING; offset += kSize * 4) { |
| 1438 ret = entry->WriteSparseData(offset, buf, kSize, &cb1); |
| 1439 if (++tries > maxtries) { |
| 1440 LOG(ERROR) << "Data writes never come back PENDING; skipping test"; |
| 1441 entry->Close(); |
| 1442 return; |
| 1443 } |
| 1444 } |
| 1452 | 1445 |
| 1453 int64 offset = 0; | 1446 // Cannot use the entry at this point. |
| 1454 rv = entry->GetAvailableRange(offset, kSize, &offset, &cb5); | 1447 offset = 0; |
| 1455 rv = cb5.GetResult(rv); | 1448 int rv = entry->GetAvailableRange(offset, kSize, &offset, &cb5); |
| 1456 if (!cb1.have_result()) { | 1449 EXPECT_EQ(net::ERR_CACHE_OPERATION_NOT_SUPPORTED, cb5.GetResult(rv)); |
| 1457 // We may or may not have finished writing to the entry. If we have not, | 1450 EXPECT_EQ(net::OK, entry->ReadyForSparseIO(&cb2)); |
| 1458 // we cannot start another operation at this time. | |
| 1459 EXPECT_EQ(net::ERR_CACHE_OPERATION_NOT_SUPPORTED, rv); | |
| 1460 } | |
| 1461 | 1451 |
| 1462 // We cancel the pending operation, and register multiple notifications. | 1452 // We cancel the pending operation, and register multiple notifications. |
| 1463 entry->CancelSparseIO(); | 1453 entry->CancelSparseIO(); |
| 1464 EXPECT_EQ(net::ERR_IO_PENDING, entry->ReadyForSparseIO(&cb2)); | 1454 EXPECT_EQ(net::ERR_IO_PENDING, entry->ReadyForSparseIO(&cb2)); |
| 1465 EXPECT_EQ(net::ERR_IO_PENDING, entry->ReadyForSparseIO(&cb3)); | 1455 EXPECT_EQ(net::ERR_IO_PENDING, entry->ReadyForSparseIO(&cb3)); |
| 1466 entry->CancelSparseIO(); // Should be a no op at this point. | 1456 entry->CancelSparseIO(); // Should be a no op at this point. |
| 1467 EXPECT_EQ(net::ERR_IO_PENDING, entry->ReadyForSparseIO(&cb4)); | 1457 EXPECT_EQ(net::ERR_IO_PENDING, entry->ReadyForSparseIO(&cb4)); |
| 1468 | 1458 |
| 1469 if (!cb1.have_result()) { | 1459 offset = 0; |
| 1470 EXPECT_EQ(net::ERR_CACHE_OPERATION_NOT_SUPPORTED, | 1460 rv = entry->GetAvailableRange(offset, kSize, &offset, &cb5); |
| 1471 entry->ReadSparseData(offset, buf, kSize, NULL)); | 1461 EXPECT_EQ(net::ERR_CACHE_OPERATION_NOT_SUPPORTED, cb5.GetResult(rv)); |
| 1472 EXPECT_EQ(net::ERR_CACHE_OPERATION_NOT_SUPPORTED, | 1462 EXPECT_EQ(net::ERR_CACHE_OPERATION_NOT_SUPPORTED, |
| 1473 entry->WriteSparseData(offset, buf, kSize, NULL)); | 1463 entry->ReadSparseData(offset, buf, kSize, NULL)); |
| 1474 } | 1464 EXPECT_EQ(net::ERR_CACHE_OPERATION_NOT_SUPPORTED, |
| 1465 entry->WriteSparseData(offset, buf, kSize, NULL)); |
| 1475 | 1466 |
| 1476 // Now see if we receive all notifications. | 1467 // Now see if we receive all notifications. |
| 1477 EXPECT_EQ(kSize, cb1.GetResult(net::ERR_IO_PENDING)); | 1468 EXPECT_EQ(kSize, cb1.GetResult(net::ERR_IO_PENDING)); |
| 1478 EXPECT_EQ(net::OK, cb2.GetResult(net::ERR_IO_PENDING)); | 1469 EXPECT_EQ(net::OK, cb2.GetResult(net::ERR_IO_PENDING)); |
| 1479 EXPECT_EQ(net::OK, cb3.GetResult(net::ERR_IO_PENDING)); | 1470 EXPECT_EQ(net::OK, cb3.GetResult(net::ERR_IO_PENDING)); |
| 1480 EXPECT_EQ(net::OK, cb4.GetResult(net::ERR_IO_PENDING)); | 1471 EXPECT_EQ(net::OK, cb4.GetResult(net::ERR_IO_PENDING)); |
| 1481 | 1472 |
| 1482 rv = entry->GetAvailableRange(offset, kSize, &offset, &cb5); | 1473 rv = entry->GetAvailableRange(offset, kSize, &offset, &cb5); |
| 1483 EXPECT_EQ(0, cb5.GetResult(rv)); | 1474 EXPECT_EQ(kSize, cb5.GetResult(rv)); |
| 1475 EXPECT_EQ(net::OK, entry->ReadyForSparseIO(&cb2)); |
| 1484 entry->Close(); | 1476 entry->Close(); |
| 1485 } | 1477 } |
| OLD | NEW |