| Index: chrome/browser/history/download_database.h
|
| diff --git a/chrome/browser/history/download_database.h b/chrome/browser/history/download_database.h
|
| index 533af26729663b97579264139b2818f528dba8b0..afb5fd0a4642500f65cf838ab8735b30db121daf 100644
|
| --- a/chrome/browser/history/download_database.h
|
| +++ b/chrome/browser/history/download_database.h
|
| @@ -8,7 +8,9 @@
|
| #include <string>
|
| #include <vector>
|
|
|
| +#include "base/gtest_prod_util.h"
|
| #include "base/threading/platform_thread.h"
|
| +#include "content/public/browser/download_item.h"
|
| #include "sql/meta_table.h"
|
|
|
| namespace sql {
|
| @@ -41,12 +43,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,16 +75,59 @@ class DownloadDatabase {
|
| bool DropDownloadTable();
|
|
|
| private:
|
| + FRIEND_TEST_ALL_PREFIXES(
|
| + HistoryBackendDBTest, ConfirmDownloadInProgressCleanup);
|
| +
|
| + // Values used in the database for DownloadItem::State.
|
| + static const int kStateInvalid;
|
| + static const int kStateInProgress;
|
| + static const int kStateComplete;
|
| + static const int kStateCancelled;
|
| + static const int kStateBug140687;
|
| + static const int kStateInterrupted;
|
| +
|
| + // Values used in the database for DownloadItem::DangerType
|
| + 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;
|
| +
|
| + // 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 function
|
| + // fixes such entries.
|
| + void EnsureInProgressEntriesCleanedUp();
|
| +
|
| bool EnsureColumnExists(const std::string& name, const std::string& type);
|
|
|
| void RemoveDownloadURLs(int64 handle);
|
|
|
| + // Utility functions for conversion between DownloadItem types
|
| + // and DownloadDatabase constants.
|
| + static int StateToInt(content::DownloadItem::DownloadState state);
|
| + static content::DownloadItem::DownloadState IntToState(int state);
|
| + static int DangerTypeToInt(content::DownloadDangerType danger_type);
|
| + static content::DownloadDangerType IntToDangerType(int danger_type);
|
| +
|
| bool owning_thread_set_;
|
| base::PlatformThreadId owning_thread_;
|
|
|
| int next_id_;
|
| int next_db_handle_;
|
|
|
| + // Initialized to false on construction, and checked in all functional
|
| + // routines post-migration in the database for a possible call to
|
| + // CleanUpInProgressEntries(). This allows us to avoid
|
| + // doing the cleanup until after any DB migration and unless we are
|
| + // actually use the downloads database.
|
| + bool in_progress_entry_cleanup_completed_;
|
| +
|
| DISALLOW_COPY_AND_ASSIGN(DownloadDatabase);
|
| };
|
|
|
|
|