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-10-09 03:25:51 +0000
committermichaeln@google.com <michaeln@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-09 03:25:51 +0000
commite7dff7bae2779884b62dc3c7f8bd40a4987627f1 (patch)
treecfc42a36432847e42eabf716cc56bc2365ed10a4 /webkit/appcache/appcache_service.h
parent55e9c25f48d8d99cc0433258b44f6e96011a63cd (diff)
downloadchromium_src-e7dff7bae2779884b62dc3c7f8bd40a4987627f1.zip
chromium_src-e7dff7bae2779884b62dc3c7f8bd40a4987627f1.tar.gz
chromium_src-e7dff7bae2779884b62dc3c7f8bd40a4987627f1.tar.bz2
AppCache StorageAPIs
TEST=none yet, these are just API definitions stubbed out for now BUG=none Review URL: http://codereview.chromium.org/209071 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@28513 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/appcache/appcache_service.h')
-rw-r--r--webkit/appcache/appcache_service.h85
1 files changed, 12 insertions, 73 deletions
diff --git a/webkit/appcache/appcache_service.h b/webkit/appcache/appcache_service.h
index 4dff28e..5cdaed4 100644
--- a/webkit/appcache/appcache_service.h
+++ b/webkit/appcache/appcache_service.h
@@ -5,40 +5,23 @@
#ifndef WEBKIT_APPCACHE_APPCACHE_SERVICE_H_
#define WEBKIT_APPCACHE_APPCACHE_SERVICE_H_
-#include <map>
-#include <set>
-#include <vector>
-
-#include "base/hash_tables.h"
#include "base/file_path.h"
-#include "base/ref_counted.h"
-#include "base/task.h"
-#include "googleurl/src/gurl.h"
+#include "base/logging.h"
+#include "base/scoped_ptr.h"
+#include "testing/gtest/include/gtest/gtest_prod.h"
+#include "webkit/appcache/appcache_storage.h"
class URLRequestContext;
namespace appcache {
-class AppCache;
class AppCacheBackendImpl;
-class AppCacheGroup;
// Class that manages the application cache service. Sends notifications
// to many frontends. One instance per user-profile. Each instance has
// 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* group,
- const GURL& manifest_url) = 0;
- };
-
AppCacheService();
virtual ~AppCacheService();
@@ -56,71 +39,27 @@ class AppCacheService {
// Track which processes are using this appcache service.
void RegisterBackend(AppCacheBackendImpl* backend_impl);
void UnregisterBackend(AppCacheBackendImpl* backend_impl);
- AppCacheBackendImpl* GetBackend(int id) {
- BackendMap::iterator it = backends_.find(id);
+ AppCacheBackendImpl* GetBackend(int id) const {
+ BackendMap::const_iterator it = backends_.find(id);
return (it != backends_.end()) ? it->second : NULL;
}
- // Track what we have in our 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;
- }
+ AppCacheStorage* storage() const { return storage_.get(); }
- // 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_; }
- int64 NewEntryId() { return ++last_entry_id_; }
- int64 NewResponseId() { return ++last_response_id_; }
-
- private:
- // In-memory representation of stored appcache data. Represents a subset
- // of the appcache database currently in use.
- typedef base::hash_map<int64, AppCache*> CacheMap;
- typedef std::map<GURL, AppCacheGroup*> GroupMap;
- CacheMap caches_;
- GroupMap groups_;
-
- // The last storage id used for different object types.
- int64 last_cache_id_;
- int64 last_group_id_;
- int64 last_entry_id_;
- int64 last_response_id_;
+ protected:
+ // Deals with persistence.
+ scoped_ptr<AppCacheStorage> storage_;
// Track current processes. One 'backend' per child process.
typedef std::map<int, AppCacheBackendImpl*> BackendMap;
BackendMap backends_;
- // Where we save our data.
- FilePath cache_directory_;
-
// Context for use during cache updates.
URLRequestContext* request_context_;
- // TODO(michaeln): cache and group loading book keeping.
- // TODO(michaeln): database and response storage
// TODO(jennb): service state: e.g. reached quota?
+
+ DISALLOW_COPY_AND_ASSIGN(AppCacheService);
};
} // namespace appcache