| Index: webkit/fileapi/file_system_file_util_proxy.cc
|
| diff --git a/webkit/fileapi/file_system_file_util_proxy.cc b/webkit/fileapi/file_system_file_util_proxy.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..2adb6bc3fc604c13faad85574499734dc38e3b21
|
| --- /dev/null
|
| +++ b/webkit/fileapi/file_system_file_util_proxy.cc
|
| @@ -0,0 +1,874 @@
|
| +// Copyright (c) 2010 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "webkit/fileapi/file_system_file_util_proxy.h"
|
| +
|
| +#include "base/message_loop_proxy.h"
|
| +#include "webkit/fileapi/file_system_file_util_base.h"
|
| +#include "webkit/fileapi/file_system_operation_context.h"
|
| +
|
| +namespace fileapi {
|
| +
|
| +class MessageLoopRelay
|
| + : public base::RefCountedThreadSafe<MessageLoopRelay> {
|
| + public:
|
| + MessageLoopRelay(FileSystemOperationContext* fs_context)
|
| + : file_util_(FileSystemFileUtilBase::GetInstance()),
|
| + fs_context_(fs_context),
|
| + origin_message_loop_proxy_(
|
| + base::MessageLoopProxy::CreateForCurrentThread()),
|
| + error_code_(base::PLATFORM_FILE_OK) {
|
| + }
|
| +
|
| + bool Start(scoped_refptr<base::MessageLoopProxy> message_loop_proxy,
|
| + const tracked_objects::Location& from_here) {
|
| + return message_loop_proxy->PostTask(
|
| + from_here,
|
| + NewRunnableMethod(this, &MessageLoopRelay::ProcessOnTargetThread));
|
| + }
|
| +
|
| + protected:
|
| + friend class base::RefCountedThreadSafe<MessageLoopRelay>;
|
| + virtual ~MessageLoopRelay() {}
|
| +
|
| + // Called to perform work on the FILE thread.
|
| + virtual void RunWork() = 0;
|
| +
|
| + // Called to notify the callback on the origin thread.
|
| + virtual void RunCallback() = 0;
|
| +
|
| + void set_error_code(base::PlatformFileError error_code) {
|
| + error_code_ = error_code;
|
| + }
|
| +
|
| + base::PlatformFileError error_code() const {
|
| + return error_code_;
|
| + }
|
| +
|
| + FileSystemFileUtilBase* file_util_;
|
| + FileSystemOperationContext* fs_context_;
|
| +
|
| + private:
|
| + void ProcessOnTargetThread() {
|
| + RunWork();
|
| + origin_message_loop_proxy_->PostTask(
|
| + FROM_HERE,
|
| + NewRunnableMethod(this, &MessageLoopRelay::RunCallback));
|
| + }
|
| +
|
| + scoped_refptr<base::MessageLoopProxy> origin_message_loop_proxy_;
|
| + base::PlatformFileError error_code_;
|
| +};
|
| +
|
| +class RelayCreateOrOpen : public MessageLoopRelay {
|
| + public:
|
| + RelayCreateOrOpen(
|
| + FileSystemOperationContext* fs_context,
|
| + scoped_refptr<base::MessageLoopProxy> message_loop_proxy,
|
| + const FilePath& file_path,
|
| + int file_flags,
|
| + FileSystemFileUtilProxy::CreateOrOpenCallback* callback)
|
| + : MessageLoopRelay(fs_context),
|
| + message_loop_proxy_(message_loop_proxy),
|
| + file_path_(file_path),
|
| + file_flags_(file_flags),
|
| + callback_(callback),
|
| + file_handle_(base::kInvalidPlatformFileValue),
|
| + created_(false) {
|
| + DCHECK(callback);
|
| + }
|
| +
|
| + protected:
|
| + virtual ~RelayCreateOrOpen() {
|
| + if (file_handle_ != base::kInvalidPlatformFileValue)
|
| + fileapi::FileSystemFileUtilProxy::Close(
|
| + fs_context_, message_loop_proxy_, file_handle_, NULL);
|
| + }
|
| +
|
| + virtual void RunWork() {
|
| + base::PlatformFileError error_code;
|
| + error_code =
|
| + file_util_->CreateOrOpen(fs_context_, file_path_, file_flags_,
|
| + file_handle_, created_);
|
| + if (error_code != base::PLATFORM_FILE_OK)
|
| + set_error_code(error_code);
|
| + }
|
| +
|
| + virtual void RunCallback() {
|
| + callback_->Run(error_code(), base::PassPlatformFile(&file_handle_),
|
| + created_);
|
| + delete callback_;
|
| + }
|
| +
|
| + private:
|
| + scoped_refptr<base::MessageLoopProxy> message_loop_proxy_;
|
| + FilePath file_path_;
|
| + int file_flags_;
|
| + FileSystemFileUtilProxy::CreateOrOpenCallback* callback_;
|
| + base::PlatformFile file_handle_;
|
| + bool created_;
|
| +};
|
| +
|
| +class RelayCreateTemporary : public MessageLoopRelay {
|
| + public:
|
| + RelayCreateTemporary(
|
| + FileSystemOperationContext* fs_context,
|
| + scoped_refptr<base::MessageLoopProxy> message_loop_proxy,
|
| + FileSystemFileUtilProxy::CreateTemporaryCallback* callback)
|
| + : MessageLoopRelay(fs_context),
|
| + message_loop_proxy_(message_loop_proxy),
|
| + callback_(callback),
|
| + file_handle_(base::kInvalidPlatformFileValue) {
|
| + DCHECK(callback);
|
| + }
|
| +
|
| + protected:
|
| + virtual ~RelayCreateTemporary() {
|
| + if (file_handle_ != base::kInvalidPlatformFileValue)
|
| + fileapi::FileSystemFileUtilProxy::Close(
|
| + fs_context_, message_loop_proxy_, file_handle_, NULL);
|
| + }
|
| +
|
| + virtual void RunWork() {
|
| + base::PlatformFileError error_code;
|
| + error_code =
|
| + file_util_->CreateTemporary(fs_context_, file_path_, file_handle_);
|
| + if (error_code != base::PLATFORM_FILE_OK)
|
| + set_error_code(error_code);
|
| + }
|
| +
|
| + virtual void RunCallback() {
|
| + callback_->Run(error_code(), base::PassPlatformFile(&file_handle_),
|
| + file_path_);
|
| + delete callback_;
|
| + }
|
| +
|
| + private:
|
| + scoped_refptr<base::MessageLoopProxy> message_loop_proxy_;
|
| + FileSystemFileUtilProxy::CreateTemporaryCallback* callback_;
|
| + base::PlatformFile file_handle_;
|
| + FilePath file_path_;
|
| +};
|
| +
|
| +class RelayWithStatusCallback : public MessageLoopRelay {
|
| + public:
|
| + explicit RelayWithStatusCallback(
|
| + FileSystemOperationContext* fs_context,
|
| + FileSystemFileUtilProxy::StatusCallback* callback)
|
| + : MessageLoopRelay(fs_context),
|
| + callback_(callback) {
|
| + // It is OK for callback to be NULL.
|
| + }
|
| +
|
| + protected:
|
| + virtual void RunCallback() {
|
| + // The caller may not have been interested in the result.
|
| + if (callback_) {
|
| + callback_->Run(error_code());
|
| + delete callback_;
|
| + }
|
| + }
|
| +
|
| + private:
|
| + FileSystemFileUtilProxy::StatusCallback* callback_;
|
| +};
|
| +
|
| +class RelayClose : public RelayWithStatusCallback {
|
| + public:
|
| + RelayClose(FileSystemOperationContext* fs_context,
|
| + base::PlatformFile file_handle,
|
| + FileSystemFileUtilProxy::StatusCallback* callback)
|
| + : RelayWithStatusCallback(fs_context, callback),
|
| + file_handle_(file_handle) {
|
| + }
|
| +
|
| + protected:
|
| + virtual void RunWork() {
|
| + base::PlatformFileError error_code;
|
| + error_code =
|
| + file_util_->Close(fs_context_, file_handle_);
|
| + if (error_code != base::PLATFORM_FILE_OK)
|
| + set_error_code(error_code);
|
| + }
|
| +
|
| + private:
|
| + base::PlatformFile file_handle_;
|
| +};
|
| +
|
| +class RelayEnsureFileExists : public MessageLoopRelay {
|
| + public:
|
| + RelayEnsureFileExists(
|
| + FileSystemOperationContext* fs_context,
|
| + scoped_refptr<base::MessageLoopProxy> message_loop_proxy,
|
| + const FilePath& file_path,
|
| + FileSystemFileUtilProxy::EnsureFileExistsCallback* callback)
|
| + : MessageLoopRelay(fs_context),
|
| + message_loop_proxy_(message_loop_proxy),
|
| + file_path_(file_path),
|
| + callback_(callback),
|
| + created_(false) {
|
| + DCHECK(callback);
|
| + }
|
| +
|
| + protected:
|
| + virtual void RunWork() {
|
| + base::PlatformFileError error_code;
|
| + error_code = file_util_->EnsureFileExists(fs_context_,
|
| + file_path_, &created_);
|
| + if (error_code != base::PLATFORM_FILE_OK)
|
| + set_error_code(error_code);
|
| + }
|
| +
|
| + virtual void RunCallback() {
|
| + callback_->Run(error_code(), created_);
|
| + delete callback_;
|
| + }
|
| +
|
| + private:
|
| + scoped_refptr<base::MessageLoopProxy> message_loop_proxy_;
|
| + FilePath file_path_;
|
| + FileSystemFileUtilProxy::EnsureFileExistsCallback* callback_;
|
| + bool created_;
|
| +};
|
| +
|
| +class RelayDelete : public RelayWithStatusCallback {
|
| + public:
|
| + RelayDelete(FileSystemOperationContext* fs_context,
|
| + const FilePath& file_path,
|
| + bool recursive,
|
| + FileSystemFileUtilProxy::StatusCallback* callback)
|
| + : RelayWithStatusCallback(fs_context, callback),
|
| + file_path_(file_path),
|
| + recursive_(recursive) {
|
| + }
|
| +
|
| + protected:
|
| + virtual void RunWork() {
|
| + base::PlatformFileError error_code;
|
| + error_code =
|
| + file_util_->Delete(fs_context_, file_path_, recursive_);
|
| + if (error_code != base::PLATFORM_FILE_OK)
|
| + set_error_code(error_code);
|
| + }
|
| +
|
| + private:
|
| + FilePath file_path_;
|
| + bool recursive_;
|
| +};
|
| +
|
| +class RelayCopy : public RelayWithStatusCallback {
|
| + public:
|
| + RelayCopy(FileSystemOperationContext* fs_context,
|
| + const FilePath& src_file_path,
|
| + const FilePath& dest_file_path,
|
| + FileSystemFileUtilProxy::StatusCallback* callback)
|
| + : RelayWithStatusCallback(fs_context, callback),
|
| + src_file_path_(src_file_path),
|
| + dest_file_path_(dest_file_path) {
|
| + }
|
| +
|
| + protected:
|
| + virtual void RunWork() {
|
| + base::PlatformFileError error_code;
|
| + error_code =
|
| + file_util_->Copy(fs_context_, src_file_path_, dest_file_path_);
|
| + if (error_code != base::PLATFORM_FILE_OK)
|
| + set_error_code(error_code);
|
| + }
|
| +
|
| + private:
|
| + FilePath src_file_path_;
|
| + FilePath dest_file_path_;
|
| +};
|
| +
|
| +class RelayMove : public RelayWithStatusCallback {
|
| + public:
|
| + RelayMove(FileSystemOperationContext* fs_context,
|
| + const FilePath& src_file_path,
|
| + const FilePath& dest_file_path,
|
| + FileSystemFileUtilProxy::StatusCallback* callback)
|
| + : RelayWithStatusCallback(fs_context, callback),
|
| + src_file_path_(src_file_path),
|
| + dest_file_path_(dest_file_path) {
|
| + }
|
| +
|
| + protected:
|
| + virtual void RunWork() {
|
| + base::PlatformFileError error_code;
|
| + error_code =
|
| + file_util_->Move(fs_context_, src_file_path_, dest_file_path_);
|
| + if (error_code != base::PLATFORM_FILE_OK)
|
| + set_error_code(error_code);
|
| + }
|
| +
|
| + private:
|
| + FilePath src_file_path_;
|
| + FilePath dest_file_path_;
|
| +};
|
| +
|
| +class RelayCreateDirectory : public RelayWithStatusCallback {
|
| + public:
|
| + RelayCreateDirectory(
|
| + FileSystemOperationContext* fs_context,
|
| + const FilePath& file_path,
|
| + bool exclusive,
|
| + bool recursive,
|
| + FileSystemFileUtilProxy::StatusCallback* callback)
|
| + : RelayWithStatusCallback(fs_context, callback),
|
| + file_path_(file_path),
|
| + exclusive_(exclusive),
|
| + recursive_(recursive) {
|
| + }
|
| +
|
| + protected:
|
| + virtual void RunWork() {
|
| + base::PlatformFileError error_code;
|
| + error_code = file_util_->CreateDirectory(fs_context_,
|
| + file_path_, exclusive_, recursive_);
|
| + if (error_code != base::PLATFORM_FILE_OK)
|
| + set_error_code(error_code);
|
| + }
|
| +
|
| + private:
|
| + FilePath file_path_;
|
| + bool exclusive_;
|
| + bool recursive_;
|
| +};
|
| +
|
| +class RelayReadDirectory : public MessageLoopRelay {
|
| + public:
|
| + RelayReadDirectory(
|
| + FileSystemOperationContext* fs_context,
|
| + const FilePath& file_path,
|
| + FileSystemFileUtilProxy::ReadDirectoryCallback* callback)
|
| + : MessageLoopRelay(fs_context),
|
| + callback_(callback),
|
| + file_path_(file_path) {
|
| + DCHECK(callback);
|
| + }
|
| +
|
| + protected:
|
| + virtual void RunWork() {
|
| + base::PlatformFileError error_code;
|
| + error_code = file_util_->ReadDirectory(fs_context_,
|
| + file_path_, entries_);
|
| + if (error_code != base::PLATFORM_FILE_OK)
|
| + set_error_code(error_code);
|
| + }
|
| +
|
| + virtual void RunCallback() {
|
| + callback_->Run(error_code(), entries_);
|
| + delete callback_;
|
| + }
|
| +
|
| + private:
|
| + FileSystemFileUtilProxy::ReadDirectoryCallback* callback_;
|
| + FilePath file_path_;
|
| + std::vector<base::FileUtilProxy::Entry> entries_;
|
| +};
|
| +
|
| +class RelayGetFileInfo : public MessageLoopRelay {
|
| + public:
|
| + RelayGetFileInfo(
|
| + FileSystemOperationContext* fs_context,
|
| + const FilePath& file_path,
|
| + FileSystemFileUtilProxy::GetFileInfoCallback* callback)
|
| + : MessageLoopRelay(fs_context),
|
| + callback_(callback),
|
| + file_path_(file_path) {
|
| + DCHECK(callback);
|
| + }
|
| +
|
| + protected:
|
| + virtual void RunWork() {
|
| + base::PlatformFileError error_code;
|
| + error_code = file_util_->GetFileInfo(fs_context_,
|
| + file_path_, file_info_);
|
| + if (error_code != base::PLATFORM_FILE_OK)
|
| + set_error_code(error_code);
|
| + }
|
| +
|
| + virtual void RunCallback() {
|
| + callback_->Run(error_code(), file_info_);
|
| + delete callback_;
|
| + }
|
| +
|
| + private:
|
| + FileSystemFileUtilProxy::GetFileInfoCallback* callback_;
|
| + FilePath file_path_;
|
| + base::PlatformFileInfo file_info_;
|
| +};
|
| +
|
| +class RelayGetFileInfoFromPlatformFile : public MessageLoopRelay {
|
| + public:
|
| + RelayGetFileInfoFromPlatformFile(
|
| + FileSystemOperationContext* fs_context,
|
| + base::PlatformFile file,
|
| + FileSystemFileUtilProxy::GetFileInfoCallback* callback)
|
| + : MessageLoopRelay(fs_context),
|
| + callback_(callback),
|
| + file_(file) {
|
| + DCHECK(callback);
|
| + }
|
| +
|
| + protected:
|
| + virtual void RunWork() {
|
| + base::PlatformFileError error_code;
|
| + error_code = file_util_->GetFileInfoFromPlatformFile(fs_context_,
|
| + file_, file_info_);
|
| + if (error_code != base::PLATFORM_FILE_OK)
|
| + set_error_code(error_code);
|
| + }
|
| +
|
| + virtual void RunCallback() {
|
| + callback_->Run(error_code(), file_info_);
|
| + delete callback_;
|
| + }
|
| +
|
| + private:
|
| + FileSystemFileUtilProxy::GetFileInfoCallback* callback_;
|
| + base::PlatformFile file_;
|
| + base::PlatformFileInfo file_info_;
|
| +};
|
| +
|
| +class RelayRead : public MessageLoopRelay {
|
| + public:
|
| + RelayRead(
|
| + FileSystemOperationContext* fs_context,
|
| + base::PlatformFile file,
|
| + int64 offset,
|
| + int bytes_to_read,
|
| + FileSystemFileUtilProxy::ReadCallback* callback)
|
| + : MessageLoopRelay(fs_context),
|
| + file_(file),
|
| + offset_(offset),
|
| + buffer_(new char[bytes_to_read]),
|
| + bytes_to_read_(bytes_to_read),
|
| + callback_(callback),
|
| + bytes_read_(0) {
|
| + }
|
| +
|
| + protected:
|
| + virtual void RunWork() {
|
| + base::PlatformFileError error_code;
|
| + error_code = file_util_->Read(fs_context_,
|
| + file_, offset_, bytes_to_read_,
|
| + bytes_read_, buffer_.get());
|
| + if (error_code != base::PLATFORM_FILE_OK)
|
| + set_error_code(error_code);
|
| + }
|
| +
|
| + virtual void RunCallback() {
|
| + if (callback_) {
|
| + callback_->Run(error_code(), buffer_.get(), bytes_read_);
|
| + delete callback_;
|
| + }
|
| + }
|
| +
|
| + private:
|
| + base::PlatformFile file_;
|
| + int64 offset_;
|
| + scoped_array<char> buffer_;
|
| + int bytes_to_read_;
|
| + FileSystemFileUtilProxy::ReadCallback* callback_;
|
| + int bytes_read_;
|
| +};
|
| +
|
| +class RelayWrite : public MessageLoopRelay {
|
| + public:
|
| + RelayWrite(
|
| + FileSystemOperationContext* fs_context,
|
| + base::PlatformFile file,
|
| + int64 offset,
|
| + const char* buffer,
|
| + int bytes_to_write,
|
| + FileSystemFileUtilProxy::WriteCallback* callback)
|
| + : MessageLoopRelay(fs_context),
|
| + file_(file),
|
| + offset_(offset),
|
| + buffer_(new char[bytes_to_write]),
|
| + bytes_to_write_(bytes_to_write),
|
| + callback_(callback) {
|
| + memcpy(buffer_.get(), buffer, bytes_to_write);
|
| + }
|
| +
|
| + protected:
|
| + virtual void RunWork() {
|
| + base::PlatformFileError error_code;
|
| + error_code = file_util_->Write(fs_context_,
|
| + file_, offset_, bytes_to_write_,
|
| + bytes_written_, buffer_.get());
|
| + if (error_code != base::PLATFORM_FILE_OK)
|
| + set_error_code(error_code);
|
| + }
|
| +
|
| + virtual void RunCallback() {
|
| + if (callback_) {
|
| + callback_->Run(error_code(), bytes_written_);
|
| + delete callback_;
|
| + }
|
| + }
|
| +
|
| + private:
|
| + base::PlatformFile file_;
|
| + int64 offset_;
|
| + scoped_array<char> buffer_;
|
| + int bytes_to_write_;
|
| + FileSystemFileUtilProxy::WriteCallback* callback_;
|
| + int bytes_written_;
|
| +};
|
| +
|
| +class RelayTouch : public RelayWithStatusCallback {
|
| + public:
|
| + RelayTouch(
|
| + FileSystemOperationContext* fs_context,
|
| + base::PlatformFile file,
|
| + const base::Time& last_access_time,
|
| + const base::Time& last_modified_time,
|
| + FileSystemFileUtilProxy::StatusCallback* callback)
|
| + : RelayWithStatusCallback(fs_context, callback),
|
| + file_(file),
|
| + last_access_time_(last_access_time),
|
| + last_modified_time_(last_modified_time) {
|
| + }
|
| +
|
| + protected:
|
| + virtual void RunWork() {
|
| + base::PlatformFileError error_code;
|
| + error_code = file_util_->Touch(fs_context_, file_,
|
| + last_access_time_, last_modified_time_);
|
| + if (error_code != base::PLATFORM_FILE_OK)
|
| + set_error_code(error_code);
|
| + }
|
| +
|
| + private:
|
| + base::PlatformFile file_;
|
| + base::Time last_access_time_;
|
| + base::Time last_modified_time_;
|
| +};
|
| +
|
| +class RelayTouchFilePath : public RelayWithStatusCallback {
|
| + public:
|
| + RelayTouchFilePath(
|
| + FileSystemOperationContext* fs_context,
|
| + const FilePath& file_path,
|
| + const base::Time& last_access_time,
|
| + const base::Time& last_modified_time,
|
| + FileSystemFileUtilProxy::StatusCallback* callback)
|
| + : RelayWithStatusCallback(fs_context, callback),
|
| + file_path_(file_path),
|
| + last_access_time_(last_access_time),
|
| + last_modified_time_(last_modified_time) {
|
| + }
|
| +
|
| + protected:
|
| + virtual void RunWork() {
|
| + base::PlatformFileError error_code;
|
| + error_code = file_util_->TouchFilePath(fs_context_, file_path_,
|
| + last_access_time_,
|
| + last_modified_time_);
|
| + if (error_code != base::PLATFORM_FILE_OK)
|
| + set_error_code(error_code);
|
| + }
|
| +
|
| + private:
|
| + FilePath file_path_;
|
| + base::Time last_access_time_;
|
| + base::Time last_modified_time_;
|
| +};
|
| +
|
| +class RelayTruncatePlatformFile : public RelayWithStatusCallback {
|
| + public:
|
| + RelayTruncatePlatformFile(
|
| + FileSystemOperationContext* fs_context,
|
| + base::PlatformFile file,
|
| + int64 length,
|
| + FileSystemFileUtilProxy::StatusCallback* callback)
|
| + : RelayWithStatusCallback(fs_context, callback),
|
| + file_(file),
|
| + length_(length) {
|
| + }
|
| +
|
| + protected:
|
| + virtual void RunWork() {
|
| + base::PlatformFileError error_code;
|
| + error_code = file_util_->TruncatePlatformFile(fs_context_,
|
| + file_, length_);
|
| + if (error_code != base::PLATFORM_FILE_OK)
|
| + set_error_code(error_code);
|
| + }
|
| +
|
| + private:
|
| + base::PlatformFile file_;
|
| + int64 length_;
|
| +};
|
| +
|
| +class RelayTruncate : public RelayWithStatusCallback {
|
| + public:
|
| + RelayTruncate(FileSystemOperationContext* fs_context,
|
| + const FilePath& path,
|
| + int64 length,
|
| + FileSystemFileUtilProxy::StatusCallback* callback)
|
| + : RelayWithStatusCallback(fs_context, callback),
|
| + path_(path),
|
| + length_(length) {
|
| + }
|
| +
|
| + protected:
|
| + virtual void RunWork() {
|
| + base::PlatformFileError error_code;
|
| + error_code = file_util_->Truncate(fs_context_, path_, length_);
|
| + if (error_code != base::PLATFORM_FILE_OK)
|
| + set_error_code(error_code);
|
| + }
|
| +
|
| + private:
|
| + FilePath path_;
|
| + int64 length_;
|
| +};
|
| +
|
| +class RelayFlush : public RelayWithStatusCallback {
|
| + public:
|
| + RelayFlush(FileSystemOperationContext* fs_context,
|
| + base::PlatformFile file,
|
| + FileSystemFileUtilProxy::StatusCallback* callback)
|
| + : RelayWithStatusCallback(fs_context, callback),
|
| + file_(file) {
|
| + }
|
| +
|
| + protected:
|
| + virtual void RunWork() {
|
| + base::PlatformFileError error_code;
|
| + error_code = file_util_->Flush(fs_context_, file_);
|
| + if (error_code != base::PLATFORM_FILE_OK)
|
| + set_error_code(error_code);
|
| + }
|
| +
|
| + private:
|
| + base::PlatformFile file_;
|
| +};
|
| +
|
| +bool Start(const tracked_objects::Location& from_here,
|
| + scoped_refptr<base::MessageLoopProxy> message_loop_proxy,
|
| + scoped_refptr<MessageLoopRelay> relay) {
|
| + return relay->Start(message_loop_proxy, from_here);
|
| +}
|
| +
|
| +// static
|
| +bool FileSystemFileUtilProxy::CreateOrOpen(
|
| + FileSystemOperationContext* fs_context,
|
| + scoped_refptr<base::MessageLoopProxy> message_loop_proxy,
|
| + const FilePath& file_path, int file_flags,
|
| + CreateOrOpenCallback* callback) {
|
| + return Start(FROM_HERE, message_loop_proxy, new RelayCreateOrOpen(
|
| + fs_context, message_loop_proxy, file_path, file_flags, callback));
|
| +}
|
| +
|
| +// static
|
| +bool FileSystemFileUtilProxy::CreateTemporary(
|
| + FileSystemOperationContext* fs_context,
|
| + scoped_refptr<base::MessageLoopProxy> message_loop_proxy,
|
| + CreateTemporaryCallback* callback) {
|
| + return Start(FROM_HERE, message_loop_proxy, new RelayCreateTemporary(
|
| + fs_context, message_loop_proxy, callback));
|
| +}
|
| +
|
| +// static
|
| +bool FileSystemFileUtilProxy::Close(
|
| + FileSystemOperationContext* fs_context,
|
| + scoped_refptr<base::MessageLoopProxy> message_loop_proxy,
|
| + base::PlatformFile file_handle,
|
| + StatusCallback* callback) {
|
| + return Start(FROM_HERE, message_loop_proxy,
|
| + new RelayClose(fs_context, file_handle, callback));
|
| +}
|
| +
|
| +// static
|
| +bool FileSystemFileUtilProxy::EnsureFileExists(
|
| + FileSystemOperationContext* fs_context,
|
| + scoped_refptr<base::MessageLoopProxy> message_loop_proxy,
|
| + const FilePath& file_path,
|
| + EnsureFileExistsCallback* callback) {
|
| + return Start(FROM_HERE, message_loop_proxy, new RelayEnsureFileExists(
|
| + fs_context, message_loop_proxy, file_path, callback));
|
| +}
|
| +
|
| +// Retrieves the information about a file. It is invalid to pass NULL for the
|
| +// callback.
|
| +bool FileSystemFileUtilProxy::GetFileInfo(
|
| + FileSystemOperationContext* fs_context,
|
| + scoped_refptr<base::MessageLoopProxy> message_loop_proxy,
|
| + const FilePath& file_path,
|
| + GetFileInfoCallback* callback) {
|
| + return Start(FROM_HERE, message_loop_proxy, new RelayGetFileInfo(
|
| + fs_context, file_path, callback));
|
| +}
|
| +
|
| +// static
|
| +bool FileSystemFileUtilProxy::GetFileInfoFromPlatformFile(
|
| + FileSystemOperationContext* fs_context,
|
| + scoped_refptr<base::MessageLoopProxy> message_loop_proxy,
|
| + base::PlatformFile file,
|
| + GetFileInfoCallback* callback) {
|
| + return Start(FROM_HERE, message_loop_proxy,
|
| + new RelayGetFileInfoFromPlatformFile(fs_context,
|
| + file, callback));
|
| +}
|
| +
|
| +// static
|
| +bool FileSystemFileUtilProxy::ReadDirectory(
|
| + FileSystemOperationContext* fs_context,
|
| + scoped_refptr<base::MessageLoopProxy> message_loop_proxy,
|
| + const FilePath& file_path,
|
| + ReadDirectoryCallback* callback) {
|
| + return Start(FROM_HERE, message_loop_proxy, new RelayReadDirectory(
|
| + fs_context, file_path, callback));
|
| +}
|
| +
|
| +// static
|
| +bool FileSystemFileUtilProxy::CreateDirectory(
|
| + FileSystemOperationContext* fs_context,
|
| + scoped_refptr<base::MessageLoopProxy> message_loop_proxy,
|
| + const FilePath& file_path,
|
| + bool exclusive,
|
| + bool recursive,
|
| + StatusCallback* callback) {
|
| + return Start(FROM_HERE, message_loop_proxy, new RelayCreateDirectory(
|
| + fs_context, file_path, exclusive, recursive, callback));
|
| +}
|
| +
|
| +// static
|
| +bool FileSystemFileUtilProxy::Copy(
|
| + FileSystemOperationContext* fs_context,
|
| + scoped_refptr<base::MessageLoopProxy> message_loop_proxy,
|
| + const FilePath& src_file_path,
|
| + const FilePath& dest_file_path,
|
| + StatusCallback* callback) {
|
| + return Start(FROM_HERE, message_loop_proxy,
|
| + new RelayCopy(fs_context,
|
| + src_file_path, dest_file_path, callback));
|
| +}
|
| +
|
| +// static
|
| +bool FileSystemFileUtilProxy::Move(
|
| + FileSystemOperationContext* fs_context,
|
| + scoped_refptr<base::MessageLoopProxy> message_loop_proxy,
|
| + const FilePath& src_file_path,
|
| + const FilePath& dest_file_path,
|
| + StatusCallback* callback) {
|
| + return Start(FROM_HERE, message_loop_proxy,
|
| + new RelayMove(fs_context,
|
| + src_file_path, dest_file_path, callback));
|
| +}
|
| +
|
| +// static
|
| +bool FileSystemFileUtilProxy::Delete(
|
| + FileSystemOperationContext* fs_context,
|
| + scoped_refptr<base::MessageLoopProxy> message_loop_proxy,
|
| + const FilePath& file_path,
|
| + bool recursive,
|
| + StatusCallback* callback) {
|
| + return Start(FROM_HERE, message_loop_proxy,
|
| + new RelayDelete(fs_context, file_path, recursive, callback));
|
| +}
|
| +
|
| +// static
|
| +bool FileSystemFileUtilProxy::RecursiveDelete(
|
| + FileSystemOperationContext* fs_context,
|
| + scoped_refptr<base::MessageLoopProxy> message_loop_proxy,
|
| + const FilePath& file_path,
|
| + StatusCallback* callback) {
|
| + return Start(FROM_HERE, message_loop_proxy,
|
| + new RelayDelete(fs_context, file_path, true, callback));
|
| +}
|
| +
|
| +// static
|
| +bool FileSystemFileUtilProxy::Read(
|
| + FileSystemOperationContext* fs_context,
|
| + scoped_refptr<base::MessageLoopProxy> message_loop_proxy,
|
| + base::PlatformFile file,
|
| + int64 offset,
|
| + int bytes_to_read,
|
| + ReadCallback* callback) {
|
| + return Start(FROM_HERE, message_loop_proxy,
|
| + new RelayRead(fs_context,
|
| + file, offset, bytes_to_read, callback));
|
| +}
|
| +
|
| +// static
|
| +bool FileSystemFileUtilProxy::Write(
|
| + FileSystemOperationContext* fs_context,
|
| + scoped_refptr<base::MessageLoopProxy> message_loop_proxy,
|
| + base::PlatformFile file,
|
| + int64 offset,
|
| + const char* buffer,
|
| + int bytes_to_write,
|
| + WriteCallback* callback) {
|
| + return Start(FROM_HERE, message_loop_proxy,
|
| + new RelayWrite(fs_context,
|
| + file, offset, buffer, bytes_to_write, callback));
|
| +}
|
| +
|
| +// static
|
| +bool FileSystemFileUtilProxy::Touch(
|
| + FileSystemOperationContext* fs_context,
|
| + scoped_refptr<base::MessageLoopProxy> message_loop_proxy,
|
| + base::PlatformFile file,
|
| + const base::Time& last_access_time,
|
| + const base::Time& last_modified_time,
|
| + StatusCallback* callback) {
|
| + return Start(FROM_HERE, message_loop_proxy,
|
| + new RelayTouch(fs_context,
|
| + file, last_access_time, last_modified_time,
|
| + callback));
|
| +}
|
| +
|
| +// static
|
| +bool FileSystemFileUtilProxy::Touch(
|
| + FileSystemOperationContext* fs_context,
|
| + scoped_refptr<base::MessageLoopProxy> message_loop_proxy,
|
| + const FilePath& file_path,
|
| + const base::Time& last_access_time,
|
| + const base::Time& last_modified_time,
|
| + StatusCallback* callback) {
|
| + return Start(FROM_HERE, message_loop_proxy,
|
| + new RelayTouchFilePath(fs_context,
|
| + file_path, last_access_time,
|
| + last_modified_time, callback));
|
| +}
|
| +
|
| +// static
|
| +bool FileSystemFileUtilProxy::Truncate(
|
| + FileSystemOperationContext* fs_context,
|
| + scoped_refptr<base::MessageLoopProxy> message_loop_proxy,
|
| + base::PlatformFile file,
|
| + int64 length,
|
| + StatusCallback* callback) {
|
| + return Start(FROM_HERE, message_loop_proxy,
|
| + new RelayTruncatePlatformFile(fs_context,
|
| + file, length, callback));
|
| +}
|
| +
|
| +// static
|
| +bool FileSystemFileUtilProxy::Truncate(
|
| + FileSystemOperationContext* fs_context,
|
| + scoped_refptr<base::MessageLoopProxy> message_loop_proxy,
|
| + const FilePath& path,
|
| + int64 length,
|
| + StatusCallback* callback) {
|
| + return Start(FROM_HERE, message_loop_proxy,
|
| + new RelayTruncate(fs_context, path, length, callback));
|
| +}
|
| +
|
| +// static
|
| +bool FileSystemFileUtilProxy::Flush(
|
| + FileSystemOperationContext* fs_context,
|
| + scoped_refptr<base::MessageLoopProxy> message_loop_proxy,
|
| + base::PlatformFile file,
|
| + StatusCallback* callback) {
|
| + return Start(FROM_HERE, message_loop_proxy,
|
| + new RelayFlush(fs_context, file, callback));
|
| +}
|
| +
|
| +} // namespace fileapi
|
|
|