| OLD | NEW | 
|---|
| 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 <unordered_map> | 
|  | 12 #include <unordered_set> | 
| 11 #include <vector> | 13 #include <vector> | 
| 12 | 14 | 
| 13 #include "base/callback.h" | 15 #include "base/callback.h" | 
| 14 #include "base/containers/hash_tables.h" |  | 
| 15 #include "base/files/file_path.h" | 16 #include "base/files/file_path.h" | 
| 16 #include "base/gtest_prod_util.h" | 17 #include "base/gtest_prod_util.h" | 
| 17 #include "base/memory/ref_counted.h" | 18 #include "base/memory/ref_counted.h" | 
| 18 #include "base/memory/scoped_ptr.h" | 19 #include "base/memory/scoped_ptr.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" | 
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 102   // iff the entry exist in the index. | 103   // iff the entry exist in the index. | 
| 103   bool UseIfExists(uint64_t entry_hash); | 104   bool UseIfExists(uint64_t entry_hash); | 
| 104 | 105 | 
| 105   void WriteToDisk(); | 106   void WriteToDisk(); | 
| 106 | 107 | 
| 107   // Update the size (in bytes) of an entry, in the metadata stored in the | 108   // Update the size (in bytes) of an entry, in the metadata stored in the | 
| 108   // index. This should be the total disk-file size including all streams of the | 109   // index. This should be the total disk-file size including all streams of the | 
| 109   // entry. | 110   // entry. | 
| 110   bool UpdateEntrySize(uint64_t entry_hash, int64_t entry_size); | 111   bool UpdateEntrySize(uint64_t entry_hash, int64_t entry_size); | 
| 111 | 112 | 
| 112   typedef base::hash_map<uint64_t, EntryMetadata> EntrySet; | 113   using EntrySet = std::unordered_map<uint64_t, EntryMetadata>; | 
| 113 | 114 | 
| 114   static void InsertInEntrySet(uint64_t entry_hash, | 115   static void InsertInEntrySet(uint64_t entry_hash, | 
| 115                                const EntryMetadata& entry_metadata, | 116                                const EntryMetadata& entry_metadata, | 
| 116                                EntrySet* entry_set); | 117                                EntrySet* entry_set); | 
| 117 | 118 | 
| 118   // Executes the |callback| when the index is ready. Allows multiple callbacks. | 119   // Executes the |callback| when the index is ready. Allows multiple callbacks. | 
| 119   int ExecuteWhenReady(const net::CompletionCallback& callback); | 120   int ExecuteWhenReady(const net::CompletionCallback& callback); | 
| 120 | 121 | 
| 121   // Returns entries from the index that have last accessed time matching the | 122   // Returns entries from the index that have last accessed time matching the | 
| 122   // range between |initial_time| and |end_time| where open intervals are | 123   // range between |initial_time| and |end_time| where open intervals are | 
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 169   const net::CacheType cache_type_; | 170   const net::CacheType cache_type_; | 
| 170   uint64_t cache_size_;  // Total cache storage size in bytes. | 171   uint64_t cache_size_;  // Total cache storage size in bytes. | 
| 171   uint64_t max_size_; | 172   uint64_t max_size_; | 
| 172   uint64_t high_watermark_; | 173   uint64_t high_watermark_; | 
| 173   uint64_t low_watermark_; | 174   uint64_t low_watermark_; | 
| 174   bool eviction_in_progress_; | 175   bool eviction_in_progress_; | 
| 175   base::TimeTicks eviction_start_time_; | 176   base::TimeTicks eviction_start_time_; | 
| 176 | 177 | 
| 177   // This stores all the entry_hash of entries that are removed during | 178   // This stores all the entry_hash of entries that are removed during | 
| 178   // initialization. | 179   // initialization. | 
| 179   base::hash_set<uint64_t> removed_entries_; | 180   std::unordered_set<uint64_t> removed_entries_; | 
| 180   bool initialized_; | 181   bool initialized_; | 
| 181 | 182 | 
| 182   scoped_ptr<SimpleIndexFile> index_file_; | 183   scoped_ptr<SimpleIndexFile> index_file_; | 
| 183 | 184 | 
| 184   scoped_refptr<base::SingleThreadTaskRunner> io_thread_; | 185   scoped_refptr<base::SingleThreadTaskRunner> io_thread_; | 
| 185 | 186 | 
| 186   // All nonstatic SimpleEntryImpl methods should always be called on the IO | 187   // All nonstatic SimpleEntryImpl methods should always be called on the IO | 
| 187   // thread, in all cases. |io_thread_checker_| documents and enforces this. | 188   // thread, in all cases. |io_thread_checker_| documents and enforces this. | 
| 188   base::ThreadChecker io_thread_checker_; | 189   base::ThreadChecker io_thread_checker_; | 
| 189 | 190 | 
| (...skipping 10 matching lines...) Expand all  Loading... | 
| 200 | 201 | 
| 201   // Set to true when the app is on the background. When the app is in the | 202   // Set to true when the app is on the background. When the app is in the | 
| 202   // background we can write the index much more frequently, to insure fresh | 203   // background we can write the index much more frequently, to insure fresh | 
| 203   // index on next startup. | 204   // index on next startup. | 
| 204   bool app_on_background_; | 205   bool app_on_background_; | 
| 205 }; | 206 }; | 
| 206 | 207 | 
| 207 }  // namespace disk_cache | 208 }  // namespace disk_cache | 
| 208 | 209 | 
| 209 #endif  // NET_DISK_CACHE_SIMPLE_SIMPLE_INDEX_H_ | 210 #endif  // NET_DISK_CACHE_SIMPLE_SIMPLE_INDEX_H_ | 
| OLD | NEW | 
|---|