summaryrefslogtreecommitdiffstats
path: root/webkit/appcache/mock_appcache_storage.cc
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/mock_appcache_storage.cc
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/mock_appcache_storage.cc')
-rw-r--r--webkit/appcache/mock_appcache_storage.cc98
1 files changed, 98 insertions, 0 deletions
diff --git a/webkit/appcache/mock_appcache_storage.cc b/webkit/appcache/mock_appcache_storage.cc
new file mode 100644
index 0000000..4dfb8c9
--- /dev/null
+++ b/webkit/appcache/mock_appcache_storage.cc
@@ -0,0 +1,98 @@
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "webkit/appcache/mock_appcache_storage.h"
+
+#include "base/logging.h"
+#include "base/ref_counted.h"
+#include "webkit/appcache/appcache.h"
+#include "webkit/appcache/appcache_backend_impl.h"
+#include "webkit/appcache/appcache_entry.h"
+#include "webkit/appcache/appcache_group.h"
+#include "webkit/appcache/appcache_response.h"
+
+namespace appcache {
+
+MockAppCacheStorage::MockAppCacheStorage(AppCacheService* service)
+ : AppCacheStorage(service) {
+ last_cache_id_ = 0;
+ last_entry_id_ = 0;
+ last_group_id_ = 0;
+ last_response_id_ = 0;
+}
+
+void MockAppCacheStorage::LoadCache(int64 id, Delegate* delegate) {
+ AppCache* cache = working_set_.GetCache(id);
+ delegate->OnCacheLoaded(cache, id);
+}
+
+void MockAppCacheStorage::LoadOrCreateGroup(
+ const GURL& manifest_url, Delegate* delegate) {
+ scoped_refptr<AppCacheGroup> group = working_set_.GetGroup(manifest_url);
+ if (!group.get()) {
+ group = new AppCacheGroup(service_, manifest_url);
+ DCHECK(working_set_.GetGroup(manifest_url));
+ }
+ delegate->OnGroupLoaded(group.get(), manifest_url);
+}
+
+void MockAppCacheStorage::LoadResponseInfo(
+ const GURL& manifest_url, int64 id, Delegate* delegate) {
+ delegate->OnResponseInfoLoaded(working_set_.GetResponseInfo(id), id);
+}
+
+void MockAppCacheStorage::StoreGroupAndNewestCache(
+ AppCacheGroup* group, Delegate* delegate) {
+ // TODO(michaeln): write me
+ delegate->OnGroupAndNewestCacheStored(group, false);
+}
+
+void MockAppCacheStorage::FindResponseForMainRequest(
+ const GURL& url, Delegate* delegate) {
+ // TODO(michaeln): write me
+ delegate->OnMainResponseFound(
+ url, kNoResponseId, false, kNoCacheId, GURL::EmptyGURL());
+}
+
+void MockAppCacheStorage::MarkEntryAsForeign(
+ const GURL& entry_url, int64 cache_id) {
+ // Update the working set.
+ AppCache* cache = working_set_.GetCache(cache_id);
+ if (cache) {
+ AppCacheEntry* entry = cache->GetEntry(entry_url);
+ DCHECK(entry);
+ if (entry)
+ entry->add_types(AppCacheEntry::FOREIGN);
+ }
+ // TODO(michaeln): actually update in storage, and if this cache is
+ // being loaded be sure to update the memory cache upon load completion.
+}
+
+void MockAppCacheStorage::MarkGroupAsObsolete(
+ AppCacheGroup* group, Delegate* delegate) {
+ // TODO(michaeln): write me
+}
+
+void MockAppCacheStorage::CancelDelegateCallbacks(Delegate* delegate) {
+ // TODO(michaeln): remove delegate from callback list
+}
+
+AppCacheResponseReader* MockAppCacheStorage::CreateResponseReader(
+ const GURL& origin, int64 response_id) {
+ return new AppCacheResponseReader(response_id, NULL);
+ // TODO(michaeln): use a disk_cache
+}
+
+AppCacheResponseWriter* MockAppCacheStorage::CreateResponseWriter(
+ const GURL& manifest_url) {
+ return new AppCacheResponseWriter(NewResponseId(), NULL);
+ // TODO(michaeln): use a disk_cache
+}
+
+void MockAppCacheStorage::DoomResponses(
+ const GURL& manifest_url, const std::vector<int64>& response_ids) {
+ // TODO(michaeln): write me
+}
+
+} // namespace appcache