#include "storage/browser/file_system/file_system_operation_impl.h"
#include <stdint.h>
#include <limits>
#include <memory>
#include <tuple>
#include <utility>
#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/functional/callback_helpers.h"
#include "base/task/sequenced_task_runner.h"
#include "base/time/time.h"
#include "base/types/pass_key.h"
#include "storage/browser/file_system/async_file_util.h"
#include "storage/browser/file_system/copy_or_move_hook_delegate.h"
#include "storage/browser/file_system/copy_or_move_operation_delegate.h"
#include "storage/browser/file_system/file_observers.h"
#include "storage/browser/file_system/file_system_backend.h"
#include "storage/browser/file_system/file_system_context.h"
#include "storage/browser/file_system/file_system_file_util.h"
#include "storage/browser/file_system/file_system_util.h"
#include "storage/browser/file_system/remove_operation_delegate.h"
#include "storage/browser/file_system/sandbox_file_system_backend_delegate.h"
#include "storage/browser/quota/quota_manager_proxy.h"
#include "storage/common/file_system/file_system_types.h"
#include "third_party/blink/public/common/storage_key/storage_key.h"
namespace storage {
namespace {
void Destruct(base::File file) { … }
void DidOpenFile(scoped_refptr<FileSystemContext> context,
base::WeakPtr<FileSystemOperationImpl> operation,
FileSystemOperationImpl::OpenFileCallback callback,
base::File file,
base::OnceClosure on_close_callback) { … }
}
std::unique_ptr<FileSystemOperation> FileSystemOperation::Create(
OperationType type,
const FileSystemURL& url,
FileSystemContext* file_system_context,
std::unique_ptr<FileSystemOperationContext> operation_context) { … }
FileSystemOperationImpl::~FileSystemOperationImpl() = default;
void FileSystemOperationImpl::CreateFile(const FileSystemURL& url,
bool exclusive,
StatusCallback callback) { … }
void FileSystemOperationImpl::CreateDirectory(const FileSystemURL& url,
bool exclusive,
bool recursive,
StatusCallback callback) { … }
void FileSystemOperationImpl::Copy(
const FileSystemURL& src_url,
const FileSystemURL& dest_url,
CopyOrMoveOptionSet options,
ErrorBehavior error_behavior,
std::unique_ptr<CopyOrMoveHookDelegate> copy_or_move_hook_delegate,
StatusCallback callback) { … }
void FileSystemOperationImpl::Move(
const FileSystemURL& src_url,
const FileSystemURL& dest_url,
CopyOrMoveOptionSet options,
ErrorBehavior error_behavior,
std::unique_ptr<CopyOrMoveHookDelegate> copy_or_move_hook_delegate,
StatusCallback callback) { … }
void FileSystemOperationImpl::DirectoryExists(const FileSystemURL& url,
StatusCallback callback) { … }
void FileSystemOperationImpl::FileExists(const FileSystemURL& url,
StatusCallback callback) { … }
void FileSystemOperationImpl::GetMetadata(const FileSystemURL& url,
GetMetadataFieldSet fields,
GetMetadataCallback callback) { … }
void FileSystemOperationImpl::ReadDirectory(
const FileSystemURL& url,
const ReadDirectoryCallback& callback) { … }
void FileSystemOperationImpl::Remove(const FileSystemURL& url,
bool recursive,
StatusCallback callback) { … }
void FileSystemOperationImpl::WriteBlob(
const FileSystemURL& url,
std::unique_ptr<FileWriterDelegate> writer_delegate,
std::unique_ptr<BlobReader> blob_reader,
const WriteCallback& callback) { … }
void FileSystemOperationImpl::Write(
const FileSystemURL& url,
std::unique_ptr<FileWriterDelegate> writer_delegate,
mojo::ScopedDataPipeConsumerHandle data_pipe,
const WriteCallback& callback) { … }
void FileSystemOperationImpl::Truncate(const FileSystemURL& url,
int64_t length,
StatusCallback callback) { … }
void FileSystemOperationImpl::TouchFile(const FileSystemURL& url,
const base::Time& last_access_time,
const base::Time& last_modified_time,
StatusCallback callback) { … }
void FileSystemOperationImpl::OpenFile(const FileSystemURL& url,
uint32_t file_flags,
OpenFileCallback callback) { … }
void FileSystemOperationImpl::Cancel(StatusCallback cancel_callback) { … }
void FileSystemOperationImpl::CreateSnapshotFile(
const FileSystemURL& url,
SnapshotFileCallback callback) { … }
void FileSystemOperationImpl::CopyInForeignFile(
const base::FilePath& src_local_disk_file_path,
const FileSystemURL& dest_url,
StatusCallback callback) { … }
void FileSystemOperationImpl::RemoveFile(const FileSystemURL& url,
StatusCallback callback) { … }
void FileSystemOperationImpl::RemoveDirectory(const FileSystemURL& url,
StatusCallback callback) { … }
void FileSystemOperationImpl::CopyFileLocal(
const FileSystemURL& src_url,
const FileSystemURL& dest_url,
CopyOrMoveOptionSet options,
const CopyFileProgressCallback& progress_callback,
StatusCallback callback) { … }
void FileSystemOperationImpl::MoveFileLocal(const FileSystemURL& src_url,
const FileSystemURL& dest_url,
CopyOrMoveOptionSet options,
StatusCallback callback) { … }
base::File::Error FileSystemOperationImpl::SyncGetPlatformPath(
const FileSystemURL& url,
base::FilePath* platform_path) { … }
FileSystemOperationImpl::FileSystemOperationImpl(
OperationType type,
const FileSystemURL& url,
FileSystemContext* file_system_context,
std::unique_ptr<FileSystemOperationContext> operation_context,
base::PassKey<FileSystemOperation>)
: … { … }
void FileSystemOperationImpl::GetBucketSpaceRemainingAndRunTask(
const FileSystemURL& url,
base::OnceClosure task,
base::OnceClosure error_callback) { … }
void FileSystemOperationImpl::DidGetBucketSpaceRemaining(
base::OnceClosure task,
base::OnceClosure error_callback,
QuotaErrorOr<int64_t> space_left) { … }
void FileSystemOperationImpl::DoCreateFile(const FileSystemURL& url,
StatusCallback callback,
bool exclusive) { … }
void FileSystemOperationImpl::DoCreateDirectory(const FileSystemURL& url,
StatusCallback callback,
bool exclusive,
bool recursive) { … }
void FileSystemOperationImpl::DoCopyFileLocal(
const FileSystemURL& src_url,
const FileSystemURL& dest_url,
CopyOrMoveOptionSet options,
const CopyFileProgressCallback& progress_callback,
StatusCallback callback) { … }
void FileSystemOperationImpl::DoMoveFileLocal(const FileSystemURL& src_url,
const FileSystemURL& dest_url,
CopyOrMoveOptionSet options,
StatusCallback callback) { … }
void FileSystemOperationImpl::DoCopyInForeignFile(
const base::FilePath& src_local_disk_file_path,
const FileSystemURL& dest_url,
StatusCallback callback) { … }
void FileSystemOperationImpl::DoTruncate(const FileSystemURL& url,
StatusCallback callback,
int64_t length) { … }
void FileSystemOperationImpl::DoOpenFile(const FileSystemURL& url,
OpenFileCallback callback,
uint32_t file_flags) { … }
void FileSystemOperationImpl::DidEnsureFileExistsExclusive(
StatusCallback callback,
base::File::Error rv,
bool created) { … }
void FileSystemOperationImpl::DidEnsureFileExistsNonExclusive(
StatusCallback callback,
base::File::Error rv,
bool ) { … }
void FileSystemOperationImpl::DidFinishOperation(StatusCallback callback,
base::File::Error rv) { … }
void FileSystemOperationImpl::DidDirectoryExists(
StatusCallback callback,
base::File::Error rv,
const base::File::Info& file_info) { … }
void FileSystemOperationImpl::DidFileExists(StatusCallback callback,
base::File::Error rv,
const base::File::Info& file_info) { … }
void FileSystemOperationImpl::DidDeleteRecursively(const FileSystemURL& url,
StatusCallback callback,
base::File::Error rv) { … }
void FileSystemOperationImpl::DidWrite(
const FileSystemURL& url,
const WriteCallback& write_callback,
base::File::Error rv,
int64_t bytes,
FileWriterDelegate::WriteProgressStatus write_status) { … }
void FileSystemOperationImpl::CheckOperationType(OperationType type) { … }
}