blob: ca0fa77b39420df6bf724ab6aea47fa21b505627 [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/url_loader_factory.mojom";
import "third_party/blink/public/mojom/blob/blob.mojom";
import "url/mojom/url.mojom";
// This interface is implemented by the browser to give renderers the ability to
// create and revoke blob URLs. BlobRegistry exposes a method get a instance of
// this interface for a particular origin.
interface BlobURLStore {
// Registers a public Blob URL. When the connection to the BlobURLStore closes
// all URLs registered through it will be revoked.
// TODO(kinuko,mek): This should probably create and return a new blob: URL rather
// than letting the caller in the renderer provide one.
[Sync] Register(pending_remote<blink.mojom.Blob> blob, url.mojom.Url url) => ();
// Revokes a public Blob URL.
Revoke(url.mojom.Url url);
// Resolves a public Blob URL.
Resolve(url.mojom.Url url) => (pending_remote<blink.mojom.Blob>? blob);
// Resolves a public Blob URL to a URLLoaderFactory that can only load the
// specified URL. The reason the API is shaped like this rather than just
// having a URLLoaderFactory for all Blob URLs is that resolution of blob URLs
// has to happen separately before fetching starts.
// As long as the resulting URLLoaderFactory is alive the resolved blob will
// also be kept alive, so it is possible to start loading the blob long after
// both the blob URL and all other references to the blob have been dropped.
ResolveAsURLLoaderFactory(
url.mojom.Url url,
pending_receiver<network.mojom.URLLoaderFactory> factory);
// Resolves a public Blob URL into a BlobURLToken. The BlobURLToken can be
// used by the browser process to securely look up the blob a URL used to
// refer to, even after the URL is revoked.
// As long as the token is alive, the resolved blob will also be kept alive.
ResolveForNavigation(url.mojom.Url url, pending_receiver<BlobURLToken> token);
};
// A token representing a Blob URL. The browser process can use this to look up
// the blob URL and blob it referred to, even after the blob URL itself is
// revoked. For the renderer this is just an opaque token without any meaning.
interface BlobURLToken {
Clone(pending_receiver<BlobURLToken> token);
GetToken() => (mojo_base.mojom.UnguessableToken token);
};