Chromium Code Reviews| Index: chrome/browser/chromeos/gdata/gdata_file_system.h |
| =================================================================== |
| --- chrome/browser/chromeos/gdata/gdata_file_system.h (revision 126063) |
| +++ chrome/browser/chromeos/gdata/gdata_file_system.h (working copy) |
| @@ -5,9 +5,10 @@ |
| #ifndef CHROME_BROWSER_CHROMEOS_GDATA_GDATA_FILE_SYSTEM_H_ |
| #define CHROME_BROWSER_CHROMEOS_GDATA_GDATA_FILE_SYSTEM_H_ |
| +#include <sys/stat.h> |
| + |
| #include <map> |
| #include <string> |
| -#include <sys/stat.h> |
| #include <vector> |
| #include "base/gtest_prod_util.h" |
| @@ -124,6 +125,22 @@ |
| void FindFileByPath(const FilePath& file_path, |
| scoped_refptr<FindFileDelegate> delegate); |
| + // Copies |src_file_path| to |dest_file_path| on the file system. |
|
satorux1
2012/03/12 17:48:24
Please document that if this allows copy of direct
Ben Chan
2012/03/13 00:29:21
Done.
|
| + // The file entries represented by |src_file_path| and the parent directory |
| + // of |dest_file_path| need to be present in the in-memory representation |
|
satorux1
2012/03/12 17:48:24
Please also document if |dest_file_path| can be a
Ben Chan
2012/03/13 00:29:21
Done.
|
| + // of the file system. |
|
satorux1
2012/03/12 17:48:24
//
// Can be called from any thread.
?
Ben Chan
2012/03/13 00:29:21
Done.
|
| + void Copy(const FilePath& src_file_path, |
| + const FilePath& dest_file_path, |
| + const FileOperationCallback& callback); |
| + |
| + // Moves |src_file_path| to |dest_file_path| on the file system. |
| + // The file entries represented by |src_file_path| and the parent directory |
| + // of |dest_file_path| need to be present in the in-memory representation |
| + // of the file system. |
|
satorux1
2012/03/12 17:48:24
ditto.
Ben Chan
2012/03/13 00:29:21
Done.
|
| + void Move(const FilePath& src_file_path, |
| + const FilePath& dest_file_path, |
| + const FileOperationCallback& callback); |
| + |
| // Removes |file_path| from the file system. If |is_recursive| is set and |
| // |file_path| represents a directory, we will also delete all of its |
| // contained children elements. The file entry represented by |file_path| |
| @@ -176,6 +193,7 @@ |
| friend class GDataFileSystemTestBase; |
| FRIEND_TEST_ALL_PREFIXES(GDataFileSystemTest, |
| FindFirstMissingParentDirectory); |
| + FRIEND_TEST_ALL_PREFIXES(GDataFileSystemTest, GetCopyMoveFileParams); |
| // Defines possible search results of FindFirstMissingParentDirectory(). |
| enum FindMissingDirectoryResult { |
| @@ -204,13 +222,34 @@ |
| FileOperationCallback callback; |
| }; |
| + // Defines set of parameters of a file/directory that is needed for |
| + // copy/move related operations. |
| + struct CopyMoveFileParams { |
| + CopyMoveFileParams(); |
| + ~CopyMoveFileParams(); |
| + |
| + GURL self_url; |
| + GURL content_url; |
| + bool is_directory; |
| + bool is_root_directory; |
| + bool is_hosted_document; |
| + std::string resource_id; |
| + std::string document_extension; |
| + }; |
| + |
| enum CacheType { // This indexes into |cache_paths_| vector. |
| CACHE_TYPE_BLOBS = 0, |
| CACHE_TYPE_META, |
| }; |
| - explicit GDataFileSystem(Profile* profile, |
| - DocumentsServiceInterface* documents_service); |
| + // Callback similar to FileOperationCallback but with a given |
| + // |file_path|. |
| + typedef base::Callback<void(base::PlatformFileError error, |
| + const FilePath& file_path)> |
| + FilePathUpdateCallback; |
| + |
| + GDataFileSystem(Profile* profile, |
| + DocumentsServiceInterface* documents_service); |
| virtual ~GDataFileSystem(); |
| // Initiates upload operation of file defined with |file_name|, |
| @@ -247,6 +286,29 @@ |
| base::Value* data, |
| base::PlatformFileError *error); |
| + // Gets the parameters of a file or directory at |file_path| for copy/move |
| + // related operations. Returns false if |file_path| is not found. |
| + bool GetCopyMoveFileParams(const FilePath& file_path, |
| + CopyMoveFileParams* params); |
| + |
| + // Renames a file or directory at |file_path| to |new_name|. |
| + void Rename(const FilePath& file_path, |
| + const FilePath::StringType& new_name, |
| + const FilePathUpdateCallback& callback); |
| + |
| + // Adds a file or directory at |file_path| to the directory at |dir_path|. |
| + void AddFileToDirectory(const FilePath& dir_path, |
| + const FileOperationCallback& callback, |
| + base::PlatformFileError error, |
| + const FilePath& file_path); |
| + |
| + // Removes a file or directory at |file_path| from the directory at |
| + // |dir_path| and moves it to the root directory. |
| + void RemoveFileFromDirectory(const FilePath& dir_path, |
| + const FilePathUpdateCallback& callback, |
| + base::PlatformFileError error, |
| + const FilePath& file_path); |
| + |
| // Callback for handling feed content fetching while searching for file info. |
| // This callback is invoked after async feed fetch operation that was |
| // invoked by StartDirectoryRefresh() completes. This callback will update |
| @@ -257,6 +319,41 @@ |
| GDataErrorCode status, |
| scoped_ptr<base::Value> data); |
| + // A pass-through callback used for bridging from |
| + // FilePathUpdateCallback to FileOperationCallback. |
| + void OnFilePathUpdated(const FileOperationCallback& cllback, |
| + base::PlatformFileError error, |
| + const FilePath& file_path); |
| + |
| + // Callback for handling resource rename attempt. |
| + void OnRenameResourceCompleted(const FilePath& file_path, |
| + const FilePath::StringType& new_name, |
| + const FilePathUpdateCallback& callback, |
| + GDataErrorCode status, |
| + const GURL& document_url); |
| + |
| + // Callback for handling document copy attempt. |
| + void OnCopyDocumentCompleted(const FilePathUpdateCallback& callback, |
| + GDataErrorCode status, |
| + scoped_ptr<base::Value> data); |
| + |
| + // Callback for handling an attempt to add a file or directory to another |
| + // directory. |
| + void OnAddFileToDirectoryCompleted(const FileOperationCallback& callback, |
| + const FilePath& file_path, |
| + const FilePath& dir_path, |
| + GDataErrorCode status, |
| + const GURL& document_url); |
| + |
| + // Callback for handling an attempt to remove a file or directory from |
| + // another directory. |
| + void OnRemoveFileFromDirectoryCompleted( |
| + const FilePathUpdateCallback& callback, |
| + const FilePath& file_path, |
| + const FilePath& dir_path, |
| + GDataErrorCode status, |
| + const GURL& document_url); |
| + |
| // Callback for handling document remove attempt. |
| void OnRemovedDocument( |
| const FileOperationCallback& callback, |
| @@ -292,6 +389,25 @@ |
| int64 start_range_received, |
| int64 end_range_received); |
| + // Renames a file or directory at |file_path| on in-memory snapshot |
| + // of the file system. Returns PLATFORM_FILE_OK if successful. |
| + base::PlatformFileError RenameFileOnFilesystem( |
| + const FilePath& file_path, const FilePath::StringType& new_name, |
| + FilePath* updated_file_path); |
| + |
| + // Adds a file or directory at |file_path| to another directory at |
| + // |dir_path| on in-memory snapshot of the file system. |
| + // Returns PLATFORM_FILE_OK if successful. |
| + base::PlatformFileError AddFileToDirectoryOnFilesystem( |
| + const FilePath& file_path, const FilePath& dir_path); |
| + |
| + // Removes a file or directory at |file_path| from another directory at |
| + // |dir_path| on in-memory snapshot of the file system. |
| + // Returns PLATFORM_FILE_OK if successful. |
| + base::PlatformFileError RemoveFileFromDirectoryOnFilesystem( |
| + const FilePath& file_path, const FilePath& dir_path, |
| + FilePath* updated_file_path); |
| + |
| // Removes file under |file_path| from in-memory snapshot of the file system. |
| // Return PLATFORM_FILE_OK if successful. |
| base::PlatformFileError RemoveFileFromFileSystem(const FilePath& file_path); |