OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 CONTENT_BROWSER_APPCACHE_APPCACHE_DATABASE_H_ | 5 #ifndef CONTENT_BROWSER_APPCACHE_APPCACHE_DATABASE_H_ |
6 #define CONTENT_BROWSER_APPCACHE_APPCACHE_DATABASE_H_ | 6 #define CONTENT_BROWSER_APPCACHE_APPCACHE_DATABASE_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <set> | 9 #include <set> |
10 #include <vector> | 10 #include <vector> |
(...skipping 13 matching lines...) Expand all Loading... |
24 class Statement; | 24 class Statement; |
25 class StatementID; | 25 class StatementID; |
26 } | 26 } |
27 | 27 |
28 namespace content { | 28 namespace content { |
29 FORWARD_DECLARE_TEST(AppCacheDatabaseTest, CacheRecords); | 29 FORWARD_DECLARE_TEST(AppCacheDatabaseTest, CacheRecords); |
30 FORWARD_DECLARE_TEST(AppCacheDatabaseTest, EntryRecords); | 30 FORWARD_DECLARE_TEST(AppCacheDatabaseTest, EntryRecords); |
31 FORWARD_DECLARE_TEST(AppCacheDatabaseTest, QuickIntegrityCheck); | 31 FORWARD_DECLARE_TEST(AppCacheDatabaseTest, QuickIntegrityCheck); |
32 FORWARD_DECLARE_TEST(AppCacheDatabaseTest, NamespaceRecords); | 32 FORWARD_DECLARE_TEST(AppCacheDatabaseTest, NamespaceRecords); |
33 FORWARD_DECLARE_TEST(AppCacheDatabaseTest, GroupRecords); | 33 FORWARD_DECLARE_TEST(AppCacheDatabaseTest, GroupRecords); |
| 34 FORWARD_DECLARE_TEST(AppCacheDatabaseTest, GroupAccessAndEvictionTimes); |
34 FORWARD_DECLARE_TEST(AppCacheDatabaseTest, LazyOpen); | 35 FORWARD_DECLARE_TEST(AppCacheDatabaseTest, LazyOpen); |
35 FORWARD_DECLARE_TEST(AppCacheDatabaseTest, ExperimentalFlags); | 36 FORWARD_DECLARE_TEST(AppCacheDatabaseTest, ExperimentalFlags); |
36 FORWARD_DECLARE_TEST(AppCacheDatabaseTest, OnlineWhiteListRecords); | 37 FORWARD_DECLARE_TEST(AppCacheDatabaseTest, OnlineWhiteListRecords); |
37 FORWARD_DECLARE_TEST(AppCacheDatabaseTest, ReCreate); | 38 FORWARD_DECLARE_TEST(AppCacheDatabaseTest, ReCreate); |
38 FORWARD_DECLARE_TEST(AppCacheDatabaseTest, DeletableResponseIds); | 39 FORWARD_DECLARE_TEST(AppCacheDatabaseTest, DeletableResponseIds); |
39 FORWARD_DECLARE_TEST(AppCacheDatabaseTest, OriginUsage); | 40 FORWARD_DECLARE_TEST(AppCacheDatabaseTest, OriginUsage); |
40 FORWARD_DECLARE_TEST(AppCacheDatabaseTest, UpgradeSchema3to5); | 41 FORWARD_DECLARE_TEST(AppCacheDatabaseTest, UpgradeSchema3to7); |
41 FORWARD_DECLARE_TEST(AppCacheDatabaseTest, UpgradeSchema4to5); | 42 FORWARD_DECLARE_TEST(AppCacheDatabaseTest, UpgradeSchema4to7); |
| 43 FORWARD_DECLARE_TEST(AppCacheDatabaseTest, UpgradeSchema5or6to7); |
42 FORWARD_DECLARE_TEST(AppCacheDatabaseTest, WasCorrutionDetected); | 44 FORWARD_DECLARE_TEST(AppCacheDatabaseTest, WasCorrutionDetected); |
43 class AppCacheDatabaseTest; | 45 class AppCacheDatabaseTest; |
44 class AppCacheStorageImplTest; | 46 class AppCacheStorageImplTest; |
45 | 47 |
46 class CONTENT_EXPORT AppCacheDatabase { | 48 class CONTENT_EXPORT AppCacheDatabase { |
47 public: | 49 public: |
48 struct CONTENT_EXPORT GroupRecord { | 50 struct CONTENT_EXPORT GroupRecord { |
49 GroupRecord(); | 51 GroupRecord(); |
50 ~GroupRecord(); | 52 ~GroupRecord(); |
51 | 53 |
52 int64 group_id; | 54 int64 group_id; |
53 GURL origin; | 55 GURL origin; |
54 GURL manifest_url; | 56 GURL manifest_url; |
55 base::Time creation_time; | 57 base::Time creation_time; |
56 base::Time last_access_time; | 58 base::Time last_access_time; |
| 59 base::Time last_full_update_check_time; |
| 60 base::Time first_evictable_error_time; |
57 }; | 61 }; |
58 | 62 |
59 struct CONTENT_EXPORT CacheRecord { | 63 struct CONTENT_EXPORT CacheRecord { |
60 CacheRecord() | 64 CacheRecord() |
61 : cache_id(0), group_id(0), online_wildcard(false), cache_size(0) {} | 65 : cache_id(0), group_id(0), online_wildcard(false), cache_size(0) {} |
62 | 66 |
63 int64 cache_id; | 67 int64 cache_id; |
64 int64 group_id; | 68 int64 group_id; |
65 bool online_wildcard; | 69 bool online_wildcard; |
66 base::Time update_time; | 70 base::Time update_time; |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 bool FindOriginsWithGroups(std::set<GURL>* origins); | 113 bool FindOriginsWithGroups(std::set<GURL>* origins); |
110 bool FindLastStorageIds( | 114 bool FindLastStorageIds( |
111 int64* last_group_id, int64* last_cache_id, int64* last_response_id, | 115 int64* last_group_id, int64* last_cache_id, int64* last_response_id, |
112 int64* last_deletable_response_rowid); | 116 int64* last_deletable_response_rowid); |
113 | 117 |
114 bool FindGroup(int64 group_id, GroupRecord* record); | 118 bool FindGroup(int64 group_id, GroupRecord* record); |
115 bool FindGroupForManifestUrl(const GURL& manifest_url, GroupRecord* record); | 119 bool FindGroupForManifestUrl(const GURL& manifest_url, GroupRecord* record); |
116 bool FindGroupsForOrigin( | 120 bool FindGroupsForOrigin( |
117 const GURL& origin, std::vector<GroupRecord>* records); | 121 const GURL& origin, std::vector<GroupRecord>* records); |
118 bool FindGroupForCache(int64 cache_id, GroupRecord* record); | 122 bool FindGroupForCache(int64 cache_id, GroupRecord* record); |
119 bool UpdateLastAccessTime( | |
120 int64 group_id, base::Time last_access_time); | |
121 bool LazyUpdateLastAccessTime( | |
122 int64 group_id, base::Time last_access_time); | |
123 bool CommitLazyLastAccessTimes(); // The destructor calls this too. | |
124 bool InsertGroup(const GroupRecord* record); | 123 bool InsertGroup(const GroupRecord* record); |
125 bool DeleteGroup(int64 group_id); | 124 bool DeleteGroup(int64 group_id); |
126 | 125 |
| 126 // The access and eviction time update methods do not fail when |
| 127 // given invalid group_ids. The return value only indicates whether |
| 128 // the database is functioning. |
| 129 bool UpdateLastAccessTime(int64 group_id, |
| 130 base::Time last_access_time); |
| 131 bool LazyUpdateLastAccessTime(int64 group_id, |
| 132 base::Time last_access_time); |
| 133 bool UpdateEvictionTimes(int64 group_id, |
| 134 base::Time last_full_update_check_time, |
| 135 base::Time first_evictable_error_time); |
| 136 bool CommitLazyLastAccessTimes(); // The destructor calls this too. |
| 137 |
127 bool FindCache(int64 cache_id, CacheRecord* record); | 138 bool FindCache(int64 cache_id, CacheRecord* record); |
128 bool FindCacheForGroup(int64 group_id, CacheRecord* record); | 139 bool FindCacheForGroup(int64 group_id, CacheRecord* record); |
129 bool FindCachesForOrigin( | 140 bool FindCachesForOrigin( |
130 const GURL& origin, std::vector<CacheRecord>* records); | 141 const GURL& origin, std::vector<CacheRecord>* records); |
131 bool InsertCache(const CacheRecord* record); | 142 bool InsertCache(const CacheRecord* record); |
132 bool DeleteCache(int64 cache_id); | 143 bool DeleteCache(int64 cache_id); |
133 | 144 |
134 bool FindEntriesForCache( | 145 bool FindEntriesForCache( |
135 int64 cache_id, std::vector<EntryRecord>* records); | 146 int64 cache_id, std::vector<EntryRecord>* records); |
136 bool FindEntriesForUrl( | 147 bool FindEntriesForUrl( |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
229 bool was_corruption_detected_; | 240 bool was_corruption_detected_; |
230 | 241 |
231 friend class content::AppCacheDatabaseTest; | 242 friend class content::AppCacheDatabaseTest; |
232 friend class content::AppCacheStorageImplTest; | 243 friend class content::AppCacheStorageImplTest; |
233 | 244 |
234 FRIEND_TEST_ALL_PREFIXES(content::AppCacheDatabaseTest, CacheRecords); | 245 FRIEND_TEST_ALL_PREFIXES(content::AppCacheDatabaseTest, CacheRecords); |
235 FRIEND_TEST_ALL_PREFIXES(content::AppCacheDatabaseTest, EntryRecords); | 246 FRIEND_TEST_ALL_PREFIXES(content::AppCacheDatabaseTest, EntryRecords); |
236 FRIEND_TEST_ALL_PREFIXES(content::AppCacheDatabaseTest, QuickIntegrityCheck); | 247 FRIEND_TEST_ALL_PREFIXES(content::AppCacheDatabaseTest, QuickIntegrityCheck); |
237 FRIEND_TEST_ALL_PREFIXES(content::AppCacheDatabaseTest, NamespaceRecords); | 248 FRIEND_TEST_ALL_PREFIXES(content::AppCacheDatabaseTest, NamespaceRecords); |
238 FRIEND_TEST_ALL_PREFIXES(content::AppCacheDatabaseTest, GroupRecords); | 249 FRIEND_TEST_ALL_PREFIXES(content::AppCacheDatabaseTest, GroupRecords); |
| 250 FRIEND_TEST_ALL_PREFIXES(content::AppCacheDatabaseTest, |
| 251 GroupAccessAndEvictionTimes); |
239 FRIEND_TEST_ALL_PREFIXES(content::AppCacheDatabaseTest, LazyOpen); | 252 FRIEND_TEST_ALL_PREFIXES(content::AppCacheDatabaseTest, LazyOpen); |
240 FRIEND_TEST_ALL_PREFIXES(content::AppCacheDatabaseTest, ExperimentalFlags); | 253 FRIEND_TEST_ALL_PREFIXES(content::AppCacheDatabaseTest, ExperimentalFlags); |
241 FRIEND_TEST_ALL_PREFIXES(content::AppCacheDatabaseTest, | 254 FRIEND_TEST_ALL_PREFIXES(content::AppCacheDatabaseTest, |
242 OnlineWhiteListRecords); | 255 OnlineWhiteListRecords); |
243 FRIEND_TEST_ALL_PREFIXES(content::AppCacheDatabaseTest, ReCreate); | 256 FRIEND_TEST_ALL_PREFIXES(content::AppCacheDatabaseTest, ReCreate); |
244 FRIEND_TEST_ALL_PREFIXES(content::AppCacheDatabaseTest, DeletableResponseIds); | 257 FRIEND_TEST_ALL_PREFIXES(content::AppCacheDatabaseTest, DeletableResponseIds); |
245 FRIEND_TEST_ALL_PREFIXES(content::AppCacheDatabaseTest, OriginUsage); | 258 FRIEND_TEST_ALL_PREFIXES(content::AppCacheDatabaseTest, OriginUsage); |
246 FRIEND_TEST_ALL_PREFIXES(content::AppCacheDatabaseTest, UpgradeSchema3to5); | 259 FRIEND_TEST_ALL_PREFIXES(content::AppCacheDatabaseTest, UpgradeSchema3to7); |
247 FRIEND_TEST_ALL_PREFIXES(content::AppCacheDatabaseTest, UpgradeSchema4to5); | 260 FRIEND_TEST_ALL_PREFIXES(content::AppCacheDatabaseTest, UpgradeSchema4to7); |
| 261 FRIEND_TEST_ALL_PREFIXES(content::AppCacheDatabaseTest, UpgradeSchema5or6to7); |
248 FRIEND_TEST_ALL_PREFIXES(content::AppCacheDatabaseTest, WasCorrutionDetected); | 262 FRIEND_TEST_ALL_PREFIXES(content::AppCacheDatabaseTest, WasCorrutionDetected); |
249 | 263 |
250 DISALLOW_COPY_AND_ASSIGN(AppCacheDatabase); | 264 DISALLOW_COPY_AND_ASSIGN(AppCacheDatabase); |
251 }; | 265 }; |
252 | 266 |
253 } // namespace content | 267 } // namespace content |
254 | 268 |
255 #endif // CONTENT_BROWSER_APPCACHE_APPCACHE_DATABASE_H_ | 269 #endif // CONTENT_BROWSER_APPCACHE_APPCACHE_DATABASE_H_ |
OLD | NEW |