OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 <algorithm> | 5 #include <algorithm> |
6 #include <functional> | 6 #include <functional> |
7 | 7 |
8 #include "base/files/scoped_temp_dir.h" | 8 #include "base/files/scoped_temp_dir.h" |
9 #include "base/hash.h" | 9 #include "base/hash.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 protected: | 94 protected: |
95 SimpleIndexTest() | 95 SimpleIndexTest() |
96 : hashes_(base::Bind(&HashesInitializer)), | 96 : hashes_(base::Bind(&HashesInitializer)), |
97 doom_entries_calls_(0) {} | 97 doom_entries_calls_(0) {} |
98 | 98 |
99 static uint64 HashesInitializer(size_t hash_index) { | 99 static uint64 HashesInitializer(size_t hash_index) { |
100 return disk_cache::simple_util::GetEntryHashKey( | 100 return disk_cache::simple_util::GetEntryHashKey( |
101 base::StringPrintf("key%d", static_cast<int>(hash_index))); | 101 base::StringPrintf("key%d", static_cast<int>(hash_index))); |
102 } | 102 } |
103 | 103 |
104 virtual void SetUp() override { | 104 void SetUp() override { |
105 scoped_ptr<MockSimpleIndexFile> index_file(new MockSimpleIndexFile()); | 105 scoped_ptr<MockSimpleIndexFile> index_file(new MockSimpleIndexFile()); |
106 index_file_ = index_file->AsWeakPtr(); | 106 index_file_ = index_file->AsWeakPtr(); |
107 index_.reset( | 107 index_.reset( |
108 new SimpleIndex(NULL, this, net::DISK_CACHE, index_file.Pass())); | 108 new SimpleIndex(NULL, this, net::DISK_CACHE, index_file.Pass())); |
109 | 109 |
110 index_->Initialize(base::Time()); | 110 index_->Initialize(base::Time()); |
111 } | 111 } |
112 | 112 |
113 void WaitForTimeChange() { | 113 void WaitForTimeChange() { |
114 const base::Time initial_time = base::Time::Now(); | 114 const base::Time initial_time = base::Time::Now(); |
(...skipping 503 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
618 WaitForTimeChange(); | 618 WaitForTimeChange(); |
619 EXPECT_EQ(expected_trigger, index()->write_to_disk_timer_.desired_run_time()); | 619 EXPECT_EQ(expected_trigger, index()->write_to_disk_timer_.desired_run_time()); |
620 index()->Insert(hashes_.at<2>()); | 620 index()->Insert(hashes_.at<2>()); |
621 index()->UpdateEntrySize(hashes_.at<2>(), 40); | 621 index()->UpdateEntrySize(hashes_.at<2>(), 40); |
622 EXPECT_TRUE(index()->write_to_disk_timer_.IsRunning()); | 622 EXPECT_TRUE(index()->write_to_disk_timer_.IsRunning()); |
623 EXPECT_LT(expected_trigger, index()->write_to_disk_timer_.desired_run_time()); | 623 EXPECT_LT(expected_trigger, index()->write_to_disk_timer_.desired_run_time()); |
624 index()->write_to_disk_timer_.Stop(); | 624 index()->write_to_disk_timer_.Stop(); |
625 } | 625 } |
626 | 626 |
627 } // namespace disk_cache | 627 } // namespace disk_cache |
OLD | NEW |