Update devtools_file_system_indexer

* Switch DevToolsFileSystemIndexer to use SequencedTaskRunner
  https://chromium-review.googlesource.com/c/chromium/src/+/545200
* Remove dead code from devtools_file_system_indexer.cc
  https://codereview.chromium.org/2508443002
* Fix DCHECKs and a crash in DevToolsFileSystemIndexer
  https://chromium-review.googlesource.com/c/chromium/src/+/553958
* reset trigram cache when devtools window closes
  https://chromium-review.googlesource.com/c/chromium/src/+/969969
* Directly use base::File instead of FileProxy in DevToolsFileSystemIndexer
  https://chromium-review.googlesource.com/c/chromium/src/+/544793
This commit is contained in:
deepak1556 2018-04-08 21:18:51 +05:30 committed by Samuel Attard
parent deb8cd458d
commit f32e59d4b2
2 changed files with 99 additions and 102 deletions

View file

@ -13,7 +13,7 @@
#include <vector>
#include "base/callback.h"
#include "base/files/file_proxy.h"
#include "base/files/file.h"
#include "base/macros.h"
#include "base/memory/ref_counted.h"
@ -23,10 +23,6 @@ class FileEnumerator;
class Time;
} // namespace base
namespace content {
class WebContents;
}
namespace brightray {
class DevToolsFileSystemIndexer
@ -37,12 +33,13 @@ class DevToolsFileSystemIndexer
typedef base::Callback<void()> DoneCallback;
typedef base::Callback<void(const std::vector<std::string>&)> SearchCallback;
class FileSystemIndexingJob : public base::RefCounted<FileSystemIndexingJob> {
class FileSystemIndexingJob
: public base::RefCountedThreadSafe<FileSystemIndexingJob> {
public:
void Stop();
private:
friend class base::RefCounted<FileSystemIndexingJob>;
friend class base::RefCountedThreadSafe<FileSystemIndexingJob>;
friend class DevToolsFileSystemIndexer;
FileSystemIndexingJob(const base::FilePath& file_system_path,
const TotalWorkCallback& total_work_callback,
@ -51,15 +48,13 @@ class DevToolsFileSystemIndexer
virtual ~FileSystemIndexingJob();
void Start();
void StopOnFileThread();
void StopOnImplSequence();
void CollectFilesToIndex();
void IndexFiles();
void StartFileIndexing(base::File::Error error);
void ReadFromFile();
void OnRead(base::File::Error error, const char* data, int bytes_read);
void FinishFileIndexing(bool success);
void CloseFile();
void CloseCallback(base::File::Error error);
void ReportWorked();
base::FilePath file_system_path_;
@ -70,7 +65,7 @@ class DevToolsFileSystemIndexer
typedef std::map<base::FilePath, base::Time> FilePathTimesMap;
FilePathTimesMap file_path_times_;
FilePathTimesMap::const_iterator indexing_it_;
base::FileProxy current_file_;
base::File current_file_;
int64_t current_file_offset_;
typedef int32_t Trigram;
std::vector<Trigram> current_trigrams_;
@ -101,9 +96,9 @@ class DevToolsFileSystemIndexer
virtual ~DevToolsFileSystemIndexer();
void SearchInPathOnFileThread(const std::string& file_system_path,
const std::string& query,
const SearchCallback& callback);
void SearchInPathOnImplSequence(const std::string& file_system_path,
const std::string& query,
const SearchCallback& callback);
DISALLOW_COPY_AND_ASSIGN(DevToolsFileSystemIndexer);
};