diff options
author | jennb@chromium.org <jennb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-12-10 23:03:30 +0000 |
---|---|---|
committer | jennb@chromium.org <jennb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-12-10 23:03:30 +0000 |
commit | dc60e95adac80ad6c9a88cde612d37d5ecba3ebd (patch) | |
tree | 7b674dda57a5c149d093ce52d1ad67910f14d9ea /webkit/appcache/appcache_group.h | |
parent | 8f0e7700181b5b69040fdd45ab775884c954461d (diff) | |
download | chromium_src-dc60e95adac80ad6c9a88cde612d37d5ecba3ebd.zip chromium_src-dc60e95adac80ad6c9a88cde612d37d5ecba3ebd.tar.gz chromium_src-dc60e95adac80ad6c9a88cde612d37d5ecba3ebd.tar.bz2 |
Queue appcache update if current update process is terminating.
TEST=update and group unittests added
BUG=none
Review URL: http://codereview.chromium.org/465132
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@34299 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/appcache/appcache_group.h')
-rw-r--r-- | webkit/appcache/appcache_group.h | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/webkit/appcache/appcache_group.h b/webkit/appcache/appcache_group.h index efe8049..5cf3d99 100644 --- a/webkit/appcache/appcache_group.h +++ b/webkit/appcache/appcache_group.h @@ -5,10 +5,13 @@ #ifndef WEBKIT_APPCACHE_APPCACHE_GROUP_H_ #define WEBKIT_APPCACHE_APPCACHE_GROUP_H_ +#include <map> #include <vector> #include "base/observer_list.h" #include "base/ref_counted.h" +#include "base/scoped_ptr.h" +#include "base/task.h" #include "googleurl/src/gurl.h" #include "testing/gtest/include/gtest/gtest_prod.h" @@ -18,6 +21,7 @@ class AppCache; class AppCacheHost; class AppCacheService; class AppCacheUpdateJob; +class HostObserver; // 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. @@ -76,6 +80,8 @@ class AppCacheGroup : public base::RefCounted<AppCacheGroup> { const GURL& new_master_resource); private: + class HostObserver; + friend class AppCacheUpdateJob; friend class AppCacheUpdateJobTest; friend class base::RefCounted<AppCacheGroup>; @@ -84,12 +90,23 @@ class AppCacheGroup : public base::RefCounted<AppCacheGroup> { ~AppCacheGroup(); typedef std::vector<AppCache*> Caches; + typedef std::map<AppCacheHost*, GURL> QueuedUpdates; + + static const int kUpdateRestartDelayMs = 1000; AppCacheUpdateJob* update_job() { return update_job_; } void SetUpdateStatus(UpdateStatus status); const Caches& old_caches() const { return old_caches_; } + // Update cannot be processed at this time. Queue it for a later run. + void QueueUpdate(AppCacheHost* host, const GURL& new_master_resource); + void RunQueuedUpdates(); + bool FindObserver(UpdateObserver* find_me, + const ObserverList<UpdateObserver>& observer_list); + void ScheduleUpdateRestart(int delay_ms); + void HostDestructionImminent(AppCacheHost* host); + const int64 group_id_; const GURL manifest_url_; UpdateStatus update_status_; @@ -110,8 +127,15 @@ class AppCacheGroup : public base::RefCounted<AppCacheGroup> { // List of objects observing this group. ObserverList<UpdateObserver> observers_; + // Updates that have been queued for the next run. + QueuedUpdates queued_updates_; + ObserverList<UpdateObserver> queued_observers_; + CancelableTask* restart_update_task_; + scoped_ptr<HostObserver> host_observer_; + FRIEND_TEST(AppCacheGroupTest, StartUpdate); FRIEND_TEST(AppCacheGroupTest, CancelUpdate); + FRIEND_TEST(AppCacheGroupTest, QueueUpdate); FRIEND_TEST(AppCacheUpdateJobTest, AlreadyChecking); FRIEND_TEST(AppCacheUpdateJobTest, AlreadyDownloading); DISALLOW_COPY_AND_ASSIGN(AppCacheGroup); |