OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_CHROMEOS_GDATA_GDATA_FILE_SYSTEM_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_GDATA_GDATA_FILE_SYSTEM_H_ |
6 #define CHROME_BROWSER_CHROMEOS_GDATA_GDATA_FILE_SYSTEM_H_ | 6 #define CHROME_BROWSER_CHROMEOS_GDATA_GDATA_FILE_SYSTEM_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 scoped_ptr<GDataEntryProto> entry_proto); | 194 scoped_ptr<GDataEntryProto> entry_proto); |
195 | 195 |
196 // Initiates transfer of |local_file_path| with |resource_id| to | 196 // Initiates transfer of |local_file_path| with |resource_id| to |
197 // |remote_dest_file_path|. |local_file_path| must be a file from the local | 197 // |remote_dest_file_path|. |local_file_path| must be a file from the local |
198 // file system, |remote_dest_file_path| is the virtual destination path within | 198 // file system, |remote_dest_file_path| is the virtual destination path within |
199 // gdata file system. If |resource_id| is a non-empty string, the transfer is | 199 // gdata file system. If |resource_id| is a non-empty string, the transfer is |
200 // handled by CopyDocumentToDirectory. Otherwise, the transfer is handled by | 200 // handled by CopyDocumentToDirectory. Otherwise, the transfer is handled by |
201 // TransferRegularFile. | 201 // TransferRegularFile. |
202 // | 202 // |
203 // Must be called from *UI* thread. |callback| is run on the calling thread. | 203 // Must be called from *UI* thread. |callback| is run on the calling thread. |
| 204 // |callback| must not be null. |
204 void TransferFileForResourceId(const FilePath& local_file_path, | 205 void TransferFileForResourceId(const FilePath& local_file_path, |
205 const FilePath& remote_dest_file_path, | 206 const FilePath& remote_dest_file_path, |
206 const FileOperationCallback& callback, | 207 const FileOperationCallback& callback, |
207 std::string* resource_id); | 208 std::string* resource_id); |
208 | 209 |
209 // Initiates transfer of |local_file_path| to |remote_dest_file_path|. | 210 // Initiates transfer of |local_file_path| to |remote_dest_file_path|. |
210 // |local_file_path| must be a regular file (i.e. not a hosted document) from | 211 // |local_file_path| must be a regular file (i.e. not a hosted document) from |
211 // the local file system, |remote_dest_file_path| is the virtual destination | 212 // the local file system, |remote_dest_file_path| is the virtual destination |
212 // path within gdata file system. | 213 // path within gdata file system. |
213 // | 214 // |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
314 const FilePath& local_file_path, | 315 const FilePath& local_file_path, |
315 const std::string& unused_mime_type, | 316 const std::string& unused_mime_type, |
316 GDataFileType file_type); | 317 GDataFileType file_type); |
317 | 318 |
318 // Invoked upon completion of GetFileByPath initiated by | 319 // Invoked upon completion of GetFileByPath initiated by |
319 // TransferFileFromRemoteToLocal. If GetFileByPath reports no error, calls | 320 // TransferFileFromRemoteToLocal. If GetFileByPath reports no error, calls |
320 // CopyLocalFileOnBlockingPool to copy |local_file_path| to | 321 // CopyLocalFileOnBlockingPool to copy |local_file_path| to |
321 // |local_dest_file_path|. | 322 // |local_dest_file_path|. |
322 // | 323 // |
323 // Can be called from UI thread. |callback| is run on the calling thread. | 324 // Can be called from UI thread. |callback| is run on the calling thread. |
| 325 // |callback| must not be null. |
324 void OnGetFileCompleteForTransferFile(const FilePath& local_dest_file_path, | 326 void OnGetFileCompleteForTransferFile(const FilePath& local_dest_file_path, |
325 const FileOperationCallback& callback, | 327 const FileOperationCallback& callback, |
326 GDataFileError error, | 328 GDataFileError error, |
327 const FilePath& local_file_path, | 329 const FilePath& local_file_path, |
328 const std::string& unused_mime_type, | 330 const std::string& unused_mime_type, |
329 GDataFileType file_type); | 331 GDataFileType file_type); |
330 | 332 |
331 // Invoked upon completion of GetFileByPath initiated by OpenFile. If | 333 // Invoked upon completion of GetFileByPath initiated by OpenFile. If |
332 // GetFileByPath is successful, calls MarkDirtyInCache to mark the cache | 334 // GetFileByPath is successful, calls MarkDirtyInCache to mark the cache |
333 // file as dirty for the file identified by |file_info.resource_id| and | 335 // file as dirty for the file identified by |file_info.resource_id| and |
334 // |file_info.md5|. | 336 // |file_info.md5|. |
335 // | 337 // |
336 // Can be called from UI thread. |callback| is run on the calling thread. | 338 // Can be called from UI thread. |callback| is run on the calling thread. |
337 void OnGetFileCompleteForOpenFile( | 339 void OnGetFileCompleteForOpenFile( |
338 const OpenFileCallback& callback, | 340 const OpenFileCallback& callback, |
339 const GetFileCompleteForOpenParams& file_info, | 341 const GetFileCompleteForOpenParams& file_info, |
340 GDataFileError error, | 342 GDataFileError error, |
341 const FilePath& file_path, | 343 const FilePath& file_path, |
342 const std::string& mime_type, | 344 const std::string& mime_type, |
343 GDataFileType file_type); | 345 GDataFileType file_type); |
344 | 346 |
345 // Copies a document with |resource_id| to the directory at |dir_path| | 347 // Copies a document with |resource_id| to the directory at |dir_path| |
346 // and names the copied document as |new_name|. | 348 // and names the copied document as |new_name|. |
347 // | 349 // |
348 // Can be called from UI thread. |callback| is run on the calling thread. | 350 // Can be called from UI thread. |callback| is run on the calling thread. |
| 351 // |callback| must not be null. |
349 void CopyDocumentToDirectory(const FilePath& dir_path, | 352 void CopyDocumentToDirectory(const FilePath& dir_path, |
350 const std::string& resource_id, | 353 const std::string& resource_id, |
351 const FilePath::StringType& new_name, | 354 const FilePath::StringType& new_name, |
352 const FileOperationCallback& callback); | 355 const FileOperationCallback& callback); |
353 | 356 |
354 // Renames a file or directory at |file_path| to |new_name| in the same | 357 // Renames a file or directory at |file_path| to |new_name| in the same |
355 // directory. |callback| will receive the new file path if the operation is | 358 // directory. |callback| will receive the new file path if the operation is |
356 // successful. If the new name already exists in the same directory, the file | 359 // successful. If the new name already exists in the same directory, the file |
357 // name is uniquified by adding a parenthesized serial number like | 360 // name is uniquified by adding a parenthesized serial number like |
358 // "foo (2).txt" | 361 // "foo (2).txt" |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
405 // | 408 // |
406 // Must be called on UI thread. | 409 // Must be called on UI thread. |
407 void OnMarkDirtyInCacheCompleteForOpenFile( | 410 void OnMarkDirtyInCacheCompleteForOpenFile( |
408 const OpenFileCallback& callback, | 411 const OpenFileCallback& callback, |
409 GDataFileError error, | 412 GDataFileError error, |
410 const std::string& resource_id, | 413 const std::string& resource_id, |
411 const std::string& md5, | 414 const std::string& md5, |
412 const FilePath& cache_file_path); | 415 const FilePath& cache_file_path); |
413 | 416 |
414 // Callback for handling document copy attempt. | 417 // Callback for handling document copy attempt. |
| 418 // |callback| must not be null. |
415 void OnCopyDocumentCompleted(const FilePath& dir_path, | 419 void OnCopyDocumentCompleted(const FilePath& dir_path, |
416 const FileOperationCallback& callback, | 420 const FileOperationCallback& callback, |
417 GDataErrorCode status, | 421 GDataErrorCode status, |
418 scoped_ptr<base::Value> data); | 422 scoped_ptr<base::Value> data); |
419 | 423 |
420 // Callback for handling an attempt to add a file or directory to another | 424 // Callback for handling an attempt to add a file or directory to another |
421 // directory. | 425 // directory. |
422 void OnAddEntryToDirectoryCompleted(const FileOperationCallback& callback, | 426 void OnAddEntryToDirectoryCompleted(const FileOperationCallback& callback, |
423 const FilePath& file_path, | 427 const FilePath& file_path, |
424 const FilePath& dir_path, | 428 const FilePath& dir_path, |
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
734 GDataEntry* directory_entry); | 738 GDataEntry* directory_entry); |
735 void GetAvailableSpaceOnUIThread(const GetAvailableSpaceCallback& callback); | 739 void GetAvailableSpaceOnUIThread(const GetAvailableSpaceCallback& callback); |
736 void AddUploadedFileOnUIThread(UploadMode upload_mode, | 740 void AddUploadedFileOnUIThread(UploadMode upload_mode, |
737 const FilePath& virtual_dir_path, | 741 const FilePath& virtual_dir_path, |
738 scoped_ptr<DocumentEntry> entry, | 742 scoped_ptr<DocumentEntry> entry, |
739 const FilePath& file_content_path, | 743 const FilePath& file_content_path, |
740 GDataCache::FileOperationType cache_operation, | 744 GDataCache::FileOperationType cache_operation, |
741 const base::Closure& callback); | 745 const base::Closure& callback); |
742 | 746 |
743 // Part of CopyOnUIThread(). Called after GetEntryInfoPairByPaths() is | 747 // Part of CopyOnUIThread(). Called after GetEntryInfoPairByPaths() is |
744 // complete. | 748 // complete. |callback| must not be null. |
745 void CopyOnUIThreadAfterGetEntryInfoPair( | 749 void CopyOnUIThreadAfterGetEntryInfoPair( |
746 const FilePath& dest_file_path, | 750 const FilePath& dest_file_path, |
747 const FileOperationCallback& callback, | 751 const FileOperationCallback& callback, |
748 scoped_ptr<EntryInfoPairResult> result); | 752 scoped_ptr<EntryInfoPairResult> result); |
749 | 753 |
750 // Part of RemoveOnUIThread(). Called after GetEntryInfoByPath() is | 754 // Part of RemoveOnUIThread(). Called after GetEntryInfoByPath() is |
751 // complete. | 755 // complete. |
752 void RemoveOnUIThreadAfterGetEntryInfo( | 756 void RemoveOnUIThreadAfterGetEntryInfo( |
753 const FilePath& file_path, | 757 const FilePath& file_path, |
754 bool is_recursive, | 758 bool is_recursive, |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
828 // invalidate the weak pointers before any other members are destroyed. | 832 // invalidate the weak pointers before any other members are destroyed. |
829 base::WeakPtrFactory<GDataFileSystem> ui_weak_ptr_factory_; | 833 base::WeakPtrFactory<GDataFileSystem> ui_weak_ptr_factory_; |
830 // Unlike other classes, we need this as we need this to redirect a task | 834 // Unlike other classes, we need this as we need this to redirect a task |
831 // from IO thread to UI thread. | 835 // from IO thread to UI thread. |
832 base::WeakPtr<GDataFileSystem> ui_weak_ptr_; | 836 base::WeakPtr<GDataFileSystem> ui_weak_ptr_; |
833 }; | 837 }; |
834 | 838 |
835 } // namespace gdata | 839 } // namespace gdata |
836 | 840 |
837 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_FILE_SYSTEM_H_ | 841 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_FILE_SYSTEM_H_ |
OLD | NEW |