#include "storage/browser/blob/write_blob_to_file.h"
#include <stdint.h>
#include <algorithm>
#include <limits>
#include <memory>
#include <utility>
#include <vector>
#include "base/containers/span.h"
#include "base/files/file_util.h"
#include "base/functional/bind.h"
#include "base/functional/callback_forward.h"
#include "base/numerics/checked_math.h"
#include "base/numerics/safe_conversions.h"
#include "base/task/task_traits.h"
#include "base/task/thread_pool.h"
#include "components/file_access/scoped_file_access.h"
#include "storage/browser/blob/blob_data_handle.h"
#include "storage/browser/blob/blob_data_item.h"
#include "storage/browser/blob/blob_data_snapshot.h"
#include "storage/browser/blob/shareable_blob_data_item.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_writer_delegate.h"
#include "storage/common/file_system/file_system_mount_option.h"
#include "third_party/blink/public/common/blob/blob_utils.h"
namespace storage {
namespace {
DelegateNoProgressWriteCallback;
CopyCallback;
struct WriteState { … };
FileWriterDelegate::DelegateWriteCallback IgnoreProgressWrapper(
std::unique_ptr<FileWriterDelegate> delegate,
DelegateNoProgressWriteCallback callback) { … }
bool CopyFileContentsWithOffsetAndSize(base::File* infile,
base::File* outfile,
int64_t* bytes_copied,
int64_t offset,
int64_t max_size) { … }
mojom::WriteBlobToFileResult CopyFileAndMaybeWriteTimeModified(
const base::FilePath& copy_from,
base::Time expected_last_modified_copy_from,
const base::FilePath& copy_to,
int64_t offset,
std::optional<int64_t> size,
std::optional<base::Time> last_modified,
bool flush_on_close,
file_access::ScopedFileAccess) { … }
mojom::WriteBlobToFileResult CreateEmptyFileAndMaybeSetModifiedTime(
base::FilePath file_path,
std::optional<base::Time> last_modified,
bool flush_on_write) { … }
void HandleModifiedTimeOnBlobFileWriteComplete(
base::FilePath file_path,
std::optional<base::Time> last_modified,
bool flush_on_write,
mojom::BlobStorageContext::WriteBlobToFileCallback callback,
base::File::Error rv,
int64_t bytes_written,
FileWriterDelegate::WriteProgressStatus write_status) { … }
void PostCopyTaskToFileThreadIfAllowed(
CopyCallback copy_cb,
mojom::BlobStorageContext::WriteBlobToFileCallback callback,
file_access::ScopedFileAccess scoped_file_access) { … }
void WriteConstructedBlobToFile(
std::unique_ptr<BlobDataHandle> blob_handle,
const base::FilePath& file_path,
bool flush_on_write,
std::optional<base::Time> last_modified,
mojom::BlobStorageContext::WriteBlobToFileCallback callback,
BlobStatus status) { … }
}
void WriteBlobToFile(
std::unique_ptr<BlobDataHandle> blob_handle,
const base::FilePath& file_path,
bool flush_on_write,
std::optional<base::Time> last_modified,
mojom::BlobStorageContext::WriteBlobToFileCallback callback) { … }
}