author | Josh Matthews <josh@joshmatthews.net> |
Sat, 25 Dec 2010 02:31:01 -0500 | |
changeset 60073 | ab1fb1ff366247dd14efa7648f3adf079eb8b341 |
parent 60072 | 267854eaa0ff8b08abcc3b2e5b0e2007c1280b54 |
child 60074 | f30f14f26ab7f4d5abda8487e5be489d4b18538f |
push id | 17850 |
push user | josh@joshmatthews.net |
push date | Thu, 06 Jan 2011 15:56:40 +0000 |
treeherder | mozilla-central@ab1fb1ff3662 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | honzab, blocking-fennec |
bugs | 621365 |
milestone | 2.0b9pre |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
--- a/dom/src/storage/PStorage.ipdl +++ b/dom/src/storage/PStorage.ipdl @@ -63,33 +63,33 @@ union StorageItem // 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, + Init(bool useDB, bool canUseChromePersist, bool sessionOnly, nsCString domain, nsCString scopeDBKey, nsCString quotaDomainDBKey, nsCString quotaETLDplus1DomainDBKey, PRUint32 storageType); sync GetKeys(bool callerSecure) returns (nsString[] keys); - sync GetLength(bool callerSecure) + sync GetLength(bool callerSecure, bool sessionOnly) returns (PRUint32 length, nsresult rv); - sync GetKey(bool callerSecure, PRUint32 index) + sync GetKey(bool callerSecure, bool sessionOnly, PRUint32 index) returns (nsString key, nsresult rv); - sync GetValue(bool callerSecure, nsString key) + sync GetValue(bool callerSecure, bool sessionOnly, nsString key) returns (StorageItem item, nsresult rv); - sync SetValue(bool callerSecure, nsString key, nsString data) + sync SetValue(bool callerSecure, bool sessionOnly, nsString key, nsString data) returns (nsString oldValue, nsresult rv); - sync RemoveValue(bool callerSecure, nsString key) + sync RemoveValue(bool callerSecure, bool sessionOnly, nsString key) returns (nsString oldValue, nsresult rv); - sync Clear(bool callerSecure) + sync Clear(bool callerSecure, bool sessionOnly) 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);
--- a/dom/src/storage/StorageChild.cpp +++ b/dom/src/storage/StorageChild.cpp @@ -107,17 +107,17 @@ StorageChild::CacheStoragePermissions() } void StorageChild::InitRemote() { ContentChild* child = ContentChild::GetSingleton(); AddIPDLReference(); child->SendPStorageConstructor(this, null_t()); - SendInit(mUseDB, mCanUseChromePersist, mDomain, mScopeDBKey, + SendInit(mUseDB, mCanUseChromePersist, mSessionOnly, mDomain, mScopeDBKey, mQuotaDomainDBKey, mQuotaETLDplus1DomainDBKey, mStorageType); } void StorageChild::InitAsSessionStorage(nsIURI* aDomainURI) { DOMStorageBase::InitAsSessionStorage(aDomainURI); InitRemote(); @@ -146,26 +146,26 @@ StorageChild::GetKeys(bool aCallerSecure *keys = remoteKeys; return keys; } nsresult StorageChild::GetLength(bool aCallerSecure, PRUint32* aLength) { nsresult rv; - SendGetLength(aCallerSecure, aLength, &rv); + SendGetLength(aCallerSecure, mSessionOnly, aLength, &rv); return rv; } nsresult StorageChild::GetKey(bool aCallerSecure, PRUint32 aIndex, nsAString& aKey) { nsresult rv; nsString key; - SendGetKey(aCallerSecure, aIndex, &key, &rv); + SendGetKey(aCallerSecure, mSessionOnly, 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: @@ -175,17 +175,17 @@ StorageChild::GetKey(bool aCallerSecure, // // 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); + SendGetValue(aCallerSecure, mSessionOnly, 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()); @@ -193,42 +193,43 @@ StorageChild::GetValue(bool aCallerSecur } 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); + SendSetValue(aCallerSecure, mSessionOnly, 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); + SendRemoveValue(aCallerSecure, mSessionOnly, 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); + SendClear(aCallerSecure, mSessionOnly, &oldCount, &rv); if (NS_FAILED(rv)) return rv; *aOldCount = oldCount; return NS_OK; } bool StorageChild::CanUseChromePersist() @@ -268,15 +269,15 @@ StorageChild::SetSecure(const nsAString& 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, + SendInit(mUseDB, mCanUseChromePersist, mSessionOnly, mDomain, mScopeDBKey, mQuotaDomainDBKey, mQuotaETLDplus1DomainDBKey, mStorageType); return NS_OK; } } }
--- a/dom/src/storage/StorageParent.cpp +++ b/dom/src/storage/StorageParent.cpp @@ -57,57 +57,63 @@ StorageParent::StorageParent(const Stora mStorage = new DOMStorageImpl(nsnull, *other->mStorage.get()); mStorage->CloneFrom(clone.callerSecure(), other->mStorage); } } bool StorageParent::RecvInit(const bool& aUseDB, const bool& aCanUseChromePersist, + const bool& aSessionOnly, const nsCString& aDomain, const nsCString& aScopeDBKey, const nsCString& aQuotaDomainDBKey, const nsCString& aQuotaETLDplus1DomainDBKey, const PRUint32& aStorageType) { - mStorage->InitFromChild(aUseDB, aCanUseChromePersist, aDomain, aScopeDBKey, - aQuotaDomainDBKey, aQuotaETLDplus1DomainDBKey, + mStorage->InitFromChild(aUseDB, aCanUseChromePersist, aSessionOnly, 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) +StorageParent::RecvGetLength(const bool& aCallerSecure, const bool& aSessionOnly, + PRUint32* aLength, nsresult* rv) { + mStorage->SetSessionOnly(aSessionOnly); *rv = mStorage->GetLength(aCallerSecure, aLength); return true; } bool -StorageParent::RecvGetKey(const bool& aCallerSecure, const PRUint32& aIndex, - nsString* aKey, nsresult* rv) +StorageParent::RecvGetKey(const bool& aCallerSecure, const bool& aSessionOnly, + const PRUint32& aIndex, nsString* aKey, nsresult* rv) { + mStorage->SetSessionOnly(aSessionOnly); *rv = mStorage->GetKey(aCallerSecure, aIndex, *aKey); return true; } bool -StorageParent::RecvGetValue(const bool& aCallerSecure, const nsString& aKey, - StorageItem* aItem, nsresult* rv) +StorageParent::RecvGetValue(const bool& aCallerSecure, const bool& aSessionOnly, + const nsString& aKey, StorageItem* aItem, + nsresult* rv) { + mStorage->SetSessionOnly(aSessionOnly); + // 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; @@ -118,36 +124,40 @@ StorageParent::RecvGetValue(const bool& 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) +StorageParent::RecvSetValue(const bool& aCallerSecure, const bool& aSessionOnly, + const nsString& aKey, const nsString& aData, + nsString* aOldValue, nsresult* rv) { + mStorage->SetSessionOnly(aSessionOnly); *rv = mStorage->SetValue(aCallerSecure, aKey, aData, *aOldValue); return true; } bool -StorageParent::RecvRemoveValue(const bool& aCallerSecure, const nsString& aKey, - nsString* aOldValue, nsresult* rv) +StorageParent::RecvRemoveValue(const bool& aCallerSecure, const bool& aSessionOnly, + const nsString& aKey, nsString* aOldValue, + nsresult* rv) { + mStorage->SetSessionOnly(aSessionOnly); *rv = mStorage->RemoveValue(aCallerSecure, aKey, *aOldValue); return true; } bool -StorageParent::RecvClear(const bool& aCallerSecure, PRInt32* aOldCount, - nsresult* rv) +StorageParent::RecvClear(const bool& aCallerSecure, const bool& aSessionOnly, + PRInt32* aOldCount, nsresult* rv) { + mStorage->SetSessionOnly(aSessionOnly); *rv = mStorage->Clear(aCallerSecure, aOldCount); return true; } bool StorageParent::RecvGetDBValue(const nsString& aKey, nsString* aValue, PRBool* aSecure, nsresult* rv) {
--- a/dom/src/storage/StorageParent.h +++ b/dom/src/storage/StorageParent.h @@ -50,36 +50,39 @@ 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 RecvGetLength(const bool& aCallerSecure, const bool& aSessionOnly, + PRUint32* aLength, nsresult* rv); + bool RecvGetKey(const bool& aCallerSecure, const bool& aSessionOnly, + const PRUint32& aIndex,nsString* aKey, nsresult* rv); + bool RecvGetValue(const bool& aCallerSecure, const bool& aSessionOnly, + const nsString& aKey, StorageItem* aItem, nsresult* rv); + bool RecvSetValue(const bool& aCallerSecure, const bool& aSessionOnly, + const nsString& aKey, const nsString& aData, + nsString* aOldValue, nsresult* rv); + bool RecvRemoveValue(const bool& aCallerSecure, const bool& aSessionOnly, + const nsString& aKey, nsString* aOldData, nsresult* rv); + bool RecvClear(const bool& aCallerSecure, const bool& aSessionOnly, + 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 RecvSetSecure(const nsString& aKey, const PRBool& aSecure, nsresult* rv); bool RecvInit(const bool& aUseDB, const bool& aCanUseChromePersist, + const bool& aSessionOnly, const nsCString& aDomain, const nsCString& aScopeDBKey, const nsCString& aQuotaDomainDBKey, const nsCString& aQuotaETLDplus1DomainDBKey, const PRUint32& aStorageType); nsRefPtr<DOMStorageImpl> mStorage; };
--- a/dom/src/storage/nsDOMStorage.cpp +++ b/dom/src/storage/nsDOMStorage.cpp @@ -788,32 +788,38 @@ DOMStorageImpl::InitDB() } #endif return NS_OK; } void DOMStorageImpl::InitFromChild(bool aUseDB, bool aCanUseChromePersist, - const nsACString& aDomain, + bool aSessionOnly, const nsACString& aDomain, const nsACString& aScopeDBKey, const nsACString& aQuotaDomainDBKey, const nsACString& aQuotaETLDplus1DomainDBKey, PRUint32 aStorageType) { mUseDB = aUseDB; mCanUseChromePersist = aCanUseChromePersist; + mSessionOnly = aSessionOnly; mDomain = aDomain; mScopeDBKey = aScopeDBKey; mQuotaDomainDBKey = aQuotaDomainDBKey; mQuotaETLDplus1DomainDBKey = aQuotaETLDplus1DomainDBKey; mStorageType = static_cast<nsPIDOMStorage::nsDOMStorageType>(aStorageType); if (mStorageType != nsPIDOMStorage::SessionStorage) RegisterObservers(); - CacheStoragePermissions(); +} + +void +DOMStorageImpl::SetSessionOnly(bool aSessionOnly) +{ + mSessionOnly = aSessionOnly; } void DOMStorageImpl::InitAsSessionStorage(nsIURI* aDomainURI) { DOMStorageBase::InitAsSessionStorage(aDomainURI); } @@ -1342,19 +1348,16 @@ DOMStorageImpl::SetValue(bool aIsCallerS aOldValue = oldValue; return NS_OK; } nsresult DOMStorageImpl::RemoveValue(bool aCallerSecure, const nsAString& aKey, nsAString& aOldValue) { - if (!CacheStoragePermissions()) - return NS_ERROR_DOM_SECURITY_ERR; - nsString oldValue; nsSessionStorageEntry *entry = mItems.GetEntry(aKey); if (entry && entry->mItem->IsSecure() && !aCallerSecure) { return NS_ERROR_DOM_SECURITY_ERR; } if (UseDB()) {
--- a/dom/src/storage/nsDOMStorage.h +++ b/dom/src/storage/nsDOMStorage.h @@ -252,25 +252,16 @@ 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; } @@ -335,16 +326,26 @@ private: #ifdef MOZ_STORAGE static nsDOMStorageDBWrapper* gStorageDB; #endif friend class nsDOMStorageManager; friend class StorageParent; void Init(nsDOMStorage*); + // 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, bool aSessionOnly, + const nsACString& aDomain, + const nsACString& aScopeDBKey, + const nsACString& aQuotaDomainDBKey, + const nsACString& aQuotaETLDplus1DomainDBKey, + PRUint32 aStorageType); + void SetSessionOnly(bool aSessionOnly); + static nsresult InitDB(); // true if items from the database are cached PRPackedBool mItemsCached; // the key->value item pairs nsTHashtable<nsSessionStorageEntry> mItems;