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

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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 void HostDestructionImminent(AppCacheHost* host); 140 void HostDestructionImminent(AppCacheHost* host);
130 141
131 const int64 group_id_; 142 const int64 group_id_;
132 const GURL manifest_url_; 143 const GURL manifest_url_;
133 base::Time creation_time_; 144 base::Time creation_time_;
134 UpdateAppCacheStatus update_status_; 145 UpdateAppCacheStatus update_status_;
135 bool is_obsolete_; 146 bool is_obsolete_;
136 bool is_being_deleted_; 147 bool is_being_deleted_;
137 std::vector<int64> newly_deletable_response_ids_; 148 std::vector<int64> newly_deletable_response_ids_;
138 149
150 // Most update checks respect the cache control headers of the manifest
151 // resource, but we bypass the http cache for a "full" update check after 24
152 // hours since the last full check was successfully performed.
153 base::Time last_full_update_check_time_;
154
155 // Groups that fail to update for a sufficiently long time are evicted. This
156 // value is reset after a successful update or update check.
157 base::Time first_evictable_error_time_;
158
139 // Old complete app caches. 159 // Old complete app caches.
140 Caches old_caches_; 160 Caches old_caches_;
141 161
142 // Newest cache in this group to be complete, aka relevant cache. 162 // Newest cache in this group to be complete, aka relevant cache.
143 AppCache* newest_complete_cache_; 163 AppCache* newest_complete_cache_;
144 164
145 // Current update job for this group, if any. 165 // Current update job for this group, if any.
146 AppCacheUpdateJob* update_job_; 166 AppCacheUpdateJob* update_job_;
147 167
148 // Central storage object. 168 // Central storage object.
(...skipping 16 matching lines...) Expand all
165 FRIEND_TEST_ALL_PREFIXES(content::AppCacheGroupTest, QueueUpdate); 185 FRIEND_TEST_ALL_PREFIXES(content::AppCacheGroupTest, QueueUpdate);
166 FRIEND_TEST_ALL_PREFIXES(content::AppCacheUpdateJobTest, AlreadyChecking); 186 FRIEND_TEST_ALL_PREFIXES(content::AppCacheUpdateJobTest, AlreadyChecking);
167 FRIEND_TEST_ALL_PREFIXES(content::AppCacheUpdateJobTest, AlreadyDownloading); 187 FRIEND_TEST_ALL_PREFIXES(content::AppCacheUpdateJobTest, AlreadyDownloading);
168 188
169 DISALLOW_COPY_AND_ASSIGN(AppCacheGroup); 189 DISALLOW_COPY_AND_ASSIGN(AppCacheGroup);
170 }; 190 };
171 191
172 } // namespace content 192 } // namespace content
173 193
174 #endif // CONTENT_BROWSER_APPCACHE_APPCACHE_GROUP_H_ 194 #endif // CONTENT_BROWSER_APPCACHE_APPCACHE_GROUP_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698