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.h | |
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.h')
-rw-r--r-- | webkit/appcache/appcache_backend_impl.h | 56 |
1 files changed, 22 insertions, 34 deletions
diff --git a/webkit/appcache/appcache_backend_impl.h b/webkit/appcache/appcache_backend_impl.h index abf4247..4ae4e49 100644 --- a/webkit/appcache/appcache_backend_impl.h +++ b/webkit/appcache/appcache_backend_impl.h @@ -5,22 +5,15 @@ #ifndef WEBKIT_APPCACHE_APPCACHE_BACKEND_IMPL_H_ #define WEBKIT_APPCACHE_APPCACHE_BACKEND_IMPL_H_ -#include <map> - #include "base/logging.h" -#include "base/task.h" +#include "base/hash_tables.h" #include "webkit/appcache/appcache_host.h" -#include "webkit/appcache/appcache_interfaces.h" namespace appcache { class AppCacheService; -typedef Callback2<Status, void*>::Type GetStatusCallback; -typedef Callback2<bool, void*>::Type StartUpdateCallback; -typedef Callback2<bool, void*>::Type SwapCacheCallback; - -class AppCacheBackendImpl : public AppCacheBackend { +class AppCacheBackendImpl { public: AppCacheBackendImpl() : service_(NULL), frontend_(NULL), process_id_(0) {} ~AppCacheBackendImpl(); @@ -31,38 +24,33 @@ class AppCacheBackendImpl : public AppCacheBackend { int process_id() const { return process_id_; } + // Methods to support the AppCacheBackend interface. A false return + // value indicates an invalid host_id and that no action was taken + // by the backend impl. + bool RegisterHost(int host_id); + bool UnregisterHost(int host_id); + bool SelectCache(int host_id, + const GURL& document_url, + const int64 cache_document_was_loaded_from, + const GURL& manifest_url); + bool MarkAsForeignEntry(int host_id, const GURL& document_url, + int64 cache_document_was_loaded_from); + bool GetStatusWithCallback(int host_id, GetStatusCallback* callback, + void* callback_param); + bool StartUpdateWithCallback(int host_id, StartUpdateCallback* callback, + void* callback_param); + bool SwapCacheWithCallback(int host_id, SwapCacheCallback* callback, + void* callback_param); + // Returns a pointer to a registered host. The backend retains ownership. AppCacheHost* GetHost(int host_id) { HostMap::iterator it = hosts_.find(host_id); - return (it != hosts_.end()) ? &(it->second) : NULL; + return (it != hosts_.end()) ? (it->second) : NULL; } - typedef std::map<int, AppCacheHost> HostMap; + typedef base::hash_map<int, AppCacheHost*> HostMap; const HostMap& hosts() { return hosts_; } - // AppCacheBackend methods - virtual void RegisterHost(int host_id); - virtual void UnregisterHost(int host_id); - virtual void SelectCache(int host_id, - const GURL& document_url, - const int64 cache_document_was_loaded_from, - const GURL& manifest_url); - virtual void MarkAsForeignEntry(int host_id, const GURL& document_url, - int64 cache_document_was_loaded_from); - - // We don't use the sync variants in the backend, would block the IO thread. - virtual Status GetStatus(int host_id) { NOTREACHED(); return UNCACHED; } - virtual bool StartUpdate(int host_id) { NOTREACHED(); return false; } - virtual bool SwapCache(int host_id) { NOTREACHED(); return false; } - - // Async variants of the sync methods defined in the backend interface. - void GetStatusWithCallback(int host_id, GetStatusCallback* callback, - void* callback_param); - void StartUpdateWithCallback(int host_id, StartUpdateCallback* callback, - void* callback_param); - void SwapCacheWithCallback(int host_id, SwapCacheCallback* callback, - void* callback_param); - private: AppCacheService* service_; AppCacheFrontend* frontend_; |