Bug 584946 - e10s: localStorage, r=honzab, a=blocking-fennec2.0b3+

This commit is contained in:
Josh Matthews 2010-11-18 20:15:23 -05:00
parent f9aa337cbf
commit 5de7e34378
22 changed files with 2040 additions and 848 deletions

View File

@ -54,6 +54,7 @@
#include "mozilla/ipc/XPCShellEnvironment.h"
#include "mozilla/jsipc/PContextWrapperChild.h"
#include "mozilla/dom/ExternalHelperAppChild.h"
#include "mozilla/dom/StorageChild.h"
#include "nsAudioStream.h"
@ -340,6 +341,21 @@ ContentChild::DeallocPExternalHelperApp(PExternalHelperAppChild* aService)
return true;
}
PStorageChild*
ContentChild::AllocPStorage(const StorageConstructData& aData)
{
NS_NOTREACHED("We should never be manually allocating PStorageChild actors");
return nsnull;
}
bool
ContentChild::DeallocPStorage(PStorageChild* aActor)
{
StorageChild* child = static_cast<StorageChild*>(aActor);
child->ReleaseIPDLReference();
return true;
}
bool
ContentChild::RecvRegisterChrome(const InfallibleTArray<ChromePackage>& packages,
const InfallibleTArray<ResourceMapping>& resources,

View File

@ -56,6 +56,7 @@ namespace dom {
class AlertObserver;
class PrefObserver;
class ConsoleListener;
class PStorageChild;
class ContentChild : public PContentChild
{
@ -100,6 +101,9 @@ public:
const IPC::URI& aReferrer);
virtual bool DeallocPExternalHelperApp(PExternalHelperAppChild *aService);
virtual PStorageChild* AllocPStorage(const StorageConstructData& aData);
virtual bool DeallocPStorage(PStorageChild* aActor);
virtual bool RecvRegisterChrome(const InfallibleTArray<ChromePackage>& packages,
const InfallibleTArray<ResourceMapping>& resources,
const InfallibleTArray<OverrideMapping>& overrides);

View File

@ -73,6 +73,7 @@
#endif
#include "mozilla/dom/ExternalHelperAppParent.h"
#include "mozilla/dom/StorageParent.h"
#include "nsAccelerometer.h"
using namespace mozilla::ipc;
@ -416,6 +417,19 @@ ContentParent::DeallocPExternalHelperApp(PExternalHelperAppParent* aService)
return true;
}
PStorageParent*
ContentParent::AllocPStorage(const StorageConstructData& aData)
{
return new StorageParent(aData);
}
bool
ContentParent::DeallocPStorage(PStorageParent* aActor)
{
delete aActor;
return true;
}
void
ContentParent::ReportChildAlreadyBlocked()
{

View File

@ -62,6 +62,7 @@ class TestShellParent;
namespace dom {
class TabParent;
class PStorageParent;
class ContentParent : public PContentParent
, public nsIObserver
@ -134,6 +135,9 @@ private:
const IPC::URI& aReferrer);
virtual bool DeallocPExternalHelperApp(PExternalHelperAppParent* aService);
virtual PStorageParent* AllocPStorage(const StorageConstructData& aData);
virtual bool DeallocPStorage(PStorageParent* aActor);
virtual bool RecvReadPrefsArray(InfallibleTArray<PrefTuple> *retValue);
void EnsurePrefService();

View File

@ -84,6 +84,7 @@ LOCAL_INCLUDES += \
-I$(topsrcdir)/uriloader/exthandler \
-I$(srcdir)/../../netwerk/base/src \
-I$(srcdir)/../src/base \
-I$(srcdir)/../src/storage \
-I$(srcdir)/../../xpcom/base \
-I$(topsrcdir)/extensions/cookie \
$(NULL)

View File

@ -41,6 +41,7 @@ include protocol PBrowser;
include protocol PTestShell;
include protocol PNecko;
include protocol PExternalHelperApp;
include protocol PStorage;
include "mozilla/chrome/RegistryMessageUtils.h";
include "mozilla/net/NeckoMessageUtils.h";
@ -56,10 +57,28 @@ using ResourceMapping;
using OverrideMapping;
using IPC::URI;
using IPC::Permission;
using mozilla::null_t;
namespace mozilla {
namespace dom {
// Data required to clone an existing DOMStorageImpl in the parent
struct StorageClone
{
// Existing cross-process storage actor to clone
PStorage actor;
// Result of calling IsCallerSecure() in the child
bool callerSecure;
};
// When creating a new PStorage protocol, an existing one can be
// cloned (see nsDOMStorage2::Clone)
union StorageConstructData
{
null_t;
StorageClone;
};
rpc protocol PContent
{
manages PAudio;
@ -67,6 +86,7 @@ rpc protocol PContent
manages PTestShell;
manages PNecko;
manages PExternalHelperApp;
manages PStorage;
child:
PBrowser(PRUint32 chromeFlags);
@ -93,6 +113,8 @@ child:
parent:
PNecko();
PStorage(StorageConstructData data);
PAudio(PRInt32 aNumChannels, PRInt32 aRate, PRInt32 aFormat);

View File

@ -54,6 +54,13 @@ CPPSRCS = \
ifdef MOZ_STORAGE
CPPSRCS += nsDOMStorageDBWrapper.cpp nsDOMStoragePersistentDB.cpp nsDOMStorageMemoryDB.cpp
ifdef MOZ_IPC
CPPSRCS += StorageChild.cpp StorageParent.cpp
EXPORTS_NAMESPACES = mozilla/dom
EXPORTS_mozilla/dom = StorageChild.h StorageParent.h
endif
endif
# we don't want the shared lib, but we want to force the creation of a static lib.
@ -65,4 +72,6 @@ LOCAL_INCLUDES = \
DEFINES += -D_IMPL_NS_LAYOUT
include $(topsrcdir)/config/config.mk
include $(topsrcdir)/ipc/chromium/chromium-config.mk
include $(topsrcdir)/config/rules.mk

View File

@ -0,0 +1,99 @@
/* -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 8 -*- */
/* vim: set sw=4 ts=8 et tw=80 ft=cpp : */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Content App.
*
* The Initial Developer of the Original Code is
* The Mozilla Foundation.
* Portions created by the Initial Developer are Copyright (C) 2010
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Josh Matthews <josh@joshmatthews.net> (original author)
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
include protocol PContent;
using mozilla::null_t;
namespace mozilla {
namespace dom {
struct ItemData
{
nsString value;
PRBool secure;
};
// A cross-process GetValue result -- either null, or containing the parameters
// with which to initialize an nsIDOMStorageItem.
union StorageItem
{
null_t;
ItemData;
};
// This protocol is little more than a thin wrapper around the DOMStorageBase
// class in nsDOMStorage.h. The child implementation simply forwards the
// arguments for any given call to the parent, and returns the result.
sync protocol PStorage
{
manager PContent;
parent:
__delete__();
Init(bool useDB, bool canUseChromePersist, nsCString domain,
nsCString scopeDBKey, nsCString quotaDomainDBKey,
nsCString quotaETLDplus1DomainDBKey, PRUint32 storageType);
sync GetKeys(bool callerSecure)
returns (nsString[] keys);
sync GetLength(bool callerSecure)
returns (PRUint32 length, nsresult rv);
sync GetKey(bool callerSecure, PRUint32 index)
returns (nsString key, nsresult rv);
sync GetValue(bool callerSecure, nsString key)
returns (StorageItem item, nsresult rv);
sync SetValue(bool callerSecure, nsString key, nsString data)
returns (nsString oldValue, nsresult rv);
sync RemoveValue(bool callerSecure, nsString key)
returns (nsString oldValue, nsresult rv);
sync Clear(bool callerSecure)
returns (PRInt32 oldCount, nsresult rv);
sync GetDBValue(nsString key)
returns (nsString value, PRBool secure, nsresult rv);
sync SetDBValue(nsString key, nsString value, PRBool secure)
returns (nsresult rv);
sync SetSecure(nsString key, PRBool secure)
returns (nsresult rv);
};
}
}

View File

@ -0,0 +1,282 @@
/* -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 8 -*- */
/* vim: set sw=4 ts=8 et tw=80 ft=cpp : */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla DOM Storage.
*
* The Initial Developer of the Original Code is
* The Mozilla Foundation.
* Portions created by the Initial Developer are Copyright (C) 2010
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Josh Matthews <josh@joshmatthews.net> (original author)
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "StorageChild.h"
#include "mozilla/dom/ContentChild.h"
#include "nsDOMError.h"
namespace mozilla {
namespace dom {
NS_IMPL_CYCLE_COLLECTION_1(StorageChild, mStorage)
NS_IMPL_CYCLE_COLLECTING_ADDREF(StorageChild)
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(StorageChild)
NS_INTERFACE_MAP_ENTRY(nsISupports)
NS_INTERFACE_MAP_END
NS_IMETHODIMP_(nsrefcnt) StorageChild::Release(void)
{
NS_PRECONDITION(0 != mRefCnt, "dup release");
NS_ASSERT_OWNINGTHREAD(StorageChild);
nsISupports* base = NS_CYCLE_COLLECTION_CLASSNAME(StorageChild)::Upcast(this);
nsrefcnt count = mRefCnt.decr(base);
NS_LOG_RELEASE(this, count, "StorageChild");
if (count == 1 && mIPCOpen) {
Send__delete__(this);
return 0;
}
if (count == 0) {
mRefCnt.stabilizeForDeletion(base);
delete this;
return 0;
}
return count;
}
StorageChild::StorageChild(nsDOMStorage* aOwner)
: mStorage(aOwner)
, mIPCOpen(false)
{
}
StorageChild::StorageChild(nsDOMStorage* aOwner, StorageChild& aOther)
: DOMStorageBase(aOther)
, mStorage(aOwner)
, mIPCOpen(false)
{
}
void
StorageChild::AddIPDLReference()
{
NS_ABORT_IF_FALSE(!mIPCOpen, "Attempting to retain multiple IPDL references");
mIPCOpen = true;
AddRef();
}
void
StorageChild::ReleaseIPDLReference()
{
NS_ABORT_IF_FALSE(mIPCOpen, "Attempting to release non-existent IPDL reference");
mIPCOpen = false;
Release();
}
bool
StorageChild::CacheStoragePermissions()
{
nsDOMStorage* storage = static_cast<nsDOMStorage*>(mStorage.get());
return storage->CacheStoragePermissions();
}
void
StorageChild::InitRemote()
{
ContentChild* child = ContentChild::GetSingleton();
AddIPDLReference();
child->SendPStorageConstructor(this, null_t());
SendInit(mUseDB, mCanUseChromePersist, mDomain, mScopeDBKey,
mQuotaDomainDBKey, mQuotaETLDplus1DomainDBKey, mStorageType);
}
void
StorageChild::InitAsSessionStorage(nsIURI* aDomainURI)
{
DOMStorageBase::InitAsSessionStorage(aDomainURI);
InitRemote();
}
void
StorageChild::InitAsLocalStorage(nsIURI* aDomainURI, bool aCanUseChromePersist)
{
DOMStorageBase::InitAsLocalStorage(aDomainURI, aCanUseChromePersist);
InitRemote();
}
void
StorageChild::InitAsGlobalStorage(const nsACString& aDomainDemanded)
{
DOMStorageBase::InitAsGlobalStorage(aDomainDemanded);
InitRemote();
}
nsTArray<nsString>*
StorageChild::GetKeys(bool aCallerSecure)
{
InfallibleTArray<nsString> remoteKeys;
SendGetKeys(aCallerSecure, &remoteKeys);
nsTArray<nsString>* keys = new nsTArray<nsString>;
*keys = remoteKeys;
return keys;
}
nsresult
StorageChild::GetLength(bool aCallerSecure, PRUint32* aLength)
{
nsresult rv;
SendGetLength(aCallerSecure, aLength, &rv);
return rv;
}
nsresult
StorageChild::GetKey(bool aCallerSecure, PRUint32 aIndex, nsAString& aKey)
{
nsresult rv;
nsString key;
SendGetKey(aCallerSecure, aIndex, &key, &rv);
if (NS_FAILED(rv))
return rv;
aKey = key;
return NS_OK;
}
// Unlike other cross-process forwarding methods, GetValue needs to replicate
// the following behaviour of DOMStorageImpl::GetValue:
//
// - if a security error occurs, or the item isn't found, return null without
// propogating the error.
//
// If DOMStorageImpl::GetValue ever changes its behaviour, this should be kept
// in sync.
nsIDOMStorageItem*
StorageChild::GetValue(bool aCallerSecure, const nsAString& aKey, nsresult* rv)
{
nsresult rv2 = *rv = NS_OK;
StorageItem storageItem;
SendGetValue(aCallerSecure, nsString(aKey), &storageItem, &rv2);
if (rv2 == NS_ERROR_DOM_SECURITY_ERR || rv2 == NS_ERROR_DOM_NOT_FOUND_ERR)
return nsnull;
*rv = rv2;
if (NS_FAILED(*rv) || storageItem.type() == StorageItem::Tnull_t)
return nsnull;
const ItemData& data = storageItem.get_ItemData();
nsIDOMStorageItem* item = new nsDOMStorageItem(this, aKey, data.value(),
data.secure());
return item;
}
nsresult
StorageChild::SetValue(bool aCallerSecure, const nsAString& aKey,
const nsAString& aData, nsAString& aOldData)
{
nsresult rv;
nsString oldData;
SendSetValue(aCallerSecure, nsString(aKey), nsString(aData), &oldData, &rv);
if (NS_FAILED(rv))
return rv;
aOldData = oldData;
return NS_OK;
}
nsresult
StorageChild::RemoveValue(bool aCallerSecure, const nsAString& aKey,
nsAString& aOldData)
{
nsresult rv;
nsString oldData;
SendRemoveValue(aCallerSecure, nsString(aKey), &oldData, &rv);
if (NS_FAILED(rv))
return rv;
aOldData = oldData;
return NS_OK;
}
nsresult
StorageChild::Clear(bool aCallerSecure, PRInt32* aOldCount)
{
nsresult rv;
PRInt32 oldCount;
SendClear(aCallerSecure, &oldCount, &rv);
if (NS_FAILED(rv))
return rv;
*aOldCount = oldCount;
return NS_OK;
}
bool
StorageChild::CanUseChromePersist()
{
return mCanUseChromePersist;
}
nsresult
StorageChild::GetDBValue(const nsAString& aKey, nsAString& aValue,
PRBool* aSecure)
{
nsresult rv;
nsString value;
SendGetDBValue(nsString(aKey), &value, aSecure, &rv);
aValue = value;
return rv;
}
nsresult
StorageChild::SetDBValue(const nsAString& aKey,
const nsAString& aValue,
PRBool aSecure)
{
nsresult rv;
SendSetDBValue(nsString(aKey), nsString(aValue), aSecure, &rv);
return rv;
}
nsresult
StorageChild::SetSecure(const nsAString& aKey, PRBool aSecure)
{
nsresult rv;
SendSetSecure(nsString(aKey), aSecure, &rv);
return rv;
}
nsresult
StorageChild::CloneFrom(bool aCallerSecure, DOMStorageBase* aThat)
{
StorageChild* other = static_cast<StorageChild*>(aThat);
ContentChild* child = ContentChild::GetSingleton();
StorageClone clone(nsnull, other, aCallerSecure);
AddIPDLReference();
child->SendPStorageConstructor(this, clone);
SendInit(mUseDB, mCanUseChromePersist, mDomain, mScopeDBKey,
mQuotaDomainDBKey, mQuotaETLDplus1DomainDBKey, mStorageType);
return NS_OK;
}
}
}

View File

@ -0,0 +1,105 @@
/* -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 8 -*- */
/* vim: set sw=4 ts=8 et tw=80 ft=cpp : */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla DOM Storage.
*
* The Initial Developer of the Original Code is
* The Mozilla Foundation.
* Portions created by the Initial Developer are Copyright (C) 2010
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Josh Matthews <josh@joshmatthews.net> (original author)
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef mozilla_dom_StorageChild_h
#define mozilla_dom_StorageChild_h
#include "mozilla/dom/PStorageChild.h"
#include "nsDOMStorage.h"
#include "nsCycleCollectionParticipant.h"
namespace mozilla {
namespace dom {
class StorageChild : public PStorageChild
, public DOMStorageBase
{
public:
NS_DECL_CYCLE_COLLECTION_CLASS(StorageChild)
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
StorageChild(nsDOMStorage* aOwner);
StorageChild(nsDOMStorage* aOwner, StorageChild& aOther);
virtual void InitAsSessionStorage(nsIURI* aDomainURI);
virtual void InitAsLocalStorage(nsIURI* aDomainURI, bool aCanUseChromePersist);
virtual void InitAsGlobalStorage(const nsACString& aDomainDemanded);
virtual bool CacheStoragePermissions();
virtual nsTArray<nsString>* GetKeys(bool aCallerSecure);
virtual nsresult GetLength(bool aCallerSecure, PRUint32* aLength);
virtual nsresult GetKey(bool aCallerSecure, PRUint32 aIndex, nsAString& aKey);
virtual nsIDOMStorageItem* GetValue(bool aCallerSecure, const nsAString& aKey,
nsresult* rv);
virtual nsresult SetValue(bool aCallerSecure, const nsAString& aKey,
const nsAString& aData, nsAString& aOldValue);
virtual nsresult RemoveValue(bool aCallerSecure, const nsAString& aKey,
nsAString& aOldValue);
virtual nsresult Clear(bool aCallerSecure, PRInt32* aOldCount);
virtual bool CanUseChromePersist();
virtual nsresult GetDBValue(const nsAString& aKey,
nsAString& aValue,
PRBool* aSecure);
virtual nsresult SetDBValue(const nsAString& aKey,
const nsAString& aValue,
PRBool aSecure);
virtual nsresult SetSecure(const nsAString& aKey, PRBool aSecure);
virtual nsresult CloneFrom(bool aCallerSecure, DOMStorageBase* aThat);
void AddIPDLReference();
void ReleaseIPDLReference();
private:
void InitRemote();
// Unimplemented
StorageChild(const StorageChild&);
nsCOMPtr<nsIDOMStorageObsolete> mStorage;
bool mIPCOpen;
};
}
}
#endif

View File

@ -0,0 +1,175 @@
/* -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 8 -*- */
/* vim: set sw=4 ts=8 et tw=80 ft=cpp : */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla DOM Storage.
*
* The Initial Developer of the Original Code is
* The Mozilla Foundation.
* Portions created by the Initial Developer are Copyright (C) 2010
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Josh Matthews <josh@joshmatthews.net> (original author)
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "StorageParent.h"
#include "mozilla/dom/PContentParent.h"
#include "mozilla/unused.h"
#include "nsDOMString.h"
using mozilla::unused;
namespace mozilla {
namespace dom {
StorageParent::StorageParent(const StorageConstructData& aData)
{
if (aData.type() == StorageConstructData::Tnull_t) {
mStorage = new DOMStorageImpl(nsnull);
} else {
const StorageClone& clone = aData.get_StorageClone();
StorageParent* other = static_cast<StorageParent*>(clone.actorParent());
mStorage = new DOMStorageImpl(nsnull, *other->mStorage.get());
mStorage->CloneFrom(clone.callerSecure(), other->mStorage);
}
}
bool
StorageParent::RecvInit(const bool& aUseDB,
const bool& aCanUseChromePersist,
const nsCString& aDomain,
const nsCString& aScopeDBKey,
const nsCString& aQuotaDomainDBKey,
const nsCString& aQuotaETLDplus1DomainDBKey,
const PRUint32& aStorageType)
{
mStorage->InitFromChild(aUseDB, aCanUseChromePersist, aDomain, aScopeDBKey,
aQuotaDomainDBKey, aQuotaETLDplus1DomainDBKey,
aStorageType);
return true;
}
bool
StorageParent::RecvGetKeys(const bool& aCallerSecure, InfallibleTArray<nsString>* aKeys)
{
// Callers are responsible for deallocating the array returned by mStorage->GetKeys
nsAutoPtr<nsTArray<nsString> > keys(mStorage->GetKeys(aCallerSecure));
aKeys->SwapElements(*keys);
return true;
}
bool
StorageParent::RecvGetLength(const bool& aCallerSecure, PRUint32* aLength,
nsresult* rv)
{
*rv = mStorage->GetLength(aCallerSecure, aLength);
return true;
}
bool
StorageParent::RecvGetKey(const bool& aCallerSecure, const PRUint32& aIndex,
nsString* aKey, nsresult* rv)
{
*rv = mStorage->GetKey(aCallerSecure, aIndex, *aKey);
return true;
}
bool
StorageParent::RecvGetValue(const bool& aCallerSecure, const nsString& aKey,
StorageItem* aItem, nsresult* rv)
{
// We need to ensure that a proper null representation is sent to the child
// if no item is found or an error occurs.
*rv = NS_OK;
nsCOMPtr<nsIDOMStorageItem> item = mStorage->GetValue(aCallerSecure, aKey, rv);
if (NS_FAILED(*rv) || !item) {
*aItem = null_t();
return true;
}
ItemData data(EmptyString(), false);
nsDOMStorageItem* internalItem = static_cast<nsDOMStorageItem*>(item.get());
data.value() = internalItem->GetValueInternal();
if (aCallerSecure)
data.secure() = internalItem->IsSecure();
*aItem = data;
return true;
}
bool
StorageParent::RecvSetValue(const bool& aCallerSecure, const nsString& aKey,
const nsString& aData, nsString* aOldValue,
nsresult* rv)
{
*rv = mStorage->SetValue(aCallerSecure, aKey, aData, *aOldValue);
return true;
}
bool
StorageParent::RecvRemoveValue(const bool& aCallerSecure, const nsString& aKey,
nsString* aOldValue, nsresult* rv)
{
*rv = mStorage->RemoveValue(aCallerSecure, aKey, *aOldValue);
return true;
}
bool
StorageParent::RecvClear(const bool& aCallerSecure, PRInt32* aOldCount,
nsresult* rv)
{
*rv = mStorage->Clear(aCallerSecure, aOldCount);
return true;
}
bool
StorageParent::RecvGetDBValue(const nsString& aKey, nsString* aValue,
PRBool* aSecure, nsresult* rv)
{
*rv = mStorage->GetDBValue(aKey, *aValue, aSecure);
return true;
}
bool
StorageParent::RecvSetDBValue(const nsString& aKey, const nsString& aValue,
const PRBool& aSecure, nsresult* rv)
{
*rv = mStorage->SetDBValue(aKey, aValue, aSecure);
return true;
}
bool
StorageParent::RecvSetSecure(const nsString& aKey, const PRBool& aSecure,
nsresult* rv)
{
*rv = mStorage->SetSecure(aKey, aSecure);
return true;
}
}
}

View File

@ -0,0 +1,90 @@
/* -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 8 -*- */
/* vim: set sw=4 ts=8 et tw=80 ft=cpp : */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla DOM Storage.
*
* The Initial Developer of the Original Code is
* The Mozilla Foundation.
* Portions created by the Initial Developer are Copyright (C) 2010
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Josh Matthews <josh@joshmatthews.net> (original author)
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef mozilla_dom_StorageParent_h
#define mozilla_dom_StorageParent_h
#include "mozilla/dom/PStorageParent.h"
#include "nsDOMStorage.h"
namespace mozilla {
namespace dom {
class StorageConstructData;
class StorageParent : public PStorageParent
{
public:
StorageParent(const StorageConstructData& aData);
private:
bool RecvGetKeys(const bool& aCallerSecure, InfallibleTArray<nsString>* aKeys);
bool RecvGetLength(const bool& aCallerSecure, PRUint32* aLength, nsresult* rv);
bool RecvGetKey(const bool& aCallerSecure, const PRUint32& aIndex,
nsString* aKey, nsresult* rv);
bool RecvGetValue(const bool& aCallerSecure, const nsString& aKey,
StorageItem* aItem, nsresult* rv);
bool RecvSetValue(const bool& aCallerSecure, const nsString& aKey,
const nsString& aData, nsString* aOldValue, nsresult* rv);
bool RecvRemoveValue(const bool& aCallerSecure, const nsString& aKey,
nsString* aOldData, nsresult* rv);
bool RecvClear(const bool& aCallerSecure, PRInt32* aOldCount, nsresult* rv);
bool RecvGetDBValue(const nsString& aKey, nsString* aValue, PRBool* aSecure,
nsresult* rv);
bool RecvSetDBValue(const nsString& aKey, const nsString& aValue,
const PRBool& aSecure, nsresult* rv);
bool RecvSetSecure(const nsString& aKey, const PRBool& aSecure,
nsresult* rv);
bool RecvInit(const bool& aUseDB,
const bool& aCanUseChromePersist,
const nsCString& aDomain,
const nsCString& aScopeDBKey,
const nsCString& aQuotaDomainDBKey,
const nsCString& aQuotaETLDplus1DomainDBKey,
const PRUint32& aStorageType);
nsRefPtr<DOMStorageImpl> mStorage;
};
}
}
#endif

39
dom/src/storage/ipdl.mk Normal file
View File

@ -0,0 +1,39 @@
# ***** BEGIN LICENSE BLOCK *****
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
#
# The contents of this file are subject to the Mozilla Public License Version
# 1.1 (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
# http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
# for the specific language governing rights and limitations under the
# License.
#
# The Original Code is Mozilla DOM Storage.
#
# The Initial Developer of the Original Code is
# The Mozilla Foundation.
# Portions created by the Initial Developer are Copyright (C) 2010
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
#
# Alternatively, the contents of this file may be used under the terms of
# either the GNU General Public License Version 2 or later (the "GPL"), or
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
# in which case the provisions of the GPL or the LGPL are applicable instead
# of those above. If you wish to allow use of your version of this file only
# under the terms of either the GPL or the LGPL, and not to allow others to
# use your version of this file under the terms of the MPL, indicate your
# decision by deleting the provisions above and replace them with the notice
# and other provisions required by the GPL or the LGPL. If you do not delete
# the provisions above, a recipient may use your version of this file under
# the terms of any one of the MPL, the GPL or the LGPL.
#
# ***** END LICENSE BLOCK *****
IPDLSRCS = \
PStorage.ipdl \
$(NULL)

File diff suppressed because it is too large Load Diff

View File

@ -80,6 +80,15 @@ class nsDOMStorageItem;
using mozilla::TimeStamp;
using mozilla::TimeDuration;
namespace mozilla {
namespace dom {
class StorageParent;
}
}
using mozilla::dom::StorageParent;
class DOMStorageImpl;
class nsDOMStorageEntry : public nsVoidPtrHashKey
{
public:
@ -88,7 +97,7 @@ public:
~nsDOMStorageEntry();
// weak reference so that it can be deleted when no longer used
nsDOMStorage* mStorage;
DOMStorageImpl* mStorage;
};
class nsSessionStorageEntry : public nsStringHashKey
@ -116,8 +125,8 @@ public:
nsDOMStorageManager();
void AddToStoragesHash(nsDOMStorage* aStorage);
void RemoveFromStoragesHash(nsDOMStorage* aStorage);
void AddToStoragesHash(DOMStorageImpl* aStorage);
void RemoveFromStoragesHash(DOMStorageImpl* aStorage);
nsresult ClearAllStorages();
@ -135,10 +144,215 @@ protected:
PRBool mInPrivateBrowsing;
};
class DOMStorageBase : public nsISupports
{
public:
DOMStorageBase();
DOMStorageBase(DOMStorageBase&);
virtual void InitAsSessionStorage(nsIURI* aDomainURI);
virtual void InitAsLocalStorage(nsIURI* aDomainURI, bool aCanUseChromePersist);
virtual void InitAsGlobalStorage(const nsACString& aDomainDemanded);
virtual nsTArray<nsString>* GetKeys(bool aCallerSecure) = 0;
virtual nsresult GetLength(bool aCallerSecure, PRUint32* aLength) = 0;
virtual nsresult GetKey(bool aCallerSecure, PRUint32 aIndex, nsAString& aKey) = 0;
virtual nsIDOMStorageItem* GetValue(bool aCallerSecure, const nsAString& aKey,
nsresult* rv) = 0;
virtual nsresult SetValue(bool aCallerSecure, const nsAString& aKey,
const nsAString& aData, nsAString& aOldValue) = 0;
virtual nsresult RemoveValue(bool aCallerSecure, const nsAString& aKey,
nsAString& aOldValue) = 0;
virtual nsresult Clear(bool aCallerSecure, PRInt32* aOldCount) = 0;
// If true, the contents of the storage should be stored in the
// database, otherwise this storage should act like a session
// storage.
// This call relies on mSessionOnly, and should only be used
// after a CacheStoragePermissions() call. See the comments
// for mSessionOnly below.
PRBool UseDB() {
return mUseDB;
}
// retrieve the value and secure state corresponding to a key out of storage.
virtual nsresult
GetDBValue(const nsAString& aKey,
nsAString& aValue,
PRBool* aSecure) = 0;
// set the value corresponding to a key in the storage. If
// aSecure is false, then attempts to modify a secure value
// throw NS_ERROR_DOM_INVALID_ACCESS_ERR
virtual nsresult
SetDBValue(const nsAString& aKey,
const nsAString& aValue,
PRBool aSecure) = 0;
// set the value corresponding to a key as secure.
virtual nsresult
SetSecure(const nsAString& aKey, PRBool aSecure) = 0;
virtual nsresult
CloneFrom(bool aCallerSecure, DOMStorageBase* aThat) = 0;
// e.g. "moc.rab.oof.:" or "moc.rab.oof.:http:80" depending
// on association with a domain (globalStorage) or
// an origin (localStorage).
nsCString& GetScopeDBKey() {return mScopeDBKey;}
// e.g. "moc.rab.%" - reversed eTLD+1 subpart of the domain or
// reversed offline application allowed domain.
nsCString& GetQuotaDomainDBKey(PRBool aOfflineAllowed)
{
return aOfflineAllowed ? mQuotaDomainDBKey : mQuotaETLDplus1DomainDBKey;
}
virtual bool CacheStoragePermissions() = 0;
protected:
friend class nsDOMStorageManager;
friend class nsDOMStorage;
nsPIDOMStorage::nsDOMStorageType mStorageType;
// true if the storage database should be used for values
PRPackedBool mUseDB;
// true if the preferences indicates that this storage should be
// session only. This member is updated by
// CacheStoragePermissions(), using the current principal.
// CacheStoragePermissions() must be called at each entry point to
// make sure this stays up to date.
PRPackedBool mSessionOnly;
// domain this store is associated with
nsCString mDomain;
// keys are used for database queries.
// see comments of the getters bellow.
nsCString mScopeDBKey;
nsCString mQuotaETLDplus1DomainDBKey;
nsCString mQuotaDomainDBKey;
bool mCanUseChromePersist;
};
class DOMStorageImpl : public DOMStorageBase
, public nsIObserver
, public nsSupportsWeakReference
{
public:
NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(DOMStorageImpl, nsIObserver)
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_NSIOBSERVER
DOMStorageImpl(nsDOMStorage*);
DOMStorageImpl(nsDOMStorage*, DOMStorageImpl&);
~DOMStorageImpl();
// Cross-process storage implementations never have InitAs(Session|Local|Global)Storage
// called, so the appropriate initialization needs to happen from the child.
void InitFromChild(bool aUseDB, bool aCanUseChromePersist,
const nsACString& aDomain,
const nsACString& aScopeDBKey,
const nsACString& aQuotaDomainDBKey,
const nsACString& aQuotaETLDplus1DomainDBKey,
PRUint32 aStorageType);
virtual void InitAsSessionStorage(nsIURI* aDomainURI);
virtual void InitAsLocalStorage(nsIURI* aDomainURI, bool aCanUseChromePersist);
virtual void InitAsGlobalStorage(const nsACString& aDomainDemanded);
PRBool SessionOnly() {
return mSessionOnly;
}
virtual nsTArray<nsString>* GetKeys(bool aCallerSecure);
virtual nsresult GetLength(bool aCallerSecure, PRUint32* aLength);
virtual nsresult GetKey(bool aCallerSecure, PRUint32 aIndex, nsAString& aKey);
virtual nsIDOMStorageItem* GetValue(bool aCallerSecure, const nsAString& aKey,
nsresult* rv);
virtual nsresult SetValue(bool aCallerSecure, const nsAString& aKey,
const nsAString& aData, nsAString& aOldValue);
virtual nsresult RemoveValue(bool aCallerSecure, const nsAString& aKey,
nsAString& aOldValue);
virtual nsresult Clear(bool aCallerSecure, PRInt32* aOldCount);
// cache the keys from the database for faster lookup
nsresult CacheKeysFromDB();
// Some privileged internal pages can use a persistent storage even in
// session-only or private-browsing modes.
bool CanUseChromePersist();
// retrieve the value and secure state corresponding to a key out of storage
// that has been cached in mItems hash table.
nsresult
GetCachedValue(const nsAString& aKey,
nsAString& aValue,
PRBool* aSecure);
// retrieve the value and secure state corresponding to a key out of storage.
virtual nsresult
GetDBValue(const nsAString& aKey,
nsAString& aValue,
PRBool* aSecure);
// set the value corresponding to a key in the storage. If
// aSecure is false, then attempts to modify a secure value
// throw NS_ERROR_DOM_INVALID_ACCESS_ERR
virtual nsresult
SetDBValue(const nsAString& aKey,
const nsAString& aValue,
PRBool aSecure);
// set the value corresponding to a key as secure.
virtual nsresult
SetSecure(const nsAString& aKey, PRBool aSecure);
// clear all values from the store
void ClearAll();
virtual nsresult
CloneFrom(bool aCallerSecure, DOMStorageBase* aThat);
nsresult RegisterObservers();
nsresult MaybeCommitTemporaryTable(bool force);
bool WasTemporaryTableLoaded();
void SetTemporaryTableLoaded(bool loaded);
virtual bool CacheStoragePermissions();
private:
#ifdef MOZ_STORAGE
static nsDOMStorageDBWrapper* gStorageDB;
#endif
friend class nsDOMStorageManager;
friend class StorageParent;
void Init(nsDOMStorage*);
static nsresult InitDB();
// true if items from the database are cached
PRPackedBool mItemsCached;
// the key->value item pairs
nsTHashtable<nsSessionStorageEntry> mItems;
// Weak reference to the owning storage instance
nsDOMStorage* mOwner;
bool mLoadedTemporaryTable;
TimeStamp mLastTemporaryTableAccessTime;
TimeStamp mTemporaryTableAge;
};
class nsDOMStorage : public nsIDOMStorageObsolete,
public nsPIDOMStorage,
public nsIObserver,
public nsSupportsWeakReference
public nsPIDOMStorage
{
public:
nsDOMStorage();
@ -149,7 +363,6 @@ public:
NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(nsDOMStorage, nsIDOMStorageObsolete)
NS_DECL_NSIDOMSTORAGEOBSOLETE
NS_DECL_NSIOBSERVER
// Helpers for implementing nsIDOMStorage
nsresult GetItem(const nsAString& key, nsAString& aData);
@ -170,24 +383,6 @@ public:
const nsSubstring &aOldValue,
const nsSubstring &aNewValue);
// If true, the contents of the storage should be stored in the
// database, otherwise this storage should act like a session
// storage.
// This call relies on mSessionOnly, and should only be used
// after a CacheStoragePermissions() call. See the comments
// for mSessionOnly below.
PRBool UseDB() {
return mUseDB;
}
PRBool SessionOnly() {
return mSessionOnly;
}
// Some privileged internal pages can use a persistent storage even in
// session-only or private-browsing modes.
bool CanUseChromePersist();
// Check whether storage may be used by the caller, and whether it
// is session only. Returns true if storage may be used.
static PRBool
@ -204,37 +399,6 @@ public:
PRBool
CacheStoragePermissions();
// retrieve the value and secure state corresponding to a key out of storage
// that has been cached in mItems hash table.
nsresult
GetCachedValue(const nsAString& aKey,
nsAString& aValue,
PRBool* aSecure);
// retrieve the value and secure state corresponding to a key out of storage.
nsresult
GetDBValue(const nsAString& aKey,
nsAString& aValue,
PRBool* aSecure);
// set the value corresponding to a key in the storage. If
// aSecure is false, then attempts to modify a secure value
// throw NS_ERROR_DOM_INVALID_ACCESS_ERR
nsresult
SetDBValue(const nsAString& aKey,
const nsAString& aValue,
PRBool aSecure);
// set the value corresponding to a key as secure.
nsresult
SetSecure(const nsAString& aKey, PRBool aSecure);
// clear all values from the store
void ClearAll();
nsresult
CloneFrom(nsDOMStorage* aThat);
nsIDOMStorageItem* GetNamedItem(const nsAString& aKey, nsresult* aResult);
static nsDOMStorage* FromSupports(nsISupports* aSupports)
@ -242,85 +406,33 @@ public:
return static_cast<nsDOMStorage*>(static_cast<nsIDOMStorageObsolete*>(aSupports));
}
nsresult RegisterObservers();
nsresult MaybeCommitTemporaryTable(bool force);
nsresult SetSecure(const nsAString& aKey, PRBool aSecure)
{
return mStorageImpl->SetSecure(aKey, aSecure);
}
bool WasTemporaryTableLoaded();
void SetTemporaryTableLoaded(bool loaded);
nsresult CloneFrom(nsDOMStorage* aThat);
protected:
friend class nsDOMStorageManager;
protected:
friend class nsDOMStorage2;
friend class nsDOMStoragePersistentDB;
static nsresult InitDB();
// cache the keys from the database for faster lookup
nsresult CacheKeysFromDB();
nsRefPtr<DOMStorageBase> mStorageImpl;
PRBool CanAccessSystem(nsIPrincipal *aPrincipal);
// true if the storage database should be used for values
PRPackedBool mUseDB;
// domain this store is associated with
nsCString mDomain;
// document URI of the document this storage is bound to
nsString mDocumentURI;
// true if the preferences indicates that this storage should be
// session only. This member is updated by
// CacheStoragePermissions(), using the current principal.
// CacheStoragePermissions() must be called at each entry point to
// make sure this stays up to date.
PRPackedBool mSessionOnly;
// true if this storage was initialized as a localStorage object. localStorage
// objects are scoped to scheme/host/port in the database, while globalStorage
// objects are scoped just to host. this flag also tells the manager to map
// this storage also in mLocalStorages hash table.
nsDOMStorageType mStorageType;
// true if items from the database are cached
PRPackedBool mItemsCached;
// the key->value item pairs
nsTHashtable<nsSessionStorageEntry> mItems;
// keys are used for database queries.
// see comments of the getters bellow.
nsCString mScopeDBKey;
nsCString mQuotaETLDplus1DomainDBKey;
nsCString mQuotaDomainDBKey;
friend class nsIDOMStorage2;
nsPIDOMStorage* mSecurityChecker;
nsPIDOMStorage* mEventBroadcaster;
bool mCanUseChromePersist;
bool mLoadedTemporaryTable;
TimeStamp mLastTemporaryTableAccessTime;
TimeStamp mTemporaryTableAge;
public:
// e.g. "moc.rab.oof.:" or "moc.rab.oof.:http:80" depending
// on association with a domain (globalStorage) or
// an origin (localStorage).
nsCString& GetScopeDBKey() {return mScopeDBKey;}
// e.g. "moc.rab.%" - reversed eTLD+1 subpart of the domain or
// reversed offline application allowed domain.
nsCString& GetQuotaDomainDBKey(PRBool aOfflineAllowed)
{
return aOfflineAllowed ? mQuotaDomainDBKey : mQuotaETLDplus1DomainDBKey;
}
#ifdef MOZ_STORAGE
static nsDOMStorageDBWrapper* gStorageDB;
#endif
};
class nsDOMStorage2 : public nsIDOMStorage,
@ -423,7 +535,7 @@ class nsDOMStorageItem : public nsIDOMStorageItem,
public nsIDOMToString
{
public:
nsDOMStorageItem(nsDOMStorage* aStorage,
nsDOMStorageItem(DOMStorageBase* aStorage,
const nsAString& aKey,
const nsAString& aValue,
PRBool aSecure);
@ -477,7 +589,7 @@ protected:
// If this item came from the db, mStorage points to the storage
// object where this item came from.
nsRefPtr<nsDOMStorage> mStorage;
nsRefPtr<DOMStorageBase> mStorage;
};
class nsDOMStorageEvent : public nsDOMEvent,

View File

@ -108,7 +108,7 @@ nsDOMStorageDBWrapper::Init()
}
nsresult
nsDOMStorageDBWrapper::EnsureLoadTemporaryTableForStorage(nsDOMStorage* aStorage)
nsDOMStorageDBWrapper::EnsureLoadTemporaryTableForStorage(DOMStorageImpl* aStorage)
{
if (aStorage->CanUseChromePersist())
return mChromePersistentDB.EnsureLoadTemporaryTableForStorage(aStorage);
@ -121,7 +121,7 @@ nsDOMStorageDBWrapper::EnsureLoadTemporaryTableForStorage(nsDOMStorage* aStorage
}
nsresult
nsDOMStorageDBWrapper::FlushAndDeleteTemporaryTableForStorage(nsDOMStorage* aStorage)
nsDOMStorageDBWrapper::FlushAndDeleteTemporaryTableForStorage(DOMStorageImpl* aStorage)
{
if (aStorage->CanUseChromePersist())
return mChromePersistentDB.FlushAndDeleteTemporaryTableForStorage(aStorage);
@ -134,7 +134,7 @@ nsDOMStorageDBWrapper::FlushAndDeleteTemporaryTableForStorage(nsDOMStorage* aSto
}
nsresult
nsDOMStorageDBWrapper::GetAllKeys(nsDOMStorage* aStorage,
nsDOMStorageDBWrapper::GetAllKeys(DOMStorageImpl* aStorage,
nsTHashtable<nsSessionStorageEntry>* aKeys)
{
if (aStorage->CanUseChromePersist())
@ -148,7 +148,7 @@ nsDOMStorageDBWrapper::GetAllKeys(nsDOMStorage* aStorage,
}
nsresult
nsDOMStorageDBWrapper::GetKeyValue(nsDOMStorage* aStorage,
nsDOMStorageDBWrapper::GetKeyValue(DOMStorageImpl* aStorage,
const nsAString& aKey,
nsAString& aValue,
PRBool* aSecure)
@ -164,7 +164,7 @@ nsDOMStorageDBWrapper::GetKeyValue(nsDOMStorage* aStorage,
}
nsresult
nsDOMStorageDBWrapper::SetKey(nsDOMStorage* aStorage,
nsDOMStorageDBWrapper::SetKey(DOMStorageImpl* aStorage,
const nsAString& aKey,
const nsAString& aValue,
PRBool aSecure,
@ -187,7 +187,7 @@ nsDOMStorageDBWrapper::SetKey(nsDOMStorage* aStorage,
}
nsresult
nsDOMStorageDBWrapper::SetSecure(nsDOMStorage* aStorage,
nsDOMStorageDBWrapper::SetSecure(DOMStorageImpl* aStorage,
const nsAString& aKey,
const PRBool aSecure)
{
@ -202,7 +202,7 @@ nsDOMStorageDBWrapper::SetSecure(nsDOMStorage* aStorage,
}
nsresult
nsDOMStorageDBWrapper::RemoveKey(nsDOMStorage* aStorage,
nsDOMStorageDBWrapper::RemoveKey(DOMStorageImpl* aStorage,
const nsAString& aKey,
PRBool aExcludeOfflineFromUsage,
PRInt32 aKeyUsage)
@ -218,7 +218,7 @@ nsDOMStorageDBWrapper::RemoveKey(nsDOMStorage* aStorage,
}
nsresult
nsDOMStorageDBWrapper::ClearStorage(nsDOMStorage* aStorage)
nsDOMStorageDBWrapper::ClearStorage(DOMStorageImpl* aStorage)
{
if (aStorage->CanUseChromePersist())
return mChromePersistentDB.ClearStorage(aStorage);
@ -306,7 +306,7 @@ nsDOMStorageDBWrapper::RemoveAll()
}
nsresult
nsDOMStorageDBWrapper::GetUsage(nsDOMStorage* aStorage,
nsDOMStorageDBWrapper::GetUsage(DOMStorageImpl* aStorage,
PRBool aExcludeOfflineFromUsage, PRInt32 *aUsage)
{
if (aStorage->CanUseChromePersist())

View File

@ -93,15 +93,15 @@ public:
Init();
nsresult
EnsureLoadTemporaryTableForStorage(nsDOMStorage* aStorage);
EnsureLoadTemporaryTableForStorage(DOMStorageImpl* aStorage);
nsresult
FlushAndDeleteTemporaryTableForStorage(nsDOMStorage* aStorage);
FlushAndDeleteTemporaryTableForStorage(DOMStorageImpl* aStorage);
/**
* Retrieve a list of all the keys associated with a particular domain.
*/
nsresult
GetAllKeys(nsDOMStorage* aStorage,
GetAllKeys(DOMStorageImpl* aStorage,
nsTHashtable<nsSessionStorageEntry>* aKeys);
/**
@ -110,7 +110,7 @@ public:
* @throws NS_ERROR_DOM_NOT_FOUND_ERR if key not found
*/
nsresult
GetKeyValue(nsDOMStorage* aStorage,
GetKeyValue(DOMStorageImpl* aStorage,
const nsAString& aKey,
nsAString& aValue,
PRBool* aSecure);
@ -119,7 +119,7 @@ public:
* Set the value and secure flag for a key in storage.
*/
nsresult
SetKey(nsDOMStorage* aStorage,
SetKey(DOMStorageImpl* aStorage,
const nsAString& aKey,
const nsAString& aValue,
PRBool aSecure,
@ -132,7 +132,7 @@ public:
* not found.
*/
nsresult
SetSecure(nsDOMStorage* aStorage,
SetSecure(DOMStorageImpl* aStorage,
const nsAString& aKey,
const PRBool aSecure);
@ -140,7 +140,7 @@ public:
* Removes a key from storage.
*/
nsresult
RemoveKey(nsDOMStorage* aStorage,
RemoveKey(DOMStorageImpl* aStorage,
const nsAString& aKey,
PRBool aExcludeOfflineFromUsage,
PRInt32 aKeyUsage);
@ -149,7 +149,7 @@ public:
* Remove all keys belonging to this storage.
*/
nsresult
ClearStorage(nsDOMStorage* aStorage);
ClearStorage(DOMStorageImpl* aStorage);
/**
* Drop session-only storage for a specific host and all it's subdomains
@ -187,7 +187,7 @@ public:
* Returns usage for a storage using its GetQuotaDomainDBKey() as a key.
*/
nsresult
GetUsage(nsDOMStorage* aStorage, PRBool aExcludeOfflineFromUsage, PRInt32 *aUsage);
GetUsage(DOMStorageImpl* aStorage, PRBool aExcludeOfflineFromUsage, PRInt32 *aUsage);
/**
* Returns usage of the domain and optionaly by any subdomain.

View File

@ -74,7 +74,7 @@ AllKeyEnum(nsSessionStorageEntry* aEntry, void* userArg)
}
nsresult
nsDOMStorageMemoryDB::GetItemsTable(nsDOMStorage* aStorage,
nsDOMStorageMemoryDB::GetItemsTable(DOMStorageImpl* aStorage,
nsInMemoryStorage** aMemoryStorage)
{
if (mData.Get(aStorage->GetScopeDBKey(), aMemoryStorage))
@ -114,7 +114,7 @@ nsDOMStorageMemoryDB::GetItemsTable(nsDOMStorage* aStorage,
struct GetAllKeysEnumStruc
{
nsTHashtable<nsSessionStorageEntry>* mTarget;
nsDOMStorage* mStorage;
DOMStorageImpl* mStorage;
};
static PLDHashOperator
@ -139,7 +139,7 @@ GetAllKeysEnum(const nsAString& keyname,
}
nsresult
nsDOMStorageMemoryDB::GetAllKeys(nsDOMStorage* aStorage,
nsDOMStorageMemoryDB::GetAllKeys(DOMStorageImpl* aStorage,
nsTHashtable<nsSessionStorageEntry>* aKeys)
{
nsresult rv;
@ -157,7 +157,7 @@ nsDOMStorageMemoryDB::GetAllKeys(nsDOMStorage* aStorage,
}
nsresult
nsDOMStorageMemoryDB::GetKeyValue(nsDOMStorage* aStorage,
nsDOMStorageMemoryDB::GetKeyValue(DOMStorageImpl* aStorage,
const nsAString& aKey,
nsAString& aValue,
PRBool* aSecure)
@ -183,7 +183,7 @@ nsDOMStorageMemoryDB::GetKeyValue(nsDOMStorage* aStorage,
}
nsresult
nsDOMStorageMemoryDB::SetKey(nsDOMStorage* aStorage,
nsDOMStorageMemoryDB::SetKey(DOMStorageImpl* aStorage,
const nsAString& aKey,
const nsAString& aValue,
PRBool aSecure,
@ -237,7 +237,7 @@ nsDOMStorageMemoryDB::SetKey(nsDOMStorage* aStorage,
}
nsresult
nsDOMStorageMemoryDB::SetSecure(nsDOMStorage* aStorage,
nsDOMStorageMemoryDB::SetSecure(DOMStorageImpl* aStorage,
const nsAString& aKey,
const PRBool aSecure)
{
@ -257,7 +257,7 @@ nsDOMStorageMemoryDB::SetSecure(nsDOMStorage* aStorage,
}
nsresult
nsDOMStorageMemoryDB::RemoveKey(nsDOMStorage* aStorage,
nsDOMStorageMemoryDB::RemoveKey(DOMStorageImpl* aStorage,
const nsAString& aKey,
PRBool aExcludeOfflineFromUsage,
PRInt32 aKeyUsage)
@ -291,7 +291,7 @@ RemoveAllKeysEnum(const nsAString& keyname,
}
nsresult
nsDOMStorageMemoryDB::ClearStorage(nsDOMStorage* aStorage)
nsDOMStorageMemoryDB::ClearStorage(DOMStorageImpl* aStorage)
{
nsresult rv;
@ -304,7 +304,7 @@ nsDOMStorageMemoryDB::ClearStorage(nsDOMStorage* aStorage)
}
nsresult
nsDOMStorageMemoryDB::DropStorage(nsDOMStorage* aStorage)
nsDOMStorageMemoryDB::DropStorage(DOMStorageImpl* aStorage)
{
mData.Remove(aStorage->GetScopeDBKey());
return NS_OK;
@ -387,7 +387,7 @@ nsDOMStorageMemoryDB::RemoveAll()
}
nsresult
nsDOMStorageMemoryDB::GetUsage(nsDOMStorage* aStorage,
nsDOMStorageMemoryDB::GetUsage(DOMStorageImpl* aStorage,
PRBool aExcludeOfflineFromUsage, PRInt32 *aUsage)
{
return GetUsageInternal(aStorage->GetQuotaDomainDBKey(!aExcludeOfflineFromUsage),

View File

@ -82,14 +82,14 @@ public:
*
*/
nsresult
GetItemsTable(nsDOMStorage* aStorage,
GetItemsTable(DOMStorageImpl* aStorage,
nsInMemoryStorage** aMemoryStorage);
/**
* Retrieve a list of all the keys associated with a particular domain.
*/
nsresult
GetAllKeys(nsDOMStorage* aStorage,
GetAllKeys(DOMStorageImpl* aStorage,
nsTHashtable<nsSessionStorageEntry>* aKeys);
/**
@ -98,7 +98,7 @@ public:
* @throws NS_ERROR_DOM_NOT_FOUND_ERR if key not found
*/
nsresult
GetKeyValue(nsDOMStorage* aStorage,
GetKeyValue(DOMStorageImpl* aStorage,
const nsAString& aKey,
nsAString& aValue,
PRBool* aSecure);
@ -107,7 +107,7 @@ public:
* Set the value and secure flag for a key in storage.
*/
nsresult
SetKey(nsDOMStorage* aStorage,
SetKey(DOMStorageImpl* aStorage,
const nsAString& aKey,
const nsAString& aValue,
PRBool aSecure,
@ -120,7 +120,7 @@ public:
* not found.
*/
nsresult
SetSecure(nsDOMStorage* aStorage,
SetSecure(DOMStorageImpl* aStorage,
const nsAString& aKey,
const PRBool aSecure);
@ -128,7 +128,7 @@ public:
* Removes a key from storage.
*/
nsresult
RemoveKey(nsDOMStorage* aStorage,
RemoveKey(DOMStorageImpl* aStorage,
const nsAString& aKey,
PRBool aExcludeOfflineFromUsage,
PRInt32 aKeyUsage);
@ -137,13 +137,13 @@ public:
* Remove all keys belonging to this storage.
*/
nsresult
ClearStorage(nsDOMStorage* aStorage);
ClearStorage(DOMStorageImpl* aStorage);
/**
* If we have changed the persistent storage, drop any potential session storages
*/
nsresult
DropStorage(nsDOMStorage* aStorage);
DropStorage(DOMStorageImpl* aStorage);
/**
* Removes all keys added by a given domain.
@ -169,7 +169,7 @@ public:
* Returns usage for a storage using its GetQuotaDomainDBKey() as a key.
*/
nsresult
GetUsage(nsDOMStorage* aStorage, PRBool aExcludeOfflineFromUsage, PRInt32 *aUsage);
GetUsage(DOMStorageImpl* aStorage, PRBool aExcludeOfflineFromUsage, PRInt32 *aUsage);
/**
* Returns usage of the domain and optionaly by any subdomain.

View File

@ -444,7 +444,7 @@ nsDOMStoragePersistentDB::Init(const nsString& aDatabaseName)
}
nsresult
nsDOMStoragePersistentDB::EnsureLoadTemporaryTableForStorage(nsDOMStorage* aStorage)
nsDOMStoragePersistentDB::EnsureLoadTemporaryTableForStorage(DOMStorageImpl* aStorage)
{
if (!aStorage->WasTemporaryTableLoaded()) {
nsresult rv;
@ -475,7 +475,7 @@ nsDOMStoragePersistentDB::EnsureLoadTemporaryTableForStorage(nsDOMStorage* aStor
}
nsresult
nsDOMStoragePersistentDB::FlushAndDeleteTemporaryTableForStorage(nsDOMStorage* aStorage)
nsDOMStoragePersistentDB::FlushAndDeleteTemporaryTableForStorage(DOMStorageImpl* aStorage)
{
if (!aStorage->WasTemporaryTableLoaded())
return NS_OK;
@ -530,7 +530,7 @@ nsDOMStoragePersistentDB::FlushAndDeleteTemporaryTableForStorage(nsDOMStorage* a
}
nsresult
nsDOMStoragePersistentDB::GetAllKeys(nsDOMStorage* aStorage,
nsDOMStoragePersistentDB::GetAllKeys(DOMStorageImpl* aStorage,
nsTHashtable<nsSessionStorageEntry>* aKeys)
{
nsresult rv;
@ -583,7 +583,7 @@ nsDOMStoragePersistentDB::GetAllKeys(nsDOMStorage* aStorage,
}
nsresult
nsDOMStoragePersistentDB::GetKeyValue(nsDOMStorage* aStorage,
nsDOMStoragePersistentDB::GetKeyValue(DOMStorageImpl* aStorage,
const nsAString& aKey,
nsAString& aValue,
PRBool* aSecure)
@ -633,7 +633,7 @@ nsDOMStoragePersistentDB::GetKeyValue(nsDOMStorage* aStorage,
}
nsresult
nsDOMStoragePersistentDB::SetKey(nsDOMStorage* aStorage,
nsDOMStoragePersistentDB::SetKey(DOMStorageImpl* aStorage,
const nsAString& aKey,
const nsAString& aValue,
PRBool aSecure,
@ -707,7 +707,7 @@ nsDOMStoragePersistentDB::SetKey(nsDOMStorage* aStorage,
}
nsresult
nsDOMStoragePersistentDB::SetSecure(nsDOMStorage* aStorage,
nsDOMStoragePersistentDB::SetSecure(DOMStorageImpl* aStorage,
const nsAString& aKey,
const PRBool aSecure)
{
@ -741,7 +741,7 @@ nsDOMStoragePersistentDB::SetSecure(nsDOMStorage* aStorage,
}
nsresult
nsDOMStoragePersistentDB::RemoveKey(nsDOMStorage* aStorage,
nsDOMStoragePersistentDB::RemoveKey(DOMStorageImpl* aStorage,
const nsAString& aKey,
PRBool aExcludeOfflineFromUsage,
PRInt32 aKeyUsage)
@ -777,7 +777,7 @@ nsDOMStoragePersistentDB::RemoveKey(nsDOMStorage* aStorage,
}
nsresult
nsDOMStoragePersistentDB::ClearStorage(nsDOMStorage* aStorage)
nsDOMStoragePersistentDB::ClearStorage(DOMStorageImpl* aStorage)
{
nsresult rv;
@ -938,7 +938,7 @@ nsDOMStoragePersistentDB::RemoveAll()
}
nsresult
nsDOMStoragePersistentDB::GetUsage(nsDOMStorage* aStorage,
nsDOMStoragePersistentDB::GetUsage(DOMStorageImpl* aStorage,
PRBool aExcludeOfflineFromUsage,
PRInt32 *aUsage)
{

View File

@ -44,7 +44,7 @@
#include "mozIStorageStatement.h"
#include "nsTHashtable.h"
class nsDOMStorage;
class DOMStorageImpl;
class nsSessionStorageEntry;
class nsDOMStoragePersistentDB
@ -57,15 +57,15 @@ public:
Init(const nsString& aDatabaseName);
nsresult
EnsureLoadTemporaryTableForStorage(nsDOMStorage* aStorage);
EnsureLoadTemporaryTableForStorage(DOMStorageImpl* aStorage);
nsresult
FlushAndDeleteTemporaryTableForStorage(nsDOMStorage* aStorage);
FlushAndDeleteTemporaryTableForStorage(DOMStorageImpl* aStorage);
/**
* Retrieve a list of all the keys associated with a particular domain.
*/
nsresult
GetAllKeys(nsDOMStorage* aStorage,
GetAllKeys(DOMStorageImpl* aStorage,
nsTHashtable<nsSessionStorageEntry>* aKeys);
/**
@ -74,7 +74,7 @@ public:
* @throws NS_ERROR_DOM_NOT_FOUND_ERR if key not found
*/
nsresult
GetKeyValue(nsDOMStorage* aStorage,
GetKeyValue(DOMStorageImpl* aStorage,
const nsAString& aKey,
nsAString& aValue,
PRBool* aSecure);
@ -83,7 +83,7 @@ public:
* Set the value and secure flag for a key in storage.
*/
nsresult
SetKey(nsDOMStorage* aStorage,
SetKey(DOMStorageImpl* aStorage,
const nsAString& aKey,
const nsAString& aValue,
PRBool aSecure,
@ -96,7 +96,7 @@ public:
* not found.
*/
nsresult
SetSecure(nsDOMStorage* aStorage,
SetSecure(DOMStorageImpl* aStorage,
const nsAString& aKey,
const PRBool aSecure);
@ -104,7 +104,7 @@ public:
* Removes a key from storage.
*/
nsresult
RemoveKey(nsDOMStorage* aStorage,
RemoveKey(DOMStorageImpl* aStorage,
const nsAString& aKey,
PRBool aExcludeOfflineFromUsage,
PRInt32 aKeyUsage);
@ -112,7 +112,7 @@ public:
/**
* Remove all keys belonging to this storage.
*/
nsresult ClearStorage(nsDOMStorage* aStorage);
nsresult ClearStorage(DOMStorageImpl* aStorage);
/**
* Removes all keys added by a given domain.
@ -138,7 +138,7 @@ public:
* Returns usage for a storage using its GetQuotaDomainDBKey() as a key.
*/
nsresult
GetUsage(nsDOMStorage* aStorage, PRBool aExcludeOfflineFromUsage, PRInt32 *aUsage);
GetUsage(DOMStorageImpl* aStorage, PRBool aExcludeOfflineFromUsage, PRInt32 *aUsage);
/**
* Returns usage of the domain and optionaly by any subdomain.

View File

@ -57,6 +57,7 @@ IPDLDIRS = \
uriloader/exthandler \
dom/plugins \
dom/ipc \
dom/src/storage \
gfx/layers/ipc \
ipc/ipdl/test/cxx \
ipc/testshell \