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 <list> | 8 #include <list> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
13 #include "base/callback.h" | 13 #include "base/callback.h" |
14 #include "base/files/file_path.h" | 14 #include "base/files/file_path.h" |
15 #include "base/hash_tables.h" | 15 #include "base/hash_tables.h" |
16 #include "base/memory/ref_counted.h" | 16 #include "base/memory/ref_counted.h" |
17 #include "base/memory/scoped_ptr.h" | 17 #include "base/memory/scoped_ptr.h" |
18 #include "base/memory/weak_ptr.h" | 18 #include "base/memory/weak_ptr.h" |
19 #include "base/threading/thread_checker.h" | 19 #include "base/threading/thread_checker.h" |
20 #include "base/time.h" | 20 #include "base/time.h" |
21 #include "base/timer.h" | 21 #include "base/timer.h" |
22 #include "net/base/completion_callback.h" | 22 #include "net/base/completion_callback.h" |
23 #include "net/base/net_export.h" | 23 #include "net/base/net_export.h" |
24 | 24 |
| 25 #if defined(OS_ANDROID) |
| 26 #include "net/android/simple_cache_activity_status_notifier.h" |
| 27 #endif |
| 28 |
25 class Pickle; | 29 class Pickle; |
26 class PickleIterator; | 30 class PickleIterator; |
27 | 31 |
28 namespace base { | 32 namespace base { |
29 class SingleThreadTaskRunner; | 33 class SingleThreadTaskRunner; |
30 } | 34 } |
31 | 35 |
32 namespace disk_cache { | 36 namespace disk_cache { |
33 | 37 |
34 class NET_EXPORT_PRIVATE EntryMetadata { | 38 class NET_EXPORT_PRIVATE EntryMetadata { |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 static scoped_ptr<SimpleIndex::EntrySet> RestoreFromDisk( | 149 static scoped_ptr<SimpleIndex::EntrySet> RestoreFromDisk( |
146 const base::FilePath& index_filename); | 150 const base::FilePath& index_filename); |
147 | 151 |
148 static void WriteToDiskInternal(const base::FilePath& index_filename, | 152 static void WriteToDiskInternal(const base::FilePath& index_filename, |
149 scoped_ptr<Pickle> pickle); | 153 scoped_ptr<Pickle> pickle); |
150 | 154 |
151 // Must run on IO Thread. | 155 // Must run on IO Thread. |
152 void MergeInitializingSet(scoped_ptr<EntrySet> index_file_entries, | 156 void MergeInitializingSet(scoped_ptr<EntrySet> index_file_entries, |
153 bool force_index_flush); | 157 bool force_index_flush); |
154 | 158 |
| 159 #if defined(OS_ANDROID) |
| 160 void ActivityStatusChanged( |
| 161 net::SimpleCacheActivityStatusNotifier::ActivityStatus activity_status); |
| 162 #endif |
| 163 |
155 EntrySet entries_set_; | 164 EntrySet entries_set_; |
156 uint64 cache_size_; // Total cache storage size in bytes. | 165 uint64 cache_size_; // Total cache storage size in bytes. |
157 uint64 max_size_; | 166 uint64 max_size_; |
158 uint64 high_watermark_; | 167 uint64 high_watermark_; |
159 uint64 low_watermark_; | 168 uint64 low_watermark_; |
160 bool eviction_in_progress_; | 169 bool eviction_in_progress_; |
161 | 170 |
162 // This stores all the hash_key of entries that are removed during | 171 // This stores all the hash_key of entries that are removed during |
163 // initialization. | 172 // initialization. |
164 base::hash_set<uint64> removed_entries_; | 173 base::hash_set<uint64> removed_entries_; |
165 bool initialized_; | 174 bool initialized_; |
166 | 175 |
167 base::FilePath index_filename_; | 176 base::FilePath index_filename_; |
168 | 177 |
169 scoped_refptr<base::SingleThreadTaskRunner> cache_thread_; | 178 scoped_refptr<base::SingleThreadTaskRunner> cache_thread_; |
170 scoped_refptr<base::SingleThreadTaskRunner> io_thread_; | 179 scoped_refptr<base::SingleThreadTaskRunner> io_thread_; |
171 | 180 |
172 // All nonstatic SimpleEntryImpl methods should always be called on the IO | 181 // All nonstatic SimpleEntryImpl methods should always be called on the IO |
173 // thread, in all cases. |io_thread_checker_| documents and enforces this. | 182 // thread, in all cases. |io_thread_checker_| documents and enforces this. |
174 base::ThreadChecker io_thread_checker_; | 183 base::ThreadChecker io_thread_checker_; |
175 | 184 |
176 // Timestamp of the last time we wrote the index to disk. | |
177 // PostponeWritingToDisk() may give up postponing and allow the write if it | |
178 // has been a while since last time we wrote. | |
179 base::Time last_write_to_disk_; | |
180 base::OneShotTimer<SimpleIndex> write_to_disk_timer_; | 185 base::OneShotTimer<SimpleIndex> write_to_disk_timer_; |
181 | 186 |
182 typedef std::list<net::CompletionCallback> CallbackList; | 187 typedef std::list<net::CompletionCallback> CallbackList; |
183 CallbackList to_run_when_initialized_; | 188 CallbackList to_run_when_initialized_; |
| 189 |
| 190 #if defined(OS_ANDROID) |
| 191 net::SimpleCacheActivityStatusNotifier activity_status_notifier_; |
| 192 #endif |
| 193 bool app_on_background_; |
184 }; | 194 }; |
185 | 195 |
186 } // namespace disk_cache | 196 } // namespace disk_cache |
187 | 197 |
188 #endif // NET_DISK_CACHE_SIMPLE_SIMPLE_INDEX_H_ | 198 #endif // NET_DISK_CACHE_SIMPLE_SIMPLE_INDEX_H_ |
OLD | NEW |