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

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

Issue 761903003: Update from https://crrev.com/306655 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years 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_entry_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 <list> 8 #include <list>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 22 matching lines...) Expand all
33 33
34 namespace disk_cache { 34 namespace disk_cache {
35 35
36 class SimpleIndexDelegate; 36 class SimpleIndexDelegate;
37 class SimpleIndexFile; 37 class SimpleIndexFile;
38 struct SimpleIndexLoadResult; 38 struct SimpleIndexLoadResult;
39 39
40 class NET_EXPORT_PRIVATE EntryMetadata { 40 class NET_EXPORT_PRIVATE EntryMetadata {
41 public: 41 public:
42 EntryMetadata(); 42 EntryMetadata();
43 EntryMetadata(base::Time last_used_time, int entry_size); 43 EntryMetadata(base::Time last_used_time, uint64 entry_size);
44 44
45 base::Time GetLastUsedTime() const; 45 base::Time GetLastUsedTime() const;
46 void SetLastUsedTime(const base::Time& last_used_time); 46 void SetLastUsedTime(const base::Time& last_used_time);
47 47
48 int GetEntrySize() const { return entry_size_; } 48 uint64 GetEntrySize() const;
49 void SetEntrySize(int entry_size) { entry_size_ = entry_size; } 49 void SetEntrySize(uint64 entry_size);
50 50
51 // Serialize the data into the provided pickle. 51 // Serialize the data into the provided pickle.
52 void Serialize(Pickle* pickle) const; 52 void Serialize(Pickle* pickle) const;
53 bool Deserialize(PickleIterator* it); 53 bool Deserialize(PickleIterator* it);
54 54
55 static base::TimeDelta GetLowerEpsilonForTimeComparisons() { 55 static base::TimeDelta GetLowerEpsilonForTimeComparisons() {
56 return base::TimeDelta::FromSeconds(1); 56 return base::TimeDelta::FromSeconds(1);
57 } 57 }
58 static base::TimeDelta GetUpperEpsilonForTimeComparisons() { 58 static base::TimeDelta GetUpperEpsilonForTimeComparisons() {
59 return base::TimeDelta(); 59 return base::TimeDelta();
(...skipping 19 matching lines...) Expand all
79 79
80 SimpleIndex(const scoped_refptr<base::SingleThreadTaskRunner>& io_thread, 80 SimpleIndex(const scoped_refptr<base::SingleThreadTaskRunner>& io_thread,
81 SimpleIndexDelegate* delegate, 81 SimpleIndexDelegate* delegate,
82 net::CacheType cache_type, 82 net::CacheType cache_type,
83 scoped_ptr<SimpleIndexFile> simple_index_file); 83 scoped_ptr<SimpleIndexFile> simple_index_file);
84 84
85 virtual ~SimpleIndex(); 85 virtual ~SimpleIndex();
86 86
87 void Initialize(base::Time cache_mtime); 87 void Initialize(base::Time cache_mtime);
88 88
89 bool SetMaxSize(int max_bytes); 89 void SetMaxSize(uint64 max_bytes);
90 int max_size() const { return max_size_; } 90 uint64 max_size() const { return max_size_; }
91 91
92 void Insert(uint64 entry_hash); 92 void Insert(uint64 entry_hash);
93 void Remove(uint64 entry_hash); 93 void Remove(uint64 entry_hash);
94 94
95 // Check whether the index has the entry given the hash of its key. 95 // Check whether the index has the entry given the hash of its key.
96 bool Has(uint64 entry_hash) const; 96 bool Has(uint64 entry_hash) const;
97 97
98 // Update the last used time of the entry with the given key and return true 98 // Update the last used time of the entry with the given key and return true
99 // iff the entry exist in the index. 99 // iff the entry exist in the index.
100 bool UseIfExists(uint64 entry_hash); 100 bool UseIfExists(uint64 entry_hash);
101 101
102 void WriteToDisk(); 102 void WriteToDisk();
103 103
104 // Update the size (in bytes) of an entry, in the metadata stored in the 104 // Update the size (in bytes) of an entry, in the metadata stored in the
105 // index. This should be the total disk-file size including all streams of the 105 // index. This should be the total disk-file size including all streams of the
106 // entry. 106 // entry.
107 bool UpdateEntrySize(uint64 entry_hash, int entry_size); 107 bool UpdateEntrySize(uint64 entry_hash, int64 entry_size);
108 108
109 typedef base::hash_map<uint64, EntryMetadata> EntrySet; 109 typedef base::hash_map<uint64, EntryMetadata> EntrySet;
110 110
111 static void InsertInEntrySet(uint64 entry_hash, 111 static void InsertInEntrySet(uint64 entry_hash,
112 const EntryMetadata& entry_metadata, 112 const EntryMetadata& entry_metadata,
113 EntrySet* entry_set); 113 EntrySet* entry_set);
114 114
115 // Executes the |callback| when the index is ready. Allows multiple callbacks. 115 // Executes the |callback| when the index is ready. Allows multiple callbacks.
116 int ExecuteWhenReady(const net::CompletionCallback& callback); 116 int ExecuteWhenReady(const net::CompletionCallback& callback);
117 117
(...skipping 18 matching lines...) Expand all
136 FRIEND_TEST_ALL_PREFIXES(SimpleIndexTest, IndexSizeCorrectOnMerge); 136 FRIEND_TEST_ALL_PREFIXES(SimpleIndexTest, IndexSizeCorrectOnMerge);
137 FRIEND_TEST_ALL_PREFIXES(SimpleIndexTest, DiskWriteQueued); 137 FRIEND_TEST_ALL_PREFIXES(SimpleIndexTest, DiskWriteQueued);
138 FRIEND_TEST_ALL_PREFIXES(SimpleIndexTest, DiskWriteExecuted); 138 FRIEND_TEST_ALL_PREFIXES(SimpleIndexTest, DiskWriteExecuted);
139 FRIEND_TEST_ALL_PREFIXES(SimpleIndexTest, DiskWritePostponed); 139 FRIEND_TEST_ALL_PREFIXES(SimpleIndexTest, DiskWritePostponed);
140 140
141 void StartEvictionIfNeeded(); 141 void StartEvictionIfNeeded();
142 void EvictionDone(int result); 142 void EvictionDone(int result);
143 143
144 void PostponeWritingToDisk(); 144 void PostponeWritingToDisk();
145 145
146 void UpdateEntryIteratorSize(EntrySet::iterator* it, int entry_size); 146 void UpdateEntryIteratorSize(EntrySet::iterator* it, int64 entry_size);
147 147
148 // Must run on IO Thread. 148 // Must run on IO Thread.
149 void MergeInitializingSet(scoped_ptr<SimpleIndexLoadResult> load_result); 149 void MergeInitializingSet(scoped_ptr<SimpleIndexLoadResult> load_result);
150 150
151 #if defined(OS_ANDROID) 151 #if defined(OS_ANDROID)
152 void OnApplicationStateChange(base::android::ApplicationState state); 152 void OnApplicationStateChange(base::android::ApplicationState state);
153 153
154 scoped_ptr<base::android::ApplicationStatusListener> app_status_listener_; 154 scoped_ptr<base::android::ApplicationStatusListener> app_status_listener_;
155 #endif 155 #endif
156 156
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 193
194 // Set to true when the app is on the background. When the app is in the 194 // Set to true when the app is on the background. When the app is in the
195 // background we can write the index much more frequently, to insure fresh 195 // background we can write the index much more frequently, to insure fresh
196 // index on next startup. 196 // index on next startup.
197 bool app_on_background_; 197 bool app_on_background_;
198 }; 198 };
199 199
200 } // namespace disk_cache 200 } // namespace disk_cache
201 201
202 #endif // NET_DISK_CACHE_SIMPLE_SIMPLE_INDEX_H_ 202 #endif // NET_DISK_CACHE_SIMPLE_SIMPLE_INDEX_H_
OLDNEW
« no previous file with comments | « net/disk_cache/simple/simple_entry_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