diff options
author | kkanetkar@chromium.org <kkanetkar@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-09-02 03:43:36 +0000 |
---|---|---|
committer | kkanetkar@chromium.org <kkanetkar@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-09-02 03:43:36 +0000 |
commit | 61da1dbbe85912d3b21310b5e934ddcc273e5cb1 (patch) | |
tree | 4a8e50420f8583b860db847d2f3ea79e907bfdaa /base/file_util_proxy.h | |
parent | 6470a9eb1c4fdcfb45b504e9b6ce57941ff956de (diff) | |
download | chromium_src-61da1dbbe85912d3b21310b5e934ddcc273e5cb1.zip chromium_src-61da1dbbe85912d3b21310b5e934ddcc273e5cb1.tar.gz chromium_src-61da1dbbe85912d3b21310b5e934ddcc273e5cb1.tar.bz2 |
Changes for browser-side implementation for file api.
BUG=32277
TEST=Separate CL for unit test.
Review URL: http://codereview.chromium.org/3212002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@58312 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/file_util_proxy.h')
-rw-r--r-- | base/file_util_proxy.h | 75 |
1 files changed, 61 insertions, 14 deletions
diff --git a/base/file_util_proxy.h b/base/file_util_proxy.h index 9899c77..dec06e3 100644 --- a/base/file_util_proxy.h +++ b/base/file_util_proxy.h @@ -2,10 +2,14 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef BASE_FILE_SYSTEM_PROXY_H_ -#define BASE_FILE_SYSTEM_PROXY_H_ +#ifndef BASE_FILE_UTIL_PROXY_H_ +#define BASE_FILE_UTIL_PROXY_H_ + +#include <vector> #include "base/callback.h" +#include "base/file_path.h" +#include "base/file_util.h" #include "base/platform_file.h" #include "base/ref_counted.h" #include "base/tracked_objects.h" @@ -16,6 +20,14 @@ struct FileInfo; namespace base { +namespace file_util_proxy { + // Holds metadata for file or directory entry. +struct Entry { + FilePath::StringType name; + bool isDirectory; +}; +} // namespace file_util_proxy + class MessageLoopProxy; // This class provides asynchronous access to common file routines. @@ -51,31 +63,66 @@ class FileUtilProxy { base::PlatformFile, StatusCallback* callback); + // Retrieves the information about a file. It is invalid to pass NULL for the + // callback. + typedef Callback2<base::PlatformFileError /* error code */, + const file_util::FileInfo& /*file_info*/ + >::Type GetFileInfoCallback; + static bool GetFileInfo( + scoped_refptr<MessageLoopProxy> message_loop_proxy, + const FilePath& file_path, + GetFileInfoCallback* callback); + + typedef Callback2<base::PlatformFileError /* error code */, + const std::vector<base::file_util_proxy::Entry>& + >::Type ReadDirectoryCallback; + static bool ReadDirectory(scoped_refptr<MessageLoopProxy> message_loop_proxy, + const FilePath& file_path, + ReadDirectoryCallback* callback); + + // Copies a file or a directory from |src_file_path| to |dest_file_path| + // Error cases: + // If destination file doesn't exist or destination's parent + // doesn't exists. + // If source dir exists but destination path is an existing file. + // If source is a parent of destination. + // If source doesn't exists. + static bool Copy(scoped_refptr<MessageLoopProxy> message_loop_proxy, + const FilePath& src_file_path, + const FilePath& dest_file_path, + StatusCallback* callback); + + // Creates directory at given path. It's an error to create + // if |exclusive| is true and dir already exists. + static bool CreateDirectory( + scoped_refptr<MessageLoopProxy> message_loop_proxy, + const FilePath& file_path, + bool exclusive, + StatusCallback* callback); + // Deletes a file or empty directory. static bool Delete(scoped_refptr<MessageLoopProxy> message_loop_proxy, const FilePath& file_path, StatusCallback* callback); - // Deletes a directory and all of its contents. - static bool RecursiveDelete( + // Moves a file or a directory from src_file_path to dest_file_path. + // Error cases are similar to Copy method's error cases. + static bool Move( scoped_refptr<MessageLoopProxy> message_loop_proxy, - const FilePath& file_path, + const FilePath& src_file_path, + const FilePath& dest_file_path, StatusCallback* callback); - // Retrieves the information about a file. It is invalid to pass NULL for the - // callback. - typedef Callback2<base::PlatformFileError /* error code */, - const file_util::FileInfo& /*file_info*/ - >::Type GetFileInfoCallback; - static bool GetFileInfo( + // Deletes a directory and all of its contents. + static bool RecursiveDelete( scoped_refptr<MessageLoopProxy> message_loop_proxy, const FilePath& file_path, - GetFileInfoCallback* callback); + StatusCallback* callback); private: DISALLOW_IMPLICIT_CONSTRUCTORS(FileUtilProxy); }; -} // namespace base +} // namespace base -#endif // BASE_FILE_SYSTEM_PROXY_H_ +#endif // BASE_FILE_UTIL_PROXY_H_ |