| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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_APPCACHE_APPCACHE_GROUP_H_ | 5 #ifndef WEBKIT_APPCACHE_APPCACHE_GROUP_H_ |
| 6 #define WEBKIT_APPCACHE_APPCACHE_GROUP_H_ | 6 #define WEBKIT_APPCACHE_APPCACHE_GROUP_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/observer_list.h" | 10 #include "base/observer_list.h" |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 }; | 38 }; |
| 39 | 39 |
| 40 AppCacheGroup(AppCacheService* service, const GURL& manifest_url); | 40 AppCacheGroup(AppCacheService* service, const GURL& manifest_url); |
| 41 ~AppCacheGroup(); | 41 ~AppCacheGroup(); |
| 42 | 42 |
| 43 // Adds/removes an update observer, the AppCacheGroup does not take | 43 // Adds/removes an update observer, the AppCacheGroup does not take |
| 44 // ownership of the observer. | 44 // ownership of the observer. |
| 45 void AddUpdateObserver(UpdateObserver* observer); | 45 void AddUpdateObserver(UpdateObserver* observer); |
| 46 void RemoveUpdateObserver(UpdateObserver* observer); | 46 void RemoveUpdateObserver(UpdateObserver* observer); |
| 47 | 47 |
| 48 const GURL& manifest_url() { return manifest_url_; } | 48 const GURL& manifest_url() const { return manifest_url_; } |
| 49 | 49 |
| 50 bool is_obsolete() { return is_obsolete_; } | 50 bool is_obsolete() const { return is_obsolete_; } |
| 51 void set_obsolete(bool value) { is_obsolete_ = value; } | 51 void set_obsolete(bool value) { is_obsolete_ = value; } |
| 52 | 52 |
| 53 AppCache* newest_complete_cache() { return newest_complete_cache_; } | 53 AppCache* newest_complete_cache() const { return newest_complete_cache_; } |
| 54 | 54 |
| 55 void AddCache(AppCache* complete_cache); | 55 void AddCache(AppCache* complete_cache); |
| 56 void RemoveCache(AppCache* cache); |
| 57 bool HasCache() const { return newest_complete_cache_ != NULL; } |
| 56 | 58 |
| 57 void RemoveCache(AppCache* cache); | 59 UpdateStatus update_status() const { return update_status_; } |
| 58 | |
| 59 bool HasCache() { return newest_complete_cache_ != NULL; } | |
| 60 | |
| 61 UpdateStatus update_status() { return update_status_; } | |
| 62 | 60 |
| 63 // Starts an update via update() javascript API. | 61 // Starts an update via update() javascript API. |
| 64 void StartUpdate() { | 62 void StartUpdate() { |
| 65 StartUpdateWithHost(NULL); | 63 StartUpdateWithHost(NULL); |
| 66 } | 64 } |
| 67 | 65 |
| 68 // Starts an update for a doc loaded from an application cache. | 66 // Starts an update for a doc loaded from an application cache. |
| 69 void StartUpdateWithHost(AppCacheHost* host) { | 67 void StartUpdateWithHost(AppCacheHost* host) { |
| 70 StartUpdateWithNewMasterEntry(host, GURL::EmptyGURL()); | 68 StartUpdateWithNewMasterEntry(host, GURL::EmptyGURL()); |
| 71 } | 69 } |
| 72 | 70 |
| 73 // Starts an update for a doc loaded using HTTP GET or equivalent with | 71 // Starts an update for a doc loaded using HTTP GET or equivalent with |
| 74 // an <html> tag manifest attribute value that matches this group's | 72 // an <html> tag manifest attribute value that matches this group's |
| 75 // manifest url. | 73 // manifest url. |
| 76 void StartUpdateWithNewMasterEntry(AppCacheHost* host, | 74 void StartUpdateWithNewMasterEntry(AppCacheHost* host, |
| 77 const GURL& new_master_resource); | 75 const GURL& new_master_resource); |
| 78 | 76 |
| 79 private: | 77 private: |
| 80 friend class AppCacheUpdateJob; | 78 friend class AppCacheUpdateJob; |
| 81 friend class AppCacheUpdateJobTest; | 79 friend class AppCacheUpdateJobTest; |
| 80 friend class MockAppCacheStorage; // for old_caches() |
| 82 | 81 |
| 83 typedef std::vector<AppCache*> Caches; | 82 typedef std::vector<AppCache*> Caches; |
| 84 | 83 |
| 85 AppCacheUpdateJob* update_job() { return update_job_; } | 84 AppCacheUpdateJob* update_job() { return update_job_; } |
| 86 void SetUpdateStatus(UpdateStatus status); | 85 void SetUpdateStatus(UpdateStatus status); |
| 87 | 86 |
| 88 const Caches& old_caches() { return old_caches_; } | 87 const Caches& old_caches() const { return old_caches_; } |
| 89 | 88 |
| 90 GURL manifest_url_; | 89 GURL manifest_url_; |
| 91 UpdateStatus update_status_; | 90 UpdateStatus update_status_; |
| 92 bool is_obsolete_; | 91 bool is_obsolete_; |
| 93 | 92 |
| 94 // Old complete app caches. | 93 // Old complete app caches. |
| 95 Caches old_caches_; | 94 Caches old_caches_; |
| 96 | 95 |
| 97 // Newest cache in this group to be complete, aka relevant cache. | 96 // Newest cache in this group to be complete, aka relevant cache. |
| 98 AppCache* newest_complete_cache_; | 97 AppCache* newest_complete_cache_; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 109 FRIEND_TEST(AppCacheGroupTest, StartUpdate); | 108 FRIEND_TEST(AppCacheGroupTest, StartUpdate); |
| 110 FRIEND_TEST(AppCacheGroupTest, CancelUpdate); | 109 FRIEND_TEST(AppCacheGroupTest, CancelUpdate); |
| 111 FRIEND_TEST(AppCacheUpdateJobTest, AlreadyChecking); | 110 FRIEND_TEST(AppCacheUpdateJobTest, AlreadyChecking); |
| 112 FRIEND_TEST(AppCacheUpdateJobTest, AlreadyDownloading); | 111 FRIEND_TEST(AppCacheUpdateJobTest, AlreadyDownloading); |
| 113 DISALLOW_COPY_AND_ASSIGN(AppCacheGroup); | 112 DISALLOW_COPY_AND_ASSIGN(AppCacheGroup); |
| 114 }; | 113 }; |
| 115 | 114 |
| 116 } // namespace appcache | 115 } // namespace appcache |
| 117 | 116 |
| 118 #endif // WEBKIT_APPCACHE_APPCACHE_GROUP_H_ | 117 #endif // WEBKIT_APPCACHE_APPCACHE_GROUP_H_ |
| OLD | NEW |