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

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: Review. 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
« no previous file with comments | « no previous file | net/extras/sqlite/sqlite_channel_id_store.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..54467014ac1eab92eeb30f9cbec62e47821ad3ae 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
Ryan Sleevi 2015/04/21 15:16:17 s/channel ids/channel IDs/
Ryan Sleevi 2015/04/21 15:16:17 Single spaces following periods (beyond being the
rohitrao (ping after 24h) 2015/04/21 16:09:53 Fixed elsewhere in the file too.
rohitrao (ping after 24h) 2015/04/21 16:09:53 Sigh =)
+ // 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"));
+ store_->AddChannelID(net::DefaultChannelIDStore::ChannelID(
+ "persistent.com", base::Time::FromInternalValue(7),
+ base::Time::FromInternalValue(8), "g", "h"));
+
+ // Now close the store, and the nonpersistent.com certs should be deleted
Ryan Sleevi 2015/04/21 15:16:17 s/certs/channel IDs/
rohitrao (ping after 24h) 2015/04/21 16:09:53 Changed everywhere in the file.
+ // 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 nonpersistent.com certs have been removed.
Ryan Sleevi 2015/04/21 15:16:17 s/certs/channel IDs/
rohitrao (ping after 24h) 2015/04/21 16:09:53 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') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698