Roll src/third_party/WebKit 9f7fb92:f103b33 (svn 202621:202622)
[chromium-blink-merge.git] / components / drive / file_system / search_operation.h
blob920c52b5ca94f1933c655f22c59c2a8c05152ff8
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 COMPONENTS_DRIVE_FILE_SYSTEM_SEARCH_OPERATION_H_
6 #define COMPONENTS_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 "base/threading/thread_checker.h"
13 #include "components/drive/file_errors.h"
14 #include "components/drive/file_system_interface.h"
15 #include "google_apis/drive/drive_api_error_codes.h"
17 namespace base {
18 class SequencedTaskRunner;
19 } // namespace base
21 namespace google_apis {
22 class FileList;
23 } // namespace google_apis
25 namespace drive {
27 class JobScheduler;
29 namespace internal {
30 class LoaderController;
31 class ResourceMetadata;
32 } // namespace internal
34 namespace file_system {
36 // This class encapsulates the drive Search function. It is responsible for
37 // sending the request to the drive API.
38 class SearchOperation {
39 public:
40 SearchOperation(base::SequencedTaskRunner* blocking_task_runner,
41 JobScheduler* scheduler,
42 internal::ResourceMetadata* metadata,
43 internal::LoaderController* loader_controller);
44 ~SearchOperation();
46 // Performs server side content search operation for |search_query|. If
47 // |next_link| is set, this is the search result url that will be fetched.
48 // Upon completion, |callback| will be called with the result. This is
49 // implementation of FileSystemInterface::Search() method.
51 // |callback| must not be null.
52 void Search(const std::string& search_query,
53 const GURL& next_link,
54 const SearchCallback& callback);
56 private:
57 // Part of Search(), called after the FileList is fetched from the server.
58 void SearchAfterGetFileList(
59 const SearchCallback& callback,
60 google_apis::DriveApiErrorCode gdata_error,
61 scoped_ptr<google_apis::FileList> file_list);
63 // Part of Search(), called after |result| is filled on the blocking pool.
64 void SearchAfterResolveSearchResult(
65 const SearchCallback& callback,
66 const GURL& next_link,
67 scoped_ptr<std::vector<SearchResultInfo> > result,
68 FileError error);
70 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_;
71 JobScheduler* scheduler_;
72 internal::ResourceMetadata* metadata_;
73 internal::LoaderController* loader_controller_;
75 base::ThreadChecker thread_checker_;
77 // Note: This should remain the last member so it'll be destroyed and
78 // invalidate the weak pointers before any other members are destroyed.
79 base::WeakPtrFactory<SearchOperation> weak_ptr_factory_;
80 DISALLOW_COPY_AND_ASSIGN(SearchOperation);
83 } // namespace file_system
84 } // namespace drive
86 #endif // COMPONENTS_DRIVE_FILE_SYSTEM_SEARCH_OPERATION_H_