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

Unified Diff: chrome/browser/history/download_database.h

Issue 13044019: Clean up entries left by crashes in the DownloadDB. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 9 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
Index: chrome/browser/history/download_database.h
diff --git a/chrome/browser/history/download_database.h b/chrome/browser/history/download_database.h
index d8ceda9c3e014dcae6eae2969c2c9f44cea99cd1..8aaec99fd971305c22f9a74de1740136089f1042 100644
--- a/chrome/browser/history/download_database.h
+++ b/chrome/browser/history/download_database.h
@@ -8,6 +8,7 @@
#include <string>
#include <vector>
+#include "base/memory/weak_ptr.h"
#include "base/threading/platform_thread.h"
#include "sql/meta_table.h"
@@ -22,6 +23,24 @@ struct DownloadRow;
// Maintains a table of downloads.
class DownloadDatabase {
public:
+ // Visible outside of download_database.cc only for testing.
+ static const int kStateInvalid;
+ static const int kStateInProgress;
+ static const int kStateComplete;
+ static const int kStateCancelled;
+ static const int kStateBug140687;
+ static const int kStateInterrupted;
+
+ static const int kDangerTypeInvalid;
+ static const int kDangerTypeNotDangerous;
+ static const int kDangerTypeDangerousFile;
+ static const int kDangerTypeDangerousUrl;
+ static const int kDangerTypeDangerousContent;
+ static const int kDangerTypeMaybeDangerousContent;
+ static const int kDangerTypeUncommonContent;
+ static const int kDangerTypeUserValidated;
+ static const int kDangerTypeDangerousHost;
+
// The value of |db_handle| indicating that the associated DownloadItem is not
// yet persisted.
static const int64 kUninitializedHandle;
@@ -41,12 +60,6 @@ class DownloadDatabase {
// to select the row in the database table to update.
bool UpdateDownload(const DownloadRow& data);
- // Fixes state of the download entries. Sometimes entries with IN_PROGRESS
- // state are not updated during browser shutdown (particularly when crashing).
- // On the next start such entries are considered canceled. This functions
- // fixes such entries.
- bool CleanUpInProgressEntries();
-
// Create a new database entry for one download and return its primary db id.
int64 CreateDownload(const DownloadRow& info);
@@ -79,6 +92,13 @@ class DownloadDatabase {
bool DropDownloadTable();
private:
+ // Fixes state of the download entries. Sometimes entries with IN_PROGRESS
+ // state are not updated during browser shutdown (particularly when crashing).
+ // On the next start such entries are considered interrupted with
+ // interrupt reason |DOWNLOAD_INTERRUPT_REASON_CRASH|. This functions
+ // fixes such entries.
+ void CleanUpInProgressEntries();
+
bool EnsureColumnExists(const std::string& name, const std::string& type);
bool owning_thread_set_;
@@ -87,6 +107,8 @@ class DownloadDatabase {
int next_id_;
int next_db_handle_;
+ base::WeakPtrFactory<DownloadDatabase> weak_ptr_factory_;
+
DISALLOW_COPY_AND_ASSIGN(DownloadDatabase);
};
« no previous file with comments | « no previous file | chrome/browser/history/download_database.cc » ('j') | chrome/browser/history/download_database.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698