Commit 5bd3e578 authored by Andrey Kosyakov's avatar Andrey Kosyakov Committed by Commit Bot

Revert "BundledExchangesParser: Update the bundle format [1/2]"

This reverts commit d8c863a6.

Reason for revert: broke build, example: https://logs.chromium.org/logs/chromium/buildbucket/cr-buildbucket.appspot.com/8905916412276160432/+/steps/compile__with_patch_/0/stdout

Original change's description:
> BundledExchangesParser: Update the bundle format [1/2]
> 
> This updates BundledExchangesParser to parse the new bundle format [1].
> 
> Changes:
> - Updated the magic header bytes [2]
> - Version field is added (we use implementation-specific version string
>   "b1\0\0", which matches gen-bundle's output [3])
> - Fallback URL (== Primary URL) field is added
> - ParseMetadata() returns error type ("format error" or "version error")
>   and fallback URL if available
> - Updated spec ref comments
> 
> The structure change of the index section is not reflected yet. It will
> be updated in the next CL.
> 
> The test bundle file (hello.wbn) is generated with gen-bundle of
> github.com/WICG/webpackage revision a3cef2c, which supports the new
> bundle format except for the new index section structure.
> 
> [1] https://github.com/WICG/webpackage/pull/450
> [2] https://github.com/WICG/webpackage/pull/454
> [3] https://github.com/WICG/webpackage/pull/458
> 
> Bug: 969596
> Change-Id: I95744ed00fdd09d369bb8648d1cdf62ca181d0dd
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1715487
> Reviewed-by: Robert Sesek <rsesek@chromium.org>
> Reviewed-by: Tsuyoshi Horo <horo@chromium.org>
> Reviewed-by: Takashi Toyoshima <toyoshim@chromium.org>
> Reviewed-by: Kinuko Yasuda <kinuko@chromium.org>
> Commit-Queue: Kunihiko Sakamoto <ksakamoto@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#684200}

TBR=horo@chromium.org,kinuko@chromium.org,toyoshim@chromium.org,ksakamoto@chromium.org,rsesek@chromium.org

Change-Id: Ifce2b07c15a57a2030887cbfaad5853cbc5af992
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 969596
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1737883Reviewed-by: default avatarAndrey Kosyakov <caseq@chromium.org>
Commit-Queue: Andrey Kosyakov <caseq@chromium.org>
Cr-Commit-Position: refs/heads/master@{#684207}
parent 7873f598
...@@ -163,9 +163,7 @@ class BundledExchangesReaderTest : public testing::Test { ...@@ -163,9 +163,7 @@ class BundledExchangesReaderTest : public testing::Test {
items.push_back(std::move(item)); items.push_back(std::move(item));
data_decoder::mojom::BundleMetadataPtr metadata = data_decoder::mojom::BundleMetadataPtr metadata =
data_decoder::mojom::BundleMetadata::New(GURL() /* primary_url */, data_decoder::mojom::BundleMetadata::New(std::move(items), GURL());
std::move(items),
GURL() /* manifest_url */);
factory_->RunMetadataCallback(std::move(metadata)); factory_->RunMetadataCallback(std::move(metadata));
run_loop.Run(); run_loop.Run();
} }
......
...@@ -60,9 +60,7 @@ void SafeBundledExchangesParser::ParseMetadata( ...@@ -60,9 +60,7 @@ void SafeBundledExchangesParser::ParseMetadata(
// simultaneous request is fine enough. // simultaneous request is fine enough.
if (disconnected_ || !metadata_callback_.is_null()) { if (disconnected_ || !metadata_callback_.is_null()) {
std::move(callback).Run( std::move(callback).Run(
nullptr, mojom::BundleMetadataParseError::New( nullptr, mojom::BundleMetadataParseError::New(kConnectionError));
mojom::BundleParseErrorType::kParserInternalError,
GURL() /* fallback_url */, kConnectionError));
return; return;
} }
metadata_callback_ = std::move(callback); metadata_callback_ = std::move(callback);
...@@ -80,9 +78,7 @@ void SafeBundledExchangesParser::ParseResponse( ...@@ -80,9 +78,7 @@ void SafeBundledExchangesParser::ParseResponse(
if (disconnected_ || if (disconnected_ ||
response_callbacks_.contains(response_callback_next_id_)) { response_callbacks_.contains(response_callback_next_id_)) {
std::move(callback).Run( std::move(callback).Run(
nullptr, mojom::BundleResponseParseError::New( nullptr, mojom::BundleResponseParseError::New(kConnectionError));
mojom::BundleParseErrorType::kParserInternalError,
kConnectionError));
return; return;
} }
size_t callback_id = response_callback_next_id_++; size_t callback_id = response_callback_next_id_++;
...@@ -97,14 +93,10 @@ void SafeBundledExchangesParser::OnDisconnect() { ...@@ -97,14 +93,10 @@ void SafeBundledExchangesParser::OnDisconnect() {
disconnected_ = true; disconnected_ = true;
if (!metadata_callback_.is_null()) if (!metadata_callback_.is_null())
std::move(metadata_callback_) std::move(metadata_callback_)
.Run(nullptr, mojom::BundleMetadataParseError::New( .Run(nullptr, mojom::BundleMetadataParseError::New(kConnectionError));
mojom::BundleParseErrorType::kParserInternalError,
GURL() /* fallback_url */, kConnectionError));
for (auto& callback : response_callbacks_) for (auto& callback : response_callbacks_)
std::move(callback.second) std::move(callback.second)
.Run(nullptr, mojom::BundleResponseParseError::New( .Run(nullptr, mojom::BundleResponseParseError::New(kConnectionError));
mojom::BundleParseErrorType::kParserInternalError,
kConnectionError));
response_callbacks_.clear(); response_callbacks_.clear();
} }
......
...@@ -38,26 +38,16 @@ interface BundleDataSource { ...@@ -38,26 +38,16 @@ interface BundleDataSource {
Read(uint64 offset, uint64 length) => (array<uint8>? buffer); Read(uint64 offset, uint64 length) => (array<uint8>? buffer);
}; };
enum BundleParseErrorType {
kParserInternalError,
kFormatError,
kVersionError,
};
struct BundleMetadataParseError { struct BundleMetadataParseError {
BundleParseErrorType type;
url.mojom.Url fallback_url;
string message; string message;
// TODO(crbug.com/969596): Add fields for error type and fallback URL.
}; };
struct BundleResponseParseError { struct BundleResponseParseError {
BundleParseErrorType type;
string message; string message;
}; };
// https://wicg.github.io/webpackage/draft-yasskin-wpack-bundled-exchanges.html#semantics-load-metadata
struct BundleMetadata { struct BundleMetadata {
url.mojom.Url primary_url;
array<BundleIndexItem> index; array<BundleIndexItem> index;
url.mojom.Url manifest_url; url.mojom.Url manifest_url;
}; };
......
...@@ -12,8 +12,7 @@ if ! command -v gen-bundle > /dev/null 2>&1; then ...@@ -12,8 +12,7 @@ if ! command -v gen-bundle > /dev/null 2>&1; then
exit 1 exit 1
fi fi
gen-bundle -version b1 \ gen-bundle -baseURL https://test.example.org/ \
-baseURL https://test.example.org/ \
-dir hello/ \ -dir hello/ \
-manifestURL manifest.webmanifest \ -manifestURL manifest.webmanifest \
-o hello.wbn -o hello.wbn
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment