#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "chrome/browser/devtools/devtools_file_system_indexer.h"
#include <stddef.h>
#include <iterator>
#include <memory>
#include <set>
#include "base/check_op.h"
#include "base/containers/heap_array.h"
#include "base/files/file_enumerator.h"
#include "base/files/file_util.h"
#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/lazy_instance.h"
#include "base/ranges/algorithm.h"
#include "base/sequence_checker.h"
#include "base/stl_util.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "base/task/lazy_thread_pool_task_runner.h"
#include "content/public/browser/browser_thread.h"
FileEnumerator;
FilePath;
Time;
TimeTicks;
BrowserThread;
map;
string;
vector;
namespace {
set;
base::SequencedTaskRunner* impl_task_runner() { … }
Trigram;
TrigramChar;
FileId;
const int kMinTimeoutBetweenWorkedNotification = …;
const size_t kTrigramCharacterCount = …;
const size_t kTrigramCount = …;
const int kMaxReadLength = …;
const TrigramChar kUndefinedTrigramChar = …;
const TrigramChar kBinaryTrigramChar = …;
const Trigram kUndefinedTrigram = …;
class Index { … };
base::LazyInstance<Index>::Leaky g_trigram_index = …;
TrigramChar TrigramCharForChar(char c) { … }
Trigram TrigramAtIndex(const vector<TrigramChar>& trigram_chars, size_t index) { … }
Index::Index() : … { … }
void Index::Reset() { … }
void Index::EnsureInitialized() { … }
Time Index::LastModifiedTimeForFile(const FilePath& file_path) { … }
void Index::SetTrigramsForFile(const FilePath& file_path,
const vector<Trigram>& index,
const Time& time) { … }
vector<FilePath> Index::Search(const string& query) { … }
FileId Index::GetFileId(const FilePath& file_path) { … }
void Index::NormalizeVectors() { … }
}
DevToolsFileSystemIndexer::FileSystemIndexingJob::FileSystemIndexingJob(
const FilePath& file_system_path,
const std::vector<base::FilePath>& excluded_folders,
TotalWorkCallback total_work_callback,
const WorkedCallback& worked_callback,
DoneCallback done_callback)
: … { … }
DevToolsFileSystemIndexer::FileSystemIndexingJob::~FileSystemIndexingJob() { … }
void DevToolsFileSystemIndexer::FileSystemIndexingJob::Start() { … }
void DevToolsFileSystemIndexer::FileSystemIndexingJob::Stop() { … }
void DevToolsFileSystemIndexer::FileSystemIndexingJob::StopOnImplSequence() { … }
void DevToolsFileSystemIndexer::FileSystemIndexingJob::CollectFilesToIndex() { … }
void DevToolsFileSystemIndexer::FileSystemIndexingJob::IndexFiles() { … }
void DevToolsFileSystemIndexer::FileSystemIndexingJob::ReadFromFile() { … }
void DevToolsFileSystemIndexer::FileSystemIndexingJob::FinishFileIndexing(
bool success) { … }
void DevToolsFileSystemIndexer::FileSystemIndexingJob::CloseFile() { … }
void DevToolsFileSystemIndexer::FileSystemIndexingJob::ReportWorked() { … }
static int g_instance_count = …;
DevToolsFileSystemIndexer::DevToolsFileSystemIndexer() { … }
DevToolsFileSystemIndexer::~DevToolsFileSystemIndexer() { … }
scoped_refptr<DevToolsFileSystemIndexer::FileSystemIndexingJob>
DevToolsFileSystemIndexer::IndexPath(
const string& file_system_path,
const vector<string>& excluded_folders,
TotalWorkCallback total_work_callback,
const WorkedCallback& worked_callback,
DoneCallback done_callback) { … }
void DevToolsFileSystemIndexer::SearchInPath(
const std::string& file_system_path,
const std::string& query,
SearchCallback callback) { … }
void DevToolsFileSystemIndexer::SearchInPathOnImplSequence(
const std::string& file_system_path,
const std::string& query,
SearchCallback callback) { … }