Chromium Code Reviews| 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 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 135 static scoped_ptr<SimpleIndex::EntrySet> RestoreFromDisk( | 139 static scoped_ptr<SimpleIndex::EntrySet> RestoreFromDisk( |
| 136 const base::FilePath& index_filename); | 140 const base::FilePath& index_filename); |
| 137 | 141 |
| 138 static void WriteToDiskInternal(const base::FilePath& index_filename, | 142 static void WriteToDiskInternal(const base::FilePath& index_filename, |
| 139 scoped_ptr<Pickle> pickle); | 143 scoped_ptr<Pickle> pickle); |
| 140 | 144 |
| 141 // Must run on IO Thread. | 145 // Must run on IO Thread. |
| 142 void MergeInitializingSet(scoped_ptr<EntrySet> index_file_entries, | 146 void MergeInitializingSet(scoped_ptr<EntrySet> index_file_entries, |
| 143 bool force_index_flush); | 147 bool force_index_flush); |
| 144 | 148 |
| 149 #if defined(OS_ANDROID) | |
| 150 void ActivityStatusChanged( | |
| 151 net::SimpleCacheActivityStatusNotifier::ActivityStatus activity_status); | |
| 152 #endif | |
| 153 | |
| 145 EntrySet entries_set_; | 154 EntrySet entries_set_; |
| 146 uint64 cache_size_; // Total cache storage size in bytes. | 155 uint64 cache_size_; // Total cache storage size in bytes. |
| 147 | 156 |
| 148 // This stores all the hash_key of entries that are removed during | 157 // This stores all the hash_key of entries that are removed during |
| 149 // initialization. | 158 // initialization. |
| 150 base::hash_set<uint64> removed_entries_; | 159 base::hash_set<uint64> removed_entries_; |
| 151 bool initialized_; | 160 bool initialized_; |
| 152 | 161 |
| 153 base::FilePath index_filename_; | 162 base::FilePath index_filename_; |
| 154 | 163 |
| 155 scoped_refptr<base::SingleThreadTaskRunner> cache_thread_; | 164 scoped_refptr<base::SingleThreadTaskRunner> cache_thread_; |
| 156 scoped_refptr<base::SingleThreadTaskRunner> io_thread_; | 165 scoped_refptr<base::SingleThreadTaskRunner> io_thread_; |
| 157 | 166 |
| 158 // All nonstatic SimpleEntryImpl methods should always be called on the IO | 167 // All nonstatic SimpleEntryImpl methods should always be called on the IO |
| 159 // thread, in all cases. |io_thread_checker_| documents and enforces this. | 168 // thread, in all cases. |io_thread_checker_| documents and enforces this. |
| 160 base::ThreadChecker io_thread_checker_; | 169 base::ThreadChecker io_thread_checker_; |
| 161 | 170 |
| 162 // Timestamp of the last time we wrote the index to disk. | 171 // Timestamp of the last time we wrote the index to disk. |
| 163 // PostponeWritingToDisk() may give up postponing and allow the write if it | 172 // PostponeWritingToDisk() may give up postponing and allow the write if it |
| 164 // has been a while since last time we wrote. | 173 // has been a while since last time we wrote. |
| 165 base::Time last_write_to_disk_; | |
| 166 base::OneShotTimer<SimpleIndex> write_to_disk_timer_; | 174 base::OneShotTimer<SimpleIndex> write_to_disk_timer_; |
| 167 | 175 |
| 168 typedef std::list<net::CompletionCallback> CallbackList; | 176 typedef std::list<net::CompletionCallback> CallbackList; |
| 169 CallbackList to_run_when_initialized_; | 177 CallbackList to_run_when_initialized_; |
| 178 | |
| 179 #if defined(OS_ANDROID) | |
| 180 net::SimpleCacheActivityStatusNotifier activity_status_notifier_; | |
|
Philippe
2013/04/22 11:35:48
So this is indeed constructed on the IO thread.
felipeg
2013/04/22 16:14:32
Done.
| |
| 181 #endif | |
| 182 bool app_on_background_; | |
| 170 }; | 183 }; |
| 171 | 184 |
| 172 } // namespace disk_cache | 185 } // namespace disk_cache |
| 173 | 186 |
| 174 #endif // NET_DISK_CACHE_SIMPLE_SIMPLE_INDEX_H_ | 187 #endif // NET_DISK_CACHE_SIMPLE_SIMPLE_INDEX_H_ |
| OLD | NEW |