зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1526891 - Part 5: Allow calling NextGenLocalStorageEnabled on any thread in the parent process; r=asuth
Differential Revision: https://phabricator.services.mozilla.com/D20914
This commit is contained in:
Родитель
dea641b977
Коммит
6b68f4dc07
|
@ -182,10 +182,15 @@ const uint32_t kFlushTimeoutMs = 5000;
|
|||
|
||||
const char kPrivateBrowsingObserverTopic[] = "last-pb-context-exited";
|
||||
|
||||
const uint32_t kDefaultNextGen = false;
|
||||
const uint32_t kDefaultOriginLimitKB = 5 * 1024;
|
||||
const uint32_t kDefaultShadowWrites = true;
|
||||
const uint32_t kDefaultSnapshotPrefill = 4096;
|
||||
const uint32_t kDefaultClientValidation = true;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
const char kNextGenPref[] = "dom.storage.next_gen";
|
||||
/**
|
||||
* LocalStorage data limit as determined by summing up the lengths of all string
|
||||
* keys and values. This is consistent with the legacy implementation and other
|
||||
|
@ -2718,6 +2723,7 @@ typedef nsClassHashtable<nsCStringHashKey, nsTArray<Observer*>>
|
|||
|
||||
StaticAutoPtr<ObserverHashtable> gObservers;
|
||||
|
||||
Atomic<bool> gNextGen(kDefaultNextGen);
|
||||
Atomic<uint32_t, Relaxed> gOriginLimitKB(kDefaultOriginLimitKB);
|
||||
Atomic<bool> gShadowWrites(kDefaultShadowWrites);
|
||||
Atomic<int32_t, Relaxed> gSnapshotPrefill(kDefaultSnapshotPrefill);
|
||||
|
@ -2940,6 +2946,11 @@ void InitializeLocalStorage() {
|
|||
NS_WARNING("Failed to initialize quota client!");
|
||||
}
|
||||
|
||||
if (NS_FAILED(Preferences::AddAtomicBoolVarCache(&gNextGen, kNextGenPref,
|
||||
kDefaultNextGen))) {
|
||||
NS_WARNING("Unable to respond to next gen pref changes!");
|
||||
}
|
||||
|
||||
if (NS_FAILED(Preferences::AddAtomicUintVarCache(
|
||||
&gOriginLimitKB, kDefaultQuotaPref, kDefaultOriginLimitKB))) {
|
||||
NS_WARNING("Unable to respond to default quota pref changes!");
|
||||
|
@ -2959,6 +2970,8 @@ void InitializeLocalStorage() {
|
|||
#endif
|
||||
}
|
||||
|
||||
bool GetCurrentNextGenPrefValue() { return gNextGen; }
|
||||
|
||||
PBackgroundLSDatabaseParent* AllocPBackgroundLSDatabaseParent(
|
||||
const PrincipalInfo& aPrincipalInfo, const uint32_t& aPrivateBrowsingId,
|
||||
const uint64_t& aDatastoreId) {
|
||||
|
|
|
@ -33,6 +33,8 @@ class Client;
|
|||
|
||||
void InitializeLocalStorage();
|
||||
|
||||
bool GetCurrentNextGenPrefValue();
|
||||
|
||||
PBackgroundLSDatabaseParent* AllocPBackgroundLSDatabaseParent(
|
||||
const mozilla::ipc::PrincipalInfo& aPrincipalInfo,
|
||||
const uint32_t& aPrivateBrowsingId, const uint64_t& aDatastoreId);
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
#include "LocalStorageCommon.h"
|
||||
|
||||
#include "mozilla/dom/ContentChild.h"
|
||||
#include "mozilla/net/MozURL.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
@ -15,6 +16,7 @@ using namespace mozilla::net;
|
|||
|
||||
namespace {
|
||||
|
||||
StaticMutex gNextGenLocalStorageMutex;
|
||||
Atomic<int32_t> gNextGenLocalStorageEnabled(-1);
|
||||
|
||||
} // namespace
|
||||
|
@ -22,6 +24,17 @@ Atomic<int32_t> gNextGenLocalStorageEnabled(-1);
|
|||
const char16_t* kLocalStorageType = u"localStorage";
|
||||
|
||||
bool NextGenLocalStorageEnabled() {
|
||||
if (XRE_IsParentProcess()) {
|
||||
StaticMutexAutoLock lock(gNextGenLocalStorageMutex);
|
||||
|
||||
if (gNextGenLocalStorageEnabled == -1) {
|
||||
bool enabled = GetCurrentNextGenPrefValue();
|
||||
gNextGenLocalStorageEnabled = enabled ? 1 : 0;
|
||||
}
|
||||
|
||||
return !!gNextGenLocalStorageEnabled;
|
||||
}
|
||||
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
if (gNextGenLocalStorageEnabled == -1) {
|
||||
|
|
|
@ -220,8 +220,12 @@ class MOZ_STACK_CLASS LSNotifyInfo {
|
|||
};
|
||||
|
||||
/**
|
||||
* Main-thread-only check of LSNG being enabled, the value is latched once
|
||||
* initialized so changing the preference during runtime has no effect.
|
||||
* A check of LSNG being enabled, the value is latched once initialized so
|
||||
* changing the preference during runtime has no effect.
|
||||
* May be called on any thread in the parent process, but you should call
|
||||
* CachedNextGenLocalStorageEnabled if you know that NextGenLocalStorageEnabled
|
||||
* was already called because it is faster.
|
||||
* May be called on the main thread only in a content process.
|
||||
*/
|
||||
bool NextGenLocalStorageEnabled();
|
||||
|
||||
|
|
|
@ -2299,8 +2299,6 @@ nsresult QuotaManager::CreateRunnable::Init() {
|
|||
return rv;
|
||||
}
|
||||
|
||||
Unused << NextGenLocalStorageEnabled();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -3237,7 +3235,7 @@ nsresult QuotaManager::Init(const nsAString& aBasePath) {
|
|||
mClients.AppendElement(asmjscache::CreateClient());
|
||||
mClients.AppendElement(cache::CreateQuotaClient());
|
||||
mClients.AppendElement(simpledb::CreateQuotaClient());
|
||||
if (CachedNextGenLocalStorageEnabled()) {
|
||||
if (NextGenLocalStorageEnabled()) {
|
||||
mClients.AppendElement(localstorage::CreateQuotaClient());
|
||||
} else {
|
||||
mClients.SetLength(Client::TypeMax());
|
||||
|
|
Загрузка…
Ссылка в новой задаче