зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1347461 - Part 2: Always initialize all DataStorage classes in the content process at initialization time; r=keeler
This commit is contained in:
Родитель
c0b6db9d07
Коммит
1d72f5911e
|
@ -2236,9 +2236,6 @@ ContentParent::InitInternal(ProcessPriority aInitialPriority,
|
|||
}
|
||||
}
|
||||
|
||||
// Ensure the SSS is initialized before we try to use its storage.
|
||||
nsCOMPtr<nsISiteSecurityService> sss = do_GetService("@mozilla.org/ssservice;1");
|
||||
|
||||
DataStorage::GetAllChildProcessData(xpcomInit.dataStorage());
|
||||
|
||||
// Must send screen info before send initialData
|
||||
|
|
|
@ -191,8 +191,33 @@ DataStorage::SetCachedStorageEntries(
|
|||
{
|
||||
MOZ_ASSERT(XRE_IsContentProcess());
|
||||
|
||||
for (auto& entry : aEntries) {
|
||||
RefPtr<DataStorage> storage = DataStorage::GetFromRawFileName(entry.filename());
|
||||
// Make sure to initialize all DataStorage classes.
|
||||
// For each one, we look through the list of our entries and if we find
|
||||
// a matching DataStorage object, we initialize it.
|
||||
//
|
||||
// Note that this is an O(n^2) operation, but the n here is very small
|
||||
// (currently 3). There is a comment in the DataStorageList.h header
|
||||
// about updating the algorithm here to something more fancy if the list
|
||||
// of DataStorage items grows some day.
|
||||
nsTArray<dom::DataStorageEntry> entries;
|
||||
#define DATA_STORAGE(_) \
|
||||
{ \
|
||||
dom::DataStorageEntry entry; \
|
||||
entry.filename() = NS_LITERAL_STRING(#_ ".txt"); \
|
||||
for (auto& e : aEntries) { \
|
||||
if (entry.filename().Equals(e.filename())) { \
|
||||
entry.items() = Move(e.items()); \
|
||||
break; \
|
||||
} \
|
||||
} \
|
||||
entries.AppendElement(Move(entry)); \
|
||||
}
|
||||
#include "mozilla/DataStorageList.h"
|
||||
#undef DATA_STORAGE
|
||||
|
||||
for (auto& entry : entries) {
|
||||
RefPtr<DataStorage> storage =
|
||||
DataStorage::GetFromRawFileName(entry.filename());
|
||||
bool dataWillPersist = false;
|
||||
storage->Init(dataWillPersist, &entry.items());
|
||||
}
|
||||
|
|
|
@ -7,6 +7,11 @@
|
|||
// This is the list of well-known PSM DataStorage classes that Gecko uses.
|
||||
// These are key value data stores that are backed by a simple text-based
|
||||
// storage in the profile directory.
|
||||
//
|
||||
// Please note that it is crucial for performance reasons for the number of
|
||||
// these classes to remain low. If you need to add to this list, you may
|
||||
// need to update the algorithm in DataStorage::SetCachedStorageEntries()
|
||||
// to something faster.
|
||||
|
||||
DATA_STORAGE(AlternateServices)
|
||||
DATA_STORAGE(SecurityPreloadState)
|
||||
|
|
Загрузка…
Ссылка в новой задаче