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/ref_counted.h" | 10 #include "base/ref_counted.h" |
11 #include "googleurl/src/gurl.h" | 11 #include "googleurl/src/gurl.h" |
12 | 12 |
13 namespace appcache { | 13 namespace appcache { |
14 | 14 |
15 class AppCache; | 15 class AppCache; |
| 16 class AppCacheHost; |
16 class AppCacheService; | 17 class AppCacheService; |
17 | 18 |
18 // Collection of application caches identified by the same manifest URL. | 19 // Collection of application caches identified by the same manifest URL. |
19 // A group exists as long as it is in use by a host or is being updated. | 20 // A group exists as long as it is in use by a host or is being updated. |
20 class AppCacheGroup : public base::RefCounted<AppCacheGroup> { | 21 class AppCacheGroup : public base::RefCounted<AppCacheGroup> { |
21 public: | 22 public: |
22 | 23 |
23 enum UpdateStatus { | 24 enum UpdateStatus { |
24 IDLE, | 25 IDLE, |
25 CHECKING, | 26 CHECKING, |
(...skipping 12 matching lines...) Expand all Loading... |
38 void set_obsolete(bool value) { is_obsolete_ = value; } | 39 void set_obsolete(bool value) { is_obsolete_ = value; } |
39 | 40 |
40 AppCache* newest_complete_cache() { return newest_complete_cache_; } | 41 AppCache* newest_complete_cache() { return newest_complete_cache_; } |
41 | 42 |
42 void AddCache(AppCache* complete_cache); | 43 void AddCache(AppCache* complete_cache); |
43 | 44 |
44 // Returns false if cache cannot be removed. The newest complete cache | 45 // Returns false if cache cannot be removed. The newest complete cache |
45 // cannot be removed as long as the group is still in use. | 46 // cannot be removed as long as the group is still in use. |
46 bool RemoveCache(AppCache* cache); | 47 bool RemoveCache(AppCache* cache); |
47 | 48 |
| 49 // Starts an update via update() javascript API. |
| 50 void StartUpdate() { |
| 51 StartUpdateWithHost(NULL); |
| 52 } |
| 53 |
| 54 // Starts an update for a doc loaded from an application cache. |
| 55 void StartUpdateWithHost(AppCacheHost* host) { |
| 56 StartUpdateWithNewMasterEntry(host, GURL::EmptyGURL()); |
| 57 } |
| 58 |
| 59 // Starts an update for a doc loaded using HTTP GET or equivalent with |
| 60 // an <html> tag manifest attribute value that matches this group's |
| 61 // manifest url. |
| 62 void StartUpdateWithNewMasterEntry(AppCacheHost* host, |
| 63 const GURL& new_master_resource); |
| 64 |
48 private: | 65 private: |
49 GURL manifest_url_; | 66 GURL manifest_url_; |
50 UpdateStatus update_status_; | 67 UpdateStatus update_status_; |
51 bool is_obsolete_; | 68 bool is_obsolete_; |
52 | 69 |
53 // old complete app caches | 70 // old complete app caches |
54 typedef std::vector<scoped_refptr<AppCache> > Caches; | 71 typedef std::vector<scoped_refptr<AppCache> > Caches; |
55 Caches old_caches_; | 72 Caches old_caches_; |
56 | 73 |
57 // newest cache in this group to be complete, aka relevant cache | 74 // newest cache in this group to be complete, aka relevant cache |
58 scoped_refptr<AppCache> newest_complete_cache_; | 75 scoped_refptr<AppCache> newest_complete_cache_; |
59 | 76 |
60 // to notify service when group is no longer needed | 77 // to notify service when group is no longer needed |
61 AppCacheService* service_; | 78 AppCacheService* service_; |
62 }; | 79 }; |
63 | 80 |
64 } // namespace appcache | 81 } // namespace appcache |
65 | 82 |
66 #endif // WEBKIT_APPCACHE_APPCACHE_GROUP_H_ | 83 #endif // WEBKIT_APPCACHE_APPCACHE_GROUP_H_ |
OLD | NEW |