OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/file_util.h" | 5 #include "base/file_util.h" |
6 #include "base/files/scoped_temp_dir.h" | 6 #include "base/files/scoped_temp_dir.h" |
7 #include "base/hash.h" | 7 #include "base/hash.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/message_loop/message_loop_proxy.h" | 10 #include "base/message_loop/message_loop_proxy.h" |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 // as public, for use in tests. | 55 // as public, for use in tests. |
56 class WrappedSimpleIndexFile : public SimpleIndexFile { | 56 class WrappedSimpleIndexFile : public SimpleIndexFile { |
57 public: | 57 public: |
58 using SimpleIndexFile::Deserialize; | 58 using SimpleIndexFile::Deserialize; |
59 using SimpleIndexFile::IsIndexFileStale; | 59 using SimpleIndexFile::IsIndexFileStale; |
60 using SimpleIndexFile::kIndexFileName; | 60 using SimpleIndexFile::kIndexFileName; |
61 using SimpleIndexFile::LoadFromDisk; | 61 using SimpleIndexFile::LoadFromDisk; |
62 using SimpleIndexFile::Serialize; | 62 using SimpleIndexFile::Serialize; |
63 | 63 |
64 explicit WrappedSimpleIndexFile(const base::FilePath& index_file_directory) | 64 explicit WrappedSimpleIndexFile(const base::FilePath& index_file_directory) |
65 : SimpleIndexFile(base::MessageLoopProxy::current(), | 65 : SimpleIndexFile(base::MessageLoopProxy::current().get(), |
66 base::MessageLoopProxy::current(), | 66 base::MessageLoopProxy::current().get(), |
67 index_file_directory) { | 67 index_file_directory) {} |
68 } | |
69 virtual ~WrappedSimpleIndexFile() { | 68 virtual ~WrappedSimpleIndexFile() { |
70 } | 69 } |
71 }; | 70 }; |
72 | 71 |
73 class SimpleIndexFileTest : public testing::Test { | 72 class SimpleIndexFileTest : public testing::Test { |
74 public: | 73 public: |
75 bool CompareTwoEntryMetadata(const EntryMetadata& a, const EntryMetadata& b) { | 74 bool CompareTwoEntryMetadata(const EntryMetadata& a, const EntryMetadata& b) { |
76 return a.last_used_time_ == b.last_used_time_ && | 75 return a.last_used_time_ == b.last_used_time_ && |
77 a.entry_size_ == b.entry_size_; | 76 a.entry_size_ == b.entry_size_; |
78 } | 77 } |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 temp_dir.path().AppendASCII(WrappedSimpleIndexFile::kIndexFileName); | 225 temp_dir.path().AppendASCII(WrappedSimpleIndexFile::kIndexFileName); |
227 EXPECT_TRUE(WrappedSimpleIndexFile::IsIndexFileStale(index_path)); | 226 EXPECT_TRUE(WrappedSimpleIndexFile::IsIndexFileStale(index_path)); |
228 const std::string kDummyData = "nothing to be seen here"; | 227 const std::string kDummyData = "nothing to be seen here"; |
229 EXPECT_EQ(static_cast<int>(kDummyData.size()), | 228 EXPECT_EQ(static_cast<int>(kDummyData.size()), |
230 file_util::WriteFile(index_path, | 229 file_util::WriteFile(index_path, |
231 kDummyData.data(), | 230 kDummyData.data(), |
232 kDummyData.size())); | 231 kDummyData.size())); |
233 EXPECT_FALSE(WrappedSimpleIndexFile::IsIndexFileStale(index_path)); | 232 EXPECT_FALSE(WrappedSimpleIndexFile::IsIndexFileStale(index_path)); |
234 | 233 |
235 WrappedSimpleIndexFile simple_index_file(temp_dir.path()); | 234 WrappedSimpleIndexFile simple_index_file(temp_dir.path()); |
236 simple_index_file.LoadIndexEntries(base::MessageLoopProxy::current(), | 235 simple_index_file.LoadIndexEntries(base::MessageLoopProxy::current().get(), |
237 GetCallback()); | 236 GetCallback()); |
238 base::RunLoop().RunUntilIdle(); | 237 base::RunLoop().RunUntilIdle(); |
239 | 238 |
240 EXPECT_FALSE(file_util::PathExists(index_path)); | 239 EXPECT_FALSE(file_util::PathExists(index_path)); |
241 ASSERT_TRUE(callback_result()); | 240 ASSERT_TRUE(callback_result()); |
242 EXPECT_TRUE(callback_result()->force_index_flush); | 241 EXPECT_TRUE(callback_result()->force_index_flush); |
243 EXPECT_TRUE(callback_result()->index_file_entries); | 242 EXPECT_TRUE(callback_result()->index_file_entries); |
244 } | 243 } |
245 | 244 |
246 } // namespace disk_cache | 245 } // namespace disk_cache |
OLD | NEW |