OLD | NEW |
| (Empty) |
1 // Copyright (c) 2012 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 CHROME_BROWSER_CHROMEOS_DRIVE_FILE_SYSTEM_DRIVE_OPERATIONS_H_ | |
6 #define CHROME_BROWSER_CHROMEOS_DRIVE_FILE_SYSTEM_DRIVE_OPERATIONS_H_ | |
7 | |
8 #include "base/memory/scoped_ptr.h" | |
9 #include "chrome/browser/chromeos/drive/file_system_interface.h" | |
10 | |
11 namespace base { | |
12 class FilePath; | |
13 class SequencedTaskRunner; | |
14 class Time; | |
15 } // namespace base | |
16 | |
17 namespace google_apis { | |
18 class DriveServiceInterface; | |
19 } // namespace google_apis | |
20 | |
21 namespace drive { | |
22 | |
23 class JobScheduler; | |
24 | |
25 namespace internal { | |
26 class FileCache; | |
27 class ResourceMetadata; | |
28 } // namespace internal | |
29 | |
30 namespace file_system { | |
31 | |
32 class CopyOperation; | |
33 class CreateDirectoryOperation; | |
34 class CreateFileOperation; | |
35 class MoveOperation; | |
36 class OperationObserver; | |
37 class RemoveOperation; | |
38 class SearchOperation; | |
39 class TouchOperation; | |
40 class UpdateOperation; | |
41 | |
42 // Callback for DriveOperations::Search. | |
43 // On success, |error| is FILE_ERROR_OK, and remaining arguments are valid to | |
44 // use. | |
45 // |next_feed| is the URL to fetch the remaining result from the server. Maybe | |
46 // empty if there is no more results. | |
47 // On error, |error| is set to other than FILE_ERROR_OK, and the caller | |
48 // shouldn't use remaining arguments. | |
49 typedef base::Callback<void(FileError error, | |
50 const GURL& next_feed, | |
51 scoped_ptr<std::vector<SearchResultInfo> > result)> | |
52 SearchOperationCallback; | |
53 | |
54 // Passes notifications from Drive operations back to the file system. | |
55 class DriveOperations { | |
56 public: | |
57 DriveOperations(); | |
58 ~DriveOperations(); | |
59 | |
60 // Allocates the operation objects and initializes the operation pointers. | |
61 void Init(OperationObserver* observer, | |
62 JobScheduler* scheduler, | |
63 internal::ResourceMetadata* metadata, | |
64 internal::FileCache* cache, | |
65 FileSystemInterface* file_system, | |
66 google_apis::DriveServiceInterface* drive_service, | |
67 base::SequencedTaskRunner* blocking_task_runner); | |
68 | |
69 // Wrapper function for create_directory_operation_. | |
70 // |callback| must not be null. | |
71 void CreateDirectory(const base::FilePath& directory_path, | |
72 bool is_exclusive, | |
73 bool is_recursive, | |
74 const FileOperationCallback& callback); | |
75 | |
76 // Wrapper function for create_file_operation_. | |
77 // |callback| must not be null. | |
78 void CreateFile(const base::FilePath& remote_file_path, | |
79 bool is_exclusive, | |
80 const FileOperationCallback& callback); | |
81 | |
82 // Wrapper function for copy_operation_. | |
83 // |callback| must not be null. | |
84 void Copy(const base::FilePath& src_file_path, | |
85 const base::FilePath& dest_file_path, | |
86 const FileOperationCallback& callback); | |
87 | |
88 // Wrapper function for copy_operation_. | |
89 // |callback| must not be null. | |
90 void TransferFileFromRemoteToLocal(const base::FilePath& remote_src_file_path, | |
91 const base::FilePath& local_dest_file_path, | |
92 const FileOperationCallback& callback); | |
93 | |
94 // Wrapper function for copy_operation_. | |
95 // |callback| must not be null. | |
96 void TransferFileFromLocalToRemote( | |
97 const base::FilePath& local_src_file_path, | |
98 const base::FilePath& remote_dest_file_path, | |
99 const FileOperationCallback& callback); | |
100 | |
101 // Wrapper function for move_operation_. | |
102 // |callback| must not be null. | |
103 void Move(const base::FilePath& src_file_path, | |
104 const base::FilePath& dest_file_path, | |
105 const FileOperationCallback& callback); | |
106 | |
107 // Wrapper function for remove_operation_. | |
108 // |callback| must not be null. | |
109 void Remove(const base::FilePath& file_path, | |
110 bool is_recursive, | |
111 const FileOperationCallback& callback); | |
112 | |
113 // Wrapper function for touch_operation_. | |
114 // |callback| must not be null. | |
115 void TouchFile(const base::FilePath& file_path, | |
116 const base::Time& last_access_time, | |
117 const base::Time& last_modified_time, | |
118 const FileOperationCallback& callback); | |
119 | |
120 // Wrapper function for update_operation_. | |
121 // |callback| must not be null. | |
122 void UpdateFileByResourceId(const std::string& resource_id, | |
123 DriveClientContext context, | |
124 const FileOperationCallback& callback); | |
125 | |
126 // Wrapper function for search_operation_. | |
127 // |callback| must not be null. | |
128 void Search(const std::string& search_query, | |
129 const GURL& next_feed, | |
130 const SearchOperationCallback& callback); | |
131 | |
132 private: | |
133 scoped_ptr<CopyOperation> copy_operation_; | |
134 scoped_ptr<CreateDirectoryOperation> create_directory_operation_; | |
135 scoped_ptr<CreateFileOperation> create_file_operation_; | |
136 scoped_ptr<MoveOperation> move_operation_; | |
137 scoped_ptr<RemoveOperation> remove_operation_; | |
138 scoped_ptr<TouchOperation> touch_operation_; | |
139 scoped_ptr<UpdateOperation> update_operation_; | |
140 scoped_ptr<SearchOperation> search_operation_; | |
141 }; | |
142 | |
143 } // namespace file_system | |
144 } // namespace drive | |
145 | |
146 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_FILE_SYSTEM_DRIVE_OPERATIONS_H_ | |
OLD | NEW |