| 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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 doom_entries_calls_(0) {} | 98 doom_entries_calls_(0) {} |
| 99 | 99 |
| 100 static uint64 HashesInitializer(size_t hash_index) { | 100 static uint64 HashesInitializer(size_t hash_index) { |
| 101 return disk_cache::simple_util::GetEntryHashKey( | 101 return disk_cache::simple_util::GetEntryHashKey( |
| 102 base::StringPrintf("key%d", static_cast<int>(hash_index))); | 102 base::StringPrintf("key%d", static_cast<int>(hash_index))); |
| 103 } | 103 } |
| 104 | 104 |
| 105 virtual void SetUp() override { | 105 virtual void SetUp() override { |
| 106 scoped_ptr<MockSimpleIndexFile> index_file(new MockSimpleIndexFile()); | 106 scoped_ptr<MockSimpleIndexFile> index_file(new MockSimpleIndexFile()); |
| 107 index_file_ = index_file->AsWeakPtr(); | 107 index_file_ = index_file->AsWeakPtr(); |
| 108 index_.reset(new SimpleIndex(NULL, this, net::DISK_CACHE, | 108 index_.reset( |
| 109 index_file.PassAs<SimpleIndexFile>())); | 109 new SimpleIndex(NULL, this, net::DISK_CACHE, index_file.Pass())); |
| 110 | 110 |
| 111 index_->Initialize(base::Time()); | 111 index_->Initialize(base::Time()); |
| 112 } | 112 } |
| 113 | 113 |
| 114 void WaitForTimeChange() { | 114 void WaitForTimeChange() { |
| 115 const base::Time initial_time = base::Time::Now(); | 115 const base::Time initial_time = base::Time::Now(); |
| 116 do { | 116 do { |
| 117 base::PlatformThread::YieldCurrentThread(); | 117 base::PlatformThread::YieldCurrentThread(); |
| 118 } while (base::Time::Now() - | 118 } while (base::Time::Now() - |
| 119 initial_time < base::TimeDelta::FromSeconds(1)); | 119 initial_time < base::TimeDelta::FromSeconds(1)); |
| (...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 619 WaitForTimeChange(); | 619 WaitForTimeChange(); |
| 620 EXPECT_EQ(expected_trigger, index()->write_to_disk_timer_.desired_run_time()); | 620 EXPECT_EQ(expected_trigger, index()->write_to_disk_timer_.desired_run_time()); |
| 621 index()->Insert(hashes_.at<2>()); | 621 index()->Insert(hashes_.at<2>()); |
| 622 index()->UpdateEntrySize(hashes_.at<2>(), 40); | 622 index()->UpdateEntrySize(hashes_.at<2>(), 40); |
| 623 EXPECT_TRUE(index()->write_to_disk_timer_.IsRunning()); | 623 EXPECT_TRUE(index()->write_to_disk_timer_.IsRunning()); |
| 624 EXPECT_LT(expected_trigger, index()->write_to_disk_timer_.desired_run_time()); | 624 EXPECT_LT(expected_trigger, index()->write_to_disk_timer_.desired_run_time()); |
| 625 index()->write_to_disk_timer_.Stop(); | 625 index()->write_to_disk_timer_.Stop(); |
| 626 } | 626 } |
| 627 | 627 |
| 628 } // namespace disk_cache | 628 } // namespace disk_cache |
| OLD | NEW |