blob: 44f0df0f2d72fa2ee7250732925d5536d25b91a7 [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
18namespace drivefs {
19
20// Handles search queries to DriveFS.
21class COMPONENT_EXPORT(DRIVEFS) DriveFsSearch {
22 public:
23 DriveFsSearch(mojom::DriveFs* drivefs, const base::Clock* clock);
24 ~DriveFsSearch();
25
26 // Starts DriveFs search query and returns whether it will be
27 // performed localy or remotely. Assumes DriveFS to be mounted.
28 mojom::QueryParameters::QuerySource PerformSearch(
29 mojom::QueryParametersPtr query,
30 mojom::SearchQuery::GetNextPageCallback callback);
31
32 private:
33 void OnSearchDriveFs(
34 drivefs::mojom::SearchQueryPtr search,
35 drivefs::mojom::QueryParametersPtr query,
36 mojom::SearchQuery::GetNextPageCallback callback,
37 drive::FileError error,
38 base::Optional<std::vector<drivefs::mojom::QueryItemPtr>> items);
39
40 mojom::DriveFs* const drivefs_;
41 const base::Clock* const clock_;
42 base::Time last_shared_with_me_response_;
43
44 base::WeakPtrFactory<DriveFsSearch> weak_ptr_factory_;
45 DISALLOW_COPY_AND_ASSIGN(DriveFsSearch);
46};
47
48} // namespace drivefs
49
50#endif // CHROMEOS_COMPONENTS_DRIVEFS_DRIVEFS_SEARCH_H_