summaryrefslogtreecommitdiffstats
path: root/webkit/appcache/appcache_update_job.h
diff options
context:
space:
mode:
authorjennb@chromium.org <jennb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-12-01 00:54:57 +0000
committerjennb@chromium.org <jennb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-12-01 00:54:57 +0000
commita17b674580be4397cf56e2c955fac9f2c4a3bfaa (patch)
tree09e01865679b16cbaa27d55de7ee02930d304ec2 /webkit/appcache/appcache_update_job.h
parentb2fb9ff65d58beffec6a59853e1c3cfa5ecdb173 (diff)
downloadchromium_src-a17b674580be4397cf56e2c955fac9f2c4a3bfaa.zip
chromium_src-a17b674580be4397cf56e2c955fac9f2c4a3bfaa.tar.gz
chromium_src-a17b674580be4397cf56e2c955fac9f2c4a3bfaa.tar.bz2
Appcache update support for pending master entries:
- Update process issues a URL request to fetch pending master entries. - Pending master entry fetch logic kept separate from regular url fetching as this will be the case in the long-term solution. - No optimizations to avoid issuing URL request if pending master entry is also listed in the manifest. (simpler) - Only optimized to prevent refetching something that has already been successfully fetched. Long-term optimized solution should be to siphon the responses as the master resource is downloaded instead of having the update job issue URL requests. TEST=new tests for update jobs with pending master entries BUG=none Review URL: http://codereview.chromium.org/402098 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@33394 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/appcache/appcache_update_job.h')
-rw-r--r--webkit/appcache/appcache_update_job.h39
1 files changed, 38 insertions, 1 deletions
diff --git a/webkit/appcache/appcache_update_job.h b/webkit/appcache/appcache_update_job.h
index b60ca0b..7c60ef1 100644
--- a/webkit/appcache/appcache_update_job.h
+++ b/webkit/appcache/appcache_update_job.h
@@ -7,12 +7,16 @@
#include <deque>
#include <map>
+#include <set>
+#include <string>
+#include <vector>
#include "base/ref_counted.h"
#include "base/task.h"
#include "googleurl/src/gurl.h"
#include "net/url_request/url_request.h"
#include "webkit/appcache/appcache.h"
+#include "webkit/appcache/appcache_host.h"
#include "webkit/appcache/appcache_interfaces.h"
#include "webkit/appcache/appcache_storage.h"
@@ -22,7 +26,8 @@ class UpdateJobInfo;
// Application cache Update algorithm and state.
class AppCacheUpdateJob : public URLRequest::Delegate,
- public AppCacheStorage::Delegate {
+ public AppCacheStorage::Delegate,
+ public AppCacheHost::Observer {
public:
AppCacheUpdateJob(AppCacheService* service, AppCacheGroup* group);
~AppCacheUpdateJob();
@@ -56,6 +61,8 @@ class AppCacheUpdateJob : public URLRequest::Delegate,
FETCH_MANIFEST,
NO_UPDATE,
DOWNLOADING,
+
+ // Every state after this comment indicates the update is terminating.
REFETCH_MANIFEST,
CACHE_FAILURE,
CANCELLED,
@@ -74,6 +81,10 @@ class AppCacheUpdateJob : public URLRequest::Delegate,
void OnGroupAndNewestCacheStored(AppCacheGroup* group, bool success);
void OnGroupMadeObsolete(AppCacheGroup* group, bool success);
+ // Methods for AppCacheHost::Observer.
+ void OnCacheSelectionComplete(AppCacheHost* host) {} // N/A
+ void OnDestructionImminent(AppCacheHost* host);
+
void FetchManifest(bool is_first_fetch);
void OnResponseCompleted(URLRequest* request);
@@ -97,6 +108,7 @@ class AppCacheUpdateJob : public URLRequest::Delegate,
void ContinueHandleManifestFetchCompleted(bool changed);
void HandleUrlFetchCompleted(URLRequest* request);
+ void HandleMasterEntryFetchCompleted(URLRequest* request);
void HandleManifestRefetchCompleted(URLRequest* request);
void OnManifestInfoWriteComplete(int result);
@@ -118,8 +130,22 @@ class AppCacheUpdateJob : public URLRequest::Delegate,
void BuildUrlFileList(const Manifest& manifest);
void AddUrlToFileList(const GURL& url, int type);
void FetchUrls();
+ void CancelAllUrlFetches();
bool ShouldSkipUrlFetch(const AppCacheEntry& entry);
+ // If entry already exists in the cache currently being updated, merge
+ // the entry type information with the existing entry.
+ // Returns true if entry exists in cache currently being updated.
+ bool AlreadyFetchedEntry(const GURL& url, int entry_type);
+
+ // TODO(jennb): Delete when update no longer fetches master entries directly.
+ // Creates the list of master entries that need to be fetched and initiates
+ // fetches.
+ void AddMasterEntryToFetchList(AppCacheHost* host, const GURL& url,
+ bool is_new);
+ void FetchMasterEntries();
+ void CancelAllMasterEntryFetches();
+
// Asynchronously loads the entry from the newest complete cache if the
// HTTP caching semantics allow.
// Returns false if immediately obvious that data cannot be loaded from
@@ -144,11 +170,14 @@ class AppCacheUpdateJob : public URLRequest::Delegate,
void ScheduleUpdateRetry(int delay_ms);
void Cancel();
+ void ClearPendingMasterEntries();
void DiscardInprogressCache();
// Deletes this object after letting the stack unwind.
void DeleteSoon();
+ bool IsTerminating() { return internal_state_ >= REFETCH_MANIFEST; }
+
// This factory will be used to schedule invocations of various methods.
ScopedRunnableMethodFactory<AppCacheUpdateJob> method_factory_;
@@ -171,6 +200,14 @@ class AppCacheUpdateJob : public URLRequest::Delegate,
PendingMasters pending_master_entries_;
size_t master_entries_completed_;
+ // TODO(jennb): Delete when update no longer fetches master entries directly.
+ // Helper containers to track which pending master entries have yet to be
+ // fetched and which are currently being fetched. Master entries that
+ // are listed in the manifest may be fetched as a regular URL instead of
+ // as a separate master entry fetch to optimize against duplicate fetches.
+ std::set<GURL> master_entries_to_fetch_;
+ PendingUrlFetches master_entry_fetches_;
+
// URLs of files to fetch along with their flags.
AppCache::EntryMap url_file_list_;
size_t url_fetches_completed_;