Sergei Datsenko | 3554b9e4 | 2018-12-18 05:49:11 | [diff] [blame] | 1 | // 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 Ferreiro | 3279d13 | 2019-10-15 12:29:57 | [diff] [blame] | 17 | #include "mojo/public/cpp/bindings/remote.h" |
Sergei Datsenko | 3554b9e4 | 2018-12-18 05:49:11 | [diff] [blame] | 18 | |
Robbie McElrath | b0acd13 | 2019-02-05 18:11:37 | [diff] [blame] | 19 | namespace network { |
| 20 | class NetworkConnectionTracker; |
| 21 | } |
| 22 | |
Sergei Datsenko | 3554b9e4 | 2018-12-18 05:49:11 | [diff] [blame] | 23 | namespace drivefs { |
| 24 | |
| 25 | // Handles search queries to DriveFS. |
| 26 | class COMPONENT_EXPORT(DRIVEFS) DriveFsSearch { |
| 27 | public: |
Robbie McElrath | b0acd13 | 2019-02-05 18:11:37 | [diff] [blame] | 28 | DriveFsSearch(mojom::DriveFs* drivefs, |
| 29 | network::NetworkConnectionTracker* network_connection_tracker, |
| 30 | const base::Clock* clock); |
Sergei Datsenko | 3554b9e4 | 2018-12-18 05:49:11 | [diff] [blame] | 31 | ~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 Ferreiro | 3279d13 | 2019-10-15 12:29:57 | [diff] [blame] | 41 | mojo::Remote<drivefs::mojom::SearchQuery> search, |
Sergei Datsenko | 3554b9e4 | 2018-12-18 05:49:11 | [diff] [blame] | 42 | drivefs::mojom::QueryParametersPtr query, |
| 43 | mojom::SearchQuery::GetNextPageCallback callback, |
| 44 | drive::FileError error, |
Anton Bikineev | a55469fa | 2021-05-15 18:01:45 | [diff] [blame] | 45 | absl::optional<std::vector<drivefs::mojom::QueryItemPtr>> items); |
Sergei Datsenko | 3554b9e4 | 2018-12-18 05:49:11 | [diff] [blame] | 46 | |
| 47 | mojom::DriveFs* const drivefs_; |
Robbie McElrath | b0acd13 | 2019-02-05 18:11:37 | [diff] [blame] | 48 | network::NetworkConnectionTracker* const network_connection_tracker_; |
Sergei Datsenko | 3554b9e4 | 2018-12-18 05:49:11 | [diff] [blame] | 49 | const base::Clock* const clock_; |
| 50 | base::Time last_shared_with_me_response_; |
| 51 | |
Jeremy Roman | 47d432e | 2019-08-20 14:24:00 | [diff] [blame] | 52 | base::WeakPtrFactory<DriveFsSearch> weak_ptr_factory_{this}; |
Sergei Datsenko | 3554b9e4 | 2018-12-18 05:49:11 | [diff] [blame] | 53 | DISALLOW_COPY_AND_ASSIGN(DriveFsSearch); |
| 54 | }; |
| 55 | |
| 56 | } // namespace drivefs |
| 57 | |
| 58 | #endif // CHROMEOS_COMPONENTS_DRIVEFS_DRIVEFS_SEARCH_H_ |