diff options
author | michaeln@google.com <michaeln@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-15 22:07:15 +0000 |
---|---|---|
committer | michaeln@google.com <michaeln@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-15 22:07:15 +0000 |
commit | 97e3edc23314c476859c22c8db601f9b3dec552d (patch) | |
tree | 9c589f47545b88c1453c2481a7844a921636485c /webkit/appcache/appcache_backend_impl.cc | |
parent | 34fce2a5030cb53a1e2decb37b5f7517f98457f7 (diff) | |
download | chromium_src-97e3edc23314c476859c22c8db601f9b3dec552d.zip chromium_src-97e3edc23314c476859c22c8db601f9b3dec552d.tar.gz chromium_src-97e3edc23314c476859c22c8db601f9b3dec552d.tar.bz2 |
* Fleshed out AppCacheHost class a fair amount, in particular the cache selection algorithm.
* Added some AppCacheHost unit tests.
* Introduced AppCacheRequestHandler class, which replaces the clunkyApp
CacheInterceptor::ExtraInfo struct. This impl is entirely skeletal
stubs for now.
TEST=appcache_unittest.cc, but really needs more
BUG=none
Review URL: http://codereview.chromium.org/192043
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@26275 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/appcache/appcache_backend_impl.cc')
-rw-r--r-- | webkit/appcache/appcache_backend_impl.cc | 73 |
1 files changed, 53 insertions, 20 deletions
diff --git a/webkit/appcache/appcache_backend_impl.cc b/webkit/appcache/appcache_backend_impl.cc index 22e4e0f..f7788ae 100644 --- a/webkit/appcache/appcache_backend_impl.cc +++ b/webkit/appcache/appcache_backend_impl.cc @@ -4,7 +4,7 @@ #include "webkit/appcache/appcache_backend_impl.h" -#include "webkit/appcache/appcache_host.h" +#include "base/stl_util-inl.h" #include "webkit/appcache/appcache.h" #include "webkit/appcache/appcache_group.h" #include "webkit/appcache/appcache_service.h" @@ -13,6 +13,7 @@ namespace appcache { AppCacheBackendImpl::~AppCacheBackendImpl() { + STLDeleteValues(&hosts_); if (service_) service_->UnregisterBackend(this); } @@ -27,47 +28,79 @@ void AppCacheBackendImpl::Initialize(AppCacheService* service, service_->RegisterBackend(this); } -void AppCacheBackendImpl::RegisterHost(int id) { - DCHECK(hosts_.find(id) == hosts_.end()); - hosts_.insert(HostMap::value_type(id, AppCacheHost(id, frontend_))); +bool AppCacheBackendImpl::RegisterHost(int id) { + if (GetHost(id)) + return false; + + hosts_.insert( + HostMap::value_type(id, new AppCacheHost(id, frontend_, service_))); + return true; } -void AppCacheBackendImpl::UnregisterHost(int id) { - hosts_.erase(id); +bool AppCacheBackendImpl::UnregisterHost(int id) { + HostMap::iterator found = hosts_.find(id); + if (found == hosts_.end()) + return false; + + delete found->second; + hosts_.erase(found); + return true; } -void AppCacheBackendImpl::SelectCache( +bool AppCacheBackendImpl::SelectCache( int host_id, const GURL& document_url, const int64 cache_document_was_loaded_from, const GURL& manifest_url) { - // TODO(michaeln): write me - frontend_->OnCacheSelected(host_id, kNoCacheId, UNCACHED); + AppCacheHost* host = GetHost(host_id); + if (!host) + return false; + + host->SelectCache(document_url, cache_document_was_loaded_from, + manifest_url); + return true; } -void AppCacheBackendImpl::MarkAsForeignEntry( +bool AppCacheBackendImpl::MarkAsForeignEntry( int host_id, const GURL& document_url, int64 cache_document_was_loaded_from) { - // TODO(michaeln): write me + AppCacheHost* host = GetHost(host_id); + if (!host) + return false; + + host->MarkAsForeignEntry(document_url, cache_document_was_loaded_from); + return true; } -void AppCacheBackendImpl::GetStatusWithCallback( +bool AppCacheBackendImpl::GetStatusWithCallback( int host_id, GetStatusCallback* callback, void* callback_param) { - // TODO(michaeln): write me - callback->Run(UNCACHED, callback_param); + AppCacheHost* host = GetHost(host_id); + if (!host) + return false; + + host->GetStatusWithCallback(callback, callback_param); + return true; } -void AppCacheBackendImpl::StartUpdateWithCallback( +bool AppCacheBackendImpl::StartUpdateWithCallback( int host_id, StartUpdateCallback* callback, void* callback_param) { - // TODO(michaeln): write me - callback->Run(false, callback_param); + AppCacheHost* host = GetHost(host_id); + if (!host) + return false; + + host->StartUpdateWithCallback(callback, callback_param); + return true; } -void AppCacheBackendImpl::SwapCacheWithCallback( +bool AppCacheBackendImpl::SwapCacheWithCallback( int host_id, SwapCacheCallback* callback, void* callback_param) { - // TODO(michaeln): write me - callback->Run(false, callback_param); + AppCacheHost* host = GetHost(host_id); + if (!host) + return false; + + host->SwapCacheWithCallback(callback, callback_param); + return true; } } // namespace appcache |