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

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

Issue 667923003: Standardize usage of virtual/override/final in net/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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_index_file_unittest.cc ('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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 50
51 class MockSimpleIndexFile : public SimpleIndexFile, 51 class MockSimpleIndexFile : public SimpleIndexFile,
52 public base::SupportsWeakPtr<MockSimpleIndexFile> { 52 public base::SupportsWeakPtr<MockSimpleIndexFile> {
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 void LoadIndexEntries(base::Time cache_last_modified,
61 base::Time cache_last_modified, 61 const base::Closure& callback,
62 const base::Closure& callback, 62 SimpleIndexLoadResult* out_load_result) override {
63 SimpleIndexLoadResult* out_load_result) override {
64 load_callback_ = callback; 63 load_callback_ = callback;
65 load_result_ = out_load_result; 64 load_result_ = out_load_result;
66 ++load_index_entries_calls_; 65 ++load_index_entries_calls_;
67 } 66 }
68 67
69 virtual void WriteToDisk(const SimpleIndex::EntrySet& entry_set, 68 void WriteToDisk(const SimpleIndex::EntrySet& entry_set,
70 uint64 cache_size, 69 uint64 cache_size,
71 const base::TimeTicks& start, 70 const base::TimeTicks& start,
72 bool app_on_background) override { 71 bool app_on_background) override {
73 disk_writes_++; 72 disk_writes_++;
74 disk_write_entry_set_ = entry_set; 73 disk_write_entry_set_ = entry_set;
75 } 74 }
76 75
77 void GetAndResetDiskWriteEntrySet(SimpleIndex::EntrySet* entry_set) { 76 void GetAndResetDiskWriteEntrySet(SimpleIndex::EntrySet* entry_set) {
78 entry_set->swap(disk_write_entry_set_); 77 entry_set->swap(disk_write_entry_set_);
79 } 78 }
80 79
81 const base::Closure& load_callback() const { return load_callback_; } 80 const base::Closure& load_callback() const { return load_callback_; }
82 SimpleIndexLoadResult* load_result() const { return load_result_; } 81 SimpleIndexLoadResult* load_result() const { return load_result_; }
(...skipping 30 matching lines...) Expand all
113 112
114 void WaitForTimeChange() { 113 void WaitForTimeChange() {
115 const base::Time initial_time = base::Time::Now(); 114 const base::Time initial_time = base::Time::Now();
116 do { 115 do {
117 base::PlatformThread::YieldCurrentThread(); 116 base::PlatformThread::YieldCurrentThread();
118 } while (base::Time::Now() - 117 } while (base::Time::Now() -
119 initial_time < base::TimeDelta::FromSeconds(1)); 118 initial_time < base::TimeDelta::FromSeconds(1));
120 } 119 }
121 120
122 // From SimpleIndexDelegate: 121 // From SimpleIndexDelegate:
123 virtual void DoomEntries(std::vector<uint64>* entry_hashes, 122 void DoomEntries(std::vector<uint64>* entry_hashes,
124 const net::CompletionCallback& callback) override { 123 const net::CompletionCallback& callback) override {
125 std::for_each(entry_hashes->begin(), entry_hashes->end(), 124 std::for_each(entry_hashes->begin(), entry_hashes->end(),
126 std::bind1st(std::mem_fun(&SimpleIndex::Remove), 125 std::bind1st(std::mem_fun(&SimpleIndex::Remove),
127 index_.get())); 126 index_.get()));
128 last_doom_entry_hashes_ = *entry_hashes; 127 last_doom_entry_hashes_ = *entry_hashes;
129 ++doom_entries_calls_; 128 ++doom_entries_calls_;
130 } 129 }
131 130
132 // Redirect to allow single "friend" declaration in base class. 131 // Redirect to allow single "friend" declaration in base class.
133 bool GetEntryForTesting(uint64 key, EntryMetadata* metadata) { 132 bool GetEntryForTesting(uint64 key, EntryMetadata* metadata) {
134 SimpleIndex::EntrySet::iterator it = index_->entries_set_.find(key); 133 SimpleIndex::EntrySet::iterator it = index_->entries_set_.find(key);
(...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after
619 WaitForTimeChange(); 618 WaitForTimeChange();
620 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());
621 index()->Insert(hashes_.at<2>()); 620 index()->Insert(hashes_.at<2>());
622 index()->UpdateEntrySize(hashes_.at<2>(), 40); 621 index()->UpdateEntrySize(hashes_.at<2>(), 40);
623 EXPECT_TRUE(index()->write_to_disk_timer_.IsRunning()); 622 EXPECT_TRUE(index()->write_to_disk_timer_.IsRunning());
624 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());
625 index()->write_to_disk_timer_.Stop(); 624 index()->write_to_disk_timer_.Stop();
626 } 625 }
627 626
628 } // namespace disk_cache 627 } // namespace disk_cache
OLDNEW
« no previous file with comments | « net/disk_cache/simple/simple_index_file_unittest.cc ('k') | net/dns/address_sorter_posix.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698