summaryrefslogtreecommitdiffstats
path: root/chrome/browser/safe_browsing/safe_browsing_database.cc
diff options
context:
space:
mode:
authorshess@chromium.org <shess@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-02-09 05:07:36 +0000
committershess@chromium.org <shess@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-02-09 05:07:36 +0000
commite50a2e4d677028164412d668f18e642f4a39215c (patch)
treec7f717a5f2bd90fd1f301f82de73f8af7f3dfb9e /chrome/browser/safe_browsing/safe_browsing_database.cc
parent2fbc7b441de7865fa24b2b886fbe04aae2999747 (diff)
downloadchromium_src-e50a2e4d677028164412d668f18e642f4a39215c.zip
chromium_src-e50a2e4d677028164412d668f18e642f4a39215c.tar.gz
chromium_src-e50a2e4d677028164412d668f18e642f4a39215c.tar.bz2
Don't update safe-browsing database if no updates come down.
For simplicity, the safe-browsing database code ran the full update cycle on every update. A significant number of updates make no changes to the database, in which case re-writing it is cost with no benefit. BUG=72216 TEST=unit test. Review URL: http://codereview.chromium.org/6250211 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@74248 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/safe_browsing/safe_browsing_database.cc')
-rw-r--r--chrome/browser/safe_browsing/safe_browsing_database.cc11
1 files changed, 9 insertions, 2 deletions
diff --git a/chrome/browser/safe_browsing/safe_browsing_database.cc b/chrome/browser/safe_browsing/safe_browsing_database.cc
index e717655..16e4c55 100644
--- a/chrome/browser/safe_browsing/safe_browsing_database.cc
+++ b/chrome/browser/safe_browsing/safe_browsing_database.cc
@@ -566,6 +566,8 @@ void SafeBrowsingDatabaseNew::InsertChunks(const std::string& list_name,
SafeBrowsingStore* store = GetStore(list_id);
if (!store) return;
+ change_detected_ = true;
+
store->BeginChunk();
if (chunks.front().is_add) {
InsertAddChunks(list_id, chunks);
@@ -590,6 +592,8 @@ void SafeBrowsingDatabaseNew::DeleteChunks(
SafeBrowsingStore* store = GetStore(list_id);
if (!store) return;
+ change_detected_ = true;
+
for (size_t i = 0; i < chunk_deletes.size(); ++i) {
std::vector<int> chunk_numbers;
RangesToChunks(chunk_deletes[i].chunk_del, &chunk_numbers);
@@ -677,6 +681,7 @@ bool SafeBrowsingDatabaseNew::UpdateStarted(
}
corruption_detected_ = false;
+ change_detected_ = false;
return true;
}
@@ -685,8 +690,10 @@ void SafeBrowsingDatabaseNew::UpdateFinished(bool update_succeeded) {
if (corruption_detected_)
return;
- // Unroll any partially-received transaction.
- if (!update_succeeded) {
+ // Unroll the transaction if there was a protocol error or if the
+ // transaction was empty. This will leave the bloom filter, the
+ // pending hashes, and the prefix miss cache in place.
+ if (!update_succeeded || !change_detected_) {
browse_store_->CancelUpdate();
if (download_store_.get())
download_store_->CancelUpdate();