OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // See net/disk_cache/disk_cache.h for the public interface of the cache. | 5 // See net/disk_cache/disk_cache.h for the public interface of the cache. |
6 | 6 |
7 #ifndef NET_DISK_CACHE_BLOCKFILE_BACKEND_IMPL_H_ | 7 #ifndef NET_DISK_CACHE_BLOCKFILE_BACKEND_IMPL_H_ |
8 #define NET_DISK_CACHE_BLOCKFILE_BACKEND_IMPL_H_ | 8 #define NET_DISK_CACHE_BLOCKFILE_BACKEND_IMPL_H_ |
9 | 9 |
10 #include <stdint.h> | 10 #include <stdint.h> |
11 | 11 |
12 #include "base/containers/hash_tables.h" | 12 #include <unordered_map> |
| 13 |
13 #include "base/files/file_path.h" | 14 #include "base/files/file_path.h" |
14 #include "base/macros.h" | 15 #include "base/macros.h" |
15 #include "base/memory/ref_counted.h" | 16 #include "base/memory/ref_counted.h" |
16 #include "base/timer/timer.h" | 17 #include "base/timer/timer.h" |
17 #include "net/disk_cache/blockfile/block_files.h" | 18 #include "net/disk_cache/blockfile/block_files.h" |
18 #include "net/disk_cache/blockfile/eviction.h" | 19 #include "net/disk_cache/blockfile/eviction.h" |
19 #include "net/disk_cache/blockfile/in_flight_backend_io.h" | 20 #include "net/disk_cache/blockfile/in_flight_backend_io.h" |
20 #include "net/disk_cache/blockfile/rankings.h" | 21 #include "net/disk_cache/blockfile/rankings.h" |
21 #include "net/disk_cache/blockfile/stats.h" | 22 #include "net/disk_cache/blockfile/stats.h" |
22 #include "net/disk_cache/blockfile/stress_support.h" | 23 #include "net/disk_cache/blockfile/stress_support.h" |
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
286 // entries on the cache only if the cache is not modified while the | 287 // entries on the cache only if the cache is not modified while the |
287 // enumeration is taking place. Significantly altering the entry pointed by | 288 // enumeration is taking place. Significantly altering the entry pointed by |
288 // the iterator (for example, deleting the entry) will invalidate the | 289 // the iterator (for example, deleting the entry) will invalidate the |
289 // iterator. Performing operations on an entry that modify the entry may | 290 // iterator. Performing operations on an entry that modify the entry may |
290 // result in loops in the iteration, skipped entries or similar. | 291 // result in loops in the iteration, skipped entries or similar. |
291 std::unique_ptr<Iterator> CreateIterator() override; | 292 std::unique_ptr<Iterator> CreateIterator() override; |
292 void GetStats(StatsItems* stats) override; | 293 void GetStats(StatsItems* stats) override; |
293 void OnExternalCacheHit(const std::string& key) override; | 294 void OnExternalCacheHit(const std::string& key) override; |
294 | 295 |
295 private: | 296 private: |
296 typedef base::hash_map<CacheAddr, EntryImpl*> EntriesMap; | 297 using EntriesMap = std::unordered_map<CacheAddr, EntryImpl*>; |
297 class IteratorImpl; | 298 class IteratorImpl; |
298 | 299 |
299 // Creates a new backing file for the cache index. | 300 // Creates a new backing file for the cache index. |
300 bool CreateBackingStore(disk_cache::File* file); | 301 bool CreateBackingStore(disk_cache::File* file); |
301 bool InitBackingStore(bool* file_created); | 302 bool InitBackingStore(bool* file_created); |
302 void AdjustMaxCacheSize(int table_len); | 303 void AdjustMaxCacheSize(int table_len); |
303 | 304 |
304 bool InitStats(); | 305 bool InitStats(); |
305 void StoreStats(); | 306 void StoreStats(); |
306 | 307 |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
407 base::WaitableEvent done_; // Signals the end of background work. | 408 base::WaitableEvent done_; // Signals the end of background work. |
408 scoped_refptr<TraceObject> trace_object_; // Initializes internal tracing. | 409 scoped_refptr<TraceObject> trace_object_; // Initializes internal tracing. |
409 base::WeakPtrFactory<BackendImpl> ptr_factory_; | 410 base::WeakPtrFactory<BackendImpl> ptr_factory_; |
410 | 411 |
411 DISALLOW_COPY_AND_ASSIGN(BackendImpl); | 412 DISALLOW_COPY_AND_ASSIGN(BackendImpl); |
412 }; | 413 }; |
413 | 414 |
414 } // namespace disk_cache | 415 } // namespace disk_cache |
415 | 416 |
416 #endif // NET_DISK_CACHE_BLOCKFILE_BACKEND_IMPL_H_ | 417 #endif // NET_DISK_CACHE_BLOCKFILE_BACKEND_IMPL_H_ |
OLD | NEW |