Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1068)

Unified Diff: webkit/appcache/appcache_group.h

Issue 201070: Implementation of application cache update algorithm.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webkit/appcache/appcache.cc ('k') | webkit/appcache/appcache_group.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/appcache/appcache_group.h
===================================================================
--- webkit/appcache/appcache_group.h (revision 26887)
+++ webkit/appcache/appcache_group.h (working copy)
@@ -7,20 +7,30 @@
#include <vector>
+#include "base/observer_list.h"
#include "base/ref_counted.h"
#include "googleurl/src/gurl.h"
+#include "testing/gtest/include/gtest/gtest_prod.h"
namespace appcache {
class AppCache;
class AppCacheHost;
class AppCacheService;
+class AppCacheUpdateJob;
// Collection of application caches identified by the same manifest URL.
// A group exists as long as it is in use by a host or is being updated.
class AppCacheGroup : public base::RefCounted<AppCacheGroup> {
public:
+ class Observer {
+ public:
+ // Called just after an appcache update has completed.
+ virtual void OnUpdateComplete(AppCacheGroup* group) = 0;
+ virtual ~Observer() { }
+ };
+
enum UpdateStatus {
IDLE,
CHECKING,
@@ -30,11 +40,13 @@
AppCacheGroup(AppCacheService* service, const GURL& manifest_url);
~AppCacheGroup();
+ // Adds/removes an observer, the AppCacheGroup does not take
+ // ownership of the observer.
+ void AddObserver(Observer* observer);
+ void RemoveObserver(Observer* observer);
+
const GURL& manifest_url() { return manifest_url_; }
- UpdateStatus update_status() { return update_status_; }
- void set_update_status(UpdateStatus status) { update_status_ = status; }
-
bool is_obsolete() { return is_obsolete_; }
void set_obsolete(bool value) { is_obsolete_ = value; }
@@ -46,6 +58,10 @@
// cannot be removed as long as the group is still in use.
bool RemoveCache(AppCache* cache);
+ bool HasCache() { return newest_complete_cache_ || !old_caches_.empty(); }
+
+ UpdateStatus update_status() { return update_status_; }
+
// Starts an update via update() javascript API.
void StartUpdate() {
StartUpdateWithHost(NULL);
@@ -63,19 +79,39 @@
const GURL& new_master_resource);
private:
+ friend class AppCacheUpdateJob;
+ friend class AppCacheUpdateJobTest;
+
+ typedef std::vector<scoped_refptr<AppCache> > Caches;
+
+ AppCacheUpdateJob* update_job() { return update_job_; }
+ void SetUpdateStatus(UpdateStatus status);
+
+ const Caches& old_caches() { return old_caches_; }
+
GURL manifest_url_;
UpdateStatus update_status_;
bool is_obsolete_;
- // old complete app caches
- typedef std::vector<scoped_refptr<AppCache> > Caches;
+ // Old complete app caches.
Caches old_caches_;
- // newest cache in this group to be complete, aka relevant cache
+ // Newest cache in this group to be complete, aka relevant cache.
scoped_refptr<AppCache> newest_complete_cache_;
- // to notify service when group is no longer needed
+ // Current update job for this group, if any.
+ AppCacheUpdateJob* update_job_;
+
+ // Central service object.
AppCacheService* service_;
+
+ // List of objects observing this group.
+ ObserverList<Observer> observers_;
+
+ FRIEND_TEST(AppCacheGroupTest, StartUpdate);
+ FRIEND_TEST(AppCacheUpdateJobTest, AlreadyChecking);
+ FRIEND_TEST(AppCacheUpdateJobTest, AlreadyDownloading);
+ DISALLOW_COPY_AND_ASSIGN(AppCacheGroup);
};
} // namespace appcache
« no previous file with comments | « webkit/appcache/appcache.cc ('k') | webkit/appcache/appcache_group.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698