| 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/port.h" | 7 #include "base/port.h" |
| 8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
| 9 #include "base/stringprintf.h" | 9 #include "base/stringprintf.h" |
| 10 #include "base/third_party/dynamic_annotations/dynamic_annotations.h" | 10 #include "base/third_party/dynamic_annotations/dynamic_annotations.h" |
| (...skipping 1543 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1554 // Tests that the cache is properly restarted on recovery error. | 1554 // Tests that the cache is properly restarted on recovery error. |
| 1555 TEST_F(DiskCacheBackendTest, DeleteOld) { | 1555 TEST_F(DiskCacheBackendTest, DeleteOld) { |
| 1556 ASSERT_TRUE(CopyTestCache("wrong_version")); | 1556 ASSERT_TRUE(CopyTestCache("wrong_version")); |
| 1557 SetNewEviction(); | 1557 SetNewEviction(); |
| 1558 base::Thread cache_thread("CacheThread"); | 1558 base::Thread cache_thread("CacheThread"); |
| 1559 ASSERT_TRUE(cache_thread.StartWithOptions( | 1559 ASSERT_TRUE(cache_thread.StartWithOptions( |
| 1560 base::Thread::Options(MessageLoop::TYPE_IO, 0))); | 1560 base::Thread::Options(MessageLoop::TYPE_IO, 0))); |
| 1561 | 1561 |
| 1562 net::TestCompletionCallback cb; | 1562 net::TestCompletionCallback cb; |
| 1563 bool prev = base::ThreadRestrictions::SetIOAllowed(false); | 1563 bool prev = base::ThreadRestrictions::SetIOAllowed(false); |
| 1564 int rv = disk_cache::CreateCacheBackend(net::DISK_CACHE, cache_path_, 0, true, | 1564 base::FilePath path(cache_path_); |
| 1565 int rv = disk_cache::CreateCacheBackend(net::DISK_CACHE, path, 0, true, |
| 1565 cache_thread.message_loop_proxy(), | 1566 cache_thread.message_loop_proxy(), |
| 1566 NULL, &cache_, cb.callback()); | 1567 NULL, &cache_, cb.callback()); |
| 1568 path.clear(); // Make sure path was captured by the previous call. |
| 1567 ASSERT_EQ(net::OK, cb.GetResult(rv)); | 1569 ASSERT_EQ(net::OK, cb.GetResult(rv)); |
| 1568 base::ThreadRestrictions::SetIOAllowed(prev); | 1570 base::ThreadRestrictions::SetIOAllowed(prev); |
| 1569 delete cache_; | 1571 delete cache_; |
| 1570 cache_ = NULL; | 1572 cache_ = NULL; |
| 1571 EXPECT_TRUE(CheckCacheIntegrity(cache_path_, new_eviction_, mask_)); | 1573 EXPECT_TRUE(CheckCacheIntegrity(cache_path_, new_eviction_, mask_)); |
| 1572 } | 1574 } |
| 1573 | 1575 |
| 1574 // We want to be able to deal with messed up entries on disk. | 1576 // We want to be able to deal with messed up entries on disk. |
| 1575 void DiskCacheBackendTest::BackendInvalidEntry2() { | 1577 void DiskCacheBackendTest::BackendInvalidEntry2() { |
| 1576 ASSERT_TRUE(CopyTestCache("bad_entry")); | 1578 ASSERT_TRUE(CopyTestCache("bad_entry")); |
| (...skipping 1188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2765 disk_cache::SimpleFileHeader header; | 2767 disk_cache::SimpleFileHeader header; |
| 2766 header.initial_magic_number = GG_UINT64_C(0xbadf00d); | 2768 header.initial_magic_number = GG_UINT64_C(0xbadf00d); |
| 2767 EXPECT_EQ( | 2769 EXPECT_EQ( |
| 2768 implicit_cast<int>(sizeof(header)), | 2770 implicit_cast<int>(sizeof(header)), |
| 2769 file_util::WriteFile(entry_file1_path, reinterpret_cast<char*>(&header), | 2771 file_util::WriteFile(entry_file1_path, reinterpret_cast<char*>(&header), |
| 2770 sizeof(header))); | 2772 sizeof(header))); |
| 2771 ASSERT_EQ(net::ERR_FAILED, OpenEntry(key, &entry)); | 2773 ASSERT_EQ(net::ERR_FAILED, OpenEntry(key, &entry)); |
| 2772 } | 2774 } |
| 2773 | 2775 |
| 2774 #endif // !defined(OS_WIN) | 2776 #endif // !defined(OS_WIN) |
| OLD | NEW |