Check USB device path access when prompting users to select a device.
[chromium-blink-merge.git] / chrome / browser / chromeos / drive / file_system / search_operation.h
blobaa2e5f70b2e2f44ce9ca53b798076089f498ebf8
1 // Copyright 2013 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.
5 #ifndef CHROME_BROWSER_CHROMEOS_DRIVE_FILE_SYSTEM_SEARCH_OPERATION_H_
6 #define CHROME_BROWSER_CHROMEOS_DRIVE_FILE_SYSTEM_SEARCH_OPERATION_H_
8 #include "base/basictypes.h"
9 #include "base/memory/ref_counted.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "base/memory/weak_ptr.h"
12 #include "chrome/browser/chromeos/drive/file_errors.h"
13 #include "chrome/browser/chromeos/drive/file_system_interface.h"
14 #include "google_apis/drive/drive_api_error_codes.h"
16 namespace base {
17 class SequencedTaskRunner;
18 } // namespace base
20 namespace google_apis {
21 class FileList;
22 } // namespace google_apis
24 namespace drive {
26 class JobScheduler;
28 namespace internal {
29 class LoaderController;
30 class ResourceMetadata;
31 } // namespace internal
33 namespace file_system {
35 // This class encapsulates the drive Search function. It is responsible for
36 // sending the request to the drive API.
37 class SearchOperation {
38 public:
39 SearchOperation(base::SequencedTaskRunner* blocking_task_runner,
40 JobScheduler* scheduler,
41 internal::ResourceMetadata* metadata,
42 internal::LoaderController* loader_controller);
43 ~SearchOperation();
45 // Performs server side content search operation for |search_query|. If
46 // |next_link| is set, this is the search result url that will be fetched.
47 // Upon completion, |callback| will be called with the result. This is
48 // implementation of FileSystemInterface::Search() method.
50 // |callback| must not be null.
51 void Search(const std::string& search_query,
52 const GURL& next_link,
53 const SearchCallback& callback);
55 private:
56 // Part of Search(), called after the FileList is fetched from the server.
57 void SearchAfterGetFileList(
58 const SearchCallback& callback,
59 google_apis::DriveApiErrorCode gdata_error,
60 scoped_ptr<google_apis::FileList> file_list);
62 // Part of Search(), called after |result| is filled on the blocking pool.
63 void SearchAfterResolveSearchResult(
64 const SearchCallback& callback,
65 const GURL& next_link,
66 scoped_ptr<std::vector<SearchResultInfo> > result,
67 FileError error);
69 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_;
70 JobScheduler* scheduler_;
71 internal::ResourceMetadata* metadata_;
72 internal::LoaderController* loader_controller_;
74 // Note: This should remain the last member so it'll be destroyed and
75 // invalidate the weak pointers before any other members are destroyed.
76 base::WeakPtrFactory<SearchOperation> weak_ptr_factory_;
77 DISALLOW_COPY_AND_ASSIGN(SearchOperation);
80 } // namespace file_system
81 } // namespace drive
83 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_FILE_SYSTEM_SEARCH_OPERATION_H_