gecko-dev/storage/public/mozIStorageServiceQuotaManagement.idl
2012-05-21 12:12:37 +01:00

100 lines
3.8 KiB
Plaintext

/* -*- 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);
};