#include "services/data_decoder/public/cpp/safe_web_bundle_parser.h"
#include <memory>
#include <optional>
#include "base/check.h"
#include "base/functional/bind.h"
#include "base/not_fatal_until.h"
#include "base/task/task_traits.h"
#include "base/task/thread_pool.h"
#include "base/types/expected.h"
#include "base/types/expected_macros.h"
#include "url/gurl.h"
namespace data_decoder {
namespace {
constexpr char kConnectionError[] = …;
void CloseFile(base::File file, base::OnceClosure close_callback) { … }
class FileDataSourceStrategy : public DataSourceCreatingStrategy { … };
void ReplyWithInternalError(
web_package::mojom::WebBundleParser::ParseIntegrityBlockCallback callback,
std::string error) { … }
void ReplyWithInternalError(
web_package::mojom::WebBundleParser::ParseMetadataCallback callback,
std::string error) { … }
void ReplyWithInternalError(
web_package::mojom::WebBundleParser::ParseResponseCallback callback,
std::string error) { … }
}
std::unique_ptr<DataSourceCreatingStrategy>
SafeWebBundleParser::GetFileStrategy(base::File file) { … }
SafeWebBundleParser::Connection::Connection() = default;
SafeWebBundleParser::Connection::~Connection() = default;
SafeWebBundleParser::SafeWebBundleParser(
std::optional<GURL> base_url,
std::unique_ptr<DataSourceCreatingStrategy> data_source_creator)
: … { … }
SafeWebBundleParser::~SafeWebBundleParser() = default;
void SafeWebBundleParser::ParseIntegrityBlock(
web_package::mojom::WebBundleParser::ParseIntegrityBlockCallback callback) { … }
void SafeWebBundleParser::ParseMetadata(
std::optional<uint64_t> offset,
web_package::mojom::WebBundleParser::ParseMetadataCallback callback) { … }
void SafeWebBundleParser::ParseResponse(
uint64_t response_offset,
uint64_t response_length,
web_package::mojom::WebBundleParser::ParseResponseCallback callback) { … }
void SafeWebBundleParser::Close(base::OnceClosure callback) { … }
web_package::mojom::WebBundleParserFactory* SafeWebBundleParser::GetFactory() { … }
base::expected<void, std::string> SafeWebBundleParser::ConnectIfNecessary() { … }
void SafeWebBundleParser::OnDisconnect() { … }
void SafeWebBundleParser::OnIntegrityBlockParsed(
web_package::mojom::BundleIntegrityBlockPtr integrity_block,
web_package::mojom::BundleIntegrityBlockParseErrorPtr error) { … }
void SafeWebBundleParser::OnMetadataParsed(
web_package::mojom::BundleMetadataPtr metadata,
web_package::mojom::BundleMetadataParseErrorPtr error) { … }
void SafeWebBundleParser::OnResponseParsed(
size_t callback_id,
web_package::mojom::BundleResponsePtr response,
web_package::mojom::BundleResponseParseErrorPtr error) { … }
void SafeWebBundleParser::CloseDataSourceCreator() { … }
void SafeWebBundleParser::ReplyClosed() { … }
}