bug 1439002 - remove useless debug spew from nsSiteSecurityService r=erahm

Differential Revision: https://phabricator.services.mozilla.com/D25489

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Dana Keeler 2019-04-01 17:07:20 +00:00
Родитель 99da408e98
Коммит f8da648dbc
6 изменённых файлов: 11 добавлений и 43 удалений

Просмотреть файл

@ -336,8 +336,7 @@ TRRService::Observe(nsISupports *aSubject, const char *aTopic,
MutexAutoLock lock(mLock); MutexAutoLock lock(mLock);
mTRRBLStorage = DataStorage::Get(DataStorageClass::TRRBlacklist); mTRRBLStorage = DataStorage::Get(DataStorageClass::TRRBlacklist);
if (mTRRBLStorage) { if (mTRRBLStorage) {
bool storageWillPersist = true; if (NS_FAILED(mTRRBLStorage->Init(nullptr))) {
if (NS_FAILED(mTRRBLStorage->Init(storageWillPersist))) {
mTRRBLStorage = nullptr; mTRRBLStorage = nullptr;
} }
if (mClearTRRBLStorage) { if (mClearTRRBLStorage) {

Просмотреть файл

@ -1005,8 +1005,7 @@ already_AddRefed<AltSvcMapping> AltSvcCache::GetAltServiceMapping(
// on another thread // on another thread
mStorage = DataStorage::Get(DataStorageClass::AlternateServices); mStorage = DataStorage::Get(DataStorageClass::AlternateServices);
if (mStorage) { if (mStorage) {
bool storageWillPersist = false; if (NS_FAILED(mStorage->Init(nullptr))) {
if (NS_FAILED(mStorage->Init(storageWillPersist))) {
mStorage = nullptr; mStorage = nullptr;
} }
} }

Просмотреть файл

@ -241,8 +241,7 @@ void DataStorage::GetAllChildProcessData(
if (!storage->mInitCalled) { if (!storage->mInitCalled) {
// Perhaps no consumer has initialized the DataStorage object yet, // Perhaps no consumer has initialized the DataStorage object yet,
// so do that now! // so do that now!
bool dataWillPersist = false; nsresult rv = storage->Init(nullptr);
nsresult rv = storage->Init(dataWillPersist);
if (NS_WARN_IF(NS_FAILED(rv))) { if (NS_WARN_IF(NS_FAILED(rv))) {
return; return;
} }
@ -284,8 +283,7 @@ void DataStorage::SetCachedStorageEntries(
for (auto& entry : entries) { for (auto& entry : entries) {
RefPtr<DataStorage> storage = RefPtr<DataStorage> storage =
DataStorage::GetFromRawFileName(entry.filename()); DataStorage::GetFromRawFileName(entry.filename());
bool dataWillPersist = false; storage->Init(&entry.items());
storage->Init(dataWillPersist, &entry.items());
} }
} }
@ -300,7 +298,6 @@ size_t DataStorage::SizeOfIncludingThis(
} }
nsresult DataStorage::Init( nsresult DataStorage::Init(
bool& aDataWillPersist,
const InfallibleTArray<mozilla::dom::DataStorageItem>* aItems) { const InfallibleTArray<mozilla::dom::DataStorageItem>* aItems) {
// Don't access the observer service or preferences off the main thread. // Don't access the observer service or preferences off the main thread.
if (!NS_IsMainThread()) { if (!NS_IsMainThread()) {
@ -335,7 +332,7 @@ nsresult DataStorage::Init(
return rv; return rv;
} }
rv = AsyncReadData(aDataWillPersist, lock); rv = AsyncReadData(lock);
if (NS_FAILED(rv)) { if (NS_FAILED(rv)) {
return rv; return rv;
} }
@ -345,7 +342,6 @@ nsresult DataStorage::Init(
MOZ_ASSERT(XRE_IsContentProcess()); MOZ_ASSERT(XRE_IsContentProcess());
MOZ_ASSERT(aItems); MOZ_ASSERT(aItems);
aDataWillPersist = false;
for (auto& item : *aItems) { for (auto& item : *aItems) {
Entry entry; Entry entry;
entry.mValue = item.value(); entry.mValue = item.value();
@ -599,10 +595,8 @@ nsresult DataStorage::Reader::ParseLine(nsDependentCSubstring& aLine,
return NS_OK; return NS_OK;
} }
nsresult DataStorage::AsyncReadData(bool& aHaveProfileDir, nsresult DataStorage::AsyncReadData(const MutexAutoLock& /*aProofOfLock*/) {
const MutexAutoLock& /*aProofOfLock*/) {
MOZ_ASSERT(XRE_IsParentProcess()); MOZ_ASSERT(XRE_IsParentProcess());
aHaveProfileDir = false;
// Allocate a Reader so that even if it isn't dispatched, // Allocate a Reader so that even if it isn't dispatched,
// the data-storage-ready notification will be fired and Get // the data-storage-ready notification will be fired and Get
// will be able to proceed (this happens in its destructor). // will be able to proceed (this happens in its destructor).
@ -627,7 +621,6 @@ nsresult DataStorage::AsyncReadData(bool& aHaveProfileDir,
return rv; return rv;
} }
aHaveProfileDir = true;
return NS_OK; return NS_OK;
} }

Просмотреть файл

@ -112,13 +112,10 @@ class DataStorage : public nsIObserver {
static already_AddRefed<DataStorage> Get(DataStorageClass aFilename); static already_AddRefed<DataStorage> Get(DataStorageClass aFilename);
// Initializes the DataStorage. Must be called before using. // Initializes the DataStorage. Must be called before using.
// aDataWillPersist returns whether or not data can be persistently saved.
// aItems is used in the content process to initialize a cache of the items // aItems is used in the content process to initialize a cache of the items
// received from the parent process over IPC. nullptr must be passed for the // received from the parent process over IPC. nullptr must be passed for the
// parent process. // parent process.
nsresult Init( nsresult Init(const InfallibleTArray<mozilla::dom::DataStorageItem>* aItems);
/*out*/ bool& aDataWillPersist,
const InfallibleTArray<mozilla::dom::DataStorageItem>* aItems = nullptr);
// Given a key and a type of data, returns a value. Returns an empty string if // Given a key and a type of data, returns a value. Returns an empty string if
// the key is not present for that type of data. If Get is called before the // the key is not present for that type of data. If Get is called before the
// "data-storage-ready" event is observed, it will block. NB: It is not // "data-storage-ready" event is observed, it will block. NB: It is not
@ -186,8 +183,7 @@ class DataStorage : public nsIObserver {
void WaitForReady(); void WaitForReady();
nsresult AsyncWriteData(const MutexAutoLock& aProofOfLock); nsresult AsyncWriteData(const MutexAutoLock& aProofOfLock);
nsresult AsyncReadData(bool& aHaveProfileDir, nsresult AsyncReadData(const MutexAutoLock& aProofOfLock);
const MutexAutoLock& aProofOfLock);
nsresult AsyncSetTimer(const MutexAutoLock& aProofOfLock); nsresult AsyncSetTimer(const MutexAutoLock& aProofOfLock);
nsresult DispatchShutdownTimer(const MutexAutoLock& aProofOfLock); nsresult DispatchShutdownTimer(const MutexAutoLock& aProofOfLock);

Просмотреть файл

@ -489,22 +489,14 @@ nsresult nsSiteSecurityService::Init() {
mozilla::DataStorage::Get(DataStorageClass::SiteSecurityServiceState); mozilla::DataStorage::Get(DataStorageClass::SiteSecurityServiceState);
mPreloadStateStorage = mPreloadStateStorage =
mozilla::DataStorage::Get(DataStorageClass::SecurityPreloadState); mozilla::DataStorage::Get(DataStorageClass::SecurityPreloadState);
bool storageWillPersist = false; nsresult rv = mSiteStateStorage->Init(nullptr);
bool preloadStorageWillPersist = false;
nsresult rv = mSiteStateStorage->Init(storageWillPersist);
if (NS_WARN_IF(NS_FAILED(rv))) { if (NS_WARN_IF(NS_FAILED(rv))) {
return rv; return rv;
} }
rv = mPreloadStateStorage->Init(preloadStorageWillPersist); rv = mPreloadStateStorage->Init(nullptr);
if (NS_WARN_IF(NS_FAILED(rv))) { if (NS_WARN_IF(NS_FAILED(rv))) {
return rv; return rv;
} }
// This is not fatal. There are some cases where there won't be a
// profile directory (e.g. running xpcshell). There isn't the
// expectation that site information will be presisted in those cases.
if (!storageWillPersist || !preloadStorageWillPersist) {
NS_WARNING("site security information will not be persisted");
}
return NS_OK; return NS_OK;
} }

Просмотреть файл

@ -23,11 +23,10 @@ class psm_DataStorageTest : public ::testing::Test {
::testing::UnitTest::GetInstance()->current_test_info(); ::testing::UnitTest::GetInstance()->current_test_info();
NS_ConvertUTF8toUTF16 testName(testInfo->name()); NS_ConvertUTF8toUTF16 testName(testInfo->name());
storage = DataStorage::GetFromRawFileName(testName); storage = DataStorage::GetFromRawFileName(testName);
storage->Init(dataWillPersist); storage->Init(nullptr);
} }
RefPtr<DataStorage> storage; RefPtr<DataStorage> storage;
bool dataWillPersist;
}; };
NS_NAMED_LITERAL_CSTRING(testKey, "test"); NS_NAMED_LITERAL_CSTRING(testKey, "test");
@ -35,8 +34,6 @@ NS_NAMED_LITERAL_CSTRING(testValue, "value");
NS_NAMED_LITERAL_CSTRING(privateTestValue, "private"); NS_NAMED_LITERAL_CSTRING(privateTestValue, "private");
TEST_F(psm_DataStorageTest, GetPutRemove) { TEST_F(psm_DataStorageTest, GetPutRemove) {
EXPECT_TRUE(dataWillPersist);
// Test Put/Get on Persistent data // Test Put/Get on Persistent data
EXPECT_EQ(NS_OK, storage->Put(testKey, testValue, DataStorage_Persistent)); EXPECT_EQ(NS_OK, storage->Put(testKey, testValue, DataStorage_Persistent));
// Don't re-use testKey / testValue here, to make sure that this works as // Don't re-use testKey / testValue here, to make sure that this works as
@ -90,8 +87,6 @@ TEST_F(psm_DataStorageTest, GetPutRemove) {
} }
TEST_F(psm_DataStorageTest, InputValidation) { TEST_F(psm_DataStorageTest, InputValidation) {
EXPECT_TRUE(dataWillPersist);
// Keys may not have tabs or newlines // Keys may not have tabs or newlines
EXPECT_EQ(NS_ERROR_INVALID_ARG, EXPECT_EQ(NS_ERROR_INVALID_ARG,
storage->Put(NS_LITERAL_CSTRING("key\thas tab"), testValue, storage->Put(NS_LITERAL_CSTRING("key\thas tab"), testValue,
@ -151,8 +146,6 @@ TEST_F(psm_DataStorageTest, InputValidation) {
} }
TEST_F(psm_DataStorageTest, Eviction) { TEST_F(psm_DataStorageTest, Eviction) {
EXPECT_TRUE(dataWillPersist);
// Eviction is on a per-table basis. Tables shouldn't affect each other. // Eviction is on a per-table basis. Tables shouldn't affect each other.
EXPECT_EQ(NS_OK, storage->Put(testKey, testValue, DataStorage_Persistent)); EXPECT_EQ(NS_OK, storage->Put(testKey, testValue, DataStorage_Persistent));
for (int i = 0; i < 1025; i++) { for (int i = 0; i < 1025; i++) {
@ -178,8 +171,6 @@ TEST_F(psm_DataStorageTest, Eviction) {
} }
TEST_F(psm_DataStorageTest, ClearPrivateData) { TEST_F(psm_DataStorageTest, ClearPrivateData) {
EXPECT_TRUE(dataWillPersist);
EXPECT_EQ(NS_OK, EXPECT_EQ(NS_OK,
storage->Put(testKey, privateTestValue, DataStorage_Private)); storage->Put(testKey, privateTestValue, DataStorage_Private));
nsCString result = storage->Get(testKey, DataStorage_Private); nsCString result = storage->Get(testKey, DataStorage_Private);
@ -190,8 +181,6 @@ TEST_F(psm_DataStorageTest, ClearPrivateData) {
} }
TEST_F(psm_DataStorageTest, Shutdown) { TEST_F(psm_DataStorageTest, Shutdown) {
EXPECT_TRUE(dataWillPersist);
EXPECT_EQ(NS_OK, storage->Put(testKey, testValue, DataStorage_Persistent)); EXPECT_EQ(NS_OK, storage->Put(testKey, testValue, DataStorage_Persistent));
nsCString result = storage->Get(testKey, DataStorage_Persistent); nsCString result = storage->Get(testKey, DataStorage_Persistent);
EXPECT_STREQ("value", result.get()); EXPECT_STREQ("value", result.get());