#include "storage/browser/file_system/file_system_context.h"
#include <stddef.h>
#include <stdint.h>
#include <memory>
#include <utility>
#include "base/containers/contains.h"
#include "base/feature_list.h"
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/memory/ptr_util.h"
#include "base/memory/scoped_refptr.h"
#include "base/task/sequenced_task_runner.h"
#include "base/task/single_thread_task_runner.h"
#include "base/types/pass_key.h"
#include "components/file_access/scoped_file_access_delegate.h"
#include "components/services/storage/public/cpp/buckets/bucket_info.h"
#include "components/services/storage/public/cpp/buckets/constants.h"
#include "components/services/storage/public/cpp/quota_client_callback_wrapper.h"
#include "components/services/storage/public/mojom/quota_client.mojom.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "mojo/public/cpp/bindings/receiver.h"
#include "storage/browser/file_system/copy_or_move_file_validator.h"
#include "storage/browser/file_system/external_mount_points.h"
#include "storage/browser/file_system/file_permission_policy.h"
#include "storage/browser/file_system/file_stream_reader.h"
#include "storage/browser/file_system/file_stream_writer.h"
#include "storage/browser/file_system/file_system_features.h"
#include "storage/browser/file_system/file_system_file_util.h"
#include "storage/browser/file_system/file_system_operation.h"
#include "storage/browser/file_system/file_system_operation_runner.h"
#include "storage/browser/file_system/file_system_options.h"
#include "storage/browser/file_system/file_system_quota_client.h"
#include "storage/browser/file_system/file_system_request_info.h"
#include "storage/browser/file_system/file_system_url.h"
#include "storage/browser/file_system/file_system_util.h"
#include "storage/browser/file_system/isolated_context.h"
#include "storage/browser/file_system/isolated_file_system_backend.h"
#include "storage/browser/file_system/mount_points.h"
#include "storage/browser/file_system/quota/quota_reservation.h"
#include "storage/browser/file_system/sandbox_file_system_backend.h"
#include "storage/browser/quota/quota_manager_proxy.h"
#include "storage/browser/quota/special_storage_policy.h"
#include "storage/common/file_system/file_system_info.h"
#include "storage/common/file_system/file_system_util.h"
#include "third_party/blink/public/common/storage_key/storage_key.h"
#include "third_party/blink/public/mojom/quota/quota_types.mojom-shared.h"
#include "third_party/blink/public/mojom/quota/quota_types.mojom.h"
#include "third_party/leveldatabase/leveldb_chrome.h"
#include "url/gurl.h"
#include "url/origin.h"
namespace storage {
namespace {
void DidGetMetadataForResolveURL(const base::FilePath& path,
FileSystemContext::ResolveURLCallback callback,
const FileSystemInfo& info,
base::File::Error error,
const base::File::Info& file_info) { … }
void RelayResolveURLCallback(
scoped_refptr<base::SingleThreadTaskRunner> task_runner,
FileSystemContext::ResolveURLCallback callback,
base::File::Error result,
const FileSystemInfo& info,
const base::FilePath& file_path,
FileSystemContext::ResolvedEntryType type) { … }
}
int FileSystemContext::GetPermissionPolicy(FileSystemType type) { … }
scoped_refptr<FileSystemContext> FileSystemContext::Create(
scoped_refptr<base::SingleThreadTaskRunner> io_task_runner,
scoped_refptr<base::SequencedTaskRunner> file_task_runner,
scoped_refptr<ExternalMountPoints> external_mount_points,
scoped_refptr<SpecialStoragePolicy> special_storage_policy,
scoped_refptr<QuotaManagerProxy> quota_manager_proxy,
std::vector<std::unique_ptr<FileSystemBackend>> additional_backends,
const std::vector<URLRequestAutoMountHandler>& auto_mount_handlers,
const base::FilePath& partition_path,
const FileSystemOptions& options) { … }
FileSystemContext::FileSystemContext(
scoped_refptr<base::SingleThreadTaskRunner> io_task_runner,
scoped_refptr<base::SequencedTaskRunner> file_task_runner,
scoped_refptr<ExternalMountPoints> external_mount_points,
scoped_refptr<SpecialStoragePolicy> special_storage_policy,
scoped_refptr<QuotaManagerProxy> quota_manager_proxy,
std::vector<std::unique_ptr<FileSystemBackend>> additional_backends,
const std::vector<URLRequestAutoMountHandler>& auto_mount_handlers,
const base::FilePath& partition_path,
const FileSystemOptions& options,
base::PassKey<FileSystemContext>)
: … { … }
void FileSystemContext::Initialize() { … }
scoped_refptr<QuotaReservation>
FileSystemContext::CreateQuotaReservationOnFileTaskRunner(
const blink::StorageKey& storage_key,
FileSystemType type) { … }
void FileSystemContext::Shutdown() { … }
FileSystemQuotaUtil* FileSystemContext::GetQuotaUtil(
FileSystemType type) const { … }
AsyncFileUtil* FileSystemContext::GetAsyncFileUtil(FileSystemType type) const { … }
CopyOrMoveFileValidatorFactory*
FileSystemContext::GetCopyOrMoveFileValidatorFactory(
FileSystemType type,
base::File::Error* error_code) const { … }
FileSystemBackend* FileSystemContext::GetFileSystemBackend(
FileSystemType type) const { … }
WatcherManager* FileSystemContext::GetWatcherManager(
FileSystemType type) const { … }
bool FileSystemContext::IsSandboxFileSystem(FileSystemType type) const { … }
const UpdateObserverList* FileSystemContext::GetUpdateObservers(
FileSystemType type) const { … }
const ChangeObserverList* FileSystemContext::GetChangeObservers(
FileSystemType type) const { … }
const AccessObserverList* FileSystemContext::GetAccessObservers(
FileSystemType type) const { … }
std::vector<FileSystemType> FileSystemContext::GetFileSystemTypes() const { … }
void FileSystemContext::OpenFileSystem(
const blink::StorageKey& storage_key,
const std::optional<storage::BucketLocator>& bucket,
FileSystemType type,
OpenFileSystemMode mode,
OpenFileSystemCallback callback) { … }
void FileSystemContext::OnGetOrCreateBucket(
const blink::StorageKey& storage_key,
FileSystemType type,
OpenFileSystemMode mode,
OpenFileSystemCallback callback,
QuotaErrorOr<BucketInfo> result) { … }
void FileSystemContext::ResolveURLOnOpenFileSystem(
const blink::StorageKey& storage_key,
const std::optional<storage::BucketLocator>& bucket,
FileSystemType type,
OpenFileSystemMode mode,
OpenFileSystemCallback callback) { … }
void FileSystemContext::DidResolveURLOnOpenFileSystem(
const FileSystemURL& filesystem_root_url,
OpenFileSystemCallback callback,
const GURL& filesystem_root,
const std::string& filesystem_name,
base::File::Error error) { … }
void FileSystemContext::ResolveURL(const FileSystemURL& url,
ResolveURLCallback callback) { … }
void FileSystemContext::AttemptAutoMountForURLRequest(
const FileSystemRequestInfo& request_info,
StatusCallback callback) { … }
void FileSystemContext::DeleteFileSystem(const blink::StorageKey& storage_key,
FileSystemType type,
StatusCallback callback) { … }
void FileSystemContext::OnGetBucketForDeleteFileSystem(
FileSystemType type,
StatusCallback callback,
QuotaErrorOr<BucketInfo> result) { … }
std::unique_ptr<FileStreamReader> FileSystemContext::CreateFileStreamReader(
const FileSystemURL& url,
int64_t offset,
int64_t max_bytes_to_read,
const base::Time& expected_modification_time,
file_access::ScopedFileAccessDelegate::RequestFilesAccessIOCallback
file_access) { … }
std::unique_ptr<FileStreamWriter> FileSystemContext::CreateFileStreamWriter(
const FileSystemURL& url,
int64_t offset) { … }
std::unique_ptr<FileSystemOperationRunner>
FileSystemContext::CreateFileSystemOperationRunner() { … }
base::SequenceBound<FileSystemOperationRunner>
FileSystemContext::CreateSequenceBoundFileSystemOperationRunner() { … }
FileSystemURL FileSystemContext::CrackURL(
const GURL& url,
const blink::StorageKey& storage_key) const { … }
FileSystemURL FileSystemContext::CrackURLInFirstPartyContext(
const GURL& url) const { … }
FileSystemURL FileSystemContext::CreateCrackedFileSystemURL(
const blink::StorageKey& storage_key,
FileSystemType type,
const base::FilePath& path) const { … }
bool FileSystemContext::CanServeURLRequest(const FileSystemURL& url) const { … }
FileSystemContext::~FileSystemContext() { … }
std::vector<blink::mojom::StorageType>
FileSystemContext::QuotaManagedStorageTypes() { … }
std::unique_ptr<FileSystemOperation>
FileSystemContext::CreateFileSystemOperation(OperationType type,
const FileSystemURL& url,
base::File::Error* error_code) { … }
FileSystemURL FileSystemContext::CrackFileSystemURL(
const FileSystemURL& url) const { … }
void FileSystemContext::RegisterBackend(FileSystemBackend* backend) { … }
void FileSystemContext::DidOpenFileSystemForResolveURL(
const FileSystemURL& url,
FileSystemContext::ResolveURLCallback callback,
const GURL& filesystem_root,
const std::string& filesystem_name,
base::File::Error error) { … }
}