diff options
Diffstat (limited to 'webkit/appcache/appcache_host.cc')
-rw-r--r-- | webkit/appcache/appcache_host.cc | 50 |
1 files changed, 45 insertions, 5 deletions
diff --git a/webkit/appcache/appcache_host.cc b/webkit/appcache/appcache_host.cc index d4ca661..6d0336b 100644 --- a/webkit/appcache/appcache_host.cc +++ b/webkit/appcache/appcache_host.cc @@ -6,13 +6,15 @@ #include "base/logging.h" #include "webkit/appcache/appcache.h" +#include "webkit/appcache/appcache_backend_impl.h" #include "webkit/appcache/appcache_request_handler.h" namespace appcache { AppCacheHost::AppCacheHost(int host_id, AppCacheFrontend* frontend, AppCacheService* service) - : host_id_(host_id), pending_main_resource_cache_id_(kNoCacheId), + : host_id_(host_id), parent_host_id_(kNoHostId), parent_process_id_(0), + pending_main_resource_cache_id_(kNoCacheId), pending_selected_cache_id_(kNoCacheId), frontend_(frontend), service_(service), pending_get_status_callback_(NULL), pending_start_update_callback_(NULL), @@ -93,6 +95,31 @@ void AppCacheHost::SelectCache(const GURL& document_url, FinishCacheSelection(NULL, NULL); } +void AppCacheHost::SelectCacheForWorker(int parent_process_id, + int parent_host_id) { + DCHECK(!pending_start_update_callback_ && + !pending_swap_cache_callback_ && + !pending_get_status_callback_ && + !is_selection_pending()); + + parent_process_id_ = parent_process_id; + parent_host_id_ = parent_host_id; + FinishCacheSelection(NULL, NULL); +} + +void AppCacheHost::SelectCacheForSharedWorker(int64 appcache_id) { + DCHECK(!pending_start_update_callback_ && + !pending_swap_cache_callback_ && + !pending_get_status_callback_ && + !is_selection_pending()); + + if (appcache_id != kNoCacheId) { + LoadSelectedCache(appcache_id); + return; + } + FinishCacheSelection(NULL, NULL); +} + // TODO(michaeln): change method name to MarkEntryAsForeign for consistency void AppCacheHost::MarkAsForeignEntry(const GURL& document_url, int64 cache_document_was_loaded_from) { @@ -197,15 +224,28 @@ void AppCacheHost::DoPendingSwapCache() { pending_callback_param_ = NULL; } +AppCacheHost* AppCacheHost::GetParentAppCacheHost() const { + DCHECK(is_for_dedicated_worker()); + AppCacheBackendImpl* backend = service_->GetBackend(parent_process_id_); + return backend ? backend->GetHost(parent_host_id_) : NULL; +} + AppCacheRequestHandler* AppCacheHost::CreateRequestHandler( URLRequest* request, - bool is_main_request) { - if (is_main_request) - return new AppCacheRequestHandler(this, true); + ResourceType::Type resource_type) { + if (is_for_dedicated_worker()) { + AppCacheHost* parent_host = GetParentAppCacheHost(); + if (parent_host) + return parent_host->CreateRequestHandler(request, resource_type); + return NULL; + } + + if (AppCacheRequestHandler::IsMainResourceType(resource_type)) + return new AppCacheRequestHandler(this, resource_type); if ((associated_cache() && associated_cache()->is_complete()) || is_selection_pending()) { - return new AppCacheRequestHandler(this, false); + return new AppCacheRequestHandler(this, resource_type); } return NULL; } |