OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/file_util.h" | 6 #include "base/file_util.h" |
7 #include "base/metrics/field_trial.h" | 7 #include "base/metrics/field_trial.h" |
8 #include "base/port.h" | 8 #include "base/port.h" |
9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
(...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
482 ASSERT_EQ(kSize, file_util::WriteFile(filename, buffer1->data(), kSize)); | 482 ASSERT_EQ(kSize, file_util::WriteFile(filename, buffer1->data(), kSize)); |
483 | 483 |
484 // Now let's create a file with the cache. | 484 // Now let's create a file with the cache. |
485 disk_cache::Entry* entry; | 485 disk_cache::Entry* entry; |
486 ASSERT_EQ(net::OK, CreateEntry("key", &entry)); | 486 ASSERT_EQ(net::OK, CreateEntry("key", &entry)); |
487 ASSERT_EQ(0, WriteData(entry, 0, 20000, buffer1.get(), 0, false)); | 487 ASSERT_EQ(0, WriteData(entry, 0, 20000, buffer1.get(), 0, false)); |
488 entry->Close(); | 488 entry->Close(); |
489 | 489 |
490 // And verify that the first file is still there. | 490 // And verify that the first file is still there. |
491 scoped_refptr<net::IOBuffer> buffer2(new net::IOBuffer(kSize)); | 491 scoped_refptr<net::IOBuffer> buffer2(new net::IOBuffer(kSize)); |
492 ASSERT_EQ(kSize, file_util::ReadFile(filename, buffer2->data(), kSize)); | 492 ASSERT_EQ(kSize, base::ReadFile(filename, buffer2->data(), kSize)); |
493 EXPECT_EQ(0, memcmp(buffer1->data(), buffer2->data(), kSize)); | 493 EXPECT_EQ(0, memcmp(buffer1->data(), buffer2->data(), kSize)); |
494 } | 494 } |
495 | 495 |
496 // Tests that we deal with file-level pending operations at destruction time. | 496 // Tests that we deal with file-level pending operations at destruction time. |
497 void DiskCacheBackendTest::BackendShutdownWithPendingFileIO(bool fast) { | 497 void DiskCacheBackendTest::BackendShutdownWithPendingFileIO(bool fast) { |
498 ASSERT_TRUE(CleanupCacheDir()); | 498 ASSERT_TRUE(CleanupCacheDir()); |
499 uint32 flags = disk_cache::kNoBuffering; | 499 uint32 flags = disk_cache::kNoBuffering; |
500 if (!fast) | 500 if (!fast) |
501 flags |= disk_cache::kNoRandom; | 501 flags |= disk_cache::kNoRandom; |
502 | 502 |
(...skipping 2961 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3464 void* iter = NULL; | 3464 void* iter = NULL; |
3465 size_t count = 0; | 3465 size_t count = 0; |
3466 ASSERT_TRUE(EnumerateAndMatchKeys(-1, &iter, &keys_to_match, &count)); | 3466 ASSERT_TRUE(EnumerateAndMatchKeys(-1, &iter, &keys_to_match, &count)); |
3467 cache_->EndEnumeration(&iter); | 3467 cache_->EndEnumeration(&iter); |
3468 | 3468 |
3469 EXPECT_EQ(key_pool.size(), count); | 3469 EXPECT_EQ(key_pool.size(), count); |
3470 EXPECT_TRUE(keys_to_match.empty()); | 3470 EXPECT_TRUE(keys_to_match.empty()); |
3471 } | 3471 } |
3472 | 3472 |
3473 #endif // defined(OS_POSIX) | 3473 #endif // defined(OS_POSIX) |
OLD | NEW |