chromium/content/browser/web_package/signed_exchange_prologue.h

// Copyright 2018 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CONTENT_BROWSER_WEB_PACKAGE_SIGNED_EXCHANGE_PROLOGUE_H_
#define CONTENT_BROWSER_WEB_PACKAGE_SIGNED_EXCHANGE_PROLOGUE_H_

#include "base/containers/span.h"
#include "base/gtest_prod_util.h"
#include "content/browser/web_package/signed_exchange_utils.h"
#include "content/common/content_export.h"
#include "url/gurl.h"

namespace content {

class SignedExchangeDevToolsProxy;

// signed_exchange_prologue namespace contains parsers for the first bytes of
// the "application/signed-exchange" format, preceding the cbor-encoded
// response header.
namespace signed_exchange_prologue {

// Parse 2-byte encoded length of the variable-length field in the signed
// exchange. Note: |input| must be pointing to a valid memory address that has
// at least 2 bytes.
CONTENT_EXPORT size_t Parse2BytesEncodedLength(base::span<const uint8_t> input);

// Parse 3-byte encoded length of the variable-length field in the signed
// exchange. Note: |input| must be pointing to a valid memory address that has
// at least 3 bytes.
CONTENT_EXPORT size_t Parse3BytesEncodedLength(base::span<const uint8_t> input);

// BeforeFallbackUrl holds the decoded data from the first
// |BeforeFallbackUrl::kEncodedSizeInBytes| bytes of the
// "application/signed-exchange" format.
class CONTENT_EXPORT BeforeFallbackUrl {};

class CONTENT_EXPORT FallbackUrlAndAfter {};

}  // namespace signed_exchange_prologue

}  // namespace content

#endif  // CONTENT_BROWSER_WEB_PACKAGE_SIGNED_EXCHANGE_PROLOGUE_H_