blob: f1b4d4252fa962452cc0869912df7402f1199bde [file] [log] [blame]
// Copyright 2016 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 content.mojom;
[Native]
struct URLRequest;
[Native]
struct URLResponseHead;
[Native]
struct URLRequestRedirectInfo;
[Native]
struct URLLoaderStatus;
// Destroying a URLLoader will cancel the associated request.
interface URLLoader {
// 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.
FollowRedirect();
};
// Opaque handle passed from the browser process to a child process to manage
// the lifetime of temporary files used for download_to_file resource loading.
// When the message pipe for this interface is closed, the browser process will
// clean up the corresponding temporary file.
interface DownloadedTempFile {
};
interface URLLoaderClient {
// Called when the response head is received. |downloaded_file| is non-null in
// the 'download_to_file' case.
OnReceiveResponse(URLResponseHead head, DownloadedTempFile? downloaded_file);
// 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 some data from a resource request has been downloaded to the
// file. This is only called in the 'download_to_file' case and replaces
// OnStartLoadingResponseBody in the call sequence in that case.
// TODO(yhirano): Remove |encoded_length| and use OnTransferSizeUpdated
// instead.
OnDataDownloaded(int64 data_length, int64 encoded_length);
// Called when cached metadata from a resource request is ready.
OnReceiveCachedMetadata(array<uint8> data);
// Called when the transfer size is updated. This is only called if
// |report_raw_headers| is set and |download_to_file| is unset in 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.
OnTransferSizeUpdated(int32 transfer_size_diff);
// Called when the loader starts loading response body. This is called after
// OnReceiveResponse is called.
OnStartLoadingResponseBody(handle<data_pipe_consumer> body);
// Called when the loading completes. No notification will be dispatched for
// this client after this message arrives.
OnComplete(URLLoaderStatus completion_status);
};