mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Backed out 5 changesets (bug 1215723) for android S4 bustage
Backed out changeset 2a945ce1cd40 (bug 1215723) Backed out changeset dd7f58b60ddc (bug 1215723) Backed out changeset 62dbb95bd79a (bug 1215723) Backed out changeset b31ac98bb3c8 (bug 1215723) Backed out changeset 228cdfaa82c1 (bug 1215723)
This commit is contained in:
parent
aee88699e0
commit
a812810bc0
@ -2262,39 +2262,6 @@ ContentChild::RecvPreferenceUpdate(const PrefSetting& aPref)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
ContentChild::RecvDataStoragePut(const nsString& aFilename,
|
||||
const DataStorageItem& aItem)
|
||||
{
|
||||
RefPtr<DataStorage> storage = DataStorage::GetIfExists(aFilename);
|
||||
if (storage) {
|
||||
storage->Put(aItem.key(), aItem.value(), aItem.type());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
ContentChild::RecvDataStorageRemove(const nsString& aFilename,
|
||||
const nsCString& aKey,
|
||||
const DataStorageType& aType)
|
||||
{
|
||||
RefPtr<DataStorage> storage = DataStorage::GetIfExists(aFilename);
|
||||
if (storage) {
|
||||
storage->Remove(aKey, aType);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
ContentChild::RecvDataStorageClear(const nsString& aFilename)
|
||||
{
|
||||
RefPtr<DataStorage> storage = DataStorage::GetIfExists(aFilename);
|
||||
if (storage) {
|
||||
storage->Clear();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
ContentChild::RecvNotifyAlertsObserver(const nsCString& aType, const nsString& aData)
|
||||
{
|
||||
|
@ -338,13 +338,6 @@ public:
|
||||
|
||||
virtual bool RecvPreferenceUpdate(const PrefSetting& aPref) override;
|
||||
|
||||
virtual bool RecvDataStoragePut(const nsString& aFilename,
|
||||
const DataStorageItem& aItem) override;
|
||||
virtual bool RecvDataStorageRemove(const nsString& aFilename,
|
||||
const nsCString& aKey,
|
||||
const DataStorageType& aType) override;
|
||||
virtual bool RecvDataStorageClear(const nsString& aFilename) override;
|
||||
|
||||
virtual bool RecvNotifyAlertsObserver(const nsCString& aType,
|
||||
const nsString& aData) override;
|
||||
|
||||
|
@ -35,7 +35,6 @@
|
||||
#include "imgIContainer.h"
|
||||
#include "mozIApplication.h"
|
||||
#include "mozilla/ClearOnShutdown.h"
|
||||
#include "mozilla/DataStorage.h"
|
||||
#include "mozilla/devtools/HeapSnapshotTempFileHelperParent.h"
|
||||
#include "mozilla/docshell/OfflineCacheUpdateParent.h"
|
||||
#include "mozilla/dom/DataStoreService.h"
|
||||
@ -2674,15 +2673,6 @@ ContentParent::RecvReadFontList(InfallibleTArray<FontListEntry>* retValue)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
ContentParent::RecvReadDataStorageArray(const nsString& aFilename,
|
||||
InfallibleTArray<DataStorageItem>* aValues)
|
||||
{
|
||||
RefPtr<DataStorage> storage = DataStorage::Get(aFilename);
|
||||
storage->GetAll(aValues);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
ContentParent::RecvReadPermissions(InfallibleTArray<IPC::Permission>* aPermissions)
|
||||
{
|
||||
|
@ -742,9 +742,6 @@ private:
|
||||
virtual bool RecvReadPrefsArray(InfallibleTArray<PrefSetting>* aPrefs) override;
|
||||
virtual bool RecvReadFontList(InfallibleTArray<FontListEntry>* retValue) override;
|
||||
|
||||
virtual bool RecvReadDataStorageArray(const nsString& aFilename,
|
||||
InfallibleTArray<DataStorageItem>* aValues) override;
|
||||
|
||||
virtual bool RecvReadPermissions(InfallibleTArray<IPC::Permission>* aPermissions) override;
|
||||
|
||||
virtual bool RecvSetClipboard(const IPCDataTransfer& aDataTransfer,
|
||||
|
@ -91,7 +91,6 @@ using mozilla::dom::TabId from "mozilla/dom/ipc/IdType.h";
|
||||
using mozilla::dom::ContentParentId from "mozilla/dom/ipc/IdType.h";
|
||||
using struct LookAndFeelInt from "mozilla/widget/WidgetMessageUtils.h";
|
||||
using class mozilla::dom::ipc::StructuredCloneData from "ipc/IPCMessageUtils.h";
|
||||
using mozilla::DataStorageType from "ipc/DataStorageIPCUtils.h";
|
||||
|
||||
union ChromeRegistryItem
|
||||
{
|
||||
@ -325,12 +324,6 @@ struct PrefSetting {
|
||||
MaybePrefValue userValue;
|
||||
};
|
||||
|
||||
struct DataStorageItem {
|
||||
nsCString key;
|
||||
nsCString value;
|
||||
DataStorageType type;
|
||||
};
|
||||
|
||||
struct DataStoreSetting {
|
||||
nsString name;
|
||||
nsString originURL;
|
||||
@ -566,10 +559,6 @@ child:
|
||||
|
||||
PreferenceUpdate(PrefSetting pref);
|
||||
|
||||
DataStoragePut(nsString aFilename, DataStorageItem aItem);
|
||||
DataStorageRemove(nsString aFilename, nsCString aKey, DataStorageType aType);
|
||||
DataStorageClear(nsString aFilename);
|
||||
|
||||
NotifyAlertsObserver(nsCString topic, nsString data);
|
||||
|
||||
GeolocationUpdate(GeoPosition somewhere);
|
||||
@ -850,9 +839,6 @@ parent:
|
||||
|
||||
sync ReadFontList() returns (FontListEntry[] retValue);
|
||||
|
||||
sync ReadDataStorageArray(nsString aFilename)
|
||||
returns (DataStorageItem[] retValue);
|
||||
|
||||
sync SyncMessage(nsString aMessage, ClonedMessageData aData,
|
||||
CpowEntry[] aCpows, Principal aPrincipal)
|
||||
returns (StructuredCloneData[] retval);
|
||||
|
@ -6,10 +6,6 @@
|
||||
|
||||
#include "DataStorage.h"
|
||||
|
||||
#include "mozilla/ClearOnShutdown.h"
|
||||
#include "mozilla/dom/PContent.h"
|
||||
#include "mozilla/dom/ContentChild.h"
|
||||
#include "mozilla/dom/ContentParent.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "mozilla/Services.h"
|
||||
#include "mozilla/Telemetry.h"
|
||||
@ -39,13 +35,10 @@ namespace mozilla {
|
||||
NS_IMPL_ISUPPORTS(DataStorage,
|
||||
nsIObserver)
|
||||
|
||||
StaticAutoPtr<DataStorage::DataStorages> DataStorage::sDataStorages;
|
||||
|
||||
DataStorage::DataStorage(const nsString& aFilename)
|
||||
: mMutex("DataStorage::mMutex")
|
||||
, mPendingWrite(false)
|
||||
, mShuttingDown(false)
|
||||
, mInitCalled(false)
|
||||
, mReadyMonitor("DataStorage::mReadyMonitor")
|
||||
, mReady(false)
|
||||
, mFilename(aFilename)
|
||||
@ -56,36 +49,6 @@ DataStorage::~DataStorage()
|
||||
{
|
||||
}
|
||||
|
||||
// static
|
||||
already_AddRefed<DataStorage>
|
||||
DataStorage::Get(const nsString& aFilename)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
if (!sDataStorages) {
|
||||
sDataStorages = new DataStorages();
|
||||
ClearOnShutdown(&sDataStorages);
|
||||
}
|
||||
RefPtr<DataStorage> storage;
|
||||
if (!sDataStorages->Get(aFilename, getter_AddRefs(storage))) {
|
||||
storage = new DataStorage(aFilename);
|
||||
sDataStorages->Put(aFilename, storage);
|
||||
}
|
||||
return storage.forget();
|
||||
}
|
||||
|
||||
// static
|
||||
already_AddRefed<DataStorage>
|
||||
DataStorage::GetIfExists(const nsString& aFilename)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
if (!sDataStorages) {
|
||||
sDataStorages = new DataStorages();
|
||||
}
|
||||
RefPtr<DataStorage> storage;
|
||||
sDataStorages->Get(aFilename, getter_AddRefs(storage));
|
||||
return storage.forget();
|
||||
}
|
||||
|
||||
nsresult
|
||||
DataStorage::Init(bool& aDataWillPersist)
|
||||
{
|
||||
@ -97,41 +60,15 @@ DataStorage::Init(bool& aDataWillPersist)
|
||||
|
||||
MutexAutoLock lock(mMutex);
|
||||
|
||||
// Ignore attempts to initialize several times.
|
||||
if (mInitCalled) {
|
||||
return NS_OK;
|
||||
nsresult rv;
|
||||
rv = NS_NewThread(getter_AddRefs(mWorkerThread));
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
mInitCalled = true;
|
||||
|
||||
nsresult rv;
|
||||
if (XRE_IsParentProcess()) {
|
||||
rv = NS_NewThread(getter_AddRefs(mWorkerThread));
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
rv = AsyncReadData(aDataWillPersist, lock);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
} else {
|
||||
// In the child process, we ask the parent process for the data.
|
||||
MOZ_ASSERT(XRE_IsContentProcess());
|
||||
aDataWillPersist = false;
|
||||
InfallibleTArray<DataStorageItem> items;
|
||||
dom::ContentChild::GetSingleton()->
|
||||
SendReadDataStorageArray(mFilename, &items);
|
||||
for (auto& item : items) {
|
||||
Entry entry;
|
||||
entry.mValue = item.value();
|
||||
rv = PutInternal(item.key(), entry, item.type(), lock);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
mReady = true;
|
||||
NotifyObservers("data-storage-ready");
|
||||
rv = AsyncReadData(aDataWillPersist, lock);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIObserverService> os = services::GetObserverService();
|
||||
@ -380,7 +317,6 @@ nsresult
|
||||
DataStorage::AsyncReadData(bool& aHaveProfileDir,
|
||||
const MutexAutoLock& /*aProofOfLock*/)
|
||||
{
|
||||
MOZ_ASSERT(XRE_IsParentProcess());
|
||||
aHaveProfileDir = false;
|
||||
// Allocate a Reader so that even if it isn't dispatched,
|
||||
// the data-storage-ready notification will be fired and Get
|
||||
@ -469,34 +405,6 @@ DataStorage::GetTableForType(DataStorageType aType,
|
||||
MOZ_CRASH("given bad DataStorage storage type");
|
||||
}
|
||||
|
||||
void
|
||||
DataStorage::ReadAllFromTable(DataStorageType aType,
|
||||
InfallibleTArray<dom::DataStorageItem>* aItems,
|
||||
const MutexAutoLock& aProofOfLock)
|
||||
{
|
||||
for (auto iter = GetTableForType(aType, aProofOfLock).Iter();
|
||||
!iter.Done(); iter.Next()) {
|
||||
DataStorageItem* item = aItems->AppendElement();
|
||||
item->key() = iter.Key();
|
||||
item->value() = iter.Data().mValue;
|
||||
item->type() = aType;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
DataStorage::GetAll(InfallibleTArray<dom::DataStorageItem>* aItems)
|
||||
{
|
||||
WaitForReady();
|
||||
MutexAutoLock lock(mMutex);
|
||||
|
||||
aItems->SetCapacity(mPersistentDataTable.Count() +
|
||||
mTemporaryDataTable.Count() +
|
||||
mPrivateDataTable.Count());
|
||||
ReadAllFromTable(DataStorage_Persistent, aItems, lock);
|
||||
ReadAllFromTable(DataStorage_Temporary, aItems, lock);
|
||||
ReadAllFromTable(DataStorage_Private, aItems, lock);
|
||||
}
|
||||
|
||||
// Limit the number of entries per table. This is to prevent unbounded
|
||||
// resource use. The eviction strategy is as follows:
|
||||
// - An entry's score is incremented once for every day it is accessed.
|
||||
@ -534,22 +442,6 @@ DataStorage::MaybeEvictOneEntry(DataStorageType aType,
|
||||
}
|
||||
}
|
||||
|
||||
template <class Functor>
|
||||
static
|
||||
void
|
||||
RunOnAllContentParents(Functor func)
|
||||
{
|
||||
if (!XRE_IsParentProcess()) {
|
||||
return;
|
||||
}
|
||||
using dom::ContentParent;
|
||||
nsTArray<ContentParent*> parents;
|
||||
ContentParent::GetAll(parents);
|
||||
for (auto& parent: parents) {
|
||||
func(parent);
|
||||
}
|
||||
}
|
||||
|
||||
nsresult
|
||||
DataStorage::Put(const nsCString& aKey, const nsCString& aValue,
|
||||
DataStorageType aType)
|
||||
@ -576,14 +468,6 @@ DataStorage::Put(const nsCString& aKey, const nsCString& aValue,
|
||||
return rv;
|
||||
}
|
||||
|
||||
RunOnAllContentParents([&](dom::ContentParent* aParent) {
|
||||
DataStorageItem item;
|
||||
item.key() = aKey;
|
||||
item.value() = aValue;
|
||||
item.type() = aType;
|
||||
Unused << aParent->SendDataStoragePut(mFilename, item);
|
||||
});
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -614,10 +498,6 @@ DataStorage::Remove(const nsCString& aKey, DataStorageType aType)
|
||||
if (aType == DataStorage_Persistent && !mPendingWrite) {
|
||||
Unused << AsyncSetTimer(lock);
|
||||
}
|
||||
|
||||
RunOnAllContentParents([&](dom::ContentParent* aParent) {
|
||||
Unused << aParent->SendDataStorageRemove(mFilename, aKey, aType);
|
||||
});
|
||||
}
|
||||
|
||||
class DataStorage::Writer : public nsRunnable
|
||||
@ -691,8 +571,6 @@ DataStorage::Writer::Run()
|
||||
nsresult
|
||||
DataStorage::AsyncWriteData(const MutexAutoLock& /*aProofOfLock*/)
|
||||
{
|
||||
MOZ_ASSERT(XRE_IsParentProcess());
|
||||
|
||||
if (mShuttingDown || !mBackingFile) {
|
||||
return NS_OK;
|
||||
}
|
||||
@ -729,20 +607,13 @@ DataStorage::Clear()
|
||||
mTemporaryDataTable.Clear();
|
||||
mPrivateDataTable.Clear();
|
||||
|
||||
if (XRE_IsParentProcess()) {
|
||||
// Asynchronously clear the file. This is similar to the permission manager
|
||||
// in that it doesn't wait to synchronously remove the data from its backing
|
||||
// storage either.
|
||||
nsresult rv = AsyncWriteData(lock);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
// Asynchronously clear the file. This is similar to the permission manager
|
||||
// in that it doesn't wait to synchronously remove the data from its backing
|
||||
// storage either.
|
||||
nsresult rv = AsyncWriteData(lock);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
RunOnAllContentParents([&](dom::ContentParent* aParent) {
|
||||
Unused << aParent->SendDataStorageClear(mFilename);
|
||||
});
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -750,8 +621,6 @@ DataStorage::Clear()
|
||||
void
|
||||
DataStorage::TimerCallback(nsITimer* aTimer, void* aClosure)
|
||||
{
|
||||
MOZ_ASSERT(XRE_IsParentProcess());
|
||||
|
||||
RefPtr<DataStorage> aDataStorage = (DataStorage*)aClosure;
|
||||
MutexAutoLock lock(aDataStorage->mMutex);
|
||||
Unused << aDataStorage->AsyncWriteData(lock);
|
||||
@ -762,7 +631,7 @@ DataStorage::TimerCallback(nsITimer* aTimer, void* aClosure)
|
||||
nsresult
|
||||
DataStorage::AsyncSetTimer(const MutexAutoLock& /*aProofOfLock*/)
|
||||
{
|
||||
if (mShuttingDown || !XRE_IsParentProcess()) {
|
||||
if (mShuttingDown) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -780,8 +649,6 @@ void
|
||||
DataStorage::SetTimer()
|
||||
{
|
||||
MOZ_ASSERT(!NS_IsMainThread());
|
||||
MOZ_ASSERT(XRE_IsParentProcess());
|
||||
|
||||
MutexAutoLock lock(mMutex);
|
||||
|
||||
nsresult rv;
|
||||
@ -815,8 +682,6 @@ DataStorage::NotifyObservers(const char* aTopic)
|
||||
nsresult
|
||||
DataStorage::DispatchShutdownTimer(const MutexAutoLock& /*aProofOfLock*/)
|
||||
{
|
||||
MOZ_ASSERT(XRE_IsParentProcess());
|
||||
|
||||
nsCOMPtr<nsIRunnable> job =
|
||||
NS_NewRunnableMethod(this, &DataStorage::ShutdownTimer);
|
||||
nsresult rv = mWorkerThread->Dispatch(job, NS_DISPATCH_NORMAL);
|
||||
@ -829,7 +694,6 @@ DataStorage::DispatchShutdownTimer(const MutexAutoLock& /*aProofOfLock*/)
|
||||
void
|
||||
DataStorage::ShutdownTimer()
|
||||
{
|
||||
MOZ_ASSERT(XRE_IsParentProcess());
|
||||
MOZ_ASSERT(!NS_IsMainThread());
|
||||
MutexAutoLock lock(mMutex);
|
||||
nsresult rv = mTimer->Cancel();
|
||||
@ -856,27 +720,23 @@ DataStorage::Observe(nsISupports* aSubject, const char* aTopic,
|
||||
MutexAutoLock lock(mMutex);
|
||||
mPrivateDataTable.Clear();
|
||||
} else if (strcmp(aTopic, "profile-before-change") == 0) {
|
||||
if (XRE_IsParentProcess()) {
|
||||
{
|
||||
MutexAutoLock lock(mMutex);
|
||||
rv = AsyncWriteData(lock);
|
||||
mShuttingDown = true;
|
||||
{
|
||||
MutexAutoLock lock(mMutex);
|
||||
rv = AsyncWriteData(lock);
|
||||
mShuttingDown = true;
|
||||
Unused << NS_WARN_IF(NS_FAILED(rv));
|
||||
if (mTimer) {
|
||||
rv = DispatchShutdownTimer(lock);
|
||||
Unused << NS_WARN_IF(NS_FAILED(rv));
|
||||
if (mTimer) {
|
||||
rv = DispatchShutdownTimer(lock);
|
||||
Unused << NS_WARN_IF(NS_FAILED(rv));
|
||||
}
|
||||
}
|
||||
// Run the thread to completion and prevent any further events
|
||||
// being scheduled to it. The thread may need the lock, so we can't
|
||||
// hold it here.
|
||||
rv = mWorkerThread->Shutdown();
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
|
||||
sDataStorages->Clear();
|
||||
// Run the thread to completion and prevent any further events
|
||||
// being scheduled to it. The thread may need the lock, so we can't
|
||||
// hold it here.
|
||||
rv = mWorkerThread->Shutdown();
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
} else if (strcmp(aTopic, NS_PREFBRANCH_PREFCHANGE_TOPIC_ID) == 0) {
|
||||
MutexAutoLock lock(mMutex);
|
||||
mTimerDelay = Preferences::GetInt("test.datastorage.write_timer_ms",
|
||||
|
@ -9,21 +9,15 @@
|
||||
|
||||
#include "mozilla/Monitor.h"
|
||||
#include "mozilla/Mutex.h"
|
||||
#include "mozilla/StaticPtr.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsDataHashtable.h"
|
||||
#include "nsIObserver.h"
|
||||
#include "nsIThread.h"
|
||||
#include "nsITimer.h"
|
||||
#include "nsRefPtrHashtable.h"
|
||||
#include "nsString.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
namespace dom {
|
||||
class DataStorageItem;
|
||||
}
|
||||
|
||||
/**
|
||||
* DataStorage is a threadsafe, generic, narrow string-based hash map that
|
||||
* persists data on disk and additionally handles temporary and private data.
|
||||
@ -87,16 +81,13 @@ enum DataStorageType {
|
||||
|
||||
class DataStorage : public nsIObserver
|
||||
{
|
||||
typedef dom::DataStorageItem DataStorageItem;
|
||||
|
||||
public:
|
||||
NS_DECL_THREADSAFE_ISUPPORTS
|
||||
NS_DECL_NSIOBSERVER
|
||||
|
||||
// If there is a profile directory, there is or will eventually be a file
|
||||
// by the name specified by aFilename there.
|
||||
static already_AddRefed<DataStorage> Get(const nsString& aFilename);
|
||||
static already_AddRefed<DataStorage> GetIfExists(const nsString& aFilename);
|
||||
explicit DataStorage(const nsString& aFilename);
|
||||
|
||||
// Initializes the DataStorage. Must be called before using.
|
||||
// aDataWillPersist returns whether or not data can be persistently saved.
|
||||
@ -116,11 +107,7 @@ public:
|
||||
// Removes all entries of all types of data.
|
||||
nsresult Clear();
|
||||
|
||||
// Read all of the data items.
|
||||
void GetAll(InfallibleTArray<DataStorageItem>* aItems);
|
||||
|
||||
private:
|
||||
explicit DataStorage(const nsString& aFilename);
|
||||
virtual ~DataStorage();
|
||||
|
||||
class Writer;
|
||||
@ -146,7 +133,6 @@ private:
|
||||
};
|
||||
|
||||
typedef nsDataHashtable<nsCStringHashKey, Entry> DataStorageTable;
|
||||
typedef nsRefPtrHashtable<nsStringHashKey, DataStorage> DataStorages;
|
||||
|
||||
void WaitForReady();
|
||||
nsresult AsyncWriteData(const MutexAutoLock& aProofOfLock);
|
||||
@ -172,10 +158,6 @@ private:
|
||||
DataStorageTable& GetTableForType(DataStorageType aType,
|
||||
const MutexAutoLock& aProofOfLock);
|
||||
|
||||
void ReadAllFromTable(DataStorageType aType,
|
||||
InfallibleTArray<DataStorageItem>* aItems,
|
||||
const MutexAutoLock& aProofOfLock);
|
||||
|
||||
Mutex mMutex; // This mutex protects access to the following members:
|
||||
DataStorageTable mPersistentDataTable;
|
||||
DataStorageTable mTemporaryDataTable;
|
||||
@ -186,15 +168,12 @@ private:
|
||||
uint32_t mTimerDelay; // in milliseconds
|
||||
bool mPendingWrite; // true if a write is needed but hasn't been dispatched
|
||||
bool mShuttingDown;
|
||||
bool mInitCalled; // Indicates that Init() has been called.
|
||||
// (End list of members protected by mMutex)
|
||||
|
||||
Monitor mReadyMonitor; // Do not acquire this at the same time as mMutex.
|
||||
bool mReady; // Indicates that saved data has been read and Get can proceed.
|
||||
|
||||
const nsString mFilename;
|
||||
|
||||
static StaticAutoPtr<DataStorages> sDataStorages;
|
||||
};
|
||||
|
||||
} // namespace mozilla
|
||||
|
@ -1,21 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef ipc_DataStorageIPCUtils_h
|
||||
#define ipc_DataStorageIPCUtils_h
|
||||
|
||||
#include "ipc/IPCMessageUtils.h"
|
||||
#include "mozilla/DataStorage.h"
|
||||
|
||||
namespace IPC {
|
||||
template<>
|
||||
struct ParamTraits<mozilla::DataStorageType> :
|
||||
public ContiguousEnumSerializer<mozilla::DataStorageType,
|
||||
mozilla::DataStorage_Persistent,
|
||||
mozilla::DataStorageType(mozilla::DataStorage_Private + 1)> {};
|
||||
} // namespace IPC
|
||||
|
||||
#endif // mozilla_DataStorageIPCUtils_hh
|
@ -75,10 +75,6 @@ EXPORTS.mozilla.psm += [
|
||||
'PSMContentListener.h',
|
||||
]
|
||||
|
||||
EXPORTS.ipc += [
|
||||
'DataStorageIPCUtils.h',
|
||||
]
|
||||
|
||||
UNIFIED_SOURCES += [
|
||||
'CertBlocklist.cpp',
|
||||
'CryptoTask.cpp',
|
||||
|
@ -228,6 +228,11 @@ NS_IMPL_ISUPPORTS(nsSiteSecurityService,
|
||||
nsresult
|
||||
nsSiteSecurityService::Init()
|
||||
{
|
||||
// Child processes are not allowed direct access to this.
|
||||
if (!XRE_IsParentProcess()) {
|
||||
MOZ_CRASH("Child process: no direct access to nsSiteSecurityService");
|
||||
}
|
||||
|
||||
// Don't access Preferences off the main thread.
|
||||
if (!NS_IsMainThread()) {
|
||||
NS_NOTREACHED("nsSiteSecurityService initialized off main thread");
|
||||
@ -247,7 +252,7 @@ nsSiteSecurityService::Init()
|
||||
mozilla::Preferences::AddStrongObserver(this,
|
||||
"test.currentTimeOffsetSeconds");
|
||||
mSiteStateStorage =
|
||||
mozilla::DataStorage::Get(NS_LITERAL_STRING("SiteSecurityServiceState.txt"));
|
||||
new mozilla::DataStorage(NS_LITERAL_STRING("SiteSecurityServiceState.txt"));
|
||||
bool storageWillPersist = false;
|
||||
nsresult rv = mSiteStateStorage->Init(storageWillPersist);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
@ -346,11 +351,6 @@ NS_IMETHODIMP
|
||||
nsSiteSecurityService::RemoveState(uint32_t aType, nsIURI* aURI,
|
||||
uint32_t aFlags)
|
||||
{
|
||||
// Child processes are not allowed direct access to this.
|
||||
if (!XRE_IsParentProcess()) {
|
||||
MOZ_CRASH("Child process: no direct access to nsISiteSecurityService::RemoveState");
|
||||
}
|
||||
|
||||
// Only HSTS is supported at the moment.
|
||||
NS_ENSURE_TRUE(aType == nsISiteSecurityService::HEADER_HSTS ||
|
||||
aType == nsISiteSecurityService::HEADER_HPKP,
|
||||
@ -401,11 +401,6 @@ nsSiteSecurityService::ProcessHeader(uint32_t aType,
|
||||
bool* aIncludeSubdomains,
|
||||
uint32_t* aFailureResult)
|
||||
{
|
||||
// Child processes are not allowed direct access to this.
|
||||
if (!XRE_IsParentProcess()) {
|
||||
MOZ_CRASH("Child process: no direct access to nsISiteSecurityService::ProcessHeader");
|
||||
}
|
||||
|
||||
if (aFailureResult) {
|
||||
*aFailureResult = nsISiteSecurityService::ERROR_UNKNOWN;
|
||||
}
|
||||
@ -427,11 +422,6 @@ nsSiteSecurityService::UnsafeProcessHeader(uint32_t aType,
|
||||
bool* aIncludeSubdomains,
|
||||
uint32_t* aFailureResult)
|
||||
{
|
||||
// Child processes are not allowed direct access to this.
|
||||
if (!XRE_IsParentProcess()) {
|
||||
MOZ_CRASH("Child process: no direct access to nsISiteSecurityService::UnsafeProcessHeader");
|
||||
}
|
||||
|
||||
return ProcessHeaderInternal(aType, aSourceURI, aHeader, nullptr, aFlags,
|
||||
aMaxAge, aIncludeSubdomains, aFailureResult);
|
||||
}
|
||||
@ -876,11 +866,6 @@ NS_IMETHODIMP
|
||||
nsSiteSecurityService::IsSecureURI(uint32_t aType, nsIURI* aURI,
|
||||
uint32_t aFlags, bool* aResult)
|
||||
{
|
||||
// Child processes are not allowed direct access to this.
|
||||
if (!XRE_IsParentProcess() && aType != nsISiteSecurityService::HEADER_HSTS) {
|
||||
MOZ_CRASH("Child process: no direct access to nsISiteSecurityService::IsSecureURI for non-HSTS entries");
|
||||
}
|
||||
|
||||
NS_ENSURE_ARG(aURI);
|
||||
NS_ENSURE_ARG(aResult);
|
||||
|
||||
@ -930,11 +915,6 @@ NS_IMETHODIMP
|
||||
nsSiteSecurityService::IsSecureHost(uint32_t aType, const char* aHost,
|
||||
uint32_t aFlags, bool* aResult)
|
||||
{
|
||||
// Child processes are not allowed direct access to this.
|
||||
if (!XRE_IsParentProcess() && aType != nsISiteSecurityService::HEADER_HSTS) {
|
||||
MOZ_CRASH("Child process: no direct access to nsISiteSecurityService::IsSecureHost for non-HSTS entries");
|
||||
}
|
||||
|
||||
NS_ENSURE_ARG(aHost);
|
||||
NS_ENSURE_ARG(aResult);
|
||||
|
||||
@ -1070,11 +1050,6 @@ nsSiteSecurityService::IsSecureHost(uint32_t aType, const char* aHost,
|
||||
NS_IMETHODIMP
|
||||
nsSiteSecurityService::ClearAll()
|
||||
{
|
||||
// Child processes are not allowed direct access to this.
|
||||
if (!XRE_IsParentProcess()) {
|
||||
MOZ_CRASH("Child process: no direct access to nsISiteSecurityService::ClearAll");
|
||||
}
|
||||
|
||||
return mSiteStateStorage->Clear();
|
||||
}
|
||||
|
||||
@ -1084,11 +1059,6 @@ nsSiteSecurityService::GetKeyPinsForHostname(const char* aHostname,
|
||||
/*out*/ nsTArray<nsCString>& pinArray,
|
||||
/*out*/ bool* aIncludeSubdomains,
|
||||
/*out*/ bool* afound) {
|
||||
// Child processes are not allowed direct access to this.
|
||||
if (!XRE_IsParentProcess()) {
|
||||
MOZ_CRASH("Child process: no direct access to nsISiteSecurityService::GetKeyPinsForHostname");
|
||||
}
|
||||
|
||||
NS_ENSURE_ARG(afound);
|
||||
NS_ENSURE_ARG(aHostname);
|
||||
|
||||
@ -1131,11 +1101,6 @@ nsSiteSecurityService::SetKeyPins(const char* aHost, bool aIncludeSubdomains,
|
||||
const char** aSha256Pins,
|
||||
/*out*/ bool* aResult)
|
||||
{
|
||||
// Child processes are not allowed direct access to this.
|
||||
if (!XRE_IsParentProcess()) {
|
||||
MOZ_CRASH("Child process: no direct access to nsISiteSecurityService::SetKeyPins");
|
||||
}
|
||||
|
||||
NS_ENSURE_ARG_POINTER(aHost);
|
||||
NS_ENSURE_ARG_POINTER(aResult);
|
||||
NS_ENSURE_ARG_POINTER(aSha256Pins);
|
||||
|
@ -24,7 +24,7 @@ protected:
|
||||
const ::testing::TestInfo* const testInfo =
|
||||
::testing::UnitTest::GetInstance()->current_test_info();
|
||||
NS_ConvertUTF8toUTF16 testName(testInfo->name());
|
||||
storage = DataStorage::Get(testName);
|
||||
storage = new DataStorage(testName);
|
||||
storage->Init(dataWillPersist);
|
||||
}
|
||||
|
||||
|
@ -1,22 +0,0 @@
|
||||
function run_test() {
|
||||
var SSService = Cc["@mozilla.org/ssservice;1"]
|
||||
.getService(Ci.nsISiteSecurityService);
|
||||
|
||||
do_check_false(SSService.isSecureHost(Ci.nsISiteSecurityService.HEADER_HSTS,
|
||||
"expired.example.com", 0));
|
||||
do_check_true(SSService.isSecureHost(Ci.nsISiteSecurityService.HEADER_HSTS,
|
||||
"notexpired.example.com", 0));
|
||||
do_check_true(SSService.isSecureHost(Ci.nsISiteSecurityService.HEADER_HSTS,
|
||||
"bugzilla.mozilla.org", 0));
|
||||
do_check_false(SSService.isSecureHost(Ci.nsISiteSecurityService.HEADER_HSTS,
|
||||
"sub.bugzilla.mozilla.org", 0));
|
||||
do_check_true(SSService.isSecureHost(Ci.nsISiteSecurityService.HEADER_HSTS,
|
||||
"incsubdomain.example.com", 0));
|
||||
do_check_true(SSService.isSecureHost(Ci.nsISiteSecurityService.HEADER_HSTS,
|
||||
"sub.incsubdomain.example.com", 0));
|
||||
do_check_false(SSService.isSecureHost(Ci.nsISiteSecurityService.HEADER_HSTS,
|
||||
"login.persona.org", 0));
|
||||
do_check_false(SSService.isSecureHost(Ci.nsISiteSecurityService.HEADER_HSTS,
|
||||
"sub.login.persona.org", 0));
|
||||
do_test_finished();
|
||||
}
|
@ -1,40 +0,0 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
// The purpose of this test is to create a site security service state file
|
||||
// and see that the site security service reads it properly. We also verify
|
||||
// that state changes are reflected in the child process.
|
||||
|
||||
function writeLine(aLine, aOutputStream) {
|
||||
aOutputStream.write(aLine, aLine.length);
|
||||
}
|
||||
|
||||
function start_test_in_child() {
|
||||
run_test_in_child("sss_readstate_child_worker.js");
|
||||
do_test_finished();
|
||||
}
|
||||
|
||||
function run_test() {
|
||||
let profileDir = do_get_profile();
|
||||
let stateFile = profileDir.clone();
|
||||
stateFile.append(SSS_STATE_FILE_NAME);
|
||||
// Assuming we're working with a clean slate, the file shouldn't exist
|
||||
// until we create it.
|
||||
do_check_false(stateFile.exists());
|
||||
let outputStream = FileUtils.openFileOutputStream(stateFile);
|
||||
let now = (new Date()).getTime();
|
||||
writeLine("expired.example.com:HSTS\t0\t0\t" + (now - 100000) + ",1,0\n", outputStream);
|
||||
writeLine("notexpired.example.com:HSTS\t0\t0\t" + (now + 100000) + ",1,0\n", outputStream);
|
||||
// This overrides an entry on the preload list.
|
||||
writeLine("bugzilla.mozilla.org:HSTS\t0\t0\t" + (now + 100000) + ",1,0\n", outputStream);
|
||||
writeLine("incsubdomain.example.com:HSTS\t0\t0\t" + (now + 100000) + ",1,1\n", outputStream);
|
||||
// This overrides an entry on the preload list.
|
||||
writeLine("login.persona.org:HSTS\t0\t0\t0,2,0\n", outputStream);
|
||||
outputStream.close();
|
||||
Services.obs.addObserver(start_test_in_child, "data-storage-ready", false);
|
||||
do_test_pending();
|
||||
var SSService = Cc["@mozilla.org/ssservice;1"]
|
||||
.getService(Ci.nsISiteSecurityService);
|
||||
do_check_true(SSService != null);
|
||||
}
|
@ -41,8 +41,6 @@ skip-if = toolkit == 'android' || toolkit == 'gonk'
|
||||
|
||||
[test_sss_eviction.js]
|
||||
[test_sss_readstate.js]
|
||||
[test_sss_readstate_child.js]
|
||||
support-files = sss_readstate_child_worker.js
|
||||
[test_sss_readstate_empty.js]
|
||||
[test_sss_readstate_garbage.js]
|
||||
[test_sss_readstate_huge.js]
|
||||
|
Loading…
Reference in New Issue
Block a user