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

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

Issue 14771009: Have SimpleCache index listen to android activity status notifications. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@1-digit
Patch Set: rebase, clear to land Created 7 years, 7 months 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 | « no previous file | 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 <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/gtest_prod_util.h" 15 #include "base/gtest_prod_util.h"
16 #include "base/hash_tables.h" 16 #include "base/hash_tables.h"
17 #include "base/memory/ref_counted.h" 17 #include "base/memory/ref_counted.h"
18 #include "base/memory/scoped_ptr.h" 18 #include "base/memory/scoped_ptr.h"
19 #include "base/memory/weak_ptr.h" 19 #include "base/memory/weak_ptr.h"
20 #include "base/threading/thread_checker.h" 20 #include "base/threading/thread_checker.h"
21 #include "base/time.h" 21 #include "base/time.h"
22 #include "base/timer.h" 22 #include "base/timer.h"
23 #include "net/base/completion_callback.h" 23 #include "net/base/completion_callback.h"
24 #include "net/base/net_export.h" 24 #include "net/base/net_export.h"
25 25
26 #if defined(OS_ANDROID)
27 #include "base/android/activity_status.h"
28 #endif
29
26 class Pickle; 30 class Pickle;
27 class PickleIterator; 31 class PickleIterator;
28 32
29 namespace base { 33 namespace base {
30 class SingleThreadTaskRunner; 34 class SingleThreadTaskRunner;
31 } 35 }
32 36
33 namespace disk_cache { 37 namespace disk_cache {
34 38
35 class NET_EXPORT_PRIVATE EntryMetadata { 39 class NET_EXPORT_PRIVATE EntryMetadata {
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 const base::FilePath& index_filename); 151 const base::FilePath& index_filename);
148 152
149 static void WriteToDiskInternal(const base::FilePath& index_filename, 153 static void WriteToDiskInternal(const base::FilePath& index_filename,
150 scoped_ptr<Pickle> pickle, 154 scoped_ptr<Pickle> pickle,
151 const base::TimeTicks& start_time); 155 const base::TimeTicks& start_time);
152 156
153 // Must run on IO Thread. 157 // Must run on IO Thread.
154 void MergeInitializingSet(scoped_ptr<EntrySet> index_file_entries, 158 void MergeInitializingSet(scoped_ptr<EntrySet> index_file_entries,
155 bool force_index_flush); 159 bool force_index_flush);
156 160
161 #if defined(OS_ANDROID)
162 void OnActivityStateChange(base::android::ActivityState state);
163
164 scoped_ptr<base::android::ActivityStatus::Listener> activity_status_listener_;
165 #endif
166
157 EntrySet entries_set_; 167 EntrySet entries_set_;
168
158 uint64 cache_size_; // Total cache storage size in bytes. 169 uint64 cache_size_; // Total cache storage size in bytes.
159 uint64 max_size_; 170 uint64 max_size_;
160 uint64 high_watermark_; 171 uint64 high_watermark_;
161 uint64 low_watermark_; 172 uint64 low_watermark_;
162 bool eviction_in_progress_; 173 bool eviction_in_progress_;
163 base::TimeTicks eviction_start_time_; 174 base::TimeTicks eviction_start_time_;
164 175
165 // This stores all the hash_key of entries that are removed during 176 // This stores all the hash_key of entries that are removed during
166 // initialization. 177 // initialization.
167 base::hash_set<uint64> removed_entries_; 178 base::hash_set<uint64> removed_entries_;
168 bool initialized_; 179 bool initialized_;
169 180
170 base::FilePath index_filename_; 181 base::FilePath index_filename_;
171 182
172 scoped_refptr<base::SingleThreadTaskRunner> cache_thread_; 183 scoped_refptr<base::SingleThreadTaskRunner> cache_thread_;
173 scoped_refptr<base::SingleThreadTaskRunner> io_thread_; 184 scoped_refptr<base::SingleThreadTaskRunner> io_thread_;
174 185
175 // All nonstatic SimpleEntryImpl methods should always be called on the IO 186 // All nonstatic SimpleEntryImpl methods should always be called on the IO
176 // thread, in all cases. |io_thread_checker_| documents and enforces this. 187 // thread, in all cases. |io_thread_checker_| documents and enforces this.
177 base::ThreadChecker io_thread_checker_; 188 base::ThreadChecker io_thread_checker_;
178 189
179 // Timestamp of the last time we wrote the index to disk. 190 // Timestamp of the last time we wrote the index to disk.
180 // PostponeWritingToDisk() may give up postponing and allow the write if it 191 // PostponeWritingToDisk() may give up postponing and allow the write if it
181 // has been a while since last time we wrote. 192 // has been a while since last time we wrote.
182 base::Time last_write_to_disk_; 193 base::Time last_write_to_disk_;
183 base::OneShotTimer<SimpleIndex> write_to_disk_timer_; 194 base::OneShotTimer<SimpleIndex> write_to_disk_timer_;
184 195
185 typedef std::list<net::CompletionCallback> CallbackList; 196 typedef std::list<net::CompletionCallback> CallbackList;
186 CallbackList to_run_when_initialized_; 197 CallbackList to_run_when_initialized_;
198
199 // Set to true when the app is on the background. When the app is in the
200 // background we can write the index much more frequently, to insure fresh
201 // index on next startup.
202 bool app_on_background_;
187 }; 203 };
188 204
189 } // namespace disk_cache 205 } // namespace disk_cache
190 206
191 #endif // NET_DISK_CACHE_SIMPLE_SIMPLE_INDEX_H_ 207 #endif // NET_DISK_CACHE_SIMPLE_SIMPLE_INDEX_H_
OLDNEW
« no previous file with comments | « no previous file | net/disk_cache/simple/simple_index.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698