summaryrefslogtreecommitdiffstats
path: root/webkit/appcache/appcache_service.h
diff options
context:
space:
mode:
authormichaeln@google.com <michaeln@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-15 22:07:15 +0000
committermichaeln@google.com <michaeln@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-15 22:07:15 +0000
commit97e3edc23314c476859c22c8db601f9b3dec552d (patch)
tree9c589f47545b88c1453c2481a7844a921636485c /webkit/appcache/appcache_service.h
parent34fce2a5030cb53a1e2decb37b5f7517f98457f7 (diff)
downloadchromium_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_service.h')
-rw-r--r--webkit/appcache/appcache_service.h46
1 files changed, 34 insertions, 12 deletions
diff --git a/webkit/appcache/appcache_service.h b/webkit/appcache/appcache_service.h
index 0ccad80..0d7609d 100644
--- a/webkit/appcache/appcache_service.h
+++ b/webkit/appcache/appcache_service.h
@@ -12,6 +12,7 @@
#include "base/hash_tables.h"
#include "base/file_path.h"
#include "base/ref_counted.h"
+#include "base/task.h"
#include "net/url_request/url_request_context.h"
#include "googleurl/src/gurl.h"
@@ -26,6 +27,17 @@ class AppCacheGroup;
// exclusive access to it's cache_directory on disk.
class AppCacheService {
public:
+
+ class LoadClient {
+ public:
+ virtual ~LoadClient() {}
+
+ // If a load fails the object pointer will be NULL.
+ virtual void CacheLoadedCallback(AppCache* cache, int64 cache_id) = 0;
+ virtual void GroupLoadedCallback(AppCacheGroup* cache,
+ const GURL& manifest_url) = 0;
+ };
+
AppCacheService();
virtual ~AppCacheService();
@@ -42,30 +54,41 @@ class AppCacheService {
// TODO(jennb): API to set service settings, like file paths for storage
- // track which processes are using this appcache service
+ // Track which processes are using this appcache service.
void RegisterBackend(AppCacheBackendImpl* backend_impl);
void UnregisterBackend(AppCacheBackendImpl* backend_impl);
-
- void AddCache(AppCache* cache);
- void RemoveCache(AppCache* cache);
- void AddGroup(AppCacheGroup* group);
- void RemoveGroup(AppCacheGroup* group);
-
AppCacheBackendImpl* GetBackend(int id) {
BackendMap::iterator it = backends_.find(id);
return (it != backends_.end()) ? it->second : NULL;
}
+ // Track what we have in or in-memory cache.
+ void AddCache(AppCache* cache);
+ void RemoveCache(AppCache* cache);
+ void AddGroup(AppCacheGroup* group);
+ void RemoveGroup(AppCacheGroup* group);
AppCache* GetCache(int64 id) {
CacheMap::iterator it = caches_.find(id);
return (it != caches_.end()) ? it->second : NULL;
}
-
AppCacheGroup* GetGroup(const GURL& manifest_url) {
GroupMap::iterator it = groups_.find(manifest_url);
return (it != groups_.end()) ? it->second : NULL;
}
+ // Load caches and groups from storage. If the request object
+ // is already in memory, the client is called immediately
+ // without returning to the message loop.
+ void LoadCache(int64 id, LoadClient* client);
+ void LoadOrCreateGroup(const GURL& manifest_url,
+ LoadClient* client);
+
+ // Cancels pending callbacks for this client.
+ void CancelLoads(LoadClient* client);
+
+ // Updates in memory and persistent storage.
+ void MarkAsForeignEntry(const GURL& entry_url, int64 cache_id);
+
// The service generates unique storage ids for different object types.
int64 NewCacheId() { return ++last_cache_id_; }
int64 NewGroupId() { return ++last_group_id_; }
@@ -90,15 +113,14 @@ class AppCacheService {
typedef std::map<int, AppCacheBackendImpl*> BackendMap;
BackendMap backends_;
+ // Where we save our data.
FilePath cache_directory_;
// Context for use during cache updates.
scoped_refptr<URLRequestContext> request_context_;
- // TODO(jennb): info about appcache storage
- // AppCacheDatabase db_;
- // DiskCache response_storage_;
-
+ // TODO(michaeln): cache and group loading book keeping.
+ // TODO(michaeln): database and response storage
// TODO(jennb): service state: e.g. reached quota?
};