| // Copyright 2019 The Chromium Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| |
| module data_decoder.mojom; |
| |
| import "mojo/public/mojom/base/file.mojom"; |
| import "url/mojom/url.mojom"; |
| |
| // Factory interface to create BundledExchangesParser for the passed |file| |
| // or |data_source| that provides application/webbundle data. |
| interface BundledExchangesParserFactory { |
| // Constructs a parser for the passed |file|. |
| GetParserForFile(pending_receiver<BundledExchangesParser> receiver, |
| mojo_base.mojom.File file); |
| |
| // Constructs a parser for the passed |data_source|. |
| GetParserForDataSource(pending_receiver<BundledExchangesParser> receiver, |
| pending_remote<BundleDataSource> data_source); |
| }; |
| |
| // Parser interface to obtain metadata and multiple responses from the bound |
| // application/webbundle data provided on the construction at the factory above. |
| interface BundledExchangesParser { |
| // Parses bundle's metadata. |
| ParseMetadata() => (BundleMetadata? Result, BundleMetadataParseError? error); |
| |
| // Parses a response from the range |
| // |[response_offset, response_offset + response_length)|. |
| ParseResponse(uint64 response_offset, |
| uint64 response_length) |
| => (BundleResponse? Result, BundleResponseParseError? error); |
| }; |
| |
| // Data source that provides application/webbundle data to the parser. |
| interface BundleDataSource { |
| GetSize() => (uint64 size); |
| Read(uint64 offset, uint64 length) => (array<uint8>? buffer); |
| }; |
| |
| struct BundleMetadataParseError { |
| string message; |
| // TODO(crbug.com/969596): Add fields for error type and fallback URL. |
| }; |
| |
| struct BundleResponseParseError { |
| string message; |
| }; |
| |
| struct BundleMetadata { |
| array<BundleIndexItem> index; |
| url.mojom.Url manifest_url; |
| }; |
| |
| struct BundleIndexItem { |
| url.mojom.Url request_url; |
| string request_method; |
| map<string, string> request_headers; |
| |
| // Used as parameters to ParseResponse(). |
| uint64 response_offset; |
| uint64 response_length; |
| }; |
| |
| struct BundleResponse { |
| int32 response_code; |
| map<string, string> response_headers; |
| |
| // Payload offset and length within the webbundle file. |
| uint64 payload_offset; |
| uint64 payload_length; |
| }; |