blob: a7d2f5d35c9a6f9c6dc1f4cebfe766043f0d9cd9 [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 "mojo/public/mojom/base/unguessable_token.mojom";
import "services/network/public/mojom/fetch_api.mojom";
import "services/network/public/mojom/request_context_frame_type.mojom";
import "services/network/public/mojom/url_loader.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
};
// Request headers for FetchAPIRequest. This is typemapped to a container with a
// case insensitive compare or hash function.
struct FetchAPIRequestHeaders {
map<string, string> headers;
};
// Struct representing a Request:
// https://fetch.spec.whatwg.org/#request-class
// Compared to network.mojom.URLRequest which is kind of internal data in the
// loading stack, FetchAPIRequest acts as a direct representation of the JS
// Request object in all API implementations like Background Fetch, Cache
// Storage and Service Worker, with no need to care how the loading logic
// happens.
// Note: When updating this struct, also update
// content/common/fetch/fetch_request_type_converters.cc.
struct FetchAPIRequest {
network.mojom.FetchRequestMode mode = network.mojom.FetchRequestMode.kNoCors;
bool is_main_resource_load = false;
RequestContextType request_context_type = RequestContextType.UNSPECIFIED;
network.mojom.RequestContextFrameType frame_type =
network.mojom.RequestContextFrameType.kNone;
url.mojom.Url url;
string method;
FetchAPIRequestHeaders headers;
// Note: |blob| and |body| are mutually exclusive.
// |blob| is used in implementing Background Fetch APIs, also used to
// represent the FetchEvent#request#body dispatched to service workers for
// non-S13nServiceWorker case.
// |body| is used only to represent the FetchEvent#request#body dispatched to
// service workers for S13nServiceWorker case.
// TODO(crbug.com/911930): Remove |blob| and use |body| instead everywhere.
SerializedBlob? blob;
network.mojom.URLRequestBody? body;
Referrer? referrer;
network.mojom.FetchCredentialsMode credentials_mode =
network.mojom.FetchCredentialsMode.kOmit;
FetchCacheMode cache_mode = FetchCacheMode.kDefault;
network.mojom.FetchRedirectMode redirect_mode =
network.mojom.FetchRedirectMode.kFollow;
string? integrity;
network.mojom.RequestPriority priority = network.mojom.RequestPriority.kIdle;
// Id of the original requestor window.
// See network::ResourceRequest::fetch_window_id.
mojo_base.mojom.UnguessableToken? fetch_window_id;
bool keepalive = false;
bool is_reload = false;
bool is_history_navigation = false;
};