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 |
11 #include "base/cancelable_callback.h" | 11 #include "base/cancelable_callback.h" |
12 #include "base/gtest_prod_util.h" | 12 #include "base/gtest_prod_util.h" |
13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
15 #include "base/observer_list.h" | 15 #include "base/observer_list.h" |
16 #include "base/time/time.h" | 16 #include "base/time/time.h" |
17 #include "url/gurl.h" | 17 #include "url/gurl.h" |
| 18 #include "webkit/browser/appcache/appcache.h" |
18 #include "webkit/browser/webkit_storage_browser_export.h" | 19 #include "webkit/browser/webkit_storage_browser_export.h" |
19 | 20 |
20 namespace appcache { | 21 namespace appcache { |
21 | 22 |
22 class AppCache; | 23 class AppCache; |
23 class AppCacheHost; | 24 class AppCacheHost; |
24 class AppCacheStorage; | 25 class AppCacheStorage; |
25 class AppCacheUpdateJob; | 26 class AppCacheUpdateJob; |
26 class HostObserver; | 27 class HostObserver; |
| 28 struct Manifest; |
27 | 29 |
28 // Collection of application caches identified by the same manifest URL. | 30 // 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. | 31 // A group exists as long as it is in use by a host or is being updated. |
30 class WEBKIT_STORAGE_BROWSER_EXPORT AppCacheGroup | 32 class WEBKIT_STORAGE_BROWSER_EXPORT AppCacheGroup |
31 : public base::RefCounted<AppCacheGroup> { | 33 : public base::RefCounted<AppCacheGroup> { |
32 public: | 34 public: |
33 | 35 |
34 class WEBKIT_STORAGE_BROWSER_EXPORT UpdateObserver { | 36 class WEBKIT_STORAGE_BROWSER_EXPORT UpdateObserver { |
35 public: | 37 public: |
36 // Called just after an appcache update has completed. | 38 // Called just after an appcache update has completed. |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 | 72 |
71 void AddNewlyDeletableResponseIds(std::vector<int64>* response_ids); | 73 void AddNewlyDeletableResponseIds(std::vector<int64>* response_ids); |
72 | 74 |
73 UpdateStatus update_status() const { return update_status_; } | 75 UpdateStatus update_status() const { return update_status_; } |
74 | 76 |
75 // Starts an update via update() javascript API. | 77 // Starts an update via update() javascript API. |
76 void StartUpdate() { | 78 void StartUpdate() { |
77 StartUpdateWithHost(NULL); | 79 StartUpdateWithHost(NULL); |
78 } | 80 } |
79 | 81 |
| 82 void StartUpdateWithManifest(const Manifest& manifest); |
| 83 |
80 // Starts an update for a doc loaded from an application cache. | 84 // Starts an update for a doc loaded from an application cache. |
81 void StartUpdateWithHost(AppCacheHost* host) { | 85 void StartUpdateWithHost(AppCacheHost* host) { |
82 StartUpdateWithNewMasterEntry(host, GURL()); | 86 StartUpdateWithNewMasterEntry(host, GURL()); |
83 } | 87 } |
84 | 88 |
85 // Starts an update for a doc loaded using HTTP GET or equivalent with | 89 // Starts an update for a doc loaded using HTTP GET or equivalent with |
86 // an <html> tag manifest attribute value that matches this group's | 90 // an <html> tag manifest attribute value that matches this group's |
87 // manifest url. | 91 // manifest url. |
88 void StartUpdateWithNewMasterEntry(AppCacheHost* host, | 92 void StartUpdateWithNewMasterEntry(AppCacheHost* host, |
89 const GURL& new_master_resource); | 93 const GURL& new_master_resource); |
90 | 94 |
91 // Cancels an update if one is running. | 95 // Cancels an update if one is running. |
92 void CancelUpdate(); | 96 void CancelUpdate(); |
93 | 97 |
| 98 // Hackery for registerController |
| 99 void StartUpdateWithFakeManifest(Manifest* manifest); |
| 100 bool IsFakeNavControllerGroup() const { |
| 101 return HasCache() && !newest_complete_cache()->GetEntry(manifest_url()) && |
| 102 (newest_complete_cache()->entries().size() == 1u); |
| 103 } |
| 104 |
94 private: | 105 private: |
95 class HostObserver; | 106 class HostObserver; |
96 | 107 |
97 friend class AppCacheUpdateJob; | 108 friend class AppCacheUpdateJob; |
98 friend class AppCacheUpdateJobTest; | 109 friend class AppCacheUpdateJobTest; |
99 friend class base::RefCounted<AppCacheGroup>; | 110 friend class base::RefCounted<AppCacheGroup>; |
100 friend class MockAppCacheStorage; // for old_caches() | 111 friend class MockAppCacheStorage; // for old_caches() |
101 | 112 |
102 ~AppCacheGroup(); | 113 ~AppCacheGroup(); |
103 | 114 |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 FRIEND_TEST_ALL_PREFIXES(AppCacheGroupTest, QueueUpdate); | 169 FRIEND_TEST_ALL_PREFIXES(AppCacheGroupTest, QueueUpdate); |
159 FRIEND_TEST_ALL_PREFIXES(AppCacheUpdateJobTest, AlreadyChecking); | 170 FRIEND_TEST_ALL_PREFIXES(AppCacheUpdateJobTest, AlreadyChecking); |
160 FRIEND_TEST_ALL_PREFIXES(AppCacheUpdateJobTest, AlreadyDownloading); | 171 FRIEND_TEST_ALL_PREFIXES(AppCacheUpdateJobTest, AlreadyDownloading); |
161 | 172 |
162 DISALLOW_COPY_AND_ASSIGN(AppCacheGroup); | 173 DISALLOW_COPY_AND_ASSIGN(AppCacheGroup); |
163 }; | 174 }; |
164 | 175 |
165 } // namespace appcache | 176 } // namespace appcache |
166 | 177 |
167 #endif // WEBKIT_BROWSER_APPCACHE_APPCACHE_GROUP_H_ | 178 #endif // WEBKIT_BROWSER_APPCACHE_APPCACHE_GROUP_H_ |
OLD | NEW |