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

Side by Side Diff: net/disk_cache/simple/simple_index.h

Issue 1897033002: Reland 'Convert //net and //chromecast to std::unordered_*' (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix TestDownloadRequestHandler Created 4 years, 8 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_backend_impl.cc ('k') | net/disk_cache/simple/simple_index.cc » ('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 #ifndef NET_DISK_CACHE_SIMPLE_SIMPLE_INDEX_H_ 5 #ifndef NET_DISK_CACHE_SIMPLE_SIMPLE_INDEX_H_
6 #define NET_DISK_CACHE_SIMPLE_SIMPLE_INDEX_H_ 6 #define NET_DISK_CACHE_SIMPLE_SIMPLE_INDEX_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <list> 10 #include <list>
11 #include <memory> 11 #include <memory>
12 #include <unordered_map>
13 #include <unordered_set>
12 #include <vector> 14 #include <vector>
13 15
14 #include "base/callback.h" 16 #include "base/callback.h"
15 #include "base/containers/hash_tables.h"
16 #include "base/files/file_path.h" 17 #include "base/files/file_path.h"
17 #include "base/gtest_prod_util.h" 18 #include "base/gtest_prod_util.h"
18 #include "base/memory/ref_counted.h" 19 #include "base/memory/ref_counted.h"
19 #include "base/memory/weak_ptr.h" 20 #include "base/memory/weak_ptr.h"
20 #include "base/single_thread_task_runner.h" 21 #include "base/single_thread_task_runner.h"
21 #include "base/threading/thread_checker.h" 22 #include "base/threading/thread_checker.h"
22 #include "base/time/time.h" 23 #include "base/time/time.h"
23 #include "base/timer/timer.h" 24 #include "base/timer/timer.h"
24 #include "net/base/cache_type.h" 25 #include "net/base/cache_type.h"
25 #include "net/base/completion_callback.h" 26 #include "net/base/completion_callback.h"
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 // iff the entry exist in the index. 111 // iff the entry exist in the index.
111 bool UseIfExists(uint64_t entry_hash); 112 bool UseIfExists(uint64_t entry_hash);
112 113
113 void WriteToDisk(); 114 void WriteToDisk();
114 115
115 // Update the size (in bytes) of an entry, in the metadata stored in the 116 // Update the size (in bytes) of an entry, in the metadata stored in the
116 // index. This should be the total disk-file size including all streams of the 117 // index. This should be the total disk-file size including all streams of the
117 // entry. 118 // entry.
118 bool UpdateEntrySize(uint64_t entry_hash, int64_t entry_size); 119 bool UpdateEntrySize(uint64_t entry_hash, int64_t entry_size);
119 120
120 typedef base::hash_map<uint64_t, EntryMetadata> EntrySet; 121 using EntrySet = std::unordered_map<uint64_t, EntryMetadata>;
121 122
122 static void InsertInEntrySet(uint64_t entry_hash, 123 static void InsertInEntrySet(uint64_t entry_hash,
123 const EntryMetadata& entry_metadata, 124 const EntryMetadata& entry_metadata,
124 EntrySet* entry_set); 125 EntrySet* entry_set);
125 126
126 // Executes the |callback| when the index is ready. Allows multiple callbacks. 127 // Executes the |callback| when the index is ready. Allows multiple callbacks.
127 int ExecuteWhenReady(const net::CompletionCallback& callback); 128 int ExecuteWhenReady(const net::CompletionCallback& callback);
128 129
129 // Returns entries from the index that have last accessed time matching the 130 // Returns entries from the index that have last accessed time matching the
130 // range between |initial_time| and |end_time| where open intervals are 131 // range between |initial_time| and |end_time| where open intervals are
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 const net::CacheType cache_type_; 181 const net::CacheType cache_type_;
181 uint64_t cache_size_; // Total cache storage size in bytes. 182 uint64_t cache_size_; // Total cache storage size in bytes.
182 uint64_t max_size_; 183 uint64_t max_size_;
183 uint64_t high_watermark_; 184 uint64_t high_watermark_;
184 uint64_t low_watermark_; 185 uint64_t low_watermark_;
185 bool eviction_in_progress_; 186 bool eviction_in_progress_;
186 base::TimeTicks eviction_start_time_; 187 base::TimeTicks eviction_start_time_;
187 188
188 // This stores all the entry_hash of entries that are removed during 189 // This stores all the entry_hash of entries that are removed during
189 // initialization. 190 // initialization.
190 base::hash_set<uint64_t> removed_entries_; 191 std::unordered_set<uint64_t> removed_entries_;
191 bool initialized_; 192 bool initialized_;
192 IndexInitMethod init_method_; 193 IndexInitMethod init_method_;
193 194
194 std::unique_ptr<SimpleIndexFile> index_file_; 195 std::unique_ptr<SimpleIndexFile> index_file_;
195 196
196 scoped_refptr<base::SingleThreadTaskRunner> io_thread_; 197 scoped_refptr<base::SingleThreadTaskRunner> io_thread_;
197 198
198 // All nonstatic SimpleEntryImpl methods should always be called on the IO 199 // All nonstatic SimpleEntryImpl methods should always be called on the IO
199 // thread, in all cases. |io_thread_checker_| documents and enforces this. 200 // thread, in all cases. |io_thread_checker_| documents and enforces this.
200 base::ThreadChecker io_thread_checker_; 201 base::ThreadChecker io_thread_checker_;
(...skipping 11 matching lines...) Expand all
212 213
213 // Set to true when the app is on the background. When the app is in the 214 // Set to true when the app is on the background. When the app is in the
214 // background we can write the index much more frequently, to insure fresh 215 // background we can write the index much more frequently, to insure fresh
215 // index on next startup. 216 // index on next startup.
216 bool app_on_background_; 217 bool app_on_background_;
217 }; 218 };
218 219
219 } // namespace disk_cache 220 } // namespace disk_cache
220 221
221 #endif // NET_DISK_CACHE_SIMPLE_SIMPLE_INDEX_H_ 222 #endif // NET_DISK_CACHE_SIMPLE_SIMPLE_INDEX_H_
OLDNEW
« no previous file with comments | « net/disk_cache/simple/simple_backend_impl.cc ('k') | net/disk_cache/simple/simple_index.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698