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