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

Unified Diff: chrome/browser/browsing_data_remover_unittest.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: More cleanup. 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 | « no previous file | chrome/browser/extensions/extension_service_unittest.cc » ('j') | chrome/test/appcache_util.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/browsing_data_remover_unittest.cc
diff --git a/chrome/browser/browsing_data_remover_unittest.cc b/chrome/browser/browsing_data_remover_unittest.cc
index 489efa7b6de50399fcae10489a15108ebeca9c01..b6e181c9005c58c04729658efdc3d0d17f379dd6 100644
--- a/chrome/browser/browsing_data_remover_unittest.cc
+++ b/chrome/browser/browsing_data_remover_unittest.cc
@@ -10,12 +10,10 @@
#include "base/platform_file.h"
#include "chrome/browser/extensions/mock_extension_special_storage_policy.h"
#include "chrome/browser/history/history.h"
+#include "chrome/test/appcache_util.h"
#include "chrome/test/testing_profile.h"
#include "content/browser/appcache/chrome_appcache_service.h"
#include "testing/gtest/include/gtest/gtest.h"
-#include "webkit/appcache/appcache.h"
-#include "webkit/appcache/appcache_group.h"
-#include "webkit/appcache/appcache_storage.h"
#include "webkit/fileapi/file_system_context.h"
#include "webkit/fileapi/file_system_operation_context.h"
#include "webkit/fileapi/file_system_file_util.h"
@@ -166,92 +164,6 @@ class RemoveFileSystemTester : public BrowsingDataRemoverTester {
DISALLOW_COPY_AND_ASSIGN(RemoveFileSystemTester);
};
-// Helper class for injecting data into AppCacheStorage.
-class AppCacheInserter : public appcache::AppCacheStorage::Delegate {
- public:
- AppCacheInserter()
- : group_id_(0),
- appcache_id_(0),
- response_id_(0) {}
- virtual ~AppCacheInserter() {}
-
- virtual void OnGroupAndNewestCacheStored(
- appcache::AppCacheGroup* /*group*/,
- appcache::AppCache* /*newest_cache*/,
- bool success,
- bool /*would_exceed_quota*/) {
- ASSERT_TRUE(success);
- MessageLoop::current()->Quit();
- }
-
- void AddGroupAndCache(ChromeAppCacheService* appcache_service,
- const GURL& manifest_url) {
- appcache::AppCacheGroup* appcache_group =
- new appcache::AppCacheGroup(appcache_service,
- manifest_url,
- ++group_id_);
- appcache::AppCache* appcache = new appcache::AppCache(appcache_service,
- ++appcache_id_);
- appcache::AppCacheEntry entry(appcache::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();
- }
-
- private:
- int group_id_;
- int appcache_id_;
- int response_id_;
-
- DISALLOW_COPY_AND_ASSIGN(AppCacheInserter);
-};
-
-// Helper class for reading appcaches.
-class AppCacheReader {
- public:
- explicit AppCacheReader(ChromeAppCacheService* appcache_service)
- : appcache_service_(appcache_service),
- ALLOW_THIS_IN_INITIALIZER_LIST(appcache_got_info_callback_(
- this, &AppCacheReader::OnGotAppCacheInfo)) {
- }
-
- std::set<GURL>* ReadAppCaches() {
- appcache_info_ = new appcache::AppCacheInfoCollection;
- appcache_service_->GetAllAppCacheInfo(
- appcache_info_, &appcache_got_info_callback_);
-
- MessageLoop::current()->Run();
- return &origins_;
- }
-
- private:
- void OnGotAppCacheInfo(int rv) {
- typedef std::map<GURL, appcache::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();
- }
-
- scoped_refptr<ChromeAppCacheService> appcache_service_;
- net::CompletionCallbackImpl<AppCacheReader>
- appcache_got_info_callback_;
- scoped_refptr<appcache::AppCacheInfoCollection> appcache_info_;
- std::set<GURL> origins_;
-
- DISALLOW_COPY_AND_ASSIGN(AppCacheReader);
-};
-
class BrowsingDataRemoverTest : public testing::Test {
public:
BrowsingDataRemoverTest()
@@ -374,8 +286,7 @@ TEST_F(BrowsingDataRemoverTest, RemoveAppCacheForever) {
&ChromeAppCacheService::InitializeOnIOThread,
FilePath(),
resource_context,
- mock_policy,
- false));
+ mock_policy));
MessageLoop::current()->RunAllPending();
TestingProfile* profile = GetProfile();
profile->SetAppCacheService(appcache_service);
« no previous file with comments | « no previous file | chrome/browser/extensions/extension_service_unittest.cc » ('j') | chrome/test/appcache_util.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698