diff options
author | shess@chromium.org <shess@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-03-18 20:41:06 +0000 |
---|---|---|
committer | shess@chromium.org <shess@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-03-18 20:41:06 +0000 |
commit | 2b7dea8f59e2517df1cd8bfba3dd90ce260dafc3 (patch) | |
tree | 90ae9fe84421fc07b14a3bec97c7edf178592824 /chrome/browser/safe_browsing/safe_browsing_store_unittest.cc | |
parent | 139c51038197965b0e010a1b4496829a6828310f (diff) | |
download | chromium_src-2b7dea8f59e2517df1cd8bfba3dd90ce260dafc3.zip chromium_src-2b7dea8f59e2517df1cd8bfba3dd90ce260dafc3.tar.gz chromium_src-2b7dea8f59e2517df1cd8bfba3dd90ce260dafc3.tar.bz2 |
Incremental PrefixSet builder for Safe Browsing store.
Incremental update of the database file implies incrementally building
the PrefixSet. Refactor the code to that end, taking advantage of the
change to get rid of the copy converting from SBAddPrefix to SBPrefix.
Change SBAddPrefix ordering to prefix-primary to remove the need to re-sort
things and get some bake time on the reordering.
BUG=351448
Review URL: https://codereview.chromium.org/200633002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@257735 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/safe_browsing/safe_browsing_store_unittest.cc')
-rw-r--r-- | chrome/browser/safe_browsing/safe_browsing_store_unittest.cc | 52 |
1 files changed, 27 insertions, 25 deletions
diff --git a/chrome/browser/safe_browsing/safe_browsing_store_unittest.cc b/chrome/browser/safe_browsing/safe_browsing_store_unittest.cc index 9ccb0e1..199138e 100644 --- a/chrome/browser/safe_browsing/safe_browsing_store_unittest.cc +++ b/chrome/browser/safe_browsing/safe_browsing_store_unittest.cc @@ -9,13 +9,15 @@ namespace { TEST(SafeBrowsingStoreTest, SBAddPrefixLess) { - // chunk_id then prefix. + // prefix dominates. + EXPECT_TRUE(SBAddPrefixLess(SBAddPrefix(11, 1), SBAddPrefix(10, 2))); + EXPECT_FALSE(SBAddPrefixLess(SBAddPrefix(10, 2), SBAddPrefix(11, 1))); + + // After prefix, chunk_id. EXPECT_TRUE(SBAddPrefixLess(SBAddPrefix(10, 1), SBAddPrefix(11, 1))); EXPECT_FALSE(SBAddPrefixLess(SBAddPrefix(11, 1), SBAddPrefix(10, 1))); - EXPECT_TRUE(SBAddPrefixLess(SBAddPrefix(10, 1), SBAddPrefix(10, 2))); - EXPECT_FALSE(SBAddPrefixLess(SBAddPrefix(10, 2), SBAddPrefix(10, 1))); - // Equal is not less. + // Equal is not less-than. EXPECT_FALSE(SBAddPrefixLess(SBAddPrefix(10, 1), SBAddPrefix(10, 1))); } @@ -36,19 +38,19 @@ TEST(SafeBrowsingStoreTest, SBAddPrefixHashLess) { const base::Time now = base::Time::Now(); - // add_id dominates. - EXPECT_TRUE(SBAddPrefixHashLess(SBAddFullHash(10, now, two), - SBAddFullHash(11, now, one))); + // prefix dominates. + EXPECT_TRUE(SBAddPrefixHashLess(SBAddFullHash(11, now, one), + SBAddFullHash(10, now, two))); EXPECT_FALSE(SBAddPrefixHashLess(SBAddFullHash(11, now, two), SBAddFullHash(10, now, one))); - // After add_id, prefix. + // After prefix, add_id. EXPECT_TRUE(SBAddPrefixHashLess(SBAddFullHash(10, now, one), - SBAddFullHash(10, now, two))); - EXPECT_FALSE(SBAddPrefixHashLess(SBAddFullHash(10, now, two), - SBAddFullHash(10, now, one))); + SBAddFullHash(11, now, onetwo))); + EXPECT_FALSE(SBAddPrefixHashLess(SBAddFullHash(11, now, one), + SBAddFullHash(10, now, onetwo))); - // After prefix, full hash. + // After add_id, full hash. EXPECT_TRUE(SBAddPrefixHashLess(SBAddFullHash(10, now, one), SBAddFullHash(10, now, onetwo))); EXPECT_FALSE(SBAddPrefixHashLess(SBAddFullHash(10, now, onetwo), @@ -60,13 +62,13 @@ TEST(SafeBrowsingStoreTest, SBAddPrefixHashLess) { } TEST(SafeBrowsingStoreTest, SBSubPrefixLess) { - // add_id dominates. - EXPECT_TRUE(SBAddPrefixLess(SBSubPrefix(12, 10, 2), SBSubPrefix(9, 11, 1))); + // prefix dominates. + EXPECT_TRUE(SBAddPrefixLess(SBSubPrefix(12, 11, 1), SBSubPrefix(9, 10, 2))); EXPECT_FALSE(SBAddPrefixLess(SBSubPrefix(12, 11, 2), SBSubPrefix(9, 10, 1))); - // After add_id, prefix. - EXPECT_TRUE(SBAddPrefixLess(SBSubPrefix(12, 10, 1), SBSubPrefix(9, 10, 2))); - EXPECT_FALSE(SBAddPrefixLess(SBSubPrefix(12, 10, 2), SBSubPrefix(9, 10, 1))); + // After prefix, add_id. + EXPECT_TRUE(SBAddPrefixLess(SBSubPrefix(12, 9, 1), SBSubPrefix(9, 10, 1))); + EXPECT_FALSE(SBAddPrefixLess(SBSubPrefix(12, 10, 1), SBSubPrefix(9, 9, 1))); // Equal is not less-than. EXPECT_FALSE(SBAddPrefixLess(SBSubPrefix(12, 10, 1), SBSubPrefix(12, 10, 1))); @@ -85,19 +87,19 @@ TEST(SafeBrowsingStoreTest, SBSubFullHashLess) { onetwo.full_hash[sizeof(SBPrefix)] = 2; two.prefix = 2; - // add_id dominates. - EXPECT_TRUE(SBAddPrefixHashLess(SBSubFullHash(12, 10, two), - SBSubFullHash(9, 11, one))); + // prefix dominates. + EXPECT_TRUE(SBAddPrefixHashLess(SBSubFullHash(12, 11, one), + SBSubFullHash(9, 10, two))); EXPECT_FALSE(SBAddPrefixHashLess(SBSubFullHash(12, 11, two), SBSubFullHash(9, 10, one))); - // After add_id, prefix. + // After prefix, add_id. EXPECT_TRUE(SBAddPrefixHashLess(SBSubFullHash(12, 10, one), - SBSubFullHash(9, 10, two))); - EXPECT_FALSE(SBAddPrefixHashLess(SBSubFullHash(12, 10, two), - SBSubFullHash(9, 10, one))); + SBSubFullHash(9, 11, onetwo))); + EXPECT_FALSE(SBAddPrefixHashLess(SBSubFullHash(12, 11, one), + SBSubFullHash(9, 10, onetwo))); - // After prefix, full_hash. + // After add_id, full_hash. EXPECT_TRUE(SBAddPrefixHashLess(SBSubFullHash(12, 10, one), SBSubFullHash(9, 10, onetwo))); EXPECT_FALSE(SBAddPrefixHashLess(SBSubFullHash(12, 10, onetwo), |