Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(293)

Unified Diff: webkit/appcache/appcache_test_helper.cc

Issue 7210006: AppCaches which belong to hosted apps are not protected from deletion (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Moving test helpers to webkit/appcache. Created 9 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webkit/appcache/appcache_test_helper.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/appcache/appcache_test_helper.cc
diff --git a/webkit/appcache/appcache_test_helper.cc b/webkit/appcache/appcache_test_helper.cc
new file mode 100644
index 0000000000000000000000000000000000000000..a9ca7e64a1476171f4b1d2c3219a8f253235277a
--- /dev/null
+++ b/webkit/appcache/appcache_test_helper.cc
@@ -0,0 +1,77 @@
+// Copyright (c) 2011 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/appcache_test_helper.h"
+
+#include "base/message_loop.h"
+#include "testing/gtest/include/gtest/gtest.h"
+#include "webkit/appcache/appcache.h"
+#include "webkit/appcache/appcache_entry.h"
+#include "webkit/appcache/appcache_group.h"
+#include "webkit/appcache/appcache_service.h"
+
+namespace appcache {
+
+AppCacheTestHelper::AppCacheTestHelper()
+ : group_id_(0),
+ appcache_id_(0),
+ response_id_(0),
+ ALLOW_THIS_IN_INITIALIZER_LIST(appcache_got_info_callback_(
+ this, &AppCacheTestHelper::OnGotAppCacheInfo)),
+ origins_(NULL) {}
+
+AppCacheTestHelper::~AppCacheTestHelper() {}
+
+void AppCacheTestHelper::OnGroupAndNewestCacheStored(
+ AppCacheGroup* /*group*/,
+ AppCache* /*newest_cache*/,
+ bool success,
+ bool /*would_exceed_quota*/) {
+ ASSERT_TRUE(success);
+ MessageLoop::current()->Quit();
+}
+
+void AppCacheTestHelper::AddGroupAndCache(AppCacheService* appcache_service,
+ const GURL& manifest_url) {
+ AppCacheGroup* appcache_group =
+ new AppCacheGroup(appcache_service,
+ manifest_url,
+ ++group_id_);
+ AppCache* appcache = new AppCache(appcache_service,
+ ++appcache_id_);
+ AppCacheEntry entry(AppCacheEntry::MANIFEST,
+ ++response_id_);
+ appcache->AddEntry(manifest_url, entry);
+ appcache->set_complete(true);
+ appcache_group->AddCache(appcache);
+ appcache_service->storage()->StoreGroupAndNewestCache(appcache_group,
+ appcache,
+ this);
+ // OnGroupAndNewestCacheStored will quit the message loop.
+ MessageLoop::current()->Run();
+}
+
+void AppCacheTestHelper::GetOriginsWithCaches(AppCacheService* appcache_service,
+ std::set<GURL>* origins) {
+ appcache_info_ = new AppCacheInfoCollection;
+ origins_ = origins;
+ appcache_service->GetAllAppCacheInfo(
+ appcache_info_, &appcache_got_info_callback_);
+ // OnGotAppCacheInfo will quit the message loop.
+ MessageLoop::current()->Run();
+}
+
+void AppCacheTestHelper::OnGotAppCacheInfo(int rv) {
+ typedef std::map<GURL, AppCacheInfoVector> InfoByOrigin;
+
+ origins_->clear();
+ for (InfoByOrigin::const_iterator origin =
+ appcache_info_->infos_by_origin.begin();
+ origin != appcache_info_->infos_by_origin.end(); ++origin) {
+ origins_->insert(origin->first);
+ }
+ MessageLoop::current()->Quit();
+}
+
+} // namespace appcache
« no previous file with comments | « webkit/appcache/appcache_test_helper.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698