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

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

Issue 14362009: Receive app notifications in SimpleCache, so we save our index file (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: sync Created 7 years, 8 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
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/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
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 void ActivityStatusChanged(int activity_status);
gavinp 2013/04/19 15:58:55 I'm not a fan of moving the activity_status around
felipeg 2013/04/19 17:10:15 lets do the enum
150
145 EntrySet entries_set_; 151 EntrySet entries_set_;
146 uint64 cache_size_; // Total cache storage size in bytes. 152 uint64 cache_size_; // Total cache storage size in bytes.
147 153
148 // This stores all the hash_key of entries that are removed during 154 // This stores all the hash_key of entries that are removed during
149 // initialization. 155 // initialization.
150 base::hash_set<uint64> removed_entries_; 156 base::hash_set<uint64> removed_entries_;
151 bool initialized_; 157 bool initialized_;
152 158
153 base::FilePath index_filename_; 159 base::FilePath index_filename_;
154 160
155 scoped_refptr<base::SingleThreadTaskRunner> cache_thread_; 161 scoped_refptr<base::SingleThreadTaskRunner> cache_thread_;
156 scoped_refptr<base::SingleThreadTaskRunner> io_thread_; 162 scoped_refptr<base::SingleThreadTaskRunner> io_thread_;
157 163
158 // All nonstatic SimpleEntryImpl methods should always be called on the IO 164 // All nonstatic SimpleEntryImpl methods should always be called on the IO
159 // thread, in all cases. |io_thread_checker_| documents and enforces this. 165 // thread, in all cases. |io_thread_checker_| documents and enforces this.
160 base::ThreadChecker io_thread_checker_; 166 base::ThreadChecker io_thread_checker_;
161 167
162 // Timestamp of the last time we wrote the index to disk. 168 // Timestamp of the last time we wrote the index to disk.
163 // PostponeWritingToDisk() may give up postponing and allow the write if it 169 // PostponeWritingToDisk() may give up postponing and allow the write if it
164 // has been a while since last time we wrote. 170 // has been a while since last time we wrote.
165 base::Time last_write_to_disk_;
166 base::OneShotTimer<SimpleIndex> write_to_disk_timer_; 171 base::OneShotTimer<SimpleIndex> write_to_disk_timer_;
167 172
168 typedef std::list<net::CompletionCallback> CallbackList; 173 typedef std::list<net::CompletionCallback> CallbackList;
169 CallbackList to_run_when_initialized_; 174 CallbackList to_run_when_initialized_;
175
176 #if defined(OS_ANDROID)
177 net::SimpleCacheActivityStatusNotifier activity_status_notifier_;
178 #endif
179 bool app_on_background_;
170 }; 180 };
171 181
172 } // namespace disk_cache 182 } // namespace disk_cache
173 183
174 #endif // NET_DISK_CACHE_SIMPLE_SIMPLE_INDEX_H_ 184 #endif // NET_DISK_CACHE_SIMPLE_SIMPLE_INDEX_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698