summaryrefslogtreecommitdiffstats
path: root/dom/interfaces/storage
diff options
context:
space:
mode:
Diffstat (limited to 'dom/interfaces/storage')
-rw-r--r--dom/interfaces/storage/moz.build15
-rw-r--r--dom/interfaces/storage/nsIDOMStorageManager.idl132
-rw-r--r--dom/interfaces/storage/nsIStorageActivityService.idl42
3 files changed, 189 insertions, 0 deletions
diff --git a/dom/interfaces/storage/moz.build b/dom/interfaces/storage/moz.build
new file mode 100644
index 0000000000..be637fadff
--- /dev/null
+++ b/dom/interfaces/storage/moz.build
@@ -0,0 +1,15 @@
+# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
+# vim: set filetype=python:
+# 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/.
+
+with Files("**"):
+ BUG_COMPONENT = ("Core", "Storage: localStorage & sessionStorage")
+
+XPIDL_SOURCES += [
+ "nsIDOMStorageManager.idl",
+ "nsIStorageActivityService.idl",
+]
+
+XPIDL_MODULE = "dom_storage"
diff --git a/dom/interfaces/storage/nsIDOMStorageManager.idl b/dom/interfaces/storage/nsIDOMStorageManager.idl
new file mode 100644
index 0000000000..1be7525e4a
--- /dev/null
+++ b/dom/interfaces/storage/nsIDOMStorageManager.idl
@@ -0,0 +1,132 @@
+/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* 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 nsIPrincipal;
+interface mozIDOMWindow;
+
+webidl Storage;
+
+%{C++
+namespace mozilla {
+namespace dom {
+class SessionStorageCache;
+} // namespace dom
+} // namespace mozilla
+%}
+
+native SessionStorageCacheAddRefed(RefPtr<mozilla::dom::SessionStorageCache>);
+
+/**
+ * General purpose interface that has two implementations, for localStorage
+ * with "@mozilla.org/dom/localStorage-manager;1".
+ */
+[scriptable, uuid(a20c742e-3ed1-44fb-b897-4080a75b1662)]
+interface nsIDOMStorageManager : nsISupports
+{
+ /**
+ * This starts async preloading of a storage cache for scope
+ * defined by the principal and storage principal.
+ *
+ * Because of how multi-e10s support was implemented in bug 1285898, the
+ * StorageCache instance can no longer use a timer to keep itself alive. So a
+ * Storage instance is returned if precaching believes the storage principal may
+ * have localStorage data. (Previously the StorageCache would be brought into
+ * existence and kept alive by the timer so that it could be returned if a
+ * call to createStorage was made due to a request by the page.)
+ */
+ Storage precacheStorage(in nsIPrincipal aPrincipal,
+ in nsIPrincipal aStoragePrincipal);
+
+ /**
+ * Returns instance of DOM storage object for given principal.
+ * A new object is always returned and it is ensured there is
+ * a storage for the scope created.
+ *
+ * @param aWindow
+ * The parent window.
+ * @param aPrincipal
+ * Principal to bound storage to.
+ * @param aStoragePrincipal
+ * StoragePrincipal to bound storage to.
+ * @param aDocumentURI
+ * URL of the demanding document, used for DOM storage event only.
+ * @param aPrivate
+ * Whether the demanding document is running in Private Browsing mode or not.
+ */
+ Storage createStorage(in mozIDOMWindow aWindow,
+ in nsIPrincipal aPrincipal,
+ in nsIPrincipal aStoragePrincipal,
+ in AString aDocumentURI,
+ [optional] in bool aPrivate);
+ /**
+ * DEPRECATED. The only good reason to use this was if you were writing a
+ * test and wanted to hackily determine if a preload happened. That's now
+ * covered by `nsILocalStorageManager.isPreloaded` and you should use that if
+ * that's what you want. If LSNG is in use, this will throw.
+ *
+ * Returns instance of DOM storage object for given principal.
+ * If there is no storage managed for the scope, then null is returned and
+ * no object is created. Otherwise, an object (new) for the existing storage
+ * scope is returned.
+ *
+ * @param aWindow
+ * The parent window.
+ * @param aPrincipal
+ * Principal to bound storage to.
+ * @param aStoragePrincipal
+ * StoragePrincipal to bound storage to.
+ * @param aPrivate
+ * Whether the demanding document is running in Private Browsing mode or not.
+ */
+ Storage getStorage(in mozIDOMWindow aWindow,
+ in nsIPrincipal aPrincipal,
+ in nsIPrincipal aStoragePrincipal,
+ [optional] in bool aPrivate);
+
+ /**
+ * Clones given storage into this storage manager.
+ *
+ * @param aStorageToCloneFrom
+ * The storage to copy all items from into this manager. Manager will then
+ * return a new and independent object that contains snapshot of data from
+ * the moment this method was called. Modification to this new object will
+ * not affect the original storage content we cloned from and vice versa.
+ */
+ void cloneStorage(in Storage aStorageToCloneFrom);
+
+ /**
+ * Returns true if the storage belongs to the given principal and is managed
+ * (i.e. has been created and is cached) by this storage manager.
+ *
+ * @param aPrincipal
+ * Principal to check the storage against.
+ * @param aStorage
+ * The storage object to examine.
+ *
+ * @result
+ * true when the storage object is bound with the principal and is managed
+ * by this storage manager.
+ * false otherwise
+ */
+ bool checkStorage(in nsIPrincipal aPrincipal,
+ in Storage aStorage);
+};
+
+[uuid(b3bfbbd0-e738-4cbf-b0f0-b65f25265e82)]
+interface nsIDOMSessionStorageManager : nsIDOMStorageManager {
+ /**
+ * Returns a SessionStorageCache object for the principal scope.
+ *
+ * @param aPrincipal
+ * Principal to bound storage to.
+ * @param aStoragePrincipal
+ * StoragePrincipal to bound storage to.
+ */
+ [noscript]
+ SessionStorageCacheAddRefed getSessionStorageCache(in nsIPrincipal aPrincipal,
+ in nsIPrincipal aStoragePrincipal);
+};
diff --git a/dom/interfaces/storage/nsIStorageActivityService.idl b/dom/interfaces/storage/nsIStorageActivityService.idl
new file mode 100644
index 0000000000..f33fcfc222
--- /dev/null
+++ b/dom/interfaces/storage/nsIStorageActivityService.idl
@@ -0,0 +1,42 @@
+/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* 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 "domstubs.idl"
+
+interface nsIArray;
+interface nsIPrincipal;
+
+/**
+ * nsIStorageActivityService is a service that can be used to know which
+ * origins have been active in a time range. This information can be used to
+ * implement "Clear Recent History" or similar features.
+ *
+ * If you are implementing a new Storage component, you should use
+ * QuotaManager. But if you don't do it, remember to call
+ * StorageActivityService methods in order to inform this service about
+ * 'writing' operations executed by origins.
+ */
+[scriptable, builtinclass, uuid(fd1310ba-d1be-4327-988e-92b39fcff6f4)]
+interface nsIStorageActivityService : nsISupports
+{
+ // This returns an array of nsIPrincipals, active between |from| and |to|
+ // timestamps. Note activities older than 1 day are forgotten.
+ // Activity details are not persisted, so this only covers activity since
+ // Firefox was started. All content principals are logged, which includes
+ // non-system principals like "moz-extension://ID", "moz-safe-about:home",
+ // "about:newtab", so principals may need to be filtered before being used.
+ nsIArray getActiveOrigins(in PRTime from, in PRTime to);
+
+ // NOTE: This method is meant to be used for testing only.
+ // The activity of |origin| is moved to the specified timestamp |when|.
+ void moveOriginInTime(in nsIPrincipal origin, in PRTime when);
+
+ // TEST-ONLY method to support clearing all previously known activity.
+ void testOnlyReset();
+};
+
+%{ C++
+#define STORAGE_ACTIVITY_SERVICE_CONTRACTID "@mozilla.org/storage/activity-service;1"
+%}