#ifndef CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_PROVIDED_FILE_SYSTEM_INTERFACE_H_
#define CHROME_BROWSER_CHROMEOS_FILE_SYSTEM_PROVIDER_PROVIDED_FILE_SYSTEM_INTERFACE_H_
+#include <string>
+
#include "base/callback.h"
#include "base/files/file.h"
#include "base/files/file_path.h"
class EventRouter;
+namespace base {
+class Time;
+} // namespace base
+
namespace net {
class IOBuffer;
} // namespace net
class ProvidedFileSystemInfo;
class RequestManager;
+// Represents metadata for either a file or a directory. Returned by GetMetadata
+// method in ProvidedFileSystemInterface.
+struct EntryMetadata {
+ EntryMetadata();
+ ~EntryMetadata();
+
+ bool is_directory;
+ std::string name;
+ int64 size;
+ base::Time modification_time;
+ std::string mime_type;
+};
+
// Interface for a provided file system. Acts as a proxy between providers
// and clients.
// TODO(mtomasz): Add more methods once implemented.
void(int chunk_length, bool has_more, base::File::Error result)>
ReadChunkReceivedCallback;
+ typedef base::Callback<void(const EntryMetadata& entry_metadata,
+ base::File::Error result)> GetMetadataCallback;
+
// Mode of opening a file. Used by OpenFile().
enum OpenFileMode { OPEN_FILE_MODE_READ, OPEN_FILE_MODE_WRITE };
// Requests metadata of the passed |entry_path|. It can be either a file
// or a directory.
- virtual void GetMetadata(
- const base::FilePath& entry_path,
- const fileapi::AsyncFileUtil::GetFileInfoCallback& callback) = 0;
+ virtual void GetMetadata(const base::FilePath& entry_path,
+ const GetMetadataCallback& callback) = 0;
// Requests enumerating entries from the passed |directory_path|. The callback
// can be called multiple times until |has_more| is set to false.
const base::FilePath& directory_path,
const fileapi::AsyncFileUtil::ReadDirectoryCallback& callback) = 0;
- // Requests opening a file at |file_path|. If |create| is set to true, it will
- // create a file and return success in case it didn't exist.
+ // Requests opening a file at |file_path|. If the file doesn't exist, then the
+ // operation will fail.
virtual void OpenFile(const base::FilePath& file_path,
OpenFileMode mode,
- bool create,
const OpenFileCallback& callback) = 0;
// Requests closing a file, previously opened with OpenFile() as a file with
int length,
const ReadChunkReceivedCallback& callback) = 0;
+ // Requests creating a directory. If |recursive| is passed, then all non
+ // existing directories on the path will be created. If |exclusive| is true,
+ // then creating the directory will fail, if it already exists.
+ virtual void CreateDirectory(
+ const base::FilePath& directory_path,
+ bool exclusive,
+ bool recursive,
+ const fileapi::AsyncFileUtil::StatusCallback& callback) = 0;
+
+ // Requests creating a file. If the entry already exists, then the
+ // FILE_ERROR_EXISTS error must be returned.
+ virtual void CreateFile(
+ const base::FilePath& file_path,
+ const fileapi::AsyncFileUtil::StatusCallback& callback) = 0;
+
+ // Requests deleting a directory. If |recursive| is passed and the entry is
+ // a directory, then all contents of it (recursively) will be deleted too.
+ virtual void DeleteEntry(
+ const base::FilePath& entry_path,
+ bool recursive,
+ const fileapi::AsyncFileUtil::StatusCallback& callback) = 0;
+
+ // Requests copying an entry (recursively in case of a directory) within the
+ // same file system.
+ virtual void CopyEntry(
+ const base::FilePath& source_path,
+ const base::FilePath& target_path,
+ const fileapi::AsyncFileUtil::StatusCallback& callback) = 0;
+
+ // Requests moving an entry (recursively in case of a directory) within the
+ // same file system.
+ virtual void MoveEntry(
+ const base::FilePath& source_path,
+ const base::FilePath& target_path,
+ const fileapi::AsyncFileUtil::StatusCallback& callback) = 0;
+
+ // Requests truncating a file to the desired length.
+ virtual void Truncate(
+ const base::FilePath& file_path,
+ int64 length,
+ const fileapi::AsyncFileUtil::StatusCallback& callback) = 0;
+
+ // Requests writing to a file previously opened with |file_handle|.
+ virtual void WriteFile(
+ int file_handle,
+ net::IOBuffer* buffer,
+ int64 offset,
+ int length,
+ const fileapi::AsyncFileUtil::StatusCallback& callback) = 0;
+
// Returns a provided file system info for this file system.
virtual const ProvidedFileSystemInfo& GetFileSystemInfo() const = 0;