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

Side by Side Diff: content/browser/appcache/appcache_group.h

Issue 879393002: Expire appcaches that fail to update for "too long". (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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_GROUP_H_ 5 #ifndef CONTENT_BROWSER_APPCACHE_APPCACHE_GROUP_H_
6 #define CONTENT_BROWSER_APPCACHE_APPCACHE_GROUP_H_ 6 #define CONTENT_BROWSER_APPCACHE_APPCACHE_GROUP_H_
7 7
8 #include <map> 8 #include <map>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 20 matching lines...) Expand all
31 class HostObserver; 31 class HostObserver;
32 class MockAppCacheStorage; 32 class MockAppCacheStorage;
33 33
34 // Collection of application caches identified by the same manifest URL. 34 // Collection of application caches identified by the same manifest URL.
35 // A group exists as long as it is in use by a host or is being updated. 35 // A group exists as long as it is in use by a host or is being updated.
36 class CONTENT_EXPORT AppCacheGroup 36 class CONTENT_EXPORT AppCacheGroup
37 : public base::RefCounted<AppCacheGroup> { 37 : public base::RefCounted<AppCacheGroup> {
38 public: 38 public:
39 39
40 class CONTENT_EXPORT UpdateObserver { 40 class CONTENT_EXPORT UpdateObserver {
41 public: 41 public:
42 // Called just after an appcache update has completed. 42 // Called just after an appcache update has completed.
43 virtual void OnUpdateComplete(AppCacheGroup* group) = 0; 43 virtual void OnUpdateComplete(AppCacheGroup* group) = 0;
44 virtual ~UpdateObserver() {} 44 virtual ~UpdateObserver() {}
45 }; 45 };
46 46
47 enum UpdateAppCacheStatus { 47 enum UpdateAppCacheStatus {
48 IDLE, 48 IDLE,
49 CHECKING, 49 CHECKING,
50 DOWNLOADING, 50 DOWNLOADING,
51 }; 51 };
52 52
53 AppCacheGroup(AppCacheStorage* storage, const GURL& manifest_url, 53 AppCacheGroup(AppCacheStorage* storage, const GURL& manifest_url,
54 int64 group_id); 54 int64 group_id);
55 55
56 // Adds/removes an update observer, the AppCacheGroup does not take 56 // Adds/removes an update observer, the AppCacheGroup does not take
57 // ownership of the observer. 57 // ownership of the observer.
58 void AddUpdateObserver(UpdateObserver* observer); 58 void AddUpdateObserver(UpdateObserver* observer);
59 void RemoveUpdateObserver(UpdateObserver* observer); 59 void RemoveUpdateObserver(UpdateObserver* observer);
60 60
61 int64 group_id() const { return group_id_; } 61 int64 group_id() const { return group_id_; }
62 const GURL& manifest_url() const { return manifest_url_; } 62 const GURL& manifest_url() const { return manifest_url_; }
63 const base::Time& creation_time() const { return creation_time_; } 63 base::Time creation_time() const { return creation_time_; }
64 void set_creation_time(const base::Time& time) { creation_time_ = time; } 64 void set_creation_time(base::Time time) { creation_time_ = time; }
65 bool is_obsolete() const { return is_obsolete_; } 65 bool is_obsolete() const { return is_obsolete_; }
66 void set_obsolete(bool value) { is_obsolete_ = value; } 66 void set_obsolete(bool value) { is_obsolete_ = value; }
67
68 bool is_being_deleted() const { return is_being_deleted_; } 67 bool is_being_deleted() const { return is_being_deleted_; }
69 void set_being_deleted(bool value) { is_being_deleted_ = value; } 68 void set_being_deleted(bool value) { is_being_deleted_ = value; }
69 base::Time last_full_update_check_time() const {
70 return last_full_update_check_time_;
71 }
72 void set_last_full_update_check_time(base::Time time) {
73 last_full_update_check_time_ = time;
74 }
75 base::Time first_evictable_error_time() const {
76 return first_evictable_error_time_;
77 }
78 void set_first_evictable_error_time(base::Time time) {
79 first_evictable_error_time_ = time;
80 }
70 81
71 AppCache* newest_complete_cache() const { return newest_complete_cache_; } 82 AppCache* newest_complete_cache() const { return newest_complete_cache_; }
72 83
73 void AddCache(AppCache* complete_cache); 84 void AddCache(AppCache* complete_cache);
74 void RemoveCache(AppCache* cache); 85 void RemoveCache(AppCache* cache);
75 bool HasCache() const { return newest_complete_cache_ != NULL; } 86 bool HasCache() const { return newest_complete_cache_ != NULL; }
76 87
77 void AddNewlyDeletableResponseIds(std::vector<int64>* response_ids); 88 void AddNewlyDeletableResponseIds(std::vector<int64>* response_ids);
78 89
79 UpdateAppCacheStatus update_status() const { return update_status_; } 90 UpdateAppCacheStatus update_status() const { return update_status_; }
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 void HostDestructionImminent(AppCacheHost* host); 139 void HostDestructionImminent(AppCacheHost* host);
129 140
130 const int64 group_id_; 141 const int64 group_id_;
131 const GURL manifest_url_; 142 const GURL manifest_url_;
132 base::Time creation_time_; 143 base::Time creation_time_;
133 UpdateAppCacheStatus update_status_; 144 UpdateAppCacheStatus update_status_;
134 bool is_obsolete_; 145 bool is_obsolete_;
135 bool is_being_deleted_; 146 bool is_being_deleted_;
136 std::vector<int64> newly_deletable_response_ids_; 147 std::vector<int64> newly_deletable_response_ids_;
137 148
149 // Most update checks respect the cache control headers of the manifest
150 // resource, but we bust the http cache for a "full" update check after 24
palmer 2015/06/01 21:09:02 Nit: What does "bust" mean here? Invalidate?
michaeln 2015/06/19 21:38:19 as in cache-busting, i used the term "bypass" inst
151 // hours since the last full check was successfully performed.
152 base::Time last_full_update_check_time_;
153
154 // Groups that fail to update for a sufficiently long time are evicted. This
155 // value is reset after a successful update or update check.
156 base::Time first_evictable_error_time_;
157
138 // Old complete app caches. 158 // Old complete app caches.
139 Caches old_caches_; 159 Caches old_caches_;
140 160
141 // Newest cache in this group to be complete, aka relevant cache. 161 // Newest cache in this group to be complete, aka relevant cache.
142 AppCache* newest_complete_cache_; 162 AppCache* newest_complete_cache_;
143 163
144 // Current update job for this group, if any. 164 // Current update job for this group, if any.
145 AppCacheUpdateJob* update_job_; 165 AppCacheUpdateJob* update_job_;
146 166
147 // Central storage object. 167 // Central storage object.
(...skipping 16 matching lines...) Expand all
164 FRIEND_TEST_ALL_PREFIXES(content::AppCacheGroupTest, QueueUpdate); 184 FRIEND_TEST_ALL_PREFIXES(content::AppCacheGroupTest, QueueUpdate);
165 FRIEND_TEST_ALL_PREFIXES(content::AppCacheUpdateJobTest, AlreadyChecking); 185 FRIEND_TEST_ALL_PREFIXES(content::AppCacheUpdateJobTest, AlreadyChecking);
166 FRIEND_TEST_ALL_PREFIXES(content::AppCacheUpdateJobTest, AlreadyDownloading); 186 FRIEND_TEST_ALL_PREFIXES(content::AppCacheUpdateJobTest, AlreadyDownloading);
167 187
168 DISALLOW_COPY_AND_ASSIGN(AppCacheGroup); 188 DISALLOW_COPY_AND_ASSIGN(AppCacheGroup);
169 }; 189 };
170 190
171 } // namespace content 191 } // namespace content
172 192
173 #endif // CONTENT_BROWSER_APPCACHE_APPCACHE_GROUP_H_ 193 #endif // CONTENT_BROWSER_APPCACHE_APPCACHE_GROUP_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698