// Copyright 2016 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
module network.mojom;
import "services/network/public/mojom/mutable_network_traffic_annotation_tag.mojom";
import "services/network/public/mojom/url_loader.mojom";
import "services/network/public/mojom/url_request.mojom";
const uint32 kURLLoadOptionNone = 0;
// Sends the net::SSLInfo struct in OnReceiveResponse.
const uint32 kURLLoadOptionSendSSLInfoWithResponse = 1;
// Enables mime sniffing.
const uint32 kURLLoadOptionSniffMimeType = 2;
// Indicates that execution is blocking on the completion of the request.
const uint32 kURLLoadOptionSynchronous = 4;
// Sends the net::SSLInfo on request completion when the connection had a major
// certificate error. The SSLInfo can be retrieved from the OnComplete struct
// when the connection failed due to the certificate error, or from the
// OnReceiveResponse struct if the connection proceeded despite the certificate
// error.
const uint32 kURLLoadOptionSendSSLInfoForCertificateError = 8;
// Uses the header client set in URLLoaderFactoryParams for this request.
const uint32 kURLLoadOptionUseHeaderClient = 16;
// Disallow the request from sending cookies. Disallow the response from writing
// cookies.
const uint32 kURLLoadOptionBlockAllCookies = 32;
// Similar to |kURLLoadOptionBlockAllCookies|, but only for third party cookies.
const uint32 kURLLoadOptionBlockThirdPartyCookies = 64;
// This request is for CORS preflight. This is used in the network service.
// This is set and used only in the network service, no callsites outside the
// service must set this.
const uint32 kURLLoadOptionAsCorsPreflight = 128;
// Specifies that the request must not be made to a non-public IP address. This
// option is needed even with CORS-RFC1918 because CORS-RFC1918 is not enabled
// by default, and sometimes the client security state is not known as the time
// of the request, which skips CORS-RFC1918.
//
// This option is supported by the network service, but might not be supported
// by other URLLoaderFactory implementations.
//
// TODO(crbug.com/40711533): This option can be removed if CORS-RFC1918 ships
// without a feature flag, and additionally it changes to block requests by
// default if the security state is unknown.
const uint32 kURLLoadOptionBlockLocalRequest = 256;
// Read and discard the body inside the URLLoader. If the URLLoader supports
// this flag, then no body will be passed to
// URLLoaderClient::OnReceiveResponse(). Not every URLLoader implementation
// supports this flag, so the caller must be prepared to discard the body
// itself if one is supplied.
// This is incompatible with the kURLLoadOptionSniffMimeType option; they cannot
// be used together.
const uint32 kURLLoadOptionReadAndDiscardBody = 512;
// URLLoaderFactory is an interface for requesting URLs. It creates URLLoader
// instances. One URLLoader instance can load one URL.
interface URLLoaderFactory {
// Creates a URLLoader and starts loading with the given `request`. `client`'s
// methods will be called when certain events related to that loading
// (e.g., response arrival) happen.
//
// `request_id` is an arbitrary id for the request. `request_id` should be
// unique over all calls to CreateLoaderAndStart() on this factory, or 0.
//
// `options` is a bitfield of the options defined above.
CreateLoaderAndStart(pending_receiver<URLLoader> loader,
int32 request_id,
uint32 options,
URLRequest request,
pending_remote<URLLoaderClient> client,
MutableNetworkTrafficAnnotationTag traffic_annotation);
// Connects a new pipe to this instance of the URLLoaderFactory interface.
Clone(pending_receiver<URLLoaderFactory> factory);
};