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

Unified Diff: chrome/browser/net/quota_policy_channel_id_store_unittest.cc

Issue 1015233002: Fixes a bug where QuotaPolicyChannelIDStore would ignore some deletes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: DCHECK. Created 5 years, 8 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
Index: chrome/browser/net/quota_policy_channel_id_store_unittest.cc
diff --git a/chrome/browser/net/quota_policy_channel_id_store_unittest.cc b/chrome/browser/net/quota_policy_channel_id_store_unittest.cc
index f82f6e477208dc28045e815d36e481fec71d7321..e805df2015f32fc5c68d866c56489eeb599a85a6 100644
--- a/chrome/browser/net/quota_policy_channel_id_store_unittest.cc
+++ b/chrome/browser/net/quota_policy_channel_id_store_unittest.cc
@@ -160,7 +160,7 @@ TEST_F(QuotaPolicyChannelIDStoreTest, TestPersistence) {
// Test if data is stored as expected in the QuotaPolicy database.
TEST_F(QuotaPolicyChannelIDStoreTest, TestPolicy) {
store_->AddChannelID(
- net::DefaultChannelIDStore::ChannelID("foo.com",
+ net::DefaultChannelIDStore::ChannelID("nonpersistent.com",
base::Time::FromInternalValue(3),
base::Time::FromInternalValue(4),
"c",
@@ -173,11 +173,11 @@ TEST_F(QuotaPolicyChannelIDStoreTest, TestPolicy) {
store_ = NULL;
// Make sure we wait until the destructor has run.
base::RunLoop().RunUntilIdle();
- // Specify storage policy that makes "foo.com" session only.
+ // Specify storage policy that makes "nonpersistent.com" session only.
scoped_refptr<content::MockSpecialStoragePolicy> storage_policy =
new content::MockSpecialStoragePolicy();
storage_policy->AddSessionOnly(
- net::cookie_util::CookieOriginToURL("foo.com", true));
+ net::cookie_util::CookieOriginToURL("nonpersistent.com", true));
// Reload store, it should still have both channel ids.
store_ = new QuotaPolicyChannelIDStore(
temp_dir_.path().Append(kTestChannelIDFilename),
@@ -186,7 +186,20 @@ TEST_F(QuotaPolicyChannelIDStoreTest, TestPolicy) {
Load(&channel_ids);
ASSERT_EQ(2U, channel_ids.size());
- // Now close the store, and "foo.com" should be deleted according to policy.
+ // Add another two channel ids before closing the store. Because additions
+ // are delayed and committed to disk in batches, these will not be committed
+ // until the store is destroyed, which is after the policy is applied. The
+ // pending operation pruning logic should prevent the "nonpersistent.com" ID
+ // from being committed to disk.
+ store_->AddChannelID(net::DefaultChannelIDStore::ChannelID(
+ "nonpersistent.com", base::Time::FromInternalValue(5),
+ base::Time::FromInternalValue(6), "e", "f"));
Ryan Sleevi 2015/04/06 18:46:55 I'm not actually sure that this is valid / consist
rohitrao (ping after 24h) 2015/04/06 19:48:24 Ah, ok. I don't actually know what channel ids ar
+ store_->AddChannelID(net::DefaultChannelIDStore::ChannelID(
+ "persistent.com", base::Time::FromInternalValue(7),
+ base::Time::FromInternalValue(8), "g", "h"));
+
+ // Now close the store, and the session-only IDs should be deleted according
+ // to policy.
store_ = NULL;
// Make sure we wait until the destructor has run.
base::RunLoop().RunUntilIdle();
@@ -196,8 +209,10 @@ TEST_F(QuotaPolicyChannelIDStoreTest, TestPolicy) {
base::MessageLoopProxy::current(),
NULL);
- // Reload and check that the "foo.com" cert has been removed.
+ // Reload and check that the proper IDs have been removed.
mef 2015/04/06 20:17:44 maybe say 'proper (nonpersistent.com)'?
rohitrao (ping after 24h) 2015/04/07 14:21:37 Done.
Load(&channel_ids);
- ASSERT_EQ(1U, channel_ids.size());
- ASSERT_EQ("google.com", channel_ids[0]->server_identifier());
+ ASSERT_EQ(2U, channel_ids.size());
+ for (const auto& id : channel_ids) {
+ ASSERT_NE("nonpersistent.com", id->server_identifier());
+ }
}
« no previous file with comments | « no previous file | net/extras/sqlite/sqlite_channel_id_store.cc » ('j') | net/extras/sqlite/sqlite_channel_id_store.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698