chromium/extensions/browser/api/declarative_net_request/request_action.h

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

#ifndef EXTENSIONS_BROWSER_API_DECLARATIVE_NET_REQUEST_REQUEST_ACTION_H_
#define EXTENSIONS_BROWSER_API_DECLARATIVE_NET_REQUEST_REQUEST_ACTION_H_

#include <cstdint>
#include <optional>
#include <vector>

#include "extensions/common/api/declarative_net_request.h"
#include "extensions/common/api/declarative_net_request/constants.h"
#include "extensions/common/extension_id.h"
#include "url/gurl.h"

namespace extensions::declarative_net_request {

namespace flat {
struct ModifyHeaderInfo;
}  // namespace flat

// A struct representing an action to be applied to a request based on DNR rule
// matches. Each action is attributed to exactly one extension.
struct RequestAction {};

// Compares RequestAction by |index_priority|, breaking ties by |ruleset_id|
// then |rule_id|.
bool operator<(const RequestAction& lhs, const RequestAction& rhs);
bool operator>(const RequestAction& lhs, const RequestAction& rhs);

std::optional<RequestAction> GetMaxPriorityAction(
    std::optional<RequestAction> lhs,
    std::optional<RequestAction> rhs);

}  // namespace extensions::declarative_net_request

#endif  // EXTENSIONS_BROWSER_API_DECLARATIVE_NET_REQUEST_REQUEST_ACTION_H_