#include "third_party/blink/renderer/modules/filesystem/file_system_dispatcher.h"
#include <utility>
#include "base/containers/contains.h"
#include "base/task/sequenced_task_runner.h"
#include "build/build_config.h"
#include "components/services/filesystem/public/mojom/types.mojom-blink.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "third_party/blink/public/platform/browser_interface_broker_proxy.h"
#include "third_party/blink/public/platform/file_path_conversion.h"
#include "third_party/blink/public/platform/platform.h"
#include "third_party/blink/public/platform/task_type.h"
#include "third_party/blink/renderer/core/execution_context/execution_context.h"
#include "third_party/blink/renderer/core/fileapi/blob.h"
#include "third_party/blink/renderer/platform/wtf/functional.h"
#include "third_party/blink/renderer/platform/wtf/text/wtf_string.h"
namespace blink {
class FileSystemDispatcher::WriteListener
: public mojom::blink::FileSystemOperationListener { … };
class FileSystemDispatcher::ReadDirectoryListener
: public mojom::blink::FileSystemOperationListener { … };
FileSystemDispatcher::FileSystemDispatcher(ExecutionContext& context)
: … { … }
const char FileSystemDispatcher::kSupplementName[] = …;
FileSystemDispatcher& FileSystemDispatcher::From(ExecutionContext* context) { … }
FileSystemDispatcher::~FileSystemDispatcher() = default;
mojom::blink::FileSystemManager& FileSystemDispatcher::GetFileSystemManager() { … }
void FileSystemDispatcher::OpenFileSystem(
const SecurityOrigin* origin,
mojom::blink::FileSystemType type,
std::unique_ptr<FileSystemCallbacks> callbacks) { … }
void FileSystemDispatcher::OpenFileSystemSync(
const SecurityOrigin* origin,
mojom::blink::FileSystemType type,
std::unique_ptr<FileSystemCallbacks> callbacks) { … }
void FileSystemDispatcher::ResolveURL(
const KURL& filesystem_url,
std::unique_ptr<ResolveURICallbacks> callbacks) { … }
void FileSystemDispatcher::ResolveURLSync(
const KURL& filesystem_url,
std::unique_ptr<ResolveURICallbacks> callbacks) { … }
void FileSystemDispatcher::Move(const KURL& src_path,
const KURL& dest_path,
std::unique_ptr<EntryCallbacks> callbacks) { … }
void FileSystemDispatcher::MoveSync(const KURL& src_path,
const KURL& dest_path,
std::unique_ptr<EntryCallbacks> callbacks) { … }
void FileSystemDispatcher::Copy(const KURL& src_path,
const KURL& dest_path,
std::unique_ptr<EntryCallbacks> callbacks) { … }
void FileSystemDispatcher::CopySync(const KURL& src_path,
const KURL& dest_path,
std::unique_ptr<EntryCallbacks> callbacks) { … }
void FileSystemDispatcher::Remove(const KURL& path,
bool recursive,
std::unique_ptr<VoidCallbacks> callbacks) { … }
void FileSystemDispatcher::RemoveSync(
const KURL& path,
bool recursive,
std::unique_ptr<VoidCallbacks> callbacks) { … }
void FileSystemDispatcher::ReadMetadata(
const KURL& path,
std::unique_ptr<MetadataCallbacks> callbacks) { … }
void FileSystemDispatcher::ReadMetadataSync(
const KURL& path,
std::unique_ptr<MetadataCallbacks> callbacks) { … }
void FileSystemDispatcher::CreateFile(
const KURL& path,
bool exclusive,
std::unique_ptr<EntryCallbacks> callbacks) { … }
void FileSystemDispatcher::CreateFileSync(
const KURL& path,
bool exclusive,
std::unique_ptr<EntryCallbacks> callbacks) { … }
void FileSystemDispatcher::CreateDirectory(
const KURL& path,
bool exclusive,
bool recursive,
std::unique_ptr<EntryCallbacks> callbacks) { … }
void FileSystemDispatcher::CreateDirectorySync(
const KURL& path,
bool exclusive,
bool recursive,
std::unique_ptr<EntryCallbacks> callbacks) { … }
void FileSystemDispatcher::Exists(const KURL& path,
bool is_directory,
std::unique_ptr<EntryCallbacks> callbacks) { … }
void FileSystemDispatcher::ExistsSync(
const KURL& path,
bool is_directory,
std::unique_ptr<EntryCallbacks> callbacks) { … }
void FileSystemDispatcher::ReadDirectory(
const KURL& path,
std::unique_ptr<EntriesCallbacks> callbacks) { … }
void FileSystemDispatcher::ReadDirectorySync(
const KURL& path,
std::unique_ptr<EntriesCallbacks> callbacks) { … }
void FileSystemDispatcher::InitializeFileWriter(
const KURL& path,
std::unique_ptr<FileWriterCallbacks> callbacks) { … }
void FileSystemDispatcher::InitializeFileWriterSync(
const KURL& path,
std::unique_ptr<FileWriterCallbacks> callbacks) { … }
void FileSystemDispatcher::Truncate(const KURL& path,
int64_t offset,
int* request_id_out,
StatusCallback callback) { … }
void FileSystemDispatcher::TruncateSync(const KURL& path,
int64_t offset,
StatusCallback callback) { … }
void FileSystemDispatcher::Write(const KURL& path,
const Blob& blob,
int64_t offset,
int* request_id_out,
const WriteCallback& success_callback,
StatusCallback error_callback) { … }
void FileSystemDispatcher::WriteSync(const KURL& path,
const Blob& blob,
int64_t offset,
const WriteCallback& success_callback,
StatusCallback error_callback) { … }
void FileSystemDispatcher::Cancel(int request_id_to_cancel,
StatusCallback callback) { … }
void FileSystemDispatcher::CreateSnapshotFile(
const KURL& file_path,
std::unique_ptr<SnapshotFileCallbackBase> callbacks) { … }
void FileSystemDispatcher::CreateSnapshotFileSync(
const KURL& file_path,
std::unique_ptr<SnapshotFileCallbackBase> callbacks) { … }
void FileSystemDispatcher::Trace(Visitor* visitor) const { … }
void FileSystemDispatcher::DidOpenFileSystem(
std::unique_ptr<FileSystemCallbacks> callbacks,
const String& name,
const KURL& root,
base::File::Error error_code) { … }
void FileSystemDispatcher::DidResolveURL(
std::unique_ptr<ResolveURICallbacks> callbacks,
mojom::blink::FileSystemInfoPtr info,
const base::FilePath& file_path,
bool is_directory,
base::File::Error error_code) { … }
void FileSystemDispatcher::DidRemove(std::unique_ptr<VoidCallbacks> callbacks,
base::File::Error error_code) { … }
void FileSystemDispatcher::DidFinish(std::unique_ptr<EntryCallbacks> callbacks,
base::File::Error error_code) { … }
void FileSystemDispatcher::DidReadMetadata(
std::unique_ptr<MetadataCallbacks> callbacks,
const base::File::Info& file_info,
base::File::Error error_code) { … }
void FileSystemDispatcher::DidReadDirectory(
std::unique_ptr<EntriesCallbacks> callbacks,
Vector<filesystem::mojom::blink::DirectoryEntryPtr> entries,
base::File::Error error_code) { … }
void FileSystemDispatcher::InitializeFileWriterCallback(
const KURL& path,
std::unique_ptr<FileWriterCallbacks> callbacks,
const base::File::Info& file_info,
base::File::Error error_code) { … }
void FileSystemDispatcher::DidTruncate(int operation_id,
StatusCallback callback,
base::File::Error error_code) { … }
void FileSystemDispatcher::DidWrite(const WriteCallback& callback,
int operation_id,
int64_t bytes,
bool complete) { … }
void FileSystemDispatcher::WriteErrorCallback(StatusCallback callback,
int operation_id,
base::File::Error error) { … }
void FileSystemDispatcher::DidCancel(StatusCallback callback,
int cancelled_operation_id,
base::File::Error error_code) { … }
void FileSystemDispatcher::DidCreateSnapshotFile(
std::unique_ptr<SnapshotFileCallbackBase> callbacks,
const base::File::Info& file_info,
const base::FilePath& platform_path,
base::File::Error error_code,
mojo::PendingRemote<mojom::blink::ReceivedSnapshotListener> listener) { … }
void FileSystemDispatcher::RemoveOperationRemote(int operation_id) { … }
}