blob: 2185d84658616c76dadd543c832be171b0266e88 [file] [log] [blame]
Sergei Datsenko3554b9e42018-12-18 05:49:111// Copyright 2018 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
Henrique Ferreiro197812962022-08-22 23:51:105#ifndef CHROMEOS_ASH_COMPONENTS_DRIVEFS_DRIVEFS_SEARCH_H_
6#define CHROMEOS_ASH_COMPONENTS_DRIVEFS_DRIVEFS_SEARCH_H_
Sergei Datsenko3554b9e42018-12-18 05:49:117
8#include <memory>
9#include <string>
10#include <vector>
11
12#include "base/component_export.h"
Sergei Datsenko3554b9e42018-12-18 05:49:1113#include "base/memory/weak_ptr.h"
14#include "base/time/clock.h"
Gabriel Charetted87f10f2022-03-31 00:44:2215#include "base/time/time.h"
Henrique Ferreiro197812962022-08-22 23:51:1016#include "chromeos/ash/components/drivefs/mojom/drivefs.mojom.h"
Henrique Ferreiro3279d132019-10-15 12:29:5717#include "mojo/public/cpp/bindings/remote.h"
Lei Zhang698df03c2021-05-21 04:23:3418#include "third_party/abseil-cpp/absl/types/optional.h"
Sergei Datsenko3554b9e42018-12-18 05:49:1119
Robbie McElrathb0acd132019-02-05 18:11:3720namespace network {
21class NetworkConnectionTracker;
22}
23
Sergei Datsenko3554b9e42018-12-18 05:49:1124namespace drivefs {
25
26// Handles search queries to DriveFS.
Henrique Ferreiro197812962022-08-22 23:51:1027class COMPONENT_EXPORT(CHROMEOS_ASH_COMPONENTS_DRIVEFS) DriveFsSearch {
Sergei Datsenko3554b9e42018-12-18 05:49:1128 public:
Robbie McElrathb0acd132019-02-05 18:11:3729 DriveFsSearch(mojom::DriveFs* drivefs,
30 network::NetworkConnectionTracker* network_connection_tracker,
31 const base::Clock* clock);
Peter Boströmec31a042021-09-16 23:37:3432
33 DriveFsSearch(const DriveFsSearch&) = delete;
34 DriveFsSearch& operator=(const DriveFsSearch&) = delete;
35
Sergei Datsenko3554b9e42018-12-18 05:49:1136 ~DriveFsSearch();
37
38 // Starts DriveFs search query and returns whether it will be
39 // performed localy or remotely. Assumes DriveFS to be mounted.
40 mojom::QueryParameters::QuerySource PerformSearch(
41 mojom::QueryParametersPtr query,
42 mojom::SearchQuery::GetNextPageCallback callback);
43
44 private:
45 void OnSearchDriveFs(
Henrique Ferreiro3279d132019-10-15 12:29:5746 mojo::Remote<drivefs::mojom::SearchQuery> search,
Sergei Datsenko3554b9e42018-12-18 05:49:1147 drivefs::mojom::QueryParametersPtr query,
48 mojom::SearchQuery::GetNextPageCallback callback,
49 drive::FileError error,
Anton Bikineeva55469fa2021-05-15 18:01:4550 absl::optional<std::vector<drivefs::mojom::QueryItemPtr>> items);
Sergei Datsenko3554b9e42018-12-18 05:49:1151
52 mojom::DriveFs* const drivefs_;
Robbie McElrathb0acd132019-02-05 18:11:3753 network::NetworkConnectionTracker* const network_connection_tracker_;
Sergei Datsenko3554b9e42018-12-18 05:49:1154 const base::Clock* const clock_;
55 base::Time last_shared_with_me_response_;
56
Jeremy Roman47d432e2019-08-20 14:24:0057 base::WeakPtrFactory<DriveFsSearch> weak_ptr_factory_{this};
Sergei Datsenko3554b9e42018-12-18 05:49:1158};
59
60} // namespace drivefs
61
Henrique Ferreiro197812962022-08-22 23:51:1062#endif // CHROMEOS_ASH_COMPONENTS_DRIVEFS_DRIVEFS_SEARCH_H_