blob: 6e487d6b70a6e2f57469ba099e6461ae6cc608b6 [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
5#ifndef CHROMEOS_COMPONENTS_DRIVEFS_DRIVEFS_SEARCH_H_
6#define CHROMEOS_COMPONENTS_DRIVEFS_DRIVEFS_SEARCH_H_
7
8#include <memory>
9#include <string>
10#include <vector>
11
12#include "base/component_export.h"
13#include "base/macros.h"
14#include "base/memory/weak_ptr.h"
15#include "base/time/clock.h"
16#include "chromeos/components/drivefs/mojom/drivefs.mojom.h"
Henrique Ferreiro3279d132019-10-15 12:29:5717#include "mojo/public/cpp/bindings/remote.h"
Sergei Datsenko3554b9e42018-12-18 05:49:1118
Robbie McElrathb0acd132019-02-05 18:11:3719namespace network {
20class NetworkConnectionTracker;
21}
22
Sergei Datsenko3554b9e42018-12-18 05:49:1123namespace drivefs {
24
25// Handles search queries to DriveFS.
26class COMPONENT_EXPORT(DRIVEFS) DriveFsSearch {
27 public:
Robbie McElrathb0acd132019-02-05 18:11:3728 DriveFsSearch(mojom::DriveFs* drivefs,
29 network::NetworkConnectionTracker* network_connection_tracker,
30 const base::Clock* clock);
Sergei Datsenko3554b9e42018-12-18 05:49:1131 ~DriveFsSearch();
32
33 // Starts DriveFs search query and returns whether it will be
34 // performed localy or remotely. Assumes DriveFS to be mounted.
35 mojom::QueryParameters::QuerySource PerformSearch(
36 mojom::QueryParametersPtr query,
37 mojom::SearchQuery::GetNextPageCallback callback);
38
39 private:
40 void OnSearchDriveFs(
Henrique Ferreiro3279d132019-10-15 12:29:5741 mojo::Remote<drivefs::mojom::SearchQuery> search,
Sergei Datsenko3554b9e42018-12-18 05:49:1142 drivefs::mojom::QueryParametersPtr query,
43 mojom::SearchQuery::GetNextPageCallback callback,
44 drive::FileError error,
Anton Bikineeva55469fa2021-05-15 18:01:4545 absl::optional<std::vector<drivefs::mojom::QueryItemPtr>> items);
Sergei Datsenko3554b9e42018-12-18 05:49:1146
47 mojom::DriveFs* const drivefs_;
Robbie McElrathb0acd132019-02-05 18:11:3748 network::NetworkConnectionTracker* const network_connection_tracker_;
Sergei Datsenko3554b9e42018-12-18 05:49:1149 const base::Clock* const clock_;
50 base::Time last_shared_with_me_response_;
51
Jeremy Roman47d432e2019-08-20 14:24:0052 base::WeakPtrFactory<DriveFsSearch> weak_ptr_factory_{this};
Sergei Datsenko3554b9e42018-12-18 05:49:1153 DISALLOW_COPY_AND_ASSIGN(DriveFsSearch);
54};
55
56} // namespace drivefs
57
58#endif // CHROMEOS_COMPONENTS_DRIVEFS_DRIVEFS_SEARCH_H_