diff options
author | paulg@google.com <paulg@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-10-13 21:03:51 +0000 |
---|---|---|
committer | paulg@google.com <paulg@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-10-13 21:03:51 +0000 |
commit | 9b167cf9f2a2ae2ba555969e474c8b59c13c23b4 (patch) | |
tree | eba629ff70a126a507f3e1fe9cb82a1a7a642030 /chrome/browser/safe_browsing | |
parent | 3b0a45e85c70e42e208780433c84ddd99e672053 (diff) | |
download | chromium_src-9b167cf9f2a2ae2ba555969e474c8b59c13c23b4.zip chromium_src-9b167cf9f2a2ae2ba555969e474c8b59c13c23b4.tar.gz chromium_src-9b167cf9f2a2ae2ba555969e474c8b59c13c23b4.tar.bz2 |
Minor code clean up.
Review URL: http://codereview.chromium.org/7271
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@3314 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/safe_browsing')
-rw-r--r-- | chrome/browser/safe_browsing/safe_browsing_database_bloom.cc | 8 | ||||
-rw-r--r-- | chrome/browser/safe_browsing/safe_browsing_database_unittest.cc | 5 |
2 files changed, 9 insertions, 4 deletions
diff --git a/chrome/browser/safe_browsing/safe_browsing_database_bloom.cc b/chrome/browser/safe_browsing/safe_browsing_database_bloom.cc index ff8244f..3da1d25 100644 --- a/chrome/browser/safe_browsing/safe_browsing_database_bloom.cc +++ b/chrome/browser/safe_browsing/safe_browsing_database_bloom.cc @@ -310,6 +310,7 @@ void SafeBrowsingDatabaseBloom::InsertChunks(const std::string& list_name, std::deque<SBChunk>::iterator i = chunks->begin(); for (; i != chunks->end(); ++i) { SBChunk& chunk = (*i); + chunk.list_id = list_id; std::deque<SBChunkHost>::iterator j = chunk.hosts.begin(); for (; j != chunk.hosts.end(); ++j) { j->entry->set_list_id(list_id); @@ -333,8 +334,7 @@ void SafeBrowsingDatabaseBloom::ProcessChunks() { while (!pending_chunks_.empty()) { std::deque<SBChunk>* chunks = pending_chunks_.front(); - // The entries in one chunk are all either adds or subs. - if (chunks->front().hosts.front().entry->IsAdd()) { + if (chunks->front().is_add) { ProcessAddChunks(chunks); } else { ProcessSubChunks(chunks); @@ -351,7 +351,7 @@ void SafeBrowsingDatabaseBloom::ProcessChunks() { void SafeBrowsingDatabaseBloom::ProcessAddChunks(std::deque<SBChunk>* chunks) { while (!chunks->empty()) { SBChunk& chunk = chunks->front(); - int list_id = chunk.hosts.front().entry->list_id(); + int list_id = chunk.list_id; int chunk_id = chunk.chunk_number; // The server can give us a chunk that we already have because it's part of @@ -511,7 +511,7 @@ void SafeBrowsingDatabaseBloom::CreateChunkCaches() { void SafeBrowsingDatabaseBloom::ProcessSubChunks(std::deque<SBChunk>* chunks) { while (!chunks->empty()) { SBChunk& chunk = chunks->front(); - int list_id = chunk.hosts.front().entry->list_id(); + int list_id = chunk.list_id; int chunk_id = chunk.chunk_number; if (!ChunkExists(list_id, SUB_CHUNK, chunk_id)) { diff --git a/chrome/browser/safe_browsing/safe_browsing_database_unittest.cc b/chrome/browser/safe_browsing/safe_browsing_database_unittest.cc index 9074e0b..21de75a 100644 --- a/chrome/browser/safe_browsing/safe_browsing_database_unittest.cc +++ b/chrome/browser/safe_browsing/safe_browsing_database_unittest.cc @@ -370,6 +370,7 @@ TEST(SafeBrowsingDatabase, ZeroSizeChunk) { chunks->push_back(chunk); database->InsertChunks("goog-malware", chunks); + database->UpdateFinished(); // Add an empty ADD and SUB chunk. std::vector<SBListChunkRanges> list_chunks_empty; @@ -387,6 +388,7 @@ TEST(SafeBrowsingDatabase, ZeroSizeChunk) { empty_chunk.is_add = false; chunks->push_back(empty_chunk); database->InsertChunks("goog-malware", chunks); + database->UpdateFinished(); list_chunks_empty.clear(); database->GetListsInfo(&list_chunks_empty); @@ -422,6 +424,7 @@ TEST(SafeBrowsingDatabase, ZeroSizeChunk) { chunks->push_back(empty_chunk); database->InsertChunks("goog-malware", chunks); + database->UpdateFinished(); const Time now = Time::Now(); std::vector<SBFullHashResult> full_hashes; @@ -441,12 +444,14 @@ TEST(SafeBrowsingDatabase, ZeroSizeChunk) { // Handle AddDel and SubDel commands for empty chunks. AddDelChunk(database, "goog-malware", 21); + database->UpdateFinished(); list_chunks_empty.clear(); database->GetListsInfo(&list_chunks_empty); EXPECT_EQ(list_chunks_empty[0].adds, "1,10,19-20,22"); EXPECT_EQ(list_chunks_empty[0].subs, "7"); SubDelChunk(database, "goog-malware", 7); + database->UpdateFinished(); list_chunks_empty.clear(); database->GetListsInfo(&list_chunks_empty); EXPECT_EQ(list_chunks_empty[0].adds, "1,10,19-20,22"); |