Make sure we end the update process if we get an errorfrom the servers. Previously, if we got a 400 (or other)error response, we'd leave the database and transactionopen.BUG=5060 (http://crbug.com/5060)
Review URL: http://codereview.chromium.org/12918

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@6337 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/chrome/browser/safe_browsing/safe_browsing_service.cc b/chrome/browser/safe_browsing/safe_browsing_service.cc
index 3a6fff3..d60f4092 100644
--- a/chrome/browser/safe_browsing/safe_browsing_service.cc
+++ b/chrome/browser/safe_browsing/safe_browsing_service.cc
@@ -32,7 +32,8 @@
       protocol_manager_(NULL),
       enabled_(false),
       resetting_(false),
-      database_loaded_(false) {
+      database_loaded_(false),
+      update_in_progress_(false) {
   new_safe_browsing_ = !CommandLine().HasSwitch(switches::kUseOldSafeBrowsing);
 }
 
@@ -469,9 +470,11 @@
   delete check;
 }
 
-void SafeBrowsingService::GetAllChunks() {
+void SafeBrowsingService::UpdateStarted() {
   DCHECK(MessageLoop::current() == io_loop_);
   DCHECK(enabled_);
+  DCHECK(!update_in_progress_);
+  update_in_progress_ = true;
   db_thread_->message_loop()->PostTask(FROM_HERE, NewRunnableMethod(
       this, &SafeBrowsingService::GetAllChunksFromDatabase));
 }
@@ -479,8 +482,11 @@
 void SafeBrowsingService::UpdateFinished(bool update_succeeded) {
   DCHECK(MessageLoop::current() == io_loop_);
   DCHECK(enabled_);
-  db_thread_->message_loop()->PostTask(FROM_HERE, NewRunnableMethod(
-      this, &SafeBrowsingService::DatabaseUpdateFinished, update_succeeded));
+  if (update_in_progress_) {
+    update_in_progress_ = false;
+    db_thread_->message_loop()->PostTask(FROM_HERE, NewRunnableMethod(
+        this, &SafeBrowsingService::DatabaseUpdateFinished, update_succeeded));
+  }
 }
 
 void SafeBrowsingService::DatabaseUpdateFinished(bool update_succeeded) {