Files
smayya 31d07ee57d Bug 2037102 - [speculation-rules] Part 1.1: Add PPrefetchRecord IPDL actor scaffolding r=dom-core-reviewers,necko-reviewers,avandolder,nika,kershaw
Plumbing-only patch for Speculation Rules prefetch (M1, same-origin).
Adds the PPrefetchRecord IPDL protocol, child/parent actor skeletons,
and PWindowGlobal management. No behavior yet — Init/Cancel bodies and
SpeculationRulesManager wiring follow in subsequent parts.

- dom/ipc/PPrefetchRecord.ipdl (new): protocol definition
- dom/ipc/PrefetchIPCTypes.ipdlh (new): shared IPDL types
  (SpeculativePrefetchArgs) usable by PPrefetchRecord + PWindowGlobal
- dom/ipc/PrefetchTypes.h (new): shared C++ enums (PrefetchState,
  PrefetchAnonymizationPolicy, PrefetchSource) and ExchangeRecord
- dom/ipc/PrefetchRecordChild.{h,cpp} (new): content-side actor; holds
  URL + anon policy
- dom/ipc/PrefetchRecordParent.{h,cpp} (new): parent-side actor; holds
  prefetch record fields; empty RecvCancel/ActorDestroy
- dom/ipc/PWindowGlobal.ipdl: add 'manages PPrefetchRecord;' and
  constructor message
- dom/ipc/WindowGlobalParent.{h,cpp}: add AllocPPrefetchRecordParent
- dom/ipc/moz.build: wire new sources

Spec: https://wicg.github.io/nav-speculation/prefetch.html

Differential Revision: https://phabricator.services.mozilla.com/D302502
2026-07-30 08:26:16 +00:00

62 lines
2.0 KiB
C++

/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef mozilla_dom_PrefetchTypes_h
#define mozilla_dom_PrefetchTypes_h
#include "mozilla/TimeStamp.h"
#include "nsCOMPtr.h"
#include "nsIURI.h"
#include "nsString.h"
#include "nsTArray.h"
namespace mozilla::dom {
// Speculation Rules Prefetch — shared types used by both child- and
// parent-side actors and by the DOM-side SpeculationRulesManager.
// Spec: https://wicg.github.io/nav-speculation/prefetch.html
// Spec: https://wicg.github.io/nav-speculation/prefetch.html#prefetch-record
// (the `state` field).
enum class PrefetchState : uint8_t {
Ongoing,
Completed,
Canceled,
};
// Spec:
// https://wicg.github.io/nav-speculation/prefetch.html#prefetch-ip-anonymization-policy
// Wire format uses `bool anonymizeClientIP`; the enum exists for clarity
// at C++ call sites.
enum class PrefetchAnonymizationPolicy : uint8_t {
None,
AnonymousClientIPWhenCrossOrigin,
};
// Spec: https://wicg.github.io/nav-speculation/prefetch.html#prefetch-record
// (the `source` field).
enum class PrefetchSource : uint8_t {
SpeculationRules,
};
// Per-hop redirect chain entry on PrefetchRecordParent.
// Spec: https://wicg.github.io/nav-speculation/prefetch.html#prefetch-record
// (the `redirect chain` field).
// Body for each hop lives in the HTTP cache, keyed by (URI, OriginAttributes).
struct ExchangeRecord {
nsCOMPtr<nsIURI> mRequestURI;
// M2 placeholder; unused in M1 (URL + partition suffices for same-origin
// cache lookup).
nsCString mResponseCacheKey;
uint32_t mResponseStatus = 0;
// Raw `No-Vary-Search` response header; parsed at match time via
// NoVarySearchUtils (bug 2038006).
nsCString mNoVarySearchHeader;
};
} // namespace mozilla::dom
#endif // mozilla_dom_PrefetchTypes_h