forked from mirrors/gecko-dev
Bug 1797506 - Add EnsureAndLoadStringBundle to preload the string bundle on main thread. r=kmag
Differential Revision: https://phabricator.services.mozilla.com/D163309
This commit is contained in:
parent
26d2865682
commit
c19e34d15c
3 changed files with 22 additions and 0 deletions
|
|
@ -365,6 +365,7 @@
|
|||
#include "nsStreamUtils.h"
|
||||
#include "nsString.h"
|
||||
#include "nsStringBuffer.h"
|
||||
#include "nsStringBundle.h"
|
||||
#include "nsStringFlags.h"
|
||||
#include "nsStringFwd.h"
|
||||
#include "nsStringIterator.h"
|
||||
|
|
@ -4084,6 +4085,16 @@ static const char* gPropertiesFiles[nsContentUtils::PropertiesFile_COUNT] = {
|
|||
"resource://gre/res/locale/layout/HtmlForm.properties",
|
||||
"resource://gre/res/locale/dom/dom.properties"};
|
||||
|
||||
/* static */
|
||||
nsresult nsContentUtils::EnsureAndLoadStringBundle(PropertiesFile aFile) {
|
||||
MOZ_ASSERT(NS_IsMainThread(), "Should be called on main thread.");
|
||||
nsresult rv = EnsureStringBundle(aFile);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
return nsStringBundleBase::Cast(sStringBundles[aFile])->LoadProperties();
|
||||
}
|
||||
|
||||
/* static */
|
||||
nsresult nsContentUtils::EnsureStringBundle(PropertiesFile aFile) {
|
||||
if (!sStringBundles[aFile]) {
|
||||
|
|
|
|||
|
|
@ -3358,6 +3358,13 @@ class nsContentUtils {
|
|||
*/
|
||||
static uint32_t ResolveObjectType(uint32_t aType);
|
||||
|
||||
/**
|
||||
* Create and load the string bundle for the 'aFile'.
|
||||
* This API is used to preload the string bundle on the main thread so later
|
||||
* other thread could access it.
|
||||
*/
|
||||
static nsresult EnsureAndLoadStringBundle(PropertiesFile aFile);
|
||||
|
||||
private:
|
||||
static bool InitializeEventTable();
|
||||
|
||||
|
|
|
|||
|
|
@ -20,6 +20,10 @@ LOCAL_INCLUDES += [
|
|||
"/xpcom/ds",
|
||||
]
|
||||
|
||||
EXPORTS += [
|
||||
"nsStringBundle.h",
|
||||
]
|
||||
|
||||
include("/ipc/chromium/chromium-config.mozbuild")
|
||||
|
||||
FINAL_LIBRARY = "xul"
|
||||
|
|
|
|||
Loading…
Reference in a new issue