blob: 48948cf7212353668a066f5742beef6bd4209c13 [file] [log] [blame]
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
module blink.mojom;
import "services/network/public/mojom/fetch_api.mojom";
import "services/network/public/mojom/request_context_frame_type.mojom";
import "third_party/blink/public/mojom/blob/serialized_blob.mojom";
import "third_party/blink/public/mojom/referrer.mojom";
import "url/mojom/url.mojom";
// Type of the context associated with a request.
// https://fetch.spec.whatwg.org/#concept-request-destination.
// TODO(crbug.com/889751): This is a deprecated spec concept, figure out
// how to refactor this to match the new spec concepts, 'destination' and
// 'initiator'.
enum RequestContextType {
UNSPECIFIED,
AUDIO,
BEACON,
CSP_REPORT,
DOWNLOAD,
EMBED,
EVENT_SOURCE,
FAVICON,
FETCH,
FONT,
FORM,
FRAME,
HYPERLINK,
IFRAME,
IMAGE,
IMAGE_SET,
IMPORT,
INTERNAL,
LOCATION,
MANIFEST,
OBJECT,
PING,
PLUGIN,
PREFETCH,
SCRIPT,
SERVICE_WORKER,
SHARED_WORKER,
SUBRESOURCE,
STYLE,
TRACK,
VIDEO,
WORKER,
XML_HTTP_REQUEST,
XSLT,
};
// https://fetch.spec.whatwg.org/#concept-request-cache-mode
enum FetchCacheMode {
// "default": Fetch will inspect the HTTP cache on the way to the network. If
// there is a fresh response it will be used. If there is a stale response a
// conditional request will be created, and a normal request otherwise. It
// then updates the HTTP cache with the response.
kDefault,
// "no-store": Fetch behaves as if there is no HTTP cache at all.
kNoStore,
// "reload": Fetch behaves as if there is no HTTP cache on the way to the
// network. Ergo, it creates a normal request and updates the HTTP cache with
// the response.
kBypassCache,
// "no-cache": Fetch creates a conditional request if there is a response in
// the HTTP cache and a normal request otherwise. It then updates the HTTP
// cache with the response.
kValidateCache,
// "force-cache": Fetch uses any response in the HTTP cache matching the
// request, not paying attention to staleness. If there was no response, it
// creates a normal request and updates the HTTP cache with the response.
kForceCache,
// "only-if-cached": Fetch uses any response in the HTTP cache matching the
// request, not paying attention to staleness. If there was no response, it
// returns a network error.
kOnlyIfCached,
// Unspecified ones
// Similar to ONLY_IF_CACHED, but checks freshness strictly.
kUnspecifiedOnlyIfCachedStrict,
// Used by devtools to trigger a request which ends up in CACHE_MISS.
kUnspecifiedForceCacheMiss,
};
// Corresponds to Fetch request's "importance mode"
// Currently discussed at: https://github.com/WICG/priority-hints
// TODO(domfarolino): add a spec link to this once specified.
enum FetchImportanceMode {
kImportanceLow,
kImportanceAuto,
kImportanceHigh
};
struct FetchAPIRequest {
network.mojom.FetchRequestMode mode;
bool is_main_resource_load;
RequestContextType request_context_type;
network.mojom.RequestContextFrameType frame_type;
url.mojom.Url url;
string method;
map<string, string> headers;
SerializedBlob? blob;
Referrer referrer;
network.mojom.FetchCredentialsMode credentials_mode;
FetchCacheMode cache_mode;
network.mojom.FetchRedirectMode redirect_mode;
string? integrity;
bool keepalive;
string? client_id;
bool is_reload;
bool is_history_navigation;
};