summaryrefslogtreecommitdiffstats
path: root/webkit/appcache/appcache_host.cc
diff options
context:
space:
mode:
authormichaeln@google.com <michaeln@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-18 01:05:09 +0000
committermichaeln@google.com <michaeln@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-18 01:05:09 +0000
commit7e8e3dd7b1633874650f8de9a818aca8cb594f5b (patch)
tree5a973e64a1b5ca1a243744e2a9aa4a336a699985 /webkit/appcache/appcache_host.cc
parent8b2034f851b1b41c2ec6539c057b63c92ef7289c (diff)
downloadchromium_src-7e8e3dd7b1633874650f8de9a818aca8cb594f5b.zip
chromium_src-7e8e3dd7b1633874650f8de9a818aca8cb594f5b.tar.gz
chromium_src-7e8e3dd7b1633874650f8de9a818aca8cb594f5b.tar.bz2
Check for supported schemes and examine request methods at key points. We support http, https, and file (dbg only) URLs for now.
* Added IsSchemeSupported, IsMethodSupported and IsMethodAndSchemeSupported helpers, and string constants. * Check for supported schemes and methods during cache selection and during request interception. Must be GET for cache selectino, GET or HEAD for request interception. * Renamed some data members in WebApplicationCacheHostImpl to more closely match naming elsewhere. * Added AppCacheHost::Observer to make life easier. (I like the observer model, and even noticed that the chrome code base has a multi-threaded version too (ala Gears)... nice :) * Switched to using the observer model in AppCacheRequestDispatcher instead of a WeakPtr. One of the observable methods is OnDestructionImminent(host). * Added gyp dependency on the net library BUG=none TEST=none Review URL: http://codereview.chromium.org/205017 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@26537 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/appcache/appcache_host.cc')
-rw-r--r--webkit/appcache/appcache_host.cc25
1 files changed, 20 insertions, 5 deletions
diff --git a/webkit/appcache/appcache_host.cc b/webkit/appcache/appcache_host.cc
index 252c618..77a0d96 100644
--- a/webkit/appcache/appcache_host.cc
+++ b/webkit/appcache/appcache_host.cc
@@ -22,11 +22,20 @@ AppCacheHost::AppCacheHost(int host_id, AppCacheFrontend* frontend,
}
AppCacheHost::~AppCacheHost() {
+ FOR_EACH_OBSERVER(Observer, observers_, OnDestructionImminent(this));
if (associated_cache_.get())
associated_cache_->UnassociateHost(this);
service_->CancelLoads(this);
}
+void AppCacheHost::AddObserver(Observer* observer) {
+ observers_.AddObserver(observer);
+}
+
+void AppCacheHost::RemoveObserver(Observer* observer) {
+ observers_.RemoveObserver(observer);
+}
+
void AppCacheHost::SelectCache(const GURL& document_url,
const int64 cache_document_was_loaded_from,
const GURL& manifest_url) {
@@ -56,9 +65,9 @@ void AppCacheHost::SelectCache(const GURL& document_url,
// 6.9.6 The application cache selection algorithm.
// The algorithm is started here and continues in FinishCacheSelection,
// after cache or group loading is complete.
- // Note: foriegn entries are detected on the client side and
+ // Note: Foreign entries are detected on the client side and
// MarkAsForeignEntry is called in that case, so that detection
- // step is skipped here.
+ // step is skipped here. See WebApplicationCacheHostImpl.cc
if (cache_document_was_loaded_from != kNoCacheId) {
LoadCache(cache_document_was_loaded_from);
@@ -67,6 +76,9 @@ void AppCacheHost::SelectCache(const GURL& document_url,
if (!manifest_url.is_empty() &&
(manifest_url.GetOrigin() == document_url.GetOrigin())) {
+ // Note: The client detects if the document was not loaded using HTTP GET
+ // and invokes SelectCache without a manifest url, so that detection step
+ // is also skipped here. See WebApplicationCacheHostImpl.cc
new_master_entry_url_ = document_url;
LoadOrCreateGroup(manifest_url);
return;
@@ -161,10 +173,11 @@ AppCacheRequestHandler* AppCacheHost::CreateRequestHandler(
URLRequest* request,
bool is_main_request) {
if (is_main_request)
- return new AppCacheRequestHandler(this);
+ return new AppCacheRequestHandler(this, true);
- if (associated_cache() && associated_cache()->is_complete())
- return new AppCacheRequestHandler(associated_cache());
+ if ((associated_cache() && associated_cache()->is_complete()) ||
+ is_selection_pending())
+ return new AppCacheRequestHandler(this, false);
return NULL;
}
@@ -240,6 +253,8 @@ void AppCacheHost::FinishCacheSelection(
DoPendingStartUpdate();
else if (pending_swap_cache_callback_)
DoPendingSwapCache();
+
+ FOR_EACH_OBSERVER(Observer, observers_, OnCacheSelectionComplete(this));
}
void AppCacheHost::AssociateCache(AppCache* cache) {