зеркало из https://github.com/mozilla/gecko-dev.git
Bug 708901 - Migrate to nsTHashSet in dom/storage. r=dom-storage-reviewers,janv
Differential Revision: https://phabricator.services.mozilla.com/D109325
This commit is contained in:
Родитель
4a308827e3
Коммит
b4f4396431
|
@ -325,9 +325,7 @@ bool StorageDBThread::ShouldPreloadOrigin(const nsACString& aOrigin) {
|
|||
|
||||
void StorageDBThread::GetOriginsHavingData(nsTArray<nsCString>* aOrigins) {
|
||||
MonitorAutoLock monitor(mThreadObserver->GetMonitor());
|
||||
for (auto iter = mOriginsHavingData.Iter(); !iter.Done(); iter.Next()) {
|
||||
aOrigins->AppendElement(iter.Get()->GetKey());
|
||||
}
|
||||
AppendToArray(*aOrigins, mOriginsHavingData);
|
||||
}
|
||||
|
||||
nsresult StorageDBThread::InsertDBOp(
|
||||
|
@ -620,7 +618,7 @@ nsresult StorageDBThread::InitDatabase() {
|
|||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
MonitorAutoLock monitor(mThreadObserver->GetMonitor());
|
||||
mOriginsHavingData.PutEntry(foundOrigin);
|
||||
mOriginsHavingData.Insert(foundOrigin);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
@ -1089,7 +1087,7 @@ nsresult StorageDBThread::DBOperation::Perform(StorageDBThread* aThread) {
|
|||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
MonitorAutoLock monitor(aThread->mThreadObserver->GetMonitor());
|
||||
aThread->mOriginsHavingData.PutEntry(Origin());
|
||||
aThread->mOriginsHavingData.Insert(Origin());
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -1140,7 +1138,7 @@ nsresult StorageDBThread::DBOperation::Perform(StorageDBThread* aThread) {
|
|||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
MonitorAutoLock monitor(aThread->mThreadObserver->GetMonitor());
|
||||
aThread->mOriginsHavingData.RemoveEntry(Origin());
|
||||
aThread->mOriginsHavingData.Remove(Origin());
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#include "nsIFile.h"
|
||||
#include "nsIThreadInternal.h"
|
||||
#include "nsThreadUtils.h"
|
||||
#include "nsTHashSet.h"
|
||||
|
||||
class mozIStorageConnection;
|
||||
|
||||
|
@ -411,7 +412,7 @@ class StorageDBThread final {
|
|||
|
||||
// List of origins (including origin attributes suffix) having data, for
|
||||
// optimization purposes only
|
||||
nsTHashtable<nsCStringHashKey> mOriginsHavingData;
|
||||
nsTHashSet<nsCString> mOriginsHavingData;
|
||||
|
||||
// Connection used by the worker thread for all read and write ops
|
||||
nsCOMPtr<mozIStorageConnection> mWorkerConnection;
|
||||
|
|
|
@ -191,9 +191,9 @@ StorageDBChild* StorageDBChild::GetOrCreate(const uint32_t aPrivateBrowsingId) {
|
|||
return storageChild;
|
||||
}
|
||||
|
||||
nsTHashtable<nsCStringHashKey>& StorageDBChild::OriginsHavingData() {
|
||||
nsTHashSet<nsCString>& StorageDBChild::OriginsHavingData() {
|
||||
if (!mOriginsHavingData) {
|
||||
mOriginsHavingData = MakeUnique<nsTHashtable<nsCStringHashKey>>();
|
||||
mOriginsHavingData = MakeUnique<nsTHashSet<nsCString>>();
|
||||
}
|
||||
|
||||
return *mOriginsHavingData;
|
||||
|
@ -244,7 +244,7 @@ void StorageDBChild::AsyncPreload(LocalStorageCacheBridge* aCache,
|
|||
if (mIPCOpen) {
|
||||
// Adding ref to cache for the time of preload. This ensures a reference to
|
||||
// to the cache and that all keys will load into this cache object.
|
||||
mLoadingCaches.PutEntry(aCache);
|
||||
mLoadingCaches.Insert(aCache);
|
||||
SendAsyncPreload(aCache->OriginSuffix(), aCache->OriginNoSuffix(),
|
||||
aPriority);
|
||||
} else {
|
||||
|
@ -296,7 +296,7 @@ nsresult StorageDBChild::AsyncAddItem(LocalStorageCacheBridge* aCache,
|
|||
|
||||
SendAsyncAddItem(aCache->OriginSuffix(), aCache->OriginNoSuffix(),
|
||||
nsString(aKey), nsString(aValue));
|
||||
OriginsHavingData().PutEntry(aCache->Origin());
|
||||
OriginsHavingData().Insert(aCache->Origin());
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -309,7 +309,7 @@ nsresult StorageDBChild::AsyncUpdateItem(LocalStorageCacheBridge* aCache,
|
|||
|
||||
SendAsyncUpdateItem(aCache->OriginSuffix(), aCache->OriginNoSuffix(),
|
||||
nsString(aKey), nsString(aValue));
|
||||
OriginsHavingData().PutEntry(aCache->Origin());
|
||||
OriginsHavingData().Insert(aCache->Origin());
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -330,7 +330,7 @@ nsresult StorageDBChild::AsyncClear(LocalStorageCacheBridge* aCache) {
|
|||
}
|
||||
|
||||
SendAsyncClear(aCache->OriginSuffix(), aCache->OriginNoSuffix());
|
||||
OriginsHavingData().RemoveEntry(aCache->Origin());
|
||||
OriginsHavingData().Remove(aCache->Origin());
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -360,7 +360,7 @@ mozilla::ipc::IPCResult StorageDBChild::RecvOriginsHavingData(
|
|||
}
|
||||
|
||||
for (uint32_t i = 0; i < aOrigins.Length(); ++i) {
|
||||
OriginsHavingData().PutEntry(aOrigins[i]);
|
||||
OriginsHavingData().Insert(aOrigins[i]);
|
||||
}
|
||||
|
||||
return IPC_OK();
|
||||
|
@ -387,7 +387,7 @@ mozilla::ipc::IPCResult StorageDBChild::RecvLoadDone(
|
|||
aCache->LoadDone(aRv);
|
||||
|
||||
// Just drop reference to this cache now since the load is done.
|
||||
mLoadingCaches.RemoveEntry(static_cast<LocalStorageCacheBridge*>(aCache));
|
||||
mLoadingCaches.Remove(static_cast<LocalStorageCacheBridge*>(aCache));
|
||||
}
|
||||
|
||||
return IPC_OK();
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
#include "mozilla/dom/PBackgroundStorageParent.h"
|
||||
#include "mozilla/dom/PSessionStorageObserverChild.h"
|
||||
#include "mozilla/dom/PSessionStorageObserverParent.h"
|
||||
#include "nsClassHashtable.h"
|
||||
#include "nsTHashSet.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
|
@ -166,17 +166,17 @@ class StorageDBChild final : public PBackgroundStorageChild {
|
|||
const int64_t& aUsage) override;
|
||||
mozilla::ipc::IPCResult RecvError(const nsresult& aRv) override;
|
||||
|
||||
nsTHashtable<nsCStringHashKey>& OriginsHavingData();
|
||||
nsTHashSet<nsCString>& OriginsHavingData();
|
||||
|
||||
// Held to get caches to forward answers to.
|
||||
RefPtr<LocalStorageManager> mManager;
|
||||
|
||||
// Origins having data hash, for optimization purposes only
|
||||
UniquePtr<nsTHashtable<nsCStringHashKey>> mOriginsHavingData;
|
||||
UniquePtr<nsTHashSet<nsCString>> mOriginsHavingData;
|
||||
|
||||
// List of caches waiting for preload. This ensures the contract that
|
||||
// AsyncPreload call references the cache for time of the preload.
|
||||
nsTHashtable<nsRefPtrHashKey<LocalStorageCacheBridge>> mLoadingCaches;
|
||||
nsTHashSet<RefPtr<LocalStorageCacheBridge>> mLoadingCaches;
|
||||
|
||||
// Expected to be only 0 or 1.
|
||||
const uint32_t mPrivateBrowsingId;
|
||||
|
|
Загрузка…
Ссылка в новой задаче