1// Copyright 2017 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5module blink.mojom;
6
7import "third_party/blink/public/mojom/quota/quota_types.mojom";
8
9// Receives quota change notifications for a frame or worker.
10//
11// The interface is used to by the quota system in the browser process, to
12// send notifications to Blink in the renderer process.
13interface QuotaChangeListener {
14  // Triggered due to storage pressure.
15  OnQuotaChange();
16};
17
18// Implements the Web Platform's quota ("Storage") API.
19//
20// The interface is consumed by Blink in the renderer process. The interface is
21// currently implemented in the browser process, and will eventually move to the
22// Storage Service.
23interface QuotaManagerHost {
24  // Subscribes to changes in the quota transmitted in a request to an URL.
25  //
26  // The subscription is canceled by closing the pipe.
27  AddChangeListener(pending_remote<QuotaChangeListener> listener) => ();
28
29  // Retrieves the origin's current usage and quota.
30  //
31  // This method can be called from frames and workers.
32  QueryStorageUsageAndQuota(blink.mojom.StorageType storage_type) =>
33      (blink.mojom.QuotaStatusCode error,
34       int64 current_usage,
35       int64 current_quota,
36       UsageBreakdown usage_breakdown);
37
38  // Requests a new quota size for the origin.
39  //
40  // This method can only be called from frames, because the implementation may
41  // involve a permission prompt. |requested_size| indicates how much storage
42  // space the origin expects to need.
43  //
44  // The callback reflects the result of the quota grant. The granted quota may
45  // be different than the requested amount.
46  //
47  // This method is only used in the old FileSystem API.
48  RequestStorageQuota(blink.mojom.StorageType storage_type,
49                      uint64 requested_size) =>
50      (blink.mojom.QuotaStatusCode error,
51       int64 current_usage,
52       int64 granted_quota);
53};
54