| OLD | NEW |
| 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 WEBKIT_BROWSER_APPCACHE_APPCACHE_GROUP_H_ | 5 #ifndef WEBKIT_BROWSER_APPCACHE_APPCACHE_GROUP_H_ |
| 6 #define WEBKIT_BROWSER_APPCACHE_APPCACHE_GROUP_H_ | 6 #define WEBKIT_BROWSER_APPCACHE_APPCACHE_GROUP_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 : public base::RefCounted<AppCacheGroup> { | 41 : public base::RefCounted<AppCacheGroup> { |
| 42 public: | 42 public: |
| 43 | 43 |
| 44 class WEBKIT_STORAGE_BROWSER_EXPORT UpdateObserver { | 44 class WEBKIT_STORAGE_BROWSER_EXPORT UpdateObserver { |
| 45 public: | 45 public: |
| 46 // Called just after an appcache update has completed. | 46 // Called just after an appcache update has completed. |
| 47 virtual void OnUpdateComplete(AppCacheGroup* group) = 0; | 47 virtual void OnUpdateComplete(AppCacheGroup* group) = 0; |
| 48 virtual ~UpdateObserver() {} | 48 virtual ~UpdateObserver() {} |
| 49 }; | 49 }; |
| 50 | 50 |
| 51 enum UpdateStatus { | 51 enum UpdateAppCacheStatus { |
| 52 IDLE, | 52 IDLE, |
| 53 CHECKING, | 53 CHECKING, |
| 54 DOWNLOADING, | 54 DOWNLOADING, |
| 55 }; | 55 }; |
| 56 | 56 |
| 57 AppCacheGroup(AppCacheStorage* storage, const GURL& manifest_url, | 57 AppCacheGroup(AppCacheStorage* storage, const GURL& manifest_url, |
| 58 int64 group_id); | 58 int64 group_id); |
| 59 | 59 |
| 60 // Adds/removes an update observer, the AppCacheGroup does not take | 60 // Adds/removes an update observer, the AppCacheGroup does not take |
| 61 // ownership of the observer. | 61 // ownership of the observer. |
| (...skipping 11 matching lines...) Expand all Loading... |
| 73 void set_being_deleted(bool value) { is_being_deleted_ = value; } | 73 void set_being_deleted(bool value) { is_being_deleted_ = value; } |
| 74 | 74 |
| 75 AppCache* newest_complete_cache() const { return newest_complete_cache_; } | 75 AppCache* newest_complete_cache() const { return newest_complete_cache_; } |
| 76 | 76 |
| 77 void AddCache(AppCache* complete_cache); | 77 void AddCache(AppCache* complete_cache); |
| 78 void RemoveCache(AppCache* cache); | 78 void RemoveCache(AppCache* cache); |
| 79 bool HasCache() const { return newest_complete_cache_ != NULL; } | 79 bool HasCache() const { return newest_complete_cache_ != NULL; } |
| 80 | 80 |
| 81 void AddNewlyDeletableResponseIds(std::vector<int64>* response_ids); | 81 void AddNewlyDeletableResponseIds(std::vector<int64>* response_ids); |
| 82 | 82 |
| 83 UpdateStatus update_status() const { return update_status_; } | 83 UpdateAppCacheStatus update_status() const { return update_status_; } |
| 84 | 84 |
| 85 // Starts an update via update() javascript API. | 85 // Starts an update via update() javascript API. |
| 86 void StartUpdate() { | 86 void StartUpdate() { |
| 87 StartUpdateWithHost(NULL); | 87 StartUpdateWithHost(NULL); |
| 88 } | 88 } |
| 89 | 89 |
| 90 // Starts an update for a doc loaded from an application cache. | 90 // Starts an update for a doc loaded from an application cache. |
| 91 void StartUpdateWithHost(AppCacheHost* host) { | 91 void StartUpdateWithHost(AppCacheHost* host) { |
| 92 StartUpdateWithNewMasterEntry(host, GURL()); | 92 StartUpdateWithNewMasterEntry(host, GURL()); |
| 93 } | 93 } |
| (...skipping 16 matching lines...) Expand all Loading... |
| 110 friend class AppCacheUpdateJob; | 110 friend class AppCacheUpdateJob; |
| 111 | 111 |
| 112 ~AppCacheGroup(); | 112 ~AppCacheGroup(); |
| 113 | 113 |
| 114 typedef std::vector<AppCache*> Caches; | 114 typedef std::vector<AppCache*> Caches; |
| 115 typedef std::map<AppCacheHost*, GURL> QueuedUpdates; | 115 typedef std::map<AppCacheHost*, GURL> QueuedUpdates; |
| 116 | 116 |
| 117 static const int kUpdateRestartDelayMs = 1000; | 117 static const int kUpdateRestartDelayMs = 1000; |
| 118 | 118 |
| 119 AppCacheUpdateJob* update_job() { return update_job_; } | 119 AppCacheUpdateJob* update_job() { return update_job_; } |
| 120 void SetUpdateStatus(UpdateStatus status); | 120 void SetUpdateAppCacheStatus(UpdateAppCacheStatus status); |
| 121 | 121 |
| 122 void NotifyContentBlocked(); | 122 void NotifyContentBlocked(); |
| 123 | 123 |
| 124 const Caches& old_caches() const { return old_caches_; } | 124 const Caches& old_caches() const { return old_caches_; } |
| 125 | 125 |
| 126 // Update cannot be processed at this time. Queue it for a later run. | 126 // Update cannot be processed at this time. Queue it for a later run. |
| 127 void QueueUpdate(AppCacheHost* host, const GURL& new_master_resource); | 127 void QueueUpdate(AppCacheHost* host, const GURL& new_master_resource); |
| 128 void RunQueuedUpdates(); | 128 void RunQueuedUpdates(); |
| 129 bool FindObserver(UpdateObserver* find_me, | 129 bool FindObserver(UpdateObserver* find_me, |
| 130 const ObserverList<UpdateObserver>& observer_list); | 130 const ObserverList<UpdateObserver>& observer_list); |
| 131 void ScheduleUpdateRestart(int delay_ms); | 131 void ScheduleUpdateRestart(int delay_ms); |
| 132 void HostDestructionImminent(AppCacheHost* host); | 132 void HostDestructionImminent(AppCacheHost* host); |
| 133 | 133 |
| 134 const int64 group_id_; | 134 const int64 group_id_; |
| 135 const GURL manifest_url_; | 135 const GURL manifest_url_; |
| 136 base::Time creation_time_; | 136 base::Time creation_time_; |
| 137 UpdateStatus update_status_; | 137 UpdateAppCacheStatus update_status_; |
| 138 bool is_obsolete_; | 138 bool is_obsolete_; |
| 139 bool is_being_deleted_; | 139 bool is_being_deleted_; |
| 140 std::vector<int64> newly_deletable_response_ids_; | 140 std::vector<int64> newly_deletable_response_ids_; |
| 141 | 141 |
| 142 // Old complete app caches. | 142 // Old complete app caches. |
| 143 Caches old_caches_; | 143 Caches old_caches_; |
| 144 | 144 |
| 145 // Newest cache in this group to be complete, aka relevant cache. | 145 // Newest cache in this group to be complete, aka relevant cache. |
| 146 AppCache* newest_complete_cache_; | 146 AppCache* newest_complete_cache_; |
| 147 | 147 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 168 FRIEND_TEST_ALL_PREFIXES(content::AppCacheGroupTest, QueueUpdate); | 168 FRIEND_TEST_ALL_PREFIXES(content::AppCacheGroupTest, QueueUpdate); |
| 169 FRIEND_TEST_ALL_PREFIXES(content::AppCacheUpdateJobTest, AlreadyChecking); | 169 FRIEND_TEST_ALL_PREFIXES(content::AppCacheUpdateJobTest, AlreadyChecking); |
| 170 FRIEND_TEST_ALL_PREFIXES(content::AppCacheUpdateJobTest, AlreadyDownloading); | 170 FRIEND_TEST_ALL_PREFIXES(content::AppCacheUpdateJobTest, AlreadyDownloading); |
| 171 | 171 |
| 172 DISALLOW_COPY_AND_ASSIGN(AppCacheGroup); | 172 DISALLOW_COPY_AND_ASSIGN(AppCacheGroup); |
| 173 }; | 173 }; |
| 174 | 174 |
| 175 } // namespace appcache | 175 } // namespace appcache |
| 176 | 176 |
| 177 #endif // WEBKIT_BROWSER_APPCACHE_APPCACHE_GROUP_H_ | 177 #endif // WEBKIT_BROWSER_APPCACHE_APPCACHE_GROUP_H_ |
| OLD | NEW |