Bug 1486932 part 1. Stop using nsIDOMStorage in xpidl APIs. r=mccr8

This commit is contained in:
Boris Zbarsky 2018-08-31 13:56:54 -04:00
Родитель b1bedbb3e3
Коммит 1fcc87c931
9 изменённых файлов: 46 добавлений и 49 удалений

Просмотреть файл

@ -4308,14 +4308,13 @@ nsDOMWindowUtils::RemoveManuallyManagedState(Element* aElement,
}
NS_IMETHODIMP
nsDOMWindowUtils::GetStorageUsage(nsIDOMStorage* aStorage, int64_t* aRetval)
nsDOMWindowUtils::GetStorageUsage(Storage* aStorage, int64_t* aRetval)
{
RefPtr<Storage> storage = static_cast<Storage*>(aStorage);
if (!storage) {
if (!aStorage) {
return NS_ERROR_UNEXPECTED;
}
*aRetval = storage->GetOriginQuotaUsage();
*aRetval = aStorage->GetOriginQuotaUsage();
return NS_OK;
}

Просмотреть файл

@ -4795,7 +4795,7 @@ nsGlobalWindowInner::GetSessionStorage(ErrorResult& aError)
return nullptr;
}
nsCOMPtr<nsIDOMStorage> storage;
RefPtr<Storage> storage;
aError = storageManager->CreateStorage(this, principal, documentURI,
IsPrivateBrowsing(),
getter_AddRefs(storage));
@ -4803,7 +4803,7 @@ nsGlobalWindowInner::GetSessionStorage(ErrorResult& aError)
return nullptr;
}
mSessionStorage = static_cast<Storage*>(storage.get());
mSessionStorage = storage;
MOZ_ASSERT(mSessionStorage);
MOZ_LOG(gDOMLeakPRLogInner, LogLevel::Debug,
@ -4856,7 +4856,7 @@ nsGlobalWindowInner::GetLocalStorage(ErrorResult& aError)
}
}
nsCOMPtr<nsIDOMStorage> storage;
RefPtr<Storage> storage;
aError = storageManager->CreateStorage(this, principal, documentURI,
IsPrivateBrowsing(),
getter_AddRefs(storage));
@ -4864,7 +4864,7 @@ nsGlobalWindowInner::GetLocalStorage(ErrorResult& aError)
return nullptr;
}
mLocalStorage = static_cast<Storage*>(storage.get());
mLocalStorage = storage;
MOZ_ASSERT(mLocalStorage);
}
@ -5684,7 +5684,7 @@ nsGlobalWindowInner::ObserveStorageNotification(StorageEvent* aEvent,
eventType.AssignLiteral("storage");
if (!NS_strcmp(aStorageType, u"sessionStorage")) {
nsCOMPtr<nsIDOMStorage> changingStorage = aEvent->GetStorageArea();
RefPtr<Storage> changingStorage = aEvent->GetStorageArea();
MOZ_ASSERT(changingStorage);
bool check = false;

Просмотреть файл

@ -2046,10 +2046,10 @@ nsGlobalWindowOuter::PreloadLocalStorage()
// private browsing windows do not persist local storage to disk so we should
// only try to precache storage when we're not a private browsing window.
if (principal->GetPrivateBrowsingId() == 0) {
nsCOMPtr<nsIDOMStorage> storage;
RefPtr<Storage> storage;
rv = storageManager->PrecacheStorage(principal, getter_AddRefs(storage));
if (NS_SUCCEEDED(rv)) {
mLocalStorage = static_cast<Storage*>(storage.get());
mLocalStorage = storage;
}
}
}

Просмотреть файл

@ -42,7 +42,6 @@ interface nsITranslationNodeList;
interface nsIJSRAIIHelper;
interface nsIContentPermissionRequest;
interface nsIObserver;
interface nsIDOMStorage;
webidl Animation;
webidl DOMRect;
@ -51,6 +50,7 @@ webidl EventTarget;
webidl Event;
webidl Node;
webidl NodeList;
webidl Storage;
[scriptable, uuid(4d6732ca-9da7-4176-b8a1-8dde15cd0bf9)]
interface nsIDOMWindowUtils : nsISupports {
@ -1901,7 +1901,7 @@ interface nsIDOMWindowUtils : nsISupports {
* @param aStorage
* The storage object to get usage data for.
*/
int64_t getStorageUsage(in nsIDOMStorage aStorage);
int64_t getStorageUsage(in Storage aStorage);
/**
* Returns the directionality of a string using the first-strong character

Просмотреть файл

@ -5,10 +5,11 @@
#include "nsISupports.idl"
interface nsIDOMStorage;
interface nsIPrincipal;
interface mozIDOMWindow;
webidl Storage;
/**
* General purpose interface that has two implementations, for localStorage
* resp. sessionStorage with "@mozilla.org/dom/localStorage-manager;1" resp.
@ -28,7 +29,7 @@ interface nsIDOMStorageManager : nsISupports
* 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.)
*/
nsIDOMStorage precacheStorage(in nsIPrincipal aPrincipal);
Storage precacheStorage(in nsIPrincipal aPrincipal);
/**
* Returns instance of DOM storage object for given principal.
@ -44,10 +45,10 @@ interface nsIDOMStorageManager : nsISupports
* @param aPrivate
* Whether the demanding document is running in Private Browsing mode or not.
*/
nsIDOMStorage createStorage(in mozIDOMWindow aWindow,
in nsIPrincipal aPrincipal,
in DOMString aDocumentURI,
[optional] in bool aPrivate);
Storage createStorage(in mozIDOMWindow aWindow,
in nsIPrincipal aPrincipal,
in DOMString aDocumentURI,
[optional] in bool aPrivate);
/**
* Returns instance of DOM storage object for given principal.
* If there is no storage managed for the scope, then null is returned and
@ -61,9 +62,9 @@ interface nsIDOMStorageManager : nsISupports
* @param aPrivate
* Whether the demanding document is running in Private Browsing mode or not.
*/
nsIDOMStorage getStorage(in mozIDOMWindow aWindow,
in nsIPrincipal aPrincipal,
[optional] in bool aPrivate);
Storage getStorage(in mozIDOMWindow aWindow,
in nsIPrincipal aPrincipal,
[optional] in bool aPrivate);
/**
* Clones given storage into this storage manager.
@ -74,7 +75,7 @@ interface nsIDOMStorageManager : nsISupports
* 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 nsIDOMStorage aStorageToCloneFrom);
void cloneStorage(in Storage aStorageToCloneFrom);
/**
* Returns true if the storage belongs to the given principal and is managed
@ -91,5 +92,5 @@ interface nsIDOMStorageManager : nsISupports
* false otherwise
*/
bool checkStorage(in nsIPrincipal aPrincipal,
in nsIDOMStorage aStorage);
in Storage aStorage);
};

Просмотреть файл

@ -212,7 +212,7 @@ LocalStorageManager::GetStorageInternal(CreateMode aCreateMode,
nsIPrincipal* aPrincipal,
const nsAString& aDocumentURI,
bool aPrivate,
nsIDOMStorage** aRetval)
Storage** aRetval)
{
nsAutoCString originAttrSuffix;
nsAutoCString originKey;
@ -287,7 +287,7 @@ LocalStorageManager::GetStorageInternal(CreateMode aCreateMode,
if (aRetval) {
nsCOMPtr<nsPIDOMWindowInner> inner = nsPIDOMWindowInner::From(aWindow);
nsCOMPtr<nsIDOMStorage> storage = new LocalStorage(
RefPtr<Storage> storage = new LocalStorage(
inner, this, cache, aDocumentURI, aPrincipal, aPrivate);
storage.forget(aRetval);
}
@ -297,7 +297,7 @@ LocalStorageManager::GetStorageInternal(CreateMode aCreateMode,
NS_IMETHODIMP
LocalStorageManager::PrecacheStorage(nsIPrincipal* aPrincipal,
nsIDOMStorage** aRetval)
Storage** aRetval)
{
return GetStorageInternal(CreateMode::CreateIfShouldPreload, nullptr,
aPrincipal, EmptyString(), false, aRetval);
@ -308,7 +308,7 @@ LocalStorageManager::CreateStorage(mozIDOMWindow* aWindow,
nsIPrincipal* aPrincipal,
const nsAString& aDocumentURI,
bool aPrivate,
nsIDOMStorage** aRetval)
Storage** aRetval)
{
return GetStorageInternal(CreateMode::CreateAlways, aWindow, aPrincipal,
aDocumentURI, aPrivate, aRetval);
@ -318,14 +318,14 @@ NS_IMETHODIMP
LocalStorageManager::GetStorage(mozIDOMWindow* aWindow,
nsIPrincipal* aPrincipal,
bool aPrivate,
nsIDOMStorage** aRetval)
Storage** aRetval)
{
return GetStorageInternal(CreateMode::UseIfExistsNeverCreate, aWindow,
aPrincipal, EmptyString(), aPrivate, aRetval);
}
NS_IMETHODIMP
LocalStorageManager::CloneStorage(nsIDOMStorage* aStorage)
LocalStorageManager::CloneStorage(Storage* aStorage)
{
// Cloning is supported only for sessionStorage
return NS_ERROR_NOT_IMPLEMENTED;
@ -333,16 +333,15 @@ LocalStorageManager::CloneStorage(nsIDOMStorage* aStorage)
NS_IMETHODIMP
LocalStorageManager::CheckStorage(nsIPrincipal* aPrincipal,
nsIDOMStorage* aStorage,
Storage* aStorage,
bool* aRetval)
{
nsresult rv;
RefPtr<LocalStorage> storage = static_cast<LocalStorage*>(aStorage);
if (!storage) {
if (!aStorage || aStorage->Type() != Storage::eLocalStorage) {
return NS_ERROR_UNEXPECTED;
}
RefPtr<LocalStorage> storage = static_cast<LocalStorage*>(aStorage);
*aRetval = false;
if (!aPrincipal) {
@ -351,7 +350,7 @@ LocalStorageManager::CheckStorage(nsIPrincipal* aPrincipal,
nsAutoCString suffix;
nsAutoCString origin;
rv = GenerateOriginKey(aPrincipal, suffix, origin);
nsresult rv = GenerateOriginKey(aPrincipal, suffix, origin);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}

Просмотреть файл

@ -104,7 +104,7 @@ private:
nsIPrincipal* aPrincipal,
const nsAString& aDocumentURI,
bool aPrivate,
nsIDOMStorage** aRetval);
Storage** aRetval);
// Suffix->origin->cache map
typedef nsTHashtable<LocalStorageCacheHashKey> CacheOriginHashtable;

Просмотреть файл

@ -37,7 +37,7 @@ SessionStorageManager::~SessionStorageManager()
NS_IMETHODIMP
SessionStorageManager::PrecacheStorage(nsIPrincipal* aPrincipal,
nsIDOMStorage** aRetval)
Storage** aRetval)
{
// Nothing to preload.
return NS_OK;
@ -48,7 +48,7 @@ SessionStorageManager::CreateStorage(mozIDOMWindow* aWindow,
nsIPrincipal* aPrincipal,
const nsAString& aDocumentURI,
bool aPrivate,
nsIDOMStorage** aRetval)
Storage** aRetval)
{
nsAutoCString originKey;
nsAutoCString originAttributes;
@ -82,7 +82,7 @@ NS_IMETHODIMP
SessionStorageManager::GetStorage(mozIDOMWindow* aWindow,
nsIPrincipal* aPrincipal,
bool aPrivate,
nsIDOMStorage** aRetval)
Storage** aRetval)
{
*aRetval = nullptr;
@ -113,20 +113,19 @@ SessionStorageManager::GetStorage(mozIDOMWindow* aWindow,
}
NS_IMETHODIMP
SessionStorageManager::CloneStorage(nsIDOMStorage* aStorage)
SessionStorageManager::CloneStorage(Storage* aStorage)
{
if (NS_WARN_IF(!aStorage)) {
return NS_ERROR_UNEXPECTED;
}
RefPtr<Storage> storage = static_cast<Storage*>(aStorage);
if (storage->Type() != Storage::eSessionStorage) {
if (aStorage->Type() != Storage::eSessionStorage) {
return NS_ERROR_UNEXPECTED;
}
nsAutoCString originKey;
nsAutoCString originAttributes;
nsresult rv = GenerateOriginKey(storage->Principal(), originAttributes,
nsresult rv = GenerateOriginKey(aStorage->Principal(), originAttributes,
originKey);
if (NS_FAILED(rv)) {
return rv;
@ -153,7 +152,7 @@ SessionStorageManager::CloneStorage(nsIDOMStorage* aStorage)
NS_IMETHODIMP
SessionStorageManager::CheckStorage(nsIPrincipal* aPrincipal,
nsIDOMStorage* aStorage,
Storage* aStorage,
bool* aRetval)
{
if (NS_WARN_IF(!aStorage)) {
@ -183,8 +182,7 @@ SessionStorageManager::CheckStorage(nsIPrincipal* aPrincipal,
return NS_OK;
}
RefPtr<Storage> storage = static_cast<Storage*>(aStorage);
if (storage->Type() != Storage::eSessionStorage) {
if (aStorage->Type() != Storage::eSessionStorage) {
return NS_OK;
}
@ -194,7 +192,7 @@ SessionStorageManager::CheckStorage(nsIPrincipal* aPrincipal,
return NS_OK;
}
if (!StorageUtils::PrincipalsEqual(storage->Principal(), aPrincipal)) {
if (!StorageUtils::PrincipalsEqual(aStorage->Principal(), aPrincipal)) {
return NS_OK;
}

Просмотреть файл

@ -1199,7 +1199,7 @@ nsWindowWatcher::OpenWindowInternal(mozIDOMWindowProxy* aParent,
do_QueryInterface(newDocShell);
if (parentStorageManager && newStorageManager) {
nsCOMPtr<nsIDOMStorage> storage;
RefPtr<Storage> storage;
nsCOMPtr<nsPIDOMWindowInner> pInnerWin = parentWindow->GetCurrentInnerWindow();
parentStorageManager->GetStorage(pInnerWin, subjectPrincipal,
isPrivateBrowsingWindow,