#include "components/omnibox/browser/history_fuzzy_provider.h"
#include <functional>
#include <memory>
#include <ostream>
#include <queue>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>
#include "base/check.h"
#include "base/containers/contains.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/scoped_refptr.h"
#include "base/metrics/histogram_functions.h"
#include "base/metrics/histogram_macros.h"
#include "base/not_fatal_until.h"
#include "base/strings/utf_string_conversions.h"
#include "base/system/sys_info.h"
#include "base/time/time.h"
#include "base/trace_event/memory_usage_estimator.h"
#include "base/trace_event/trace_event.h"
#include "build/build_config.h"
#include "components/history/core/browser/history_database.h"
#include "components/history/core/browser/history_db_task.h"
#include "components/history/core/browser/history_service.h"
#include "components/history/core/browser/url_database.h"
#include "components/omnibox/browser/autocomplete_match_classification.h"
#include "components/omnibox/browser/autocomplete_match_type.h"
#include "components/omnibox/browser/autocomplete_provider_client.h"
#include "components/omnibox/browser/bookmark_provider.h"
#include "components/omnibox/browser/history_quick_provider.h"
#include "components/omnibox/browser/omnibox_field_trial.h"
#include "components/omnibox/browser/omnibox_triggered_feature_service.h"
#include "components/url_formatter/elide_url.h"
#include "third_party/metrics_proto/omnibox_event.pb.h"
#include "third_party/metrics_proto/omnibox_focus_type.pb.h"
#include "url/gurl.h"
namespace {
const char kMetricMatchConversionHistoryQuick[] = …;
const char kMetricMatchConversionBookmark[] = …;
const char kMetricSearchDuration[] = …;
const char kMetricPrecision[] = …;
constexpr int kMaxTerminalCount = …;
std::u16string UrlDomainReduction(const GURL& url) { … }
std::u16string ReduceInputTextForMatching(const std::u16string& input) { … }
}
namespace fuzzy {
Edit::Edit(Kind kind, size_t at, char16_t new_char)
: … { … }
void Edit::ApplyTo(std::u16string& text) const { … }
Correction Correction::WithEdit(Edit edit) const { … }
void Correction::ApplyTo(std::u16string& text) const { … }
Node::Node() = default;
Node::Node(Node&&) = default;
Node::~Node() = default;
void Node::Insert(const std::u16string& text, size_t text_index) { … }
void Node::Delete(const std::u16string& text, size_t text_index) { … }
void Node::Clear() { … }
bool Node::FindCorrections(const std::u16string& text,
ToleranceSchedule tolerance_schedule,
std::vector<Correction>& corrections) const { … }
size_t Node::EstimateMemoryUsage() const { … }
int Node::TerminalCount() const { … }
class LoadSignificantUrls : public history::HistoryDBTask { … };
}
void HistoryFuzzyProvider::RecordOpenMatchMetrics(
const AutocompleteResult& result,
const AutocompleteMatch& match_opened) { … }
HistoryFuzzyProvider::HistoryFuzzyProvider(AutocompleteProviderClient* client)
: … { … }
void HistoryFuzzyProvider::Start(const AutocompleteInput& input,
bool minimal_changes) { … }
size_t HistoryFuzzyProvider::EstimateMemoryUsage() const { … }
HistoryFuzzyProvider::~HistoryFuzzyProvider() = default;
void HistoryFuzzyProvider::DoAutocomplete() { … }
int HistoryFuzzyProvider::AddConvertedMatches(const ACMatches& matches,
int penalty) { … }
void HistoryFuzzyProvider::OnUrlsLoaded(fuzzy::Node node) { … }
void HistoryFuzzyProvider::OnURLVisited(
history::HistoryService* history_service,
const history::URLRow& url_row,
const history::VisitRow& new_visit) { … }
void HistoryFuzzyProvider::OnHistoryDeletions(
history::HistoryService* history_service,
const history::DeletionInfo& deletion_info) { … }
void HistoryFuzzyProvider::RecordMatchConversion(const char* name, int count) { … }