chromium/services/network/public/cpp/link_header_parser.cc

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

#include "services/network/public/cpp/link_header_parser.h"

#include <algorithm>
#include <string>
#include <unordered_map>

#include "base/strings/string_util.h"
#include "components/link_header_util/link_header_util.h"
#include "net/base/mime_util.h"
#include "net/http/http_response_headers.h"

namespace network {

namespace {

bool IsValidMimeType(const std::string& type_string) {}

// Parses `rel` attribute and returns its parsed representation. Returns
// std::nullopt when the value isn't pre-defined.
std::optional<mojom::LinkRelAttribute> ParseRelAttribute(
    const std::optional<std::string>& attr) {}

// Parses `as` attribute and returns its parsed representation. Returns
// std::nullopt when the value isn't pre-defined.
std::optional<mojom::LinkAsAttribute> ParseAsAttribute(
    const std::optional<std::string>& attr) {}

// Parses `crossorigin` attribute and returns its parsed representation. Returns
// std::nullopt when the value isn't pre-defined.
std::optional<mojom::CrossOriginAttribute> ParseCrossOriginAttribute(
    const std::optional<std::string>& attr) {}

// Parses `fetchpriority` attribute and returns its parsed representation.
// Returns mojom::FetchPriorityAttribute::kAuto which is the missing and
// invalid value for the attribute.
std::optional<mojom::FetchPriorityAttribute> ParseFetchPriorityAttribute(
    const std::optional<std::string>& attr) {}

// Parses attributes of a Link header and populates parsed representations of
// attributes. Returns true only when all attributes and their values are
// pre-definied.
bool ParseAttributes(
    const std::unordered_map<std::string, std::optional<std::string>>& attrs,
    mojom::LinkHeaderPtr& parsed) {}

}  // namespace

std::vector<mojom::LinkHeaderPtr> ParseLinkHeaders(
    const net::HttpResponseHeaders& headers,
    const GURL& base_url) {}

}  // namespace network