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