diff options
author | michaeln@google.com <michaeln@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-01 22:30:30 +0000 |
---|---|---|
committer | michaeln@google.com <michaeln@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-01 22:30:30 +0000 |
commit | 23f1ef1a445a53bcefc8ddab9f4184b1db7321c5 (patch) | |
tree | c9f17a33025ed5b5c5dee76a7b4fef9104e9a995 /webkit/appcache/appcache_backend_impl.h | |
parent | e143c823ce66af5a83a9a17b6f5938eb16e49392 (diff) | |
download | chromium_src-23f1ef1a445a53bcefc8ddab9f4184b1db7321c5.zip chromium_src-23f1ef1a445a53bcefc8ddab9f4184b1db7321c5.tar.gz chromium_src-23f1ef1a445a53bcefc8ddab9f4184b1db7321c5.tar.bz2 |
Plumb request interception into the appcache library for both chrome and test_shell.
AppCache library:
* Added AppCacheInterceptor, which is derived from URLRequest::Interceptor.
Chrome:
* Each UserProfile instantiates a ChromeAppCacheService, which is derived from an appcache library class.
* Each ChromeURLRequestContext associated with that profile has a reference to that instance.
* ResourceDispatcherHost pokes AppCacheInterceptor when initiating URLRequests and when returning the response head.
TestShell:
* Added SimpleAppCacheSystem which bundles together appcache lib components for use in a single process with an UI and IO thread.
* TestShellWebKit instantiates and initializes an instance of the above, aimed at at temp directory that will get cleaned up when the test run is over.
* SimpleResourceLoaderBridge pokes the system when initiating URLRequests and when returning the response head.
TEST=none, although many existing tests exercise this stuff
BUG=none
Review URL: http://codereview.chromium.org/173406
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@25099 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/appcache/appcache_backend_impl.h')
-rw-r--r-- | webkit/appcache/appcache_backend_impl.h | 44 |
1 files changed, 39 insertions, 5 deletions
diff --git a/webkit/appcache/appcache_backend_impl.h b/webkit/appcache/appcache_backend_impl.h index 93a7083..abf4247 100644 --- a/webkit/appcache/appcache_backend_impl.h +++ b/webkit/appcache/appcache_backend_impl.h @@ -5,20 +5,42 @@ #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 "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 { public: - AppCacheBackendImpl() : service_(NULL), frontend_(NULL) {} + AppCacheBackendImpl() : service_(NULL), frontend_(NULL), process_id_(0) {} ~AppCacheBackendImpl(); void Initialize(AppCacheService* service, - AppCacheFrontend* frontend); + AppCacheFrontend* frontend, + int process_id); + + int process_id() const { return process_id_; } + + // 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; + } + typedef std::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, @@ -27,13 +49,25 @@ class AppCacheBackendImpl : public AppCacheBackend { const GURL& manifest_url); virtual void MarkAsForeignEntry(int host_id, const GURL& document_url, int64 cache_document_was_loaded_from); - virtual Status GetStatus(int host_id); - virtual bool StartUpdate(int host_id); - virtual bool SwapCache(int host_id); + + // 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_; + int process_id_; + HostMap hosts_; }; } // namespace |