summaryrefslogtreecommitdiffstats
path: root/webkit
diff options
context:
space:
mode:
authormichaeln@google.com <michaeln@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-13 01:45:09 +0000
committermichaeln@google.com <michaeln@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-13 01:45:09 +0000
commitd144b0590e00629570c3f729b1d0baf048dc1d45 (patch)
treed25a1d6c65206140be31495625fb2895f7cebaf0 /webkit
parentfd9c35f41bcab4966a5db8d24de812b1e9f87967 (diff)
downloadchromium_src-d144b0590e00629570c3f729b1d0baf048dc1d45.zip
chromium_src-d144b0590e00629570c3f729b1d0baf048dc1d45.tar.gz
chromium_src-d144b0590e00629570c3f729b1d0baf048dc1d45.tar.bz2
Add some unimplemented methods from my last CL.
TEST=yes, appcache_storage_unittest.cc BUG=none Review URL: http://codereview.chromium.org/266042 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@28772 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r--webkit/appcache/appcache_response.h4
-rw-r--r--webkit/appcache/appcache_storage_unittest.cc30
-rw-r--r--webkit/appcache/appcache_working_set.cc11
3 files changed, 43 insertions, 2 deletions
diff --git a/webkit/appcache/appcache_response.h b/webkit/appcache/appcache_response.h
index c791a01..c3a08e1 100644
--- a/webkit/appcache/appcache_response.h
+++ b/webkit/appcache/appcache_response.h
@@ -9,6 +9,7 @@
#include "base/ref_counted.h"
#include "net/base/completion_callback.h"
#include "net/http/http_response_info.h"
+#include "webkit/appcache/appcache_interfaces.h"
#include "webkit/appcache/appcache_service.h"
#include "webkit/appcache/appcache_storage.h"
@@ -19,14 +20,13 @@ namespace disk_cache {
class Backend;
};
-
namespace appcache {
// Response info for a particular response id. Instances are tracked in
// the working set.
class AppCacheResponseInfo
: public base::RefCounted<AppCacheResponseInfo> {
-
+ public:
// AppCacheResponseInfo takes ownership of the http_info.
AppCacheResponseInfo(AppCacheService* service, int64 response_id,
net::HttpResponseInfo* http_info)
diff --git a/webkit/appcache/appcache_storage_unittest.cc b/webkit/appcache/appcache_storage_unittest.cc
index f5f9e06..6e06265 100644
--- a/webkit/appcache/appcache_storage_unittest.cc
+++ b/webkit/appcache/appcache_storage_unittest.cc
@@ -6,6 +6,7 @@
#include "webkit/appcache/appcache.h"
#include "webkit/appcache/appcache_group.h"
#include "webkit/appcache/appcache_storage.h"
+#include "webkit/appcache/appcache_response.h"
#include "webkit/appcache/mock_appcache_service.h"
namespace appcache {
@@ -16,8 +17,14 @@ class AppCacheStorageTest : public testing::Test {
TEST(AppCacheStorageTest, AddRemoveCache) {
MockAppCacheService service;
scoped_refptr<AppCache> cache = new AppCache(&service, 111);
+
+ EXPECT_EQ(cache.get(),
+ service.storage()->working_set()->GetCache(111));
+
service.storage()->working_set()->RemoveCache(cache);
+ EXPECT_TRUE(!service.storage()->working_set()->GetCache(111));
+
// Removing non-existing cache from service should not fail.
MockAppCacheService dummy;
dummy.storage()->working_set()->RemoveCache(cache);
@@ -27,11 +34,34 @@ TEST(AppCacheStorageTest, AddRemoveGroup) {
MockAppCacheService service;
scoped_refptr<AppCacheGroup> group =
new AppCacheGroup(&service, GURL::EmptyGURL());
+
+ EXPECT_EQ(group.get(),
+ service.storage()->working_set()->GetGroup(GURL::EmptyGURL()));
+
service.storage()->working_set()->RemoveGroup(group);
+ EXPECT_TRUE(!service.storage()->working_set()->GetGroup(GURL::EmptyGURL()));
+
// Removing non-existing group from service should not fail.
MockAppCacheService dummy;
dummy.storage()->working_set()->RemoveGroup(group);
}
+TEST(AppCacheStorageTest, AddRemoveResponseInfo) {
+ MockAppCacheService service;
+ scoped_refptr<AppCacheResponseInfo> info =
+ new AppCacheResponseInfo(&service, 111, new net::HttpResponseInfo);
+
+ EXPECT_EQ(info.get(),
+ service.storage()->working_set()->GetResponseInfo(111));
+
+ service.storage()->working_set()->RemoveResponseInfo(info);
+
+ EXPECT_TRUE(!service.storage()->working_set()->GetResponseInfo(111));
+
+ // Removing non-existing info from service should not fail.
+ MockAppCacheService dummy;
+ dummy.storage()->working_set()->RemoveResponseInfo(info);
+}
+
} // namespace appcache
diff --git a/webkit/appcache/appcache_working_set.cc b/webkit/appcache/appcache_working_set.cc
index a5b544f..9b67942 100644
--- a/webkit/appcache/appcache_working_set.cc
+++ b/webkit/appcache/appcache_working_set.cc
@@ -7,6 +7,7 @@
#include "base/logging.h"
#include "webkit/appcache/appcache.h"
#include "webkit/appcache/appcache_group.h"
+#include "webkit/appcache/appcache_response.h"
namespace appcache {
@@ -35,4 +36,14 @@ void AppCacheWorkingSet::RemoveGroup(AppCacheGroup* group) {
groups_.erase(group->manifest_url());
}
+void AppCacheWorkingSet::AddResponseInfo(AppCacheResponseInfo* info) {
+ int64 response_id = info->response_id();
+ DCHECK(response_infos_.find(response_id) == response_infos_.end());
+ response_infos_.insert(ResponseInfoMap::value_type(response_id, info));
+}
+
+void AppCacheWorkingSet::RemoveResponseInfo(AppCacheResponseInfo* info) {
+ response_infos_.erase(info->response_id());
+}
+
} // namespace