#ifndef CHROME_BROWSER_ASH_FILEAPI_RECENT_DRIVE_SOURCE_H_
#define CHROME_BROWSER_ASH_FILEAPI_RECENT_DRIVE_SOURCE_H_
#include <memory>
#include <optional>
#include <vector>
#include "base/containers/id_map.h"
#include "base/files/file.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/weak_ptr.h"
#include "base/time/time.h"
#include "chrome/browser/ash/fileapi/recent_source.h"
#include "chromeos/ash/components/drivefs/mojom/drivefs.mojom.h"
#include "components/drive/file_errors.h"
#include "mojo/public/cpp/bindings/remote.h"
class Profile;
namespace ash {
class RecentFile;
class RecentDriveSource : public RecentSource {
public:
explicit RecentDriveSource(Profile* profile);
RecentDriveSource(const RecentDriveSource&) = delete;
RecentDriveSource& operator=(const RecentDriveSource&) = delete;
~RecentDriveSource() override;
void GetRecentFiles(const Params& params,
GetRecentFilesCallback callback) override;
std::vector<RecentFile> Stop(const int32_t call_id) override;
static std::vector<std::string> CreateTypeFilters(
RecentSource::FileType file_type);
private:
static const char kLoadHistogramName[];
struct CallContext {
explicit CallContext(GetRecentFilesCallback callback);
CallContext(CallContext&& callcontext);
~CallContext();
GetRecentFilesCallback callback;
base::TimeTicks build_start_time;
std::vector<RecentFile> files;
mojo::Remote<drivefs::mojom::SearchQuery> search_query;
};
void OnComplete(const int32_t call_id);
void GotSearchResults(
const Params& params,
drive::FileError error,
std::optional<std::vector<drivefs::mojom::QueryItemPtr>> results);
const raw_ptr<Profile> profile_;
base::IDMap<std::unique_ptr<CallContext>> context_map_;
base::WeakPtrFactory<RecentDriveSource> weak_ptr_factory_{this};
};
}
#endif