summaryrefslogtreecommitdiffstats
path: root/webkit/appcache/appcache_update_job.h
diff options
context:
space:
mode:
authormichaeln@chromium.org <michaeln@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-24 01:38:36 +0000
committermichaeln@chromium.org <michaeln@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-24 01:38:36 +0000
commitdcd3de72cb870e3b70fdeadbb43acbbc35fc11ae (patch)
tree69e7255163d4c84fe54a60282b6c257cf6cd97df /webkit/appcache/appcache_update_job.h
parentb13bfc4f2e0eeaf36827025920f783e41374dba9 (diff)
downloadchromium_src-dcd3de72cb870e3b70fdeadbb43acbbc35fc11ae.zip
chromium_src-dcd3de72cb870e3b70fdeadbb43acbbc35fc11ae.tar.gz
chromium_src-dcd3de72cb870e3b70fdeadbb43acbbc35fc11ae.tar.bz2
Fix for a big appcache storage bug. Now stores a record of the new master entry in the database even when there is no manifest update.
BUG=none TEST=manual and unittest Review URL: http://codereview.chromium.org/549127 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@36973 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/appcache/appcache_update_job.h')
-rw-r--r--webkit/appcache/appcache_update_job.h30
1 files changed, 19 insertions, 11 deletions
diff --git a/webkit/appcache/appcache_update_job.h b/webkit/appcache/appcache_update_job.h
index 1eec1a4..2580ff8 100644
--- a/webkit/appcache/appcache_update_job.h
+++ b/webkit/appcache/appcache_update_job.h
@@ -44,7 +44,6 @@ class AppCacheUpdateJob : public URLRequest::Delegate,
// Master entries have multiple hosts, for example, the same page is opened
// in different tabs.
- // TODO(jennb): detect when hosts are deleted
typedef std::vector<AppCacheHost*> PendingHosts;
typedef std::map<GURL, PendingHosts> PendingMasters;
typedef std::map<GURL, URLRequest*> PendingUrlFetches;
@@ -53,6 +52,10 @@ class AppCacheUpdateJob : public URLRequest::Delegate,
static const int kRerunDelayMs = 1000;
+ // TODO(michaeln): Rework the set of states vs update types vs stored states.
+ // The NO_UPDATE state is really more of an update type. For all update types
+ // storing the results is relevant.
+
enum UpdateType {
UNKNOWN_TYPE,
UPGRADE_ATTEMPT,
@@ -71,6 +74,12 @@ class AppCacheUpdateJob : public URLRequest::Delegate,
COMPLETED,
};
+ enum StoredState {
+ UNSTORED,
+ STORING,
+ STORED,
+ };
+
// Methods for URLRequest::Delegate.
void OnResponseStarted(URLRequest* request);
void OnReadCompleted(URLRequest* request, int bytes_read);
@@ -82,7 +91,8 @@ class AppCacheUpdateJob : public URLRequest::Delegate,
// Methods for AppCacheStorage::Delegate.
void OnResponseInfoLoaded(AppCacheResponseInfo* response_info,
int64 response_id);
- void OnGroupAndNewestCacheStored(AppCacheGroup* group, bool success);
+ void OnGroupAndNewestCacheStored(AppCacheGroup* group, AppCache* newest_cache,
+ bool success);
void OnGroupMadeObsolete(AppCacheGroup* group, bool success);
// Methods for AppCacheHost::Observer.
@@ -122,8 +132,8 @@ class AppCacheUpdateJob : public URLRequest::Delegate,
void HandleManifestRefetchCompleted(URLRequest* request);
void OnManifestInfoWriteComplete(int result);
void OnManifestDataWriteComplete(int result);
- void CompleteInprogressCache();
- void HandleManifestRefetchFailure();
+
+ void StoreGroupAndCache();
void NotifySingleHost(AppCacheHost* host, EventID event_id);
void NotifyAllPendingMasterHosts(EventID event_id);
@@ -179,7 +189,8 @@ class AppCacheUpdateJob : public URLRequest::Delegate,
// Deletes this object after letting the stack unwind.
void DeleteSoon();
- bool IsTerminating() { return internal_state_ >= REFETCH_MANIFEST; }
+ bool IsTerminating() { return internal_state_ >= REFETCH_MANIFEST ||
+ stored_state_ != UNSTORED; }
// This factory will be used to schedule invocations of various methods.
ScopedRunnableMethodFactory<AppCacheUpdateJob> method_factory_;
@@ -189,12 +200,6 @@ class AppCacheUpdateJob : public URLRequest::Delegate,
scoped_refptr<AppCache> inprogress_cache_;
- // Hold a reference to the newly created cache until this update is
- // destroyed. The host that started the update will add a reference to the
- // new cache when notified that the update is complete. AppCacheGroup sends
- // the notification when its status is set to IDLE in ~AppCacheUpdateJob.
- scoped_refptr<AppCache> protect_new_cache_;
-
AppCacheGroup* group_;
UpdateType update_type_;
@@ -248,6 +253,9 @@ class AppCacheUpdateJob : public URLRequest::Delegate,
// TODO(michaeln): Rework when we no longer fetches master entries directly.
std::vector<int64> duplicate_response_ids_;
+ // Whether we've stored the resulting group/cache yet.
+ StoredState stored_state_;
+
net::CompletionCallbackImpl<AppCacheUpdateJob> manifest_info_write_callback_;
net::CompletionCallbackImpl<AppCacheUpdateJob> manifest_data_write_callback_;
net::CompletionCallbackImpl<AppCacheUpdateJob> manifest_data_read_callback_;