blob: 5137db8e8bfee4c869c0a385e0d86f6ecea322db [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"
17
Robbie McElrathb0acd132019-02-05 18:11:3718namespace network {
19class NetworkConnectionTracker;
20}
21
Sergei Datsenko3554b9e42018-12-18 05:49:1122namespace drivefs {
23
24// Handles search queries to DriveFS.
25class COMPONENT_EXPORT(DRIVEFS) DriveFsSearch {
26 public:
Robbie McElrathb0acd132019-02-05 18:11:3727 DriveFsSearch(mojom::DriveFs* drivefs,
28 network::NetworkConnectionTracker* network_connection_tracker,
29 const base::Clock* clock);
Sergei Datsenko3554b9e42018-12-18 05:49:1130 ~DriveFsSearch();
31
32 // Starts DriveFs search query and returns whether it will be
33 // performed localy or remotely. Assumes DriveFS to be mounted.
34 mojom::QueryParameters::QuerySource PerformSearch(
35 mojom::QueryParametersPtr query,
36 mojom::SearchQuery::GetNextPageCallback callback);
37
38 private:
39 void OnSearchDriveFs(
40 drivefs::mojom::SearchQueryPtr search,
41 drivefs::mojom::QueryParametersPtr query,
42 mojom::SearchQuery::GetNextPageCallback callback,
43 drive::FileError error,
44 base::Optional<std::vector<drivefs::mojom::QueryItemPtr>> items);
45
46 mojom::DriveFs* const drivefs_;
Robbie McElrathb0acd132019-02-05 18:11:3747 network::NetworkConnectionTracker* const network_connection_tracker_;
Sergei Datsenko3554b9e42018-12-18 05:49:1148 const base::Clock* const clock_;
49 base::Time last_shared_with_me_response_;
50
51 base::WeakPtrFactory<DriveFsSearch> weak_ptr_factory_;
52 DISALLOW_COPY_AND_ASSIGN(DriveFsSearch);
53};
54
55} // namespace drivefs
56
57#endif // CHROMEOS_COMPONENTS_DRIVEFS_DRIVEFS_SEARCH_H_