| 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_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 <map> | 8 #include <map> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/gtest_prod_util.h" | 11 #include "base/gtest_prod_util.h" |
| 12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
| 13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 14 #include "base/observer_list.h" | 14 #include "base/observer_list.h" |
| 15 #include "base/task.h" | 15 #include "base/task.h" |
| 16 #include "base/time.h" | 16 #include "base/time.h" |
| 17 #include "googleurl/src/gurl.h" |
| 17 #include "webkit/appcache/appcache_export.h" | 18 #include "webkit/appcache/appcache_export.h" |
| 18 #include "googleurl/src/gurl.h" | |
| 19 | 19 |
| 20 namespace appcache { | 20 namespace appcache { |
| 21 | 21 |
| 22 class AppCache; | 22 class AppCache; |
| 23 class AppCacheHost; | 23 class AppCacheHost; |
| 24 class AppCacheService; | 24 class AppCacheService; |
| 25 class AppCacheUpdateJob; | 25 class AppCacheUpdateJob; |
| 26 class HostObserver; | 26 class HostObserver; |
| 27 | 27 |
| 28 // Collection of application caches identified by the same manifest URL. | 28 // Collection of application caches identified by the same manifest URL. |
| 29 // A group exists as long as it is in use by a host or is being updated. | 29 // A group exists as long as it is in use by a host or is being updated. |
| 30 class AppCacheGroup : public base::RefCounted<AppCacheGroup> { | 30 class APPCACHE_EXPORT AppCacheGroup : public base::RefCounted<AppCacheGroup> { |
| 31 public: | 31 public: |
| 32 | 32 |
| 33 class UpdateObserver { | 33 class APPCACHE_EXPORT UpdateObserver { |
| 34 public: | 34 public: |
| 35 // Called just after an appcache update has completed. | 35 // Called just after an appcache update has completed. |
| 36 virtual void OnUpdateComplete(AppCacheGroup* group) = 0; | 36 virtual void OnUpdateComplete(AppCacheGroup* group) = 0; |
| 37 virtual ~UpdateObserver() {} | 37 virtual ~UpdateObserver() {} |
| 38 }; | 38 }; |
| 39 | 39 |
| 40 enum UpdateStatus { | 40 enum UpdateStatus { |
| 41 IDLE, | 41 IDLE, |
| 42 CHECKING, | 42 CHECKING, |
| 43 DOWNLOADING, | 43 DOWNLOADING, |
| 44 }; | 44 }; |
| 45 | 45 |
| 46 APPCACHE_EXPORT AppCacheGroup(AppCacheService* service, | 46 AppCacheGroup(AppCacheService* service, const GURL& manifest_url, |
| 47 const GURL& manifest_url, | 47 int64 group_id); |
| 48 int64 group_id); | |
| 49 | 48 |
| 50 // Adds/removes an update observer, the AppCacheGroup does not take | 49 // Adds/removes an update observer, the AppCacheGroup does not take |
| 51 // ownership of the observer. | 50 // ownership of the observer. |
| 52 void AddUpdateObserver(UpdateObserver* observer); | 51 void AddUpdateObserver(UpdateObserver* observer); |
| 53 void RemoveUpdateObserver(UpdateObserver* observer); | 52 void RemoveUpdateObserver(UpdateObserver* observer); |
| 54 | 53 |
| 55 int64 group_id() const { return group_id_; } | 54 int64 group_id() const { return group_id_; } |
| 56 const GURL& manifest_url() const { return manifest_url_; } | 55 const GURL& manifest_url() const { return manifest_url_; } |
| 57 const base::Time& creation_time() const { return creation_time_; } | 56 const base::Time& creation_time() const { return creation_time_; } |
| 58 void set_creation_time(const base::Time& time) { creation_time_ = time; } | 57 void set_creation_time(const base::Time& time) { creation_time_ = time; } |
| 59 bool is_obsolete() const { return is_obsolete_; } | 58 bool is_obsolete() const { return is_obsolete_; } |
| 60 void set_obsolete(bool value) { is_obsolete_ = value; } | 59 void set_obsolete(bool value) { is_obsolete_ = value; } |
| 61 | 60 |
| 62 bool is_being_deleted() const { return is_being_deleted_; } | 61 bool is_being_deleted() const { return is_being_deleted_; } |
| 63 void set_being_deleted(bool value) { is_being_deleted_ = value; } | 62 void set_being_deleted(bool value) { is_being_deleted_ = value; } |
| 64 | 63 |
| 65 AppCache* newest_complete_cache() const { return newest_complete_cache_; } | 64 AppCache* newest_complete_cache() const { return newest_complete_cache_; } |
| 66 | 65 |
| 67 APPCACHE_EXPORT void AddCache(AppCache* complete_cache); | 66 void AddCache(AppCache* complete_cache); |
| 68 void RemoveCache(AppCache* cache); | 67 void RemoveCache(AppCache* cache); |
| 69 bool HasCache() const { return newest_complete_cache_ != NULL; } | 68 bool HasCache() const { return newest_complete_cache_ != NULL; } |
| 70 | 69 |
| 71 void AddNewlyDeletableResponseIds(std::vector<int64>* response_ids); | 70 void AddNewlyDeletableResponseIds(std::vector<int64>* response_ids); |
| 72 | 71 |
| 73 UpdateStatus update_status() const { return update_status_; } | 72 UpdateStatus update_status() const { return update_status_; } |
| 74 | 73 |
| 75 // Starts an update via update() javascript API. | 74 // Starts an update via update() javascript API. |
| 76 void StartUpdate() { | 75 void StartUpdate() { |
| 77 StartUpdateWithHost(NULL); | 76 StartUpdateWithHost(NULL); |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 FRIEND_TEST_ALL_PREFIXES(AppCacheGroupTest, QueueUpdate); | 157 FRIEND_TEST_ALL_PREFIXES(AppCacheGroupTest, QueueUpdate); |
| 159 FRIEND_TEST_ALL_PREFIXES(AppCacheUpdateJobTest, AlreadyChecking); | 158 FRIEND_TEST_ALL_PREFIXES(AppCacheUpdateJobTest, AlreadyChecking); |
| 160 FRIEND_TEST_ALL_PREFIXES(AppCacheUpdateJobTest, AlreadyDownloading); | 159 FRIEND_TEST_ALL_PREFIXES(AppCacheUpdateJobTest, AlreadyDownloading); |
| 161 | 160 |
| 162 DISALLOW_COPY_AND_ASSIGN(AppCacheGroup); | 161 DISALLOW_COPY_AND_ASSIGN(AppCacheGroup); |
| 163 }; | 162 }; |
| 164 | 163 |
| 165 } // namespace appcache | 164 } // namespace appcache |
| 166 | 165 |
| 167 #endif // WEBKIT_APPCACHE_APPCACHE_GROUP_H_ | 166 #endif // WEBKIT_APPCACHE_APPCACHE_GROUP_H_ |
| OLD | NEW |