#include "components/history/core/browser/download_database.h"
#include <inttypes.h>
#include <limits>
#include <memory>
#include <string>
#include <vector>
#include "base/containers/contains.h"
#include "base/debug/alias.h"
#include "base/files/file_path.h"
#include "base/metrics/histogram_macros.h"
#include "base/rand_util.h"
#include "base/strings/strcat.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "base/time/time.h"
#include "build/build_config.h"
#include "components/history/core/browser/download_constants.h"
#include "components/history/core/browser/download_row.h"
#include "components/history/core/browser/download_slice_info.h"
#include "components/history/core/browser/history_types.h"
#include "sql/statement.h"
namespace history {
namespace {
#define DOWNLOADS_TABLE …
#define DOWNLOADS_SLICES_TABLE …
enum DroppedReason { … };
#if BUILDFLAG(IS_POSIX) || BUILDFLAG(IS_FUCHSIA)
void BindFilePath(sql::Statement& statement,
const base::FilePath& path,
int col) { … }
base::FilePath ColumnFilePath(sql::Statement& statement, int col) { … }
#else
void BindFilePath(sql::Statement& statement,
const base::FilePath& path,
int col) {
statement.BindString(col, path.AsUTF8Unsafe());
}
base::FilePath ColumnFilePath(sql::Statement& statement, int col) {
return base::FilePath::FromUTF8Unsafe(statement.ColumnString(col));
}
#endif
}
DownloadDatabase::DownloadDatabase(
DownloadInterruptReason download_interrupt_reason_none,
DownloadInterruptReason download_interrupt_reason_crash)
: … { … }
DownloadDatabase::~DownloadDatabase() { … }
bool DownloadDatabase::EnsureColumnExists(const std::string& name,
const std::string& type) { … }
bool DownloadDatabase::EnsureColumnExistsInTable(const std::string& table,
const std::string& name,
const std::string& type) { … }
bool DownloadDatabase::MigrateMimeType() { … }
bool DownloadDatabase::MigrateDownloadsState() { … }
bool DownloadDatabase::MigrateDownloadsReasonPathsAndDangerType() { … }
bool DownloadDatabase::MigrateReferrer() { … }
bool DownloadDatabase::MigrateDownloadedByExtension() { … }
bool DownloadDatabase::MigrateDownloadValidators() { … }
bool DownloadDatabase::MigrateHashHttpMethodAndGenerateGuids() { … }
bool DownloadDatabase::MigrateDownloadTabUrl() { … }
bool DownloadDatabase::MigrateDownloadSiteInstanceUrl() { … }
bool DownloadDatabase::MigrateEmbedderDownloadData() { … }
bool DownloadDatabase::MigrateDownloadLastAccessTime() { … }
bool DownloadDatabase::MigrateDownloadTransient() { … }
bool DownloadDatabase::MigrateDownloadSliceFinished() { … }
bool DownloadDatabase::MigrateDownloadByWebApp() { … }
bool DownloadDatabase::InitDownloadTable() { … }
uint32_t DownloadDatabase::GetNextDownloadId() { … }
bool DownloadDatabase::DropDownloadTable() { … }
void DownloadDatabase::QueryDownloads(std::vector<DownloadRow>* results) { … }
bool DownloadDatabase::UpdateDownload(const DownloadRow& data) { … }
void DownloadDatabase::EnsureInProgressEntriesCleanedUp() { … }
bool DownloadDatabase::CreateDownload(const DownloadRow& info) { … }
void DownloadDatabase::RemoveDownload(DownloadId id) { … }
void DownloadDatabase::RemoveDownloadURLs(DownloadId id) { … }
size_t DownloadDatabase::CountDownloads() { … }
bool DownloadDatabase::CreateOrUpdateDownloadSlice(
const DownloadSliceInfo& info) { … }
void DownloadDatabase::RemoveDownloadSlices(DownloadId id) { … }
void DownloadDatabase::QueryDownloadSlices(DownloadRowMap* download_row_map) { … }
}