Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(101)

Side by Side Diff: net/disk_cache/simple/simple_index_unittest.cc

Issue 623213004: replace OVERRIDE and FINAL with override and final in net/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: undo unwanted change in comment Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/disk_cache/simple/simple_entry_impl.h ('k') | net/dns/address_sorter_posix.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 public: 53 public:
54 MockSimpleIndexFile() 54 MockSimpleIndexFile()
55 : SimpleIndexFile(NULL, NULL, net::DISK_CACHE, base::FilePath()), 55 : SimpleIndexFile(NULL, NULL, net::DISK_CACHE, base::FilePath()),
56 load_result_(NULL), 56 load_result_(NULL),
57 load_index_entries_calls_(0), 57 load_index_entries_calls_(0),
58 disk_writes_(0) {} 58 disk_writes_(0) {}
59 59
60 virtual void LoadIndexEntries( 60 virtual void LoadIndexEntries(
61 base::Time cache_last_modified, 61 base::Time cache_last_modified,
62 const base::Closure& callback, 62 const base::Closure& callback,
63 SimpleIndexLoadResult* out_load_result) OVERRIDE { 63 SimpleIndexLoadResult* out_load_result) override {
64 load_callback_ = callback; 64 load_callback_ = callback;
65 load_result_ = out_load_result; 65 load_result_ = out_load_result;
66 ++load_index_entries_calls_; 66 ++load_index_entries_calls_;
67 } 67 }
68 68
69 virtual void WriteToDisk(const SimpleIndex::EntrySet& entry_set, 69 virtual void WriteToDisk(const SimpleIndex::EntrySet& entry_set,
70 uint64 cache_size, 70 uint64 cache_size,
71 const base::TimeTicks& start, 71 const base::TimeTicks& start,
72 bool app_on_background) OVERRIDE { 72 bool app_on_background) override {
73 disk_writes_++; 73 disk_writes_++;
74 disk_write_entry_set_ = entry_set; 74 disk_write_entry_set_ = entry_set;
75 } 75 }
76 76
77 void GetAndResetDiskWriteEntrySet(SimpleIndex::EntrySet* entry_set) { 77 void GetAndResetDiskWriteEntrySet(SimpleIndex::EntrySet* entry_set) {
78 entry_set->swap(disk_write_entry_set_); 78 entry_set->swap(disk_write_entry_set_);
79 } 79 }
80 80
81 const base::Closure& load_callback() const { return load_callback_; } 81 const base::Closure& load_callback() const { return load_callback_; }
82 SimpleIndexLoadResult* load_result() const { return load_result_; } 82 SimpleIndexLoadResult* load_result() const { return load_result_; }
(...skipping 12 matching lines...) Expand all
95 protected: 95 protected:
96 SimpleIndexTest() 96 SimpleIndexTest()
97 : hashes_(base::Bind(&HashesInitializer)), 97 : hashes_(base::Bind(&HashesInitializer)),
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(new SimpleIndex(NULL, this, net::DISK_CACHE,
109 index_file.PassAs<SimpleIndexFile>())); 109 index_file.PassAs<SimpleIndexFile>()));
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));
120 } 120 }
121 121
122 // From SimpleIndexDelegate: 122 // From SimpleIndexDelegate:
123 virtual void DoomEntries(std::vector<uint64>* entry_hashes, 123 virtual void DoomEntries(std::vector<uint64>* entry_hashes,
124 const net::CompletionCallback& callback) OVERRIDE { 124 const net::CompletionCallback& callback) override {
125 std::for_each(entry_hashes->begin(), entry_hashes->end(), 125 std::for_each(entry_hashes->begin(), entry_hashes->end(),
126 std::bind1st(std::mem_fun(&SimpleIndex::Remove), 126 std::bind1st(std::mem_fun(&SimpleIndex::Remove),
127 index_.get())); 127 index_.get()));
128 last_doom_entry_hashes_ = *entry_hashes; 128 last_doom_entry_hashes_ = *entry_hashes;
129 ++doom_entries_calls_; 129 ++doom_entries_calls_;
130 } 130 }
131 131
132 // Redirect to allow single "friend" declaration in base class. 132 // Redirect to allow single "friend" declaration in base class.
133 bool GetEntryForTesting(uint64 key, EntryMetadata* metadata) { 133 bool GetEntryForTesting(uint64 key, EntryMetadata* metadata) {
134 SimpleIndex::EntrySet::iterator it = index_->entries_set_.find(key); 134 SimpleIndex::EntrySet::iterator it = index_->entries_set_.find(key);
(...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
OLDNEW
« no previous file with comments | « net/disk_cache/simple/simple_entry_impl.h ('k') | net/dns/address_sorter_posix.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698