#ifndef CONTENT_PUBLIC_BROWSER_PROCESS_ALLOCATION_CONTEXT_H_
#define CONTENT_PUBLIC_BROWSER_PROCESS_ALLOCATION_CONTEXT_H_
#include <stdint.h>
#include <optional>
#include "base/types/strong_alias.h"
namespace content {
using RequiresNewProcessForCoop =
base::StrongAlias<struct RequiresNewProcessForCoopTag, bool>;
using IsOutermostMainFrame =
base::StrongAlias<struct IsOutermostMainFrameTag, bool>;
enum class ProcessAllocationSource : uint8_t {
kRFHInitRoot = 0,
kNavigationRequest = 1,
kOverrideNavigationParams = 2,
kCanRequestURL = 3,
kAuctionProcessManager = 4,
kServiceWorkerProcessManager = 5,
kSharedStorageRenderThreadWorkletDriver = 6,
kSharedWorker = 7,
kNoProcessCreationExpected = 8,
kTest = 9,
kEmbedder = 10,
kMaxValue = kEmbedder,
};
enum class ProcessAllocationNavigationStage : uint8_t {
kNoURLLoader = 0,
kBeforeNetworkRequest = 1,
kAfterNetworkRequest = 2,
kHandlingEarlyHints = 3,
kAfterResponse = 4,
kAfterFailure = 5,
kMaxValue = kAfterFailure,
};
struct NavigationProcessAllocationContext {
NavigationProcessAllocationContext(
ProcessAllocationNavigationStage stage,
int64_t navigation_id,
RequiresNewProcessForCoop requires_new_process_for_coop,
IsOutermostMainFrame is_outermost_main_frame)
: stage(stage),
navigation_id(navigation_id),
requires_new_process_for_coop(*requires_new_process_for_coop),
is_outermost_main_frame(*is_outermost_main_frame) {}
ProcessAllocationNavigationStage stage;
int64_t navigation_id;
bool requires_new_process_for_coop;
bool is_outermost_main_frame;
};
struct ProcessAllocationContext {
static ProcessAllocationContext CreateForNavigationRequest(
ProcessAllocationNavigationStage stage,
int64_t navigation_id,
bool is_outermost_main_frame);
bool IsForNavigation() const;
ProcessAllocationSource source;
std::optional<NavigationProcessAllocationContext> navigation_context;
};
}
#endif