#include "chrome/browser/download/download_query.h"
#include <stdint.h>
#include <algorithm>
#include <limits>
#include <memory>
#include <string>
#include <vector>
#include "base/check_op.h"
#include "base/files/file_path.h"
#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/i18n/case_conversion.h"
#include "base/i18n/string_search.h"
#include "base/i18n/time_formatting.h"
#include "base/memory/raw_ref.h"
#include "base/notreached.h"
#include "base/strings/string_split.h"
#include "base/strings/utf_string_conversions.h"
#include "base/time/time.h"
#include "base/values.h"
#include "components/download/public/common/download_item.h"
#include "components/url_formatter/url_formatter.h"
#include "content/public/browser/content_browser_client.h"
#include "third_party/re2/src/re2/re2.h"
#include "url/gurl.h"
DownloadDangerType;
DownloadItem;
namespace {
template <typename T> bool GetAs(const base::Value& in, T* out);
template<> bool GetAs(const base::Value& in, bool* out) { … }
template <>
bool GetAs(const base::Value& in, double* out) { … }
template<> bool GetAs(const base::Value& in, std::string* out) { … }
template <>
bool GetAs(const base::Value& in, std::u16string* out) { … }
template <>
bool GetAs(const base::Value& in, std::vector<std::u16string>* out) { … }
int64_t GetStartTimeMsEpoch(const DownloadItem& item) { … }
int64_t GetEndTimeMsEpoch(const DownloadItem& item) { … }
std::string GetStartTime(const DownloadItem& item) { … }
std::string GetEndTime(const DownloadItem& item) { … }
bool GetDangerAccepted(const DownloadItem& item) { … }
bool GetExists(const DownloadItem& item) { … }
std::u16string GetFilename(const DownloadItem& item) { … }
std::string GetFilenameUTF8(const DownloadItem& item) { … }
std::string GetOriginalUrl(const DownloadItem& item) { … }
std::string GetUrl(const DownloadItem& item) { … }
DownloadItem::DownloadState GetState(const DownloadItem& item) { … }
DownloadDangerType GetDangerType(const DownloadItem& item) { … }
double GetReceivedBytes(const DownloadItem& item) { … }
double GetTotalBytes(const DownloadItem& item) { … }
std::string GetMimeType(const DownloadItem& item) { … }
bool IsPaused(const DownloadItem& item) { … }
enum ComparisonType { … };
template <typename ValueType>
bool FieldMatches(
const ValueType& value,
ComparisonType cmptype,
const base::RepeatingCallback<ValueType(const DownloadItem&)>& accessor,
const DownloadItem& item) { … }
template <typename ValueType> DownloadQuery::FilterCallback BuildFilter(
const base::Value& value, ComparisonType cmptype,
ValueType (*accessor)(const DownloadItem&)) { … }
bool FindRegex(
RE2* pattern,
const base::RepeatingCallback<std::string(const DownloadItem&)>& accessor,
const DownloadItem& item) { … }
DownloadQuery::FilterCallback BuildRegexFilter(
const base::Value& regex_value,
std::string (*accessor)(const DownloadItem&)) { … }
template <typename ValueType>
ComparisonType Compare(
const base::RepeatingCallback<ValueType(const DownloadItem&)>& accessor,
const DownloadItem& left,
const DownloadItem& right) { … }
}
struct DownloadQuery::Sorter { … };
class DownloadQuery::DownloadComparator { … };
bool DownloadQuery::DownloadComparator::operator()(const DownloadItem* left,
const DownloadItem* right) { … }
bool DownloadQuery::MatchesQuery(const std::vector<std::u16string>& query_terms,
const DownloadItem& item) { … }
DownloadQuery::DownloadQuery() : … { … }
DownloadQuery::~DownloadQuery() { … }
bool DownloadQuery::AddFilter(const DownloadQuery::FilterCallback& value) { … }
void DownloadQuery::AddFilter(DownloadItem::DownloadState state) { … }
void DownloadQuery::AddFilter(DownloadDangerType danger) { … }
bool DownloadQuery::AddFilter(DownloadQuery::FilterType type,
const base::Value& value) { … }
bool DownloadQuery::Matches(const DownloadItem& item) const { … }
void DownloadQuery::AddSorter(DownloadQuery::SortType type,
DownloadQuery::SortDirection direction) { … }
void DownloadQuery::FinishSearch(DownloadQuery::DownloadVector* results) const { … }