[go: nahoru, domu]

blob: d46ed0640b5b58eb11cdfb737fa69d3567fac83f [file] [log] [blame]
// 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 "mojo/public/mojom/base/big_buffer.mojom";
import "mojo/public/mojom/base/file_path.mojom";
import "mojo/public/mojom/base/time.mojom";
import "mojo/public/mojom/base/unguessable_token.mojom";
import "services/network/public/mojom/url_loader_network_service_observer.mojom";
import "services/network/public/mojom/client_security_state.mojom";
import "services/network/public/mojom/cors.mojom";
import "services/network/public/mojom/cookie_access_observer.mojom";
import "services/network/public/mojom/chunked_data_pipe_getter.mojom";
import "services/network/public/mojom/data_pipe_getter.mojom";
import "services/network/public/mojom/early_hints.mojom";
import "services/network/public/mojom/fetch_api.mojom";
import "services/network/public/mojom/http_request_headers.mojom";
import "services/network/public/mojom/isolation_info.mojom";
import "services/network/public/mojom/network_param.mojom";
import "services/network/public/mojom/request_priority.mojom";
import "services/network/public/mojom/site_for_cookies.mojom";
import "services/network/public/mojom/trust_tokens.mojom";
import "services/network/public/mojom/url_loader_completion_status.mojom";
import "services/network/public/mojom/url_request.mojom";
import "services/network/public/mojom/url_response_head.mojom";
import "services/network/public/mojom/web_bundle_handle.mojom";
import "url/mojom/origin.mojom";
import "url/mojom/url.mojom";
[Native]
struct URLRequestRedirectInfo;
// URLLoader is an interface for performing a single request to a URL.
//
// Destroying a URLLoader will cancel the associated request.
//
// A URLLoader is normally created and started using
// URLLoaderFactory::CreateLoaderAndStart(). The result of the load is
// communicated to the URLLoaderClient provided to that function.
interface URLLoader {
// If a disconnection is initiated by the client side, it may send the
// following disconnection reason, along with an application-defined string
// description, to notify the service side.
const uint32 kClientDisconnectReason = 1;
// If the associated request has |auto_follow_redirects| set to false, then
// upon receiving an URLResponse with a non-NULL |redirect_url| field,
// |FollowRedirect| may be called to load the URL indicated by the redirect.
//
// |removed_headers| can be used to remove existing headers for the redirect.
// This parameter is before |modified_headers| since removing headers is
// applied first in the URLLoader::FollowRedirect().
//
// |modified_headers| can be used to add or override existing headers for the
// redirect. |modified_cors_exempt_headers| can be used to modify
// |cors_exempt_headers| in the URLRequest. See
// NetworkContextParams::cors_exempt_header_list and
// URLRequest::cors_exempt_headers for details.
//
// If |new_url| is specified, then the request will be made to it instead of
// the redirected URL. |new_url| must be same-origin to the redirected URL.
FollowRedirect(array<string> removed_headers,
network.mojom.HttpRequestHeaders modified_headers,
network.mojom.HttpRequestHeaders modified_cors_exempt_headers,
url.mojom.Url? new_url);
// Sets the request priority.
// |intra_priority_value| is a lesser priority which is used to prioritize
// requests within a given priority level. If -1 is passed, the existing
// intra priority value is maintained.
SetPriority(RequestPriority priority, int32 intra_priority_value);
// If the resource is being fetched from the network,
// PauseReadingBodyFromNet() pauses fetching the response body. It is okay to
// call this method before fetching the body starts, too.
// ResumeReadingBodyFromNet() resumes fetching the body if it has been paused.
//
// Note that PauseReadingBodyFromNet() is asynchronous and only gurantees to
// pause if the response body is fetched from the network. This means:
// - any data in flight before PauseReadingBodyFromNet() is processed will
// still be passed to the client data pipe.
// - a response body not from the network, e.g. from blob, may not be paused
// at all.
//
// Redundant calls to these methods are ingored. It is not required to match
// pause and resume calls. It is not an error to resume a non-paused request,
// or pause a request multiple times.
PauseReadingBodyFromNet();
ResumeReadingBodyFromNet();
};
// Receives messages from a single URLLoader.
interface URLLoaderClient {
// Called when a 103 Early Hints response is received.
OnReceiveEarlyHints(EarlyHints early_hints);
// Called when the response head is received.
// The loader is expected to close its end of the pipe after finishing
// writing the body, so that the client knows when it is done reading.
// Optionally, the response can contain cached metadata, such as a V8 code
// cache.
OnReceiveResponse(URLResponseHead head,
handle<data_pipe_consumer>? body,
mojo_base.mojom.BigBuffer? cached_metadata);
// Called when the request has been redirected. The receiver is expected to
// call FollowRedirect or cancel the request.
OnReceiveRedirect(URLRequestRedirectInfo redirect_info, URLResponseHead head);
// Called when the service made some progress on the file upload. This is
// called only when the request has an upload data.
// The implementation should call the response closure when the client is
// ready to receive the next upload progress.
OnUploadProgress(int64 current_position, int64 total_size) => ();
// Called when the transfer size is updated. This is only called if
// |report_raw_headers| is set or the renderer has permission to read the
// request. The transfer size is the length of the response (including both
// headers and the body) over the network. |transfer_size_diff| is the
// difference from the value previously reported one (including the one in
// OnReceiveResponse and OnReceiveRedirect). It must be positive.
// TODO(yhirano): Dispatch this notification even when |download_to_file| is
// set.
// TODO(yhirano): Consider using an unsigned type.
// TODO(rajendrant): Consider reporting the transfer size directly to browser
// process from net service, and not pass it via renderer process. This can be
// done after the upcoming network servicification work.
OnTransferSizeUpdated(int32 transfer_size_diff);
// Called when the loading completes. No notification will be dispatched for
// this client after this message arrives. |status| has its |ssl_info| field
// set only when |kURLLoadOptionsSendSSLInfoForCertificateError| was set.
//
// The loader should only call this after it has finished the load or
// errored, as the client could potentially close the Mojo connection upon
// receiving this which may delete the loader. For example, if it passed a
// data pipe to OnStartLoadingResponseBody(), the loader should only call
// OnComplete() after it has finished writing to the data pipe (or errored).
// Note that the client might not have finished reading the body by the time
// it receives this message, and only knows it is done when the data pipe is
// closed.
OnComplete(URLLoaderCompletionStatus status);
};
// Convenient struct that groups the two communication endpoints most
// implementations of URLLoaderClient use to communicate with their URLLoader.
struct URLLoaderClientEndpoints {
pending_remote<URLLoader> url_loader;
pending_receiver<URLLoaderClient> url_loader_client;
};