storage/public/mozIStorageServiceQuotaManagement.idl
author Ehsan Akhgari <ehsan@mozilla.com>
Wed, 12 Dec 2012 00:05:49 -0500
changeset 115629 553a3bcf1fe771c09cdfd1640e8059c312622b4a
parent 94475 f4157e8c410708d76703f19e4dfb61859bfe32d8
permissions -rw-r--r--
Backed out 7 changesets (bug 769288) because of leaks Backed out changeset b2fb475b6e4e (bug 769288) Backed out changeset 912331d0c2fd (bug 769288) Backed out changeset 6d8d78bd56a9 (bug 769288) Backed out changeset e75cd1e1fca3 (bug 769288) Backed out changeset e10c24f10bd2 (bug 769288) Backed out changeset 7b0fdedb4fa9 (bug 769288) Backed out changeset 42b468942a84 (bug 769288)

/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#include "nsISupports.idl"

interface mozIStorageConnection;
interface nsIFile;

[scriptable, function, uuid(ae94f0a5-ebdf-48f4-9959-085e13235d8d)]
interface mozIStorageQuotaCallback : nsISupports
{
  /**
   * Called when the file size quota for a group of databases is exceeded.
   *
   * @param aFilename
   *        The filename of the database that has exceeded the quota.
   *
   * @param aCurrentSizeLimit
   *        The current size (in bytes) of the quota.
   *
   * @param aCurrentTotalSize
   *        The current size of all databases in the quota group.
   *
   * @param aUserData
   *        Any additional data that was provided to the
   *        setQuotaForFilenamePattern function.
   *
   * @returns A new quota size. A new quota of 0 will disable the quota callback
   *          and any quota value less than aCurrentTotalSize will cause the
   *          database operation to fail with NS_ERROR_FILE_NO_DEVICE_SPACE.
   */
  long long quotaExceeded(in ACString aFilename,
                          in long long aCurrentSizeLimit,
                          in long long aCurrentTotalSize,
                          in nsISupports aUserData);
};

/**
 * This is a temporary interface that should eventually merge with
 * mozIStorageService.
 */
[scriptable, uuid(4d81faf5-fe01-428b-99b8-c94cba12fd72)]
interface mozIStorageServiceQuotaManagement : nsISupports
{
  /**
   * See mozIStorageService.openDatabase. Exactly the same only with a custom
   * SQLite VFS.
   */
  mozIStorageConnection openDatabaseWithVFS(in nsIFile aDatabaseFile,
                                            in ACString aVFSName);

  /**
   * Set a file size quota for a group of databases matching the given filename
   * pattern, optionally specifying a callback when the quota is exceeded.
   *
   * @param aPattern
   *        A pattern to match filenames for inclusion in the quota system. May
   *        contain the following special characters:
   *          '*'    Matches any sequence of zero or more characters.
   *          '?'    Matches exactly one character.
   *          [...]  Matches one character from the enclosed list of characters.
   *          [^...] Matches one character not in the enclosed list.
   *
   * @param aSizeLimit
   *        The size limit (in bytes) for the quota group.
   *
   * @param aCallback
   *        A callback that will be used when the quota is exceeded.
   *
   * @param aUserData
   *        Additional information to be passed to the callback.
   */
  void setQuotaForFilenamePattern(in ACString aPattern,
                                  in long long aSizeLimit,
                                  in mozIStorageQuotaCallback aCallback,
                                  in nsISupports aUserData);

  /**
   * Adds, removes, or updates the file size information maintained by the quota
   * system for files not opened through openDatabaseWithVFS().
   *
   * Use this function when you want files to be included in quota calculations
   * that are either a) not SQLite databases, or b) SQLite databases that have
   * not been opened.
   *
   * This function will have no effect on files that do not match an existing
   * quota pattern (set previously by setQuotaForFilenamePattern()).
   * 
   * @param aFile
   *        The file for which quota information should be updated. If the file
   *        exists then its size information will be added or refreshed. If the
   *        file does not exist then the file will be removed from tracking
   *        under the quota system.
   */
  void updateQuotaInformationForFile(in nsIFile aFile);
};