Bug 1648010 - Fix uses of NS_LITERAL_STRING with C string literals. r=geckoview-reviewers,agi,froydnj

Differential Revision: https://phabricator.services.mozilla.com/D80861
This commit is contained in:
Simon Giesecke 2020-07-01 08:34:12 +00:00
parent cd8b8939b9
commit e3c223da3e
88 changed files with 541 additions and 473 deletions

View File

@ -14,7 +14,7 @@ using mozilla::Preferences;
#define SITE_PREF "privacy.firstparty.isolate.use_site"
#define TEST_FPD(_spec, _expected) \
TestFPD(NS_LITERAL_STRING(_spec), NS_LITERAL_STRING(_expected))
TestFPD(nsLiteralString(_spec), nsLiteralString(_expected))
namespace mozilla {
@ -58,20 +58,20 @@ TEST(OriginAttributes, FirstPartyDomain_default)
bool oldSitePref = Preferences::GetBool(SITE_PREF);
Preferences::SetBool(SITE_PREF, false);
TEST_FPD("http://www.example.com", "example.com");
TEST_FPD("http://www.example.com:80", "example.com");
TEST_FPD("http://www.example.com:8080", "example.com");
TEST_FPD("http://s3.amazonaws.com", "s3.amazonaws.com");
TEST_FPD("http://com", "com");
TEST_FPD("http://com.", "com.");
TEST_FPD("http://com:8080", "com");
TEST_FPD("http://.com", "");
TEST_FPD("http://..com", "");
TEST_FPD("http://127.0.0.1", "127.0.0.1");
TEST_FPD("http://[::1]", "[::1]");
TEST_FPD("about:config",
"about.ef2a7dd5-93bc-417f-a698-142c3116864f.mozilla");
TEST_FPD("moz-extension://f5b6ca10-5bd4-4ed6-9baf-820dc5152bc1", "");
TEST_FPD(u"http://www.example.com", u"example.com");
TEST_FPD(u"http://www.example.com:80", u"example.com");
TEST_FPD(u"http://www.example.com:8080", u"example.com");
TEST_FPD(u"http://s3.amazonaws.com", u"s3.amazonaws.com");
TEST_FPD(u"http://com", u"com");
TEST_FPD(u"http://com.", u"com.");
TEST_FPD(u"http://com:8080", u"com");
TEST_FPD(u"http://.com", u"");
TEST_FPD(u"http://..com", u"");
TEST_FPD(u"http://127.0.0.1", u"127.0.0.1");
TEST_FPD(u"http://[::1]", u"[::1]");
TEST_FPD(u"about:config",
u"about.ef2a7dd5-93bc-417f-a698-142c3116864f.mozilla");
TEST_FPD(u"moz-extension://f5b6ca10-5bd4-4ed6-9baf-820dc5152bc1", u"");
Preferences::SetBool(FPI_PREF, oldFpiPref);
Preferences::SetBool(FPI_PREF, oldSitePref);
@ -84,20 +84,20 @@ TEST(OriginAttributes, FirstPartyDomain_site)
bool oldSitePref = Preferences::GetBool(SITE_PREF);
Preferences::SetBool(SITE_PREF, true);
TEST_FPD("http://www.example.com", "(http,example.com)");
TEST_FPD("http://www.example.com:80", "(http,example.com)");
TEST_FPD("http://www.example.com:8080", "(http,example.com)");
TEST_FPD("http://s3.amazonaws.com", "(http,s3.amazonaws.com)");
TEST_FPD("http://com", "(http,com)");
TEST_FPD("http://com.", "(http,com.)");
TEST_FPD("http://com:8080", "(http,com,8080)");
TEST_FPD("http://.com", "(http,.com)");
TEST_FPD("http://..com", "(http,..com)");
TEST_FPD("http://127.0.0.1", "(http,127.0.0.1)");
TEST_FPD("http://[::1]", "(http,[::1])");
TEST_FPD("about:config",
"(about,about.ef2a7dd5-93bc-417f-a698-142c3116864f.mozilla)");
TEST_FPD("moz-extension://f5b6ca10-5bd4-4ed6-9baf-820dc5152bc1", "");
TEST_FPD(u"http://www.example.com", u"(http,example.com)");
TEST_FPD(u"http://www.example.com:80", u"(http,example.com)");
TEST_FPD(u"http://www.example.com:8080", u"(http,example.com)");
TEST_FPD(u"http://s3.amazonaws.com", u"(http,s3.amazonaws.com)");
TEST_FPD(u"http://com", u"(http,com)");
TEST_FPD(u"http://com.", u"(http,com.)");
TEST_FPD(u"http://com:8080", u"(http,com,8080)");
TEST_FPD(u"http://.com", u"(http,.com)");
TEST_FPD(u"http://..com", u"(http,..com)");
TEST_FPD(u"http://127.0.0.1", u"(http,127.0.0.1)");
TEST_FPD(u"http://[::1]", u"(http,[::1])");
TEST_FPD(u"about:config",
u"(about,about.ef2a7dd5-93bc-417f-a698-142c3116864f.mozilla)");
TEST_FPD(u"moz-extension://f5b6ca10-5bd4-4ed6-9baf-820dc5152bc1", u"");
Preferences::SetBool(FPI_PREF, oldFpiPref);
Preferences::SetBool(FPI_PREF, oldSitePref);

View File

@ -1043,8 +1043,9 @@ bool BrowsingContext::CrossOriginIsolated() {
nsILoadInfo::
OPENER_POLICY_SAME_ORIGIN_EMBEDDER_POLICY_REQUIRE_CORP &&
XRE_IsContentProcess() &&
StringBeginsWith(ContentChild::GetSingleton()->GetRemoteType(),
NS_LITERAL_STRING(WITH_COOP_COEP_REMOTE_TYPE_PREFIX));
StringBeginsWith(
ContentChild::GetSingleton()->GetRemoteType(),
NS_LITERAL_STRING_FROM_CSTRING(WITH_COOP_COEP_REMOTE_TYPE_PREFIX));
}
BrowsingContext::~BrowsingContext() {

View File

@ -832,16 +832,16 @@ already_AddRefed<Promise> ChromeUtils::RequestProcInfo(GlobalObject& aGlobal,
// Ideally, the remoteType should be strongly typed
// upstream, this would make the conversion less brittle.
nsAutoString remoteType(contentParent->GetRemoteType());
if (StringBeginsWith(
remoteType,
NS_LITERAL_STRING(FISSION_WEB_REMOTE_TYPE))) {
if (StringBeginsWith(remoteType,
NS_LITERAL_STRING_FROM_CSTRING(
FISSION_WEB_REMOTE_TYPE))) {
// WARNING: Do not change the order, as
// `DEFAULT_REMOTE_TYPE` is a prefix of
// `FISSION_WEB_REMOTE_TYPE`.
type = mozilla::ProcType::WebIsolated;
} else if (StringBeginsWith(
remoteType,
NS_LITERAL_STRING(DEFAULT_REMOTE_TYPE))) {
remoteType, NS_LITERAL_STRING_FROM_CSTRING(
DEFAULT_REMOTE_TYPE))) {
type = mozilla::ProcType::Web;
} else if (remoteType.EqualsLiteral(FILE_REMOTE_TYPE)) {
type = mozilla::ProcType::File;
@ -856,7 +856,7 @@ already_AddRefed<Promise> ChromeUtils::RequestProcInfo(GlobalObject& aGlobal,
type = mozilla::ProcType::PrivilegedMozilla;
} else if (StringBeginsWith(
remoteType,
NS_LITERAL_STRING(
NS_LITERAL_STRING_FROM_CSTRING(
WITH_COOP_COEP_REMOTE_TYPE_PREFIX))) {
type = mozilla::ProcType::WebCOOPCOEP;
} else if (remoteType.EqualsLiteral(

View File

@ -15387,8 +15387,8 @@ class UserIntractionTimer final : public Runnable,
nsCOMPtr<nsIAsyncShutdownClient> phase = GetShutdownPhase();
NS_ENSURE_TRUE(!!phase, NS_OK);
rv = phase->AddBlocker(this, NS_LITERAL_STRING(__FILE__), __LINE__,
u"UserIntractionTimer shutdown"_ns);
rv = phase->AddBlocker(this, NS_LITERAL_STRING_FROM_CSTRING(__FILE__),
__LINE__, u"UserIntractionTimer shutdown"_ns);
NS_ENSURE_SUCCESS(rv, NS_OK);
raii.release();

View File

@ -811,35 +811,35 @@ nsresult DragDataProducer::AddStringsToDataTransfer(
title.ReplaceChar("\r\n", ' ');
dragData += title;
AddString(aDataTransfer, NS_LITERAL_STRING(kURLMime), dragData, principal);
AddString(aDataTransfer, NS_LITERAL_STRING(kURLDataMime), mUrlString,
AddString(aDataTransfer, NS_LITERAL_STRING_FROM_CSTRING(kURLMime), dragData,
principal);
AddString(aDataTransfer, NS_LITERAL_STRING(kURLDataMime), mUrlString,
AddString(aDataTransfer, NS_LITERAL_STRING_FROM_CSTRING(kURLDataMime),
mUrlString, principal);
AddString(aDataTransfer,
NS_LITERAL_STRING_FROM_CSTRING(kURLDescriptionMime), mTitleString,
principal);
AddString(aDataTransfer, NS_LITERAL_STRING(kURLDescriptionMime),
mTitleString, principal);
AddString(aDataTransfer, u"text/uri-list"_ns, mUrlString, principal);
}
// add a special flavor for the html context data
if (!mContextString.IsEmpty())
AddString(aDataTransfer, NS_LITERAL_STRING(kHTMLContext), mContextString,
principal);
AddString(aDataTransfer, NS_LITERAL_STRING_FROM_CSTRING(kHTMLContext),
mContextString, principal);
// add a special flavor if we have html info data
if (!mInfoString.IsEmpty())
AddString(aDataTransfer, NS_LITERAL_STRING(kHTMLInfo), mInfoString,
principal);
AddString(aDataTransfer, NS_LITERAL_STRING_FROM_CSTRING(kHTMLInfo),
mInfoString, principal);
// add the full html
if (!mHtmlString.IsEmpty())
AddString(aDataTransfer, NS_LITERAL_STRING(kHTMLMime), mHtmlString,
principal);
AddString(aDataTransfer, NS_LITERAL_STRING_FROM_CSTRING(kHTMLMime),
mHtmlString, principal);
// add the plain text. we use the url for text/plain data if an anchor is
// being dragged, rather than the title text of the link or the alt text for
// an anchor image.
AddString(aDataTransfer, NS_LITERAL_STRING(kTextMime),
AddString(aDataTransfer, NS_LITERAL_STRING_FROM_CSTRING(kTextMime),
mIsAnchor ? mUrlString : mTitleString, principal);
// add image data, if present. For now, all we're going to do with
@ -849,8 +849,9 @@ nsresult DragDataProducer::AddStringsToDataTransfer(
if (mImage) {
RefPtr<nsVariantCC> variant = new nsVariantCC();
variant->SetAsISupports(mImage);
aDataTransfer->SetDataWithPrincipal(NS_LITERAL_STRING(kNativeImageMime),
variant, 0, principal);
aDataTransfer->SetDataWithPrincipal(
NS_LITERAL_STRING_FROM_CSTRING(kNativeImageMime), variant, 0,
principal);
// assume the image comes from a file, and add a file promise. We
// register ourselves as a nsIFlavorDataProvider, and will use the
@ -861,23 +862,26 @@ nsresult DragDataProducer::AddStringsToDataTransfer(
if (dataProvider) {
RefPtr<nsVariantCC> variant = new nsVariantCC();
variant->SetAsISupports(dataProvider);
aDataTransfer->SetDataWithPrincipal(NS_LITERAL_STRING(kFilePromiseMime),
variant, 0, principal);
aDataTransfer->SetDataWithPrincipal(
NS_LITERAL_STRING_FROM_CSTRING(kFilePromiseMime), variant, 0,
principal);
}
AddString(aDataTransfer, NS_LITERAL_STRING(kFilePromiseURLMime),
AddString(aDataTransfer,
NS_LITERAL_STRING_FROM_CSTRING(kFilePromiseURLMime),
mImageSourceString, principal);
AddString(aDataTransfer, NS_LITERAL_STRING(kFilePromiseDestFilename),
AddString(aDataTransfer,
NS_LITERAL_STRING_FROM_CSTRING(kFilePromiseDestFilename),
mImageDestFileName, principal);
#if defined(XP_MACOSX)
AddString(aDataTransfer, NS_LITERAL_STRING(kImageRequestMime),
AddString(aDataTransfer, NS_LITERAL_STRING_FROM_CSTRING(kImageRequestMime),
mImageRequestMime, principal, /* aHidden= */ true);
#endif
// if not an anchor, add the image url
if (!mIsAnchor) {
AddString(aDataTransfer, NS_LITERAL_STRING(kURLDataMime), mUrlString,
principal);
AddString(aDataTransfer, NS_LITERAL_STRING_FROM_CSTRING(kURLDataMime),
mUrlString, principal);
AddString(aDataTransfer, u"text/uri-list"_ns, mUrlString, principal);
}
}

View File

@ -34,7 +34,7 @@ using mozilla::Unused; // <snicker>
using namespace mozilla::dom;
using namespace mozilla;
using DelegateInfo = PermissionDelegateHandler::PermissionDelegateInfo;
#define kVisibilityChange "visibilitychange"
#define kVisibilityChange u"visibilitychange"
class VisibilityChangeListener final : public nsIDOMEventListener {
public:
@ -63,7 +63,7 @@ VisibilityChangeListener::VisibilityChangeListener(
mWindow = do_GetWeakReference(aWindow);
nsCOMPtr<Document> doc = aWindow->GetExtantDoc();
if (doc) {
doc->AddSystemEventListener(NS_LITERAL_STRING(kVisibilityChange),
doc->AddSystemEventListener(nsLiteralString(kVisibilityChange),
/* listener */ this,
/* use capture */ true,
/* wants untrusted */ false);
@ -96,7 +96,7 @@ void VisibilityChangeListener::RemoveListener() {
nsCOMPtr<EventTarget> target = window->GetExtantDoc();
if (target) {
target->RemoveSystemEventListener(NS_LITERAL_STRING(kVisibilityChange),
target->RemoveSystemEventListener(nsLiteralString(kVisibilityChange),
/* listener */ this,
/* use capture */ true);
}

View File

@ -553,10 +553,10 @@ static nsresult AppendDOMNode(nsITransferable* aTransferable,
NS_ENSURE_TRUE(document->IsHTMLDocument(), NS_OK);
// init encoder with document and node
rv =
docEncoder->NativeInit(document, NS_LITERAL_STRING(kHTMLMime),
nsIDocumentEncoder::OutputAbsoluteLinks |
nsIDocumentEncoder::OutputEncodeBasicEntities);
rv = docEncoder->NativeInit(
document, NS_LITERAL_STRING_FROM_CSTRING(kHTMLMime),
nsIDocumentEncoder::OutputAbsoluteLinks |
nsIDocumentEncoder::OutputEncodeBasicEntities);
NS_ENSURE_SUCCESS(rv, rv);
rv = docEncoder->SetNode(aDOMNode);

View File

@ -464,9 +464,9 @@ nsresult LockedDirectoryPaddingWrite(nsIFile* aBaseDir,
}
if (aPaddingFileType == DirPaddingFile::TMP_FILE) {
rv = file->Append(NS_LITERAL_STRING(PADDING_TMP_FILE_NAME));
rv = file->Append(nsLiteralString(PADDING_TMP_FILE_NAME));
} else {
rv = file->Append(NS_LITERAL_STRING(PADDING_FILE_NAME));
rv = file->Append(nsLiteralString(PADDING_FILE_NAME));
}
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
@ -767,9 +767,9 @@ bool DirectoryPaddingFileExists(nsIFile* aBaseDir,
nsString fileName;
if (aPaddingFileType == DirPaddingFile::TMP_FILE) {
fileName = NS_LITERAL_STRING(PADDING_TMP_FILE_NAME);
fileName = nsLiteralString(PADDING_TMP_FILE_NAME);
} else {
fileName = NS_LITERAL_STRING(PADDING_FILE_NAME);
fileName = nsLiteralString(PADDING_FILE_NAME);
}
rv = file->Append(fileName);
@ -800,7 +800,7 @@ nsresult LockedDirectoryPaddingGet(nsIFile* aBaseDir,
return rv;
}
rv = file->Append(NS_LITERAL_STRING(PADDING_FILE_NAME));
rv = file->Append(nsLiteralString(PADDING_FILE_NAME));
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
@ -966,12 +966,12 @@ nsresult LockedDirectoryPaddingFinalizeWrite(nsIFile* aBaseDir) {
return rv;
}
rv = file->Append(NS_LITERAL_STRING(PADDING_TMP_FILE_NAME));
rv = file->Append(nsLiteralString(PADDING_TMP_FILE_NAME));
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
rv = file->RenameTo(nullptr, NS_LITERAL_STRING(PADDING_FILE_NAME));
rv = file->RenameTo(nullptr, nsLiteralString(PADDING_FILE_NAME));
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
@ -1030,9 +1030,9 @@ nsresult LockedDirectoryPaddingDeleteFile(nsIFile* aBaseDir,
}
if (aPaddingFileType == DirPaddingFile::TMP_FILE) {
rv = file->Append(NS_LITERAL_STRING(PADDING_TMP_FILE_NAME));
rv = file->Append(nsLiteralString(PADDING_TMP_FILE_NAME));
} else {
rv = file->Append(NS_LITERAL_STRING(PADDING_FILE_NAME));
rv = file->Append(nsLiteralString(PADDING_FILE_NAME));
}
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;

View File

@ -20,8 +20,8 @@ namespace mozilla {
namespace dom {
namespace cache {
#define PADDING_FILE_NAME ".padding"
#define PADDING_TMP_FILE_NAME ".padding-tmp"
#define PADDING_FILE_NAME u".padding"
#define PADDING_TMP_FILE_NAME u".padding-tmp"
enum DirPaddingFile { FILE, TMP_FILE };

View File

@ -223,7 +223,7 @@ nsresult CacheQuotaClient::InitOriginWithoutTracking(
// though this shouldn't happen with a "good" profile, we shouldn't return an
// error here, since that would cause origin initialization to fail. We just
// warn and otherwise ignore that.
UNKNOWN_FILE_WARNING(NS_LITERAL_STRING(DOMCACHE_DIRECTORY_NAME));
UNKNOWN_FILE_WARNING(NS_LITERAL_STRING_FROM_CSTRING(DOMCACHE_DIRECTORY_NAME));
return NS_OK;
}
@ -383,7 +383,7 @@ Result<UsageInfo, nsresult> CacheQuotaClient::GetUsageForOriginInternal(
return Err(rv);
}
rv = dir->Append(NS_LITERAL_STRING(DOMCACHE_DIRECTORY_NAME));
rv = dir->Append(NS_LITERAL_STRING_FROM_CSTRING(DOMCACHE_DIRECTORY_NAME));
if (NS_WARN_IF(NS_FAILED(rv))) {
REPORT_TELEMETRY_ERR_IN_INIT(aInitializing, kQuotaExternalError,
Cache_Append);

View File

@ -92,8 +92,8 @@ RefPtr<GenericPromise> OnShutdown() {
nsCOMPtr<nsIAsyncShutdownBlocker> blocker =
new ClientShutdownBlocker(ref);
nsresult rv =
phase->AddBlocker(blocker, NS_LITERAL_STRING(__FILE__), __LINE__,
u"ClientManagerService shutdown"_ns);
phase->AddBlocker(blocker, NS_LITERAL_STRING_FROM_CSTRING(__FILE__),
__LINE__, u"ClientManagerService shutdown"_ns);
if (NS_FAILED(rv)) {
ref->Resolve(true, __func__);

View File

@ -980,24 +980,24 @@ void Console::ClearStorage() {
#define METHOD(name, string) \
/* static */ void Console::name(const GlobalObject& aGlobal, \
const Sequence<JS::Value>& aData) { \
Method(aGlobal, Method##name, NS_LITERAL_STRING(string), aData); \
Method(aGlobal, Method##name, nsLiteralString(string), aData); \
}
METHOD(Log, "log")
METHOD(Info, "info")
METHOD(Warn, "warn")
METHOD(Error, "error")
METHOD(Exception, "exception")
METHOD(Debug, "debug")
METHOD(Table, "table")
METHOD(Trace, "trace")
METHOD(Log, u"log")
METHOD(Info, u"info")
METHOD(Warn, u"warn")
METHOD(Error, u"error")
METHOD(Exception, u"exception")
METHOD(Debug, u"debug")
METHOD(Table, u"table")
METHOD(Trace, u"trace")
// Displays an interactive listing of all the properties of an object.
METHOD(Dir, "dir");
METHOD(Dirxml, "dirxml");
METHOD(Dir, u"dir");
METHOD(Dirxml, u"dirxml");
METHOD(Group, "group")
METHOD(GroupCollapsed, "groupCollapsed")
METHOD(Group, u"group")
METHOD(GroupCollapsed, u"groupCollapsed")
#undef METHOD

View File

@ -113,21 +113,21 @@ JSObject* ConsoleInstance::WrapObject(JSContext* aCx,
const Sequence<JS::Value>& aData) { \
RefPtr<Console> console(mConsole); \
console->MethodInternal(aCx, Console::Method##name, \
NS_LITERAL_STRING(string), aData); \
nsLiteralString(string), aData); \
}
METHOD(Log, "log")
METHOD(Info, "info")
METHOD(Warn, "warn")
METHOD(Error, "error")
METHOD(Exception, "exception")
METHOD(Debug, "debug")
METHOD(Table, "table")
METHOD(Trace, "trace")
METHOD(Dir, "dir");
METHOD(Dirxml, "dirxml");
METHOD(Group, "group")
METHOD(GroupCollapsed, "groupCollapsed")
METHOD(Log, u"log")
METHOD(Info, u"info")
METHOD(Warn, u"warn")
METHOD(Error, u"error")
METHOD(Exception, u"exception")
METHOD(Debug, u"debug")
METHOD(Table, u"table")
METHOD(Trace, u"trace")
METHOD(Dir, u"dir");
METHOD(Dirxml, u"dirxml");
METHOD(Group, u"group")
METHOD(GroupCollapsed, u"groupCollapsed")
#undef METHOD

View File

@ -191,28 +191,36 @@ void CryptoKey::GetAlgorithm(JSContext* cx,
void CryptoKey::GetUsages(nsTArray<nsString>& aRetVal) const {
if (mAttributes & ENCRYPT) {
aRetVal.AppendElement(NS_LITERAL_STRING(WEBCRYPTO_KEY_USAGE_ENCRYPT));
aRetVal.AppendElement(
NS_LITERAL_STRING_FROM_CSTRING(WEBCRYPTO_KEY_USAGE_ENCRYPT));
}
if (mAttributes & DECRYPT) {
aRetVal.AppendElement(NS_LITERAL_STRING(WEBCRYPTO_KEY_USAGE_DECRYPT));
aRetVal.AppendElement(
NS_LITERAL_STRING_FROM_CSTRING(WEBCRYPTO_KEY_USAGE_DECRYPT));
}
if (mAttributes & SIGN) {
aRetVal.AppendElement(NS_LITERAL_STRING(WEBCRYPTO_KEY_USAGE_SIGN));
aRetVal.AppendElement(
NS_LITERAL_STRING_FROM_CSTRING(WEBCRYPTO_KEY_USAGE_SIGN));
}
if (mAttributes & VERIFY) {
aRetVal.AppendElement(NS_LITERAL_STRING(WEBCRYPTO_KEY_USAGE_VERIFY));
aRetVal.AppendElement(
NS_LITERAL_STRING_FROM_CSTRING(WEBCRYPTO_KEY_USAGE_VERIFY));
}
if (mAttributes & DERIVEKEY) {
aRetVal.AppendElement(NS_LITERAL_STRING(WEBCRYPTO_KEY_USAGE_DERIVEKEY));
aRetVal.AppendElement(
NS_LITERAL_STRING_FROM_CSTRING(WEBCRYPTO_KEY_USAGE_DERIVEKEY));
}
if (mAttributes & DERIVEBITS) {
aRetVal.AppendElement(NS_LITERAL_STRING(WEBCRYPTO_KEY_USAGE_DERIVEBITS));
aRetVal.AppendElement(
NS_LITERAL_STRING_FROM_CSTRING(WEBCRYPTO_KEY_USAGE_DERIVEBITS));
}
if (mAttributes & WRAPKEY) {
aRetVal.AppendElement(NS_LITERAL_STRING(WEBCRYPTO_KEY_USAGE_WRAPKEY));
aRetVal.AppendElement(
NS_LITERAL_STRING_FROM_CSTRING(WEBCRYPTO_KEY_USAGE_WRAPKEY));
}
if (mAttributes & UNWRAPKEY) {
aRetVal.AppendElement(NS_LITERAL_STRING(WEBCRYPTO_KEY_USAGE_UNWRAPKEY));
aRetVal.AppendElement(
NS_LITERAL_STRING_FROM_CSTRING(WEBCRYPTO_KEY_USAGE_UNWRAPKEY));
}
}
@ -668,15 +676,18 @@ bool ECKeyToJwk(const PK11ObjectType aKeyType, void* aKey,
switch (SECOID_FindOIDTag(&oid)) {
case SEC_OID_SECG_EC_SECP256R1:
flen = 32; // bytes
aRetVal.mCrv.Construct(NS_LITERAL_STRING(WEBCRYPTO_NAMED_CURVE_P256));
aRetVal.mCrv.Construct(
NS_LITERAL_STRING_FROM_CSTRING(WEBCRYPTO_NAMED_CURVE_P256));
break;
case SEC_OID_SECG_EC_SECP384R1:
flen = 48; // bytes
aRetVal.mCrv.Construct(NS_LITERAL_STRING(WEBCRYPTO_NAMED_CURVE_P384));
aRetVal.mCrv.Construct(
NS_LITERAL_STRING_FROM_CSTRING(WEBCRYPTO_NAMED_CURVE_P384));
break;
case SEC_OID_SECG_EC_SECP521R1:
flen = 66; // bytes
aRetVal.mCrv.Construct(NS_LITERAL_STRING(WEBCRYPTO_NAMED_CURVE_P521));
aRetVal.mCrv.Construct(
NS_LITERAL_STRING_FROM_CSTRING(WEBCRYPTO_NAMED_CURVE_P521));
break;
default:
return false;
@ -710,7 +721,7 @@ bool ECKeyToJwk(const PK11ObjectType aKeyType, void* aKey,
return false;
}
aRetVal.mKty = NS_LITERAL_STRING(JWK_TYPE_EC);
aRetVal.mKty = NS_LITERAL_STRING_FROM_CSTRING(JWK_TYPE_EC);
return true;
}
@ -738,7 +749,7 @@ nsresult CryptoKey::PrivateKeyToJwk(SECKEYPrivateKey* aPrivKey,
return NS_ERROR_DOM_OPERATION_ERR;
}
aRetVal.mKty = NS_LITERAL_STRING(JWK_TYPE_RSA);
aRetVal.mKty = NS_LITERAL_STRING_FROM_CSTRING(JWK_TYPE_RSA);
return NS_OK;
}
case ecKey: {
@ -902,7 +913,7 @@ nsresult CryptoKey::PublicKeyToJwk(SECKEYPublicKey* aPubKey,
return NS_ERROR_DOM_OPERATION_ERR;
}
aRetVal.mKty = NS_LITERAL_STRING(JWK_TYPE_RSA);
aRetVal.mKty = NS_LITERAL_STRING_FROM_CSTRING(JWK_TYPE_RSA);
return NS_OK;
}
case ecKey:

View File

@ -107,96 +107,96 @@ nsString KeyAlgorithmProxy::JwkAlg() const {
if (mName.EqualsLiteral(WEBCRYPTO_ALG_AES_CBC)) {
switch (mAes.mLength) {
case 128:
return NS_LITERAL_STRING(JWK_ALG_A128CBC);
return NS_LITERAL_STRING_FROM_CSTRING(JWK_ALG_A128CBC);
case 192:
return NS_LITERAL_STRING(JWK_ALG_A192CBC);
return NS_LITERAL_STRING_FROM_CSTRING(JWK_ALG_A192CBC);
case 256:
return NS_LITERAL_STRING(JWK_ALG_A256CBC);
return NS_LITERAL_STRING_FROM_CSTRING(JWK_ALG_A256CBC);
}
}
if (mName.EqualsLiteral(WEBCRYPTO_ALG_AES_CTR)) {
switch (mAes.mLength) {
case 128:
return NS_LITERAL_STRING(JWK_ALG_A128CTR);
return NS_LITERAL_STRING_FROM_CSTRING(JWK_ALG_A128CTR);
case 192:
return NS_LITERAL_STRING(JWK_ALG_A192CTR);
return NS_LITERAL_STRING_FROM_CSTRING(JWK_ALG_A192CTR);
case 256:
return NS_LITERAL_STRING(JWK_ALG_A256CTR);
return NS_LITERAL_STRING_FROM_CSTRING(JWK_ALG_A256CTR);
}
}
if (mName.EqualsLiteral(WEBCRYPTO_ALG_AES_GCM)) {
switch (mAes.mLength) {
case 128:
return NS_LITERAL_STRING(JWK_ALG_A128GCM);
return NS_LITERAL_STRING_FROM_CSTRING(JWK_ALG_A128GCM);
case 192:
return NS_LITERAL_STRING(JWK_ALG_A192GCM);
return NS_LITERAL_STRING_FROM_CSTRING(JWK_ALG_A192GCM);
case 256:
return NS_LITERAL_STRING(JWK_ALG_A256GCM);
return NS_LITERAL_STRING_FROM_CSTRING(JWK_ALG_A256GCM);
}
}
if (mName.EqualsLiteral(WEBCRYPTO_ALG_AES_KW)) {
switch (mAes.mLength) {
case 128:
return NS_LITERAL_STRING(JWK_ALG_A128KW);
return NS_LITERAL_STRING_FROM_CSTRING(JWK_ALG_A128KW);
case 192:
return NS_LITERAL_STRING(JWK_ALG_A192KW);
return NS_LITERAL_STRING_FROM_CSTRING(JWK_ALG_A192KW);
case 256:
return NS_LITERAL_STRING(JWK_ALG_A256KW);
return NS_LITERAL_STRING_FROM_CSTRING(JWK_ALG_A256KW);
}
}
if (mName.EqualsLiteral(WEBCRYPTO_ALG_HMAC)) {
nsString hashName = mHmac.mHash.mName;
if (hashName.EqualsLiteral(WEBCRYPTO_ALG_SHA1)) {
return NS_LITERAL_STRING(JWK_ALG_HS1);
return NS_LITERAL_STRING_FROM_CSTRING(JWK_ALG_HS1);
} else if (hashName.EqualsLiteral(WEBCRYPTO_ALG_SHA256)) {
return NS_LITERAL_STRING(JWK_ALG_HS256);
return NS_LITERAL_STRING_FROM_CSTRING(JWK_ALG_HS256);
} else if (hashName.EqualsLiteral(WEBCRYPTO_ALG_SHA384)) {
return NS_LITERAL_STRING(JWK_ALG_HS384);
return NS_LITERAL_STRING_FROM_CSTRING(JWK_ALG_HS384);
} else if (hashName.EqualsLiteral(WEBCRYPTO_ALG_SHA512)) {
return NS_LITERAL_STRING(JWK_ALG_HS512);
return NS_LITERAL_STRING_FROM_CSTRING(JWK_ALG_HS512);
}
}
if (mName.EqualsLiteral(WEBCRYPTO_ALG_RSASSA_PKCS1)) {
nsString hashName = mRsa.mHash.mName;
if (hashName.EqualsLiteral(WEBCRYPTO_ALG_SHA1)) {
return NS_LITERAL_STRING(JWK_ALG_RS1);
return NS_LITERAL_STRING_FROM_CSTRING(JWK_ALG_RS1);
} else if (hashName.EqualsLiteral(WEBCRYPTO_ALG_SHA256)) {
return NS_LITERAL_STRING(JWK_ALG_RS256);
return NS_LITERAL_STRING_FROM_CSTRING(JWK_ALG_RS256);
} else if (hashName.EqualsLiteral(WEBCRYPTO_ALG_SHA384)) {
return NS_LITERAL_STRING(JWK_ALG_RS384);
return NS_LITERAL_STRING_FROM_CSTRING(JWK_ALG_RS384);
} else if (hashName.EqualsLiteral(WEBCRYPTO_ALG_SHA512)) {
return NS_LITERAL_STRING(JWK_ALG_RS512);
return NS_LITERAL_STRING_FROM_CSTRING(JWK_ALG_RS512);
}
}
if (mName.EqualsLiteral(WEBCRYPTO_ALG_RSA_OAEP)) {
nsString hashName = mRsa.mHash.mName;
if (hashName.EqualsLiteral(WEBCRYPTO_ALG_SHA1)) {
return NS_LITERAL_STRING(JWK_ALG_RSA_OAEP);
return NS_LITERAL_STRING_FROM_CSTRING(JWK_ALG_RSA_OAEP);
} else if (hashName.EqualsLiteral(WEBCRYPTO_ALG_SHA256)) {
return NS_LITERAL_STRING(JWK_ALG_RSA_OAEP_256);
return NS_LITERAL_STRING_FROM_CSTRING(JWK_ALG_RSA_OAEP_256);
} else if (hashName.EqualsLiteral(WEBCRYPTO_ALG_SHA384)) {
return NS_LITERAL_STRING(JWK_ALG_RSA_OAEP_384);
return NS_LITERAL_STRING_FROM_CSTRING(JWK_ALG_RSA_OAEP_384);
} else if (hashName.EqualsLiteral(WEBCRYPTO_ALG_SHA512)) {
return NS_LITERAL_STRING(JWK_ALG_RSA_OAEP_512);
return NS_LITERAL_STRING_FROM_CSTRING(JWK_ALG_RSA_OAEP_512);
}
}
if (mName.EqualsLiteral(WEBCRYPTO_ALG_RSA_PSS)) {
nsString hashName = mRsa.mHash.mName;
if (hashName.EqualsLiteral(WEBCRYPTO_ALG_SHA1)) {
return NS_LITERAL_STRING(JWK_ALG_PS1);
return NS_LITERAL_STRING_FROM_CSTRING(JWK_ALG_PS1);
} else if (hashName.EqualsLiteral(WEBCRYPTO_ALG_SHA256)) {
return NS_LITERAL_STRING(JWK_ALG_PS256);
return NS_LITERAL_STRING_FROM_CSTRING(JWK_ALG_PS256);
} else if (hashName.EqualsLiteral(WEBCRYPTO_ALG_SHA384)) {
return NS_LITERAL_STRING(JWK_ALG_PS384);
return NS_LITERAL_STRING_FROM_CSTRING(JWK_ALG_PS384);
} else if (hashName.EqualsLiteral(WEBCRYPTO_ALG_SHA512)) {
return NS_LITERAL_STRING(JWK_ALG_PS512);
return NS_LITERAL_STRING_FROM_CSTRING(JWK_ALG_PS512);
}
}

View File

@ -83,8 +83,8 @@ struct KeyAlgorithmProxy {
void MakeHmac(uint32_t aLength, const nsString& aHashName) {
mType = HMAC;
mName = NS_LITERAL_STRING(WEBCRYPTO_ALG_HMAC);
mHmac.mName = NS_LITERAL_STRING(WEBCRYPTO_ALG_HMAC);
mName = NS_LITERAL_STRING_FROM_CSTRING(WEBCRYPTO_ALG_HMAC);
mHmac.mName = NS_LITERAL_STRING_FROM_CSTRING(WEBCRYPTO_ALG_HMAC);
mHmac.mLength = aLength;
mHmac.mHash.mName = aHashName;
}

View File

@ -179,7 +179,8 @@ inline CK_MECHANISM_TYPE MapAlgorithmNameToMechanism(const nsString& aName) {
}
#define NORMALIZED_EQUALS(aTest, aConst) \
nsContentUtils::EqualsIgnoreASCIICase(aTest, NS_LITERAL_STRING(aConst))
nsContentUtils::EqualsIgnoreASCIICase( \
aTest, NS_LITERAL_STRING_FROM_CSTRING(aConst))
inline bool NormalizeToken(const nsString& aName, nsString& aDest) {
// Algorithm names

View File

@ -1971,7 +1971,7 @@ class ExportKeyTask : public WebCryptoTask {
return NS_ERROR_DOM_OPERATION_ERR;
}
mJwk.mK.Construct(k);
mJwk.mKty = NS_LITERAL_STRING(JWK_TYPE_SYMMETRIC);
mJwk.mKty = NS_LITERAL_STRING_FROM_CSTRING(JWK_TYPE_SYMMETRIC);
} else if (mKeyType == CryptoKey::PUBLIC) {
if (!mPublicKey) {
return NS_ERROR_DOM_UNKNOWN_ERR;
@ -2637,7 +2637,8 @@ class DeriveKeyTask : public DeriveBitsTask {
return;
}
NS_NAMED_LITERAL_STRING(format, WEBCRYPTO_KEY_FORMAT_RAW);
constexpr auto format =
NS_LITERAL_STRING_FROM_CSTRING(WEBCRYPTO_KEY_FORMAT_RAW);
mTask = new ImportSymmetricKeyTask(aGlobal, aCx, format, aDerivedKeyType,
aExtractable, aKeyUsages);
}

View File

@ -73,8 +73,8 @@ already_AddRefed<Promise> Clipboard::ReadHelper(
MOZ_LOG(GetClipboardLog(), LogLevel::Debug,
("Clipboard, ReadHelper, read text case\n"));
nsAutoString str;
dataTransfer->GetData(NS_LITERAL_STRING(kTextMime), str,
aSubjectPrincipal, ier);
dataTransfer->GetData(NS_LITERAL_STRING_FROM_CSTRING(kTextMime),
str, aSubjectPrincipal, ier);
// Either resolve with a string extracted from data transfer item
// or resolve with an empty string if nothing was found
p->MaybeResolve(str);
@ -166,8 +166,8 @@ already_AddRefed<Promise> Clipboard::WriteText(const nsAString& aData,
RefPtr<DataTransfer> dataTransfer = new DataTransfer(this, eCopy,
/* is external */ true,
/* clipboard type */ -1);
dataTransfer->SetData(NS_LITERAL_STRING(kTextMime), aData, aSubjectPrincipal,
aRv);
dataTransfer->SetData(NS_LITERAL_STRING_FROM_CSTRING(kTextMime), aData,
aSubjectPrincipal, aRv);
return Write(*dataTransfer, aSubjectPrincipal, aRv);
}

View File

@ -1464,7 +1464,8 @@ void DataTransfer::FillAllExternalData() {
void DataTransfer::FillInExternalCustomTypes(uint32_t aIndex,
nsIPrincipal* aPrincipal) {
RefPtr<DataTransferItem> item = new DataTransferItem(
this, NS_LITERAL_STRING(kCustomTypesMime), DataTransferItem::KIND_STRING);
this, NS_LITERAL_STRING_FROM_CSTRING(kCustomTypesMime),
DataTransferItem::KIND_STRING);
item->SetIndex(aIndex);
nsCOMPtr<nsIVariant> variant = item->DataNoSecurityCheck();

View File

@ -83,7 +83,7 @@ InternalRequest::InternalRequest(const nsACString& aURL,
mHeaders(new InternalHeaders(HeadersGuardEnum::None)),
mBodyLength(InternalResponse::UNKNOWN_BODY_SIZE),
mContentPolicyType(nsIContentPolicy::TYPE_FETCH),
mReferrer(NS_LITERAL_STRING(kFETCH_CLIENT_REFERRER_STR)),
mReferrer(NS_LITERAL_STRING_FROM_CSTRING(kFETCH_CLIENT_REFERRER_STR)),
mReferrerPolicy(ReferrerPolicy::_empty),
mEnvironmentReferrerPolicy(ReferrerPolicy::_empty),
mMode(RequestMode::No_cors),

View File

@ -352,7 +352,8 @@ SafeRefPtr<Request> Request::Constructor(nsIGlobalObject* aGlobal,
}
if (aInit.IsAnyMemberPresent()) {
request->SetReferrer(NS_LITERAL_STRING(kFETCH_CLIENT_REFERRER_STR));
request->SetReferrer(
NS_LITERAL_STRING_FROM_CSTRING(kFETCH_CLIENT_REFERRER_STR));
request->SetReferrerPolicy(ReferrerPolicy::_empty);
}
if (aInit.mReferrer.WasPassed()) {

View File

@ -32,12 +32,12 @@
namespace mozilla {
namespace dom {
#define ABORT_STR "abort"
#define LOAD_STR "load"
#define LOADSTART_STR "loadstart"
#define LOADEND_STR "loadend"
#define ERROR_STR "error"
#define PROGRESS_STR "progress"
#define ABORT_STR u"abort"
#define LOAD_STR u"load"
#define LOADSTART_STR u"loadstart"
#define LOADEND_STR u"loadend"
#define ERROR_STR u"error"
#define PROGRESS_STR u"progress"
const uint64_t kUnknownSize = uint64_t(-1);
@ -443,7 +443,7 @@ void FileReader::InitialAsyncWait() {
return;
}
DispatchProgressEvent(NS_LITERAL_STRING(LOADSTART_STR));
DispatchProgressEvent(nsLiteralString(LOADSTART_STR));
}
nsresult FileReader::GetAsText(Blob* aBlob, const nsACString& aCharset,
@ -546,8 +546,8 @@ void FileReader::FreeDataAndDispatchSuccess() {
mBlob = nullptr;
// Dispatch event to signify end of a successful operation
DispatchProgressEvent(NS_LITERAL_STRING(LOAD_STR));
DispatchProgressEvent(NS_LITERAL_STRING(LOADEND_STR));
DispatchProgressEvent(nsLiteralString(LOAD_STR));
DispatchProgressEvent(nsLiteralString(LOADEND_STR));
}
void FileReader::FreeDataAndDispatchError() {
@ -559,8 +559,8 @@ void FileReader::FreeDataAndDispatchError() {
mBlob = nullptr;
// Dispatch error event to signify load failure
DispatchProgressEvent(NS_LITERAL_STRING(ERROR_STR));
DispatchProgressEvent(NS_LITERAL_STRING(LOADEND_STR));
DispatchProgressEvent(nsLiteralString(ERROR_STR));
DispatchProgressEvent(nsLiteralString(LOADEND_STR));
}
void FileReader::FreeDataAndDispatchError(nsresult aRv) {
@ -654,7 +654,7 @@ FileReader::OnInputStreamReady(nsIAsyncInputStream* aStream) {
if (mTimerIsActive) {
mProgressEventWasDelayed = true;
} else {
rv = DispatchProgressEvent(NS_LITERAL_STRING(PROGRESS_STR));
rv = DispatchProgressEvent(nsLiteralString(PROGRESS_STR));
NS_ENSURE_SUCCESS(rv, rv);
StartProgressEventTimer();
@ -764,8 +764,8 @@ void FileReader::Abort() {
FreeFileData();
// Dispatch the events
DispatchProgressEvent(NS_LITERAL_STRING(ABORT_STR));
DispatchProgressEvent(NS_LITERAL_STRING(LOADEND_STR));
DispatchProgressEvent(nsLiteralString(ABORT_STR));
DispatchProgressEvent(nsLiteralString(LOADEND_STR));
} // namespace dom
nsresult FileReader::IncreaseBusyCounter() {

View File

@ -412,8 +412,8 @@ class ReleasingTimerHolder final : public Runnable,
nsCOMPtr<nsIAsyncShutdownClient> phase = GetShutdownPhase();
NS_ENSURE_TRUE(!!phase, NS_OK);
rv = phase->AddBlocker(this, NS_LITERAL_STRING(__FILE__), __LINE__,
u"ReleasingTimerHolder shutdown"_ns);
rv = phase->AddBlocker(this, NS_LITERAL_STRING_FROM_CSTRING(__FILE__),
__LINE__, u"ReleasingTimerHolder shutdown"_ns);
NS_ENSURE_SUCCESS(rv, NS_OK);
raii.release();

View File

@ -623,7 +623,7 @@ nsresult FSTextPlain::AddNameValuePair(const nsAString& aName,
// XXX This won't work well with a name like "a=b" or "a\nb" but I suppose
// text/plain doesn't care about that. Parsers aren't built for escaped
// values so we'll have to live with it.
mBody.Append(aName + u"="_ns + aValue + NS_LITERAL_STRING(CRLF));
mBody.Append(aName + u"="_ns + aValue + NS_LITERAL_STRING_FROM_CSTRING(CRLF));
return NS_OK;
}

View File

@ -347,7 +347,7 @@ UploadLastDir::ContentPrefCallback::HandleCompletion(uint16_t aReason) {
// If no custom directory was set through the pref, default to
// "desktop" directory for each platform.
mFilePicker->SetDisplaySpecialDirectory(
NS_LITERAL_STRING(NS_OS_DESKTOP_DIR));
NS_LITERAL_STRING_FROM_CSTRING(NS_OS_DESKTOP_DIR));
}
mFilePicker->Open(mFpCallback);

View File

@ -17545,7 +17545,7 @@ nsresult QuotaClient::GetDirectory(PersistenceType aPersistenceType,
MOZ_ASSERT(directory);
rv = directory->Append(NS_LITERAL_STRING(IDB_DIRECTORY_NAME));
rv = directory->Append(NS_LITERAL_STRING_FROM_CSTRING(IDB_DIRECTORY_NAME));
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
@ -17988,7 +17988,8 @@ nsresult Maintenance::DirectoryWork() {
size_t(PERSISTENCE_TYPE_INVALID),
"Something changed with available persistence types!");
NS_NAMED_LITERAL_STRING(idbDirName, IDB_DIRECTORY_NAME);
constexpr auto idbDirName =
NS_LITERAL_STRING_FROM_CSTRING(IDB_DIRECTORY_NAME);
for (const PersistenceType persistenceType : kPersistenceTypes) {
// Loop over "<persistence>" directories.
@ -20757,7 +20758,7 @@ nsresult FactoryOp::OpenDirectory() {
return rv;
}
rv = dbFile->Append(NS_LITERAL_STRING(IDB_DIRECTORY_NAME));
rv = dbFile->Append(NS_LITERAL_STRING_FROM_CSTRING(IDB_DIRECTORY_NAME));
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
@ -21008,7 +21009,7 @@ nsresult OpenDatabaseOp::DoDatabaseWork() {
return rv;
}
rv = dbDirectory->Append(NS_LITERAL_STRING(IDB_DIRECTORY_NAME));
rv = dbDirectory->Append(NS_LITERAL_STRING_FROM_CSTRING(IDB_DIRECTORY_NAME));
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
@ -22317,7 +22318,7 @@ nsresult DeleteDatabaseOp::DoDatabaseWork() {
return rv;
}
rv = directory->Append(NS_LITERAL_STRING(IDB_DIRECTORY_NAME));
rv = directory->Append(NS_LITERAL_STRING_FROM_CSTRING(IDB_DIRECTORY_NAME));
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}

View File

@ -638,7 +638,7 @@ static const char* sObserverTopics[] = {
/*static*/ RefPtr<ContentParent::LaunchPromise>
ContentParent::PreallocateProcess() {
RefPtr<ContentParent> process =
new ContentParent(NS_LITERAL_STRING(PREALLOC_REMOTE_TYPE));
new ContentParent(NS_LITERAL_STRING_FROM_CSTRING(PREALLOC_REMOTE_TYPE));
MOZ_LOG(ContentParent::GetLog(), LogLevel::Debug,
("Preallocating process of type " PREALLOC_REMOTE_TYPE));
@ -723,12 +723,13 @@ bool IsWebRemoteType(const nsAString& aContentProcessType) {
// Note: matches webIsolated as well as web (and webLargeAllocation, and
// webCOOP+COEP)
return StringBeginsWith(aContentProcessType,
NS_LITERAL_STRING(DEFAULT_REMOTE_TYPE));
NS_LITERAL_STRING_FROM_CSTRING(DEFAULT_REMOTE_TYPE));
}
bool IsWebCoopCoepRemoteType(const nsAString& aContentProcessType) {
return StringBeginsWith(aContentProcessType,
NS_LITERAL_STRING(WITH_COOP_COEP_REMOTE_TYPE_PREFIX));
return StringBeginsWith(
aContentProcessType,
NS_LITERAL_STRING_FROM_CSTRING(WITH_COOP_COEP_REMOTE_TYPE_PREFIX));
}
/*static*/
@ -996,7 +997,8 @@ ContentParent::GetNewOrUsedLaunchingBrowserProcess(Element* aFrameElement,
MOZ_LOG(ContentParent::GetLog(), LogLevel::Debug,
("GetNewOrUsedProcess: returning Large Used process"));
return GetNewOrUsedLaunchingBrowserProcess(
aFrameElement, NS_LITERAL_STRING(DEFAULT_REMOTE_TYPE), aPriority,
aFrameElement, NS_LITERAL_STRING_FROM_CSTRING(DEFAULT_REMOTE_TYPE),
aPriority,
/*aPreferUsed =*/false);
}
@ -2029,8 +2031,8 @@ bool ContentParent::ShouldKeepProcessAlive() {
nsAutoCString keepAlivePref("dom.ipc.keepProcessesAlive.");
if (StringBeginsWith(mRemoteType,
NS_LITERAL_STRING(FISSION_WEB_REMOTE_TYPE)) &&
if (StringBeginsWith(mRemoteType, NS_LITERAL_STRING_FROM_CSTRING(
FISSION_WEB_REMOTE_TYPE)) &&
xpc::IsInAutomation()) {
keepAlivePref.Append(FISSION_WEB_REMOTE_TYPE);
keepAlivePref.AppendLiteral(".perOrigin");
@ -3229,10 +3231,10 @@ static void InitClients() {
void ContentParent::AddShutdownBlockers() {
InitClients();
sXPCOMShutdownClient->AddBlocker(this, NS_LITERAL_STRING(__FILE__), __LINE__,
EmptyString());
sProfileBeforeChangeClient->AddBlocker(this, NS_LITERAL_STRING(__FILE__),
__LINE__, EmptyString());
sXPCOMShutdownClient->AddBlocker(
this, NS_LITERAL_STRING_FROM_CSTRING(__FILE__), __LINE__, EmptyString());
sProfileBeforeChangeClient->AddBlocker(
this, NS_LITERAL_STRING_FROM_CSTRING(__FILE__), __LINE__, EmptyString());
}
void ContentParent::RemoveShutdownBlockers() {

View File

@ -299,8 +299,9 @@ void PreallocatedProcessManagerImpl::RemoveBlocker(ContentParent* aParent) {
bool PreallocatedProcessManagerImpl::CanAllocate() {
return mEnabled && sNumBlockers == 0 &&
mPreallocatedProcesses.size() < mNumberPreallocs && !sShutdown &&
(FissionAutostart() || !ContentParent::IsMaxProcessCountReached(
NS_LITERAL_STRING(DEFAULT_REMOTE_TYPE)));
(FissionAutostart() ||
!ContentParent::IsMaxProcessCountReached(
NS_LITERAL_STRING_FROM_CSTRING(DEFAULT_REMOTE_TYPE)));
}
void PreallocatedProcessManagerImpl::AllocateAfterDelay() {

View File

@ -19,7 +19,7 @@ int FuzzingInitContentParentIPC(int* argc, char*** argv) { return 0; }
static int RunContentParentIPCFuzzing(const uint8_t* data, size_t size) {
static mozilla::dom::ContentParent* p =
mozilla::ipc::ProtocolFuzzerHelper::CreateContentParent(
NS_LITERAL_STRING(DEFAULT_REMOTE_TYPE));
NS_LITERAL_STRING_FROM_CSTRING(DEFAULT_REMOTE_TYPE));
static nsTArray<nsCString> ignored = mozilla::ipc::LoadIPCMessageBlacklist(
getenv("MOZ_IPC_MESSAGE_FUZZ_BLACKLIST"));

View File

@ -142,11 +142,11 @@ static_assert(kSQLiteGrowthIncrement >= 0 &&
/**
* The database name for LocalStorage data in a per-origin directory.
*/
#define DATA_FILE_NAME "data.sqlite"
#define DATA_FILE_NAME u"data.sqlite"
/**
* The journal corresponding to DATA_FILE_NAME. (We don't use WAL mode.)
*/
#define JOURNAL_FILE_NAME "data.sqlite-journal"
#define JOURNAL_FILE_NAME u"data.sqlite-journal"
/**
* This file contains the current usage of the LocalStorage database as defined
@ -159,7 +159,7 @@ static_assert(kSQLiteGrowthIncrement >= 0 &&
* The file contains a binary verification cookie (32-bits) followed by the
* actual usage (64-bits).
*/
#define USAGE_FILE_NAME "usage"
#define USAGE_FILE_NAME u"usage"
/**
* Following a QuotaManager idiom, this journal file's existence is a marker
@ -174,7 +174,7 @@ static_assert(kSQLiteGrowthIncrement >= 0 &&
* If the journal file is found to exist at origin initialization time, the
* usage will be re-computed from the current state of DATA_FILE_NAME.
*/
#define USAGE_JOURNAL_FILE_NAME "usage-journal"
#define USAGE_JOURNAL_FILE_NAME u"usage-journal"
static const uint32_t kUsageFileSize = 12;
static const uint32_t kUsageFileCookie = 0x420a420a;
@ -251,12 +251,12 @@ const uint32_t kPreparedDatastoreTimeoutMs = 20000;
* LocalStorage data that we can potentially get rid of at some point in the
* future.
*/
#define LS_ARCHIVE_FILE_NAME "ls-archive.sqlite"
#define LS_ARCHIVE_FILE_NAME u"ls-archive.sqlite"
/**
* The legacy LocalStorage database. Its contents are maintained as our
* "shadow" database so that LSNG can be disabled without loss of user data.
*/
#define WEB_APPS_STORE_FILE_NAME "webappsstore.sqlite"
#define WEB_APPS_STORE_FILE_NAME u"webappsstore.sqlite"
// Shadow database Write Ahead Log's maximum size is 512KB
const uint32_t kShadowMaxWALSize = 512 * 1024;
@ -690,7 +690,7 @@ nsresult GetArchiveFile(const nsAString& aStoragePath, nsIFile** aArchiveFile) {
nsCOMPtr<nsIFile> archiveFile = archiveFileOrErr.unwrap();
nsresult rv = archiveFile->Append(NS_LITERAL_STRING(LS_ARCHIVE_FILE_NAME));
nsresult rv = archiveFile->Append(nsLiteralString(LS_ARCHIVE_FILE_NAME));
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
@ -829,8 +829,7 @@ nsresult GetShadowFile(const nsAString& aBasePath, nsIFile** aArchiveFile) {
nsCOMPtr<nsIFile> archiveFile = archiveFileOrErr.unwrap();
nsresult rv =
archiveFile->Append(NS_LITERAL_STRING(WEB_APPS_STORE_FILE_NAME));
nsresult rv = archiveFile->Append(nsLiteralString(WEB_APPS_STORE_FILE_NAME));
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
@ -1104,7 +1103,7 @@ nsresult GetUsageFile(const nsAString& aDirectoryPath, nsIFile** aUsageFile) {
nsCOMPtr<nsIFile> usageFile = usageFileOrErr.unwrap();
nsresult rv = usageFile->Append(NS_LITERAL_STRING(USAGE_FILE_NAME));
nsresult rv = usageFile->Append(nsLiteralString(USAGE_FILE_NAME));
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
@ -1127,7 +1126,7 @@ nsresult GetUsageJournalFile(const nsAString& aDirectoryPath,
nsCOMPtr<nsIFile> usageJournalFile = usageJournalFileOrErr.unwrap();
nsresult rv =
usageJournalFile->Append(NS_LITERAL_STRING(USAGE_JOURNAL_FILE_NAME));
usageJournalFile->Append(nsLiteralString(USAGE_JOURNAL_FILE_NAME));
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
@ -4276,7 +4275,8 @@ nsresult Connection::EnsureStorageConnection() {
return rv;
}
rv = directoryEntry->Append(NS_LITERAL_STRING(LS_DIRECTORY_NAME));
rv = directoryEntry->Append(
NS_LITERAL_STRING_FROM_CSTRING(LS_DIRECTORY_NAME));
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
@ -4286,7 +4286,7 @@ nsresult Connection::EnsureStorageConnection() {
return rv;
}
rv = directoryEntry->Append(NS_LITERAL_STRING(DATA_FILE_NAME));
rv = directoryEntry->Append(nsLiteralString(DATA_FILE_NAME));
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
@ -4325,7 +4325,8 @@ nsresult Connection::EnsureStorageConnection() {
nsCOMPtr<nsIFile> directoryEntry = directoryEntryOrErr.unwrap();
rv = directoryEntry->Append(NS_LITERAL_STRING(LS_DIRECTORY_NAME));
rv =
directoryEntry->Append(NS_LITERAL_STRING_FROM_CSTRING(LS_DIRECTORY_NAME));
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
@ -4348,7 +4349,7 @@ nsresult Connection::EnsureStorageConnection() {
}
}
rv = directoryEntry->Append(NS_LITERAL_STRING(DATA_FILE_NAME));
rv = directoryEntry->Append(nsLiteralString(DATA_FILE_NAME));
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
@ -7370,7 +7371,8 @@ nsresult PrepareDatastoreOp::DatabaseWork() {
mOrigin);
}
rv = directoryEntry->Append(NS_LITERAL_STRING(LS_DIRECTORY_NAME));
rv =
directoryEntry->Append(NS_LITERAL_STRING_FROM_CSTRING(LS_DIRECTORY_NAME));
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
@ -7391,7 +7393,7 @@ nsresult PrepareDatastoreOp::DatabaseWork() {
return rv;
}
rv = directoryEntry->Append(NS_LITERAL_STRING(DATA_FILE_NAME));
rv = directoryEntry->Append(nsLiteralString(DATA_FILE_NAME));
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
@ -8823,7 +8825,7 @@ Result<UsageInfo, nsresult> QuotaClient::InitOrigin(
MOZ_ASSERT(directory);
rv = directory->Append(NS_LITERAL_STRING(LS_DIRECTORY_NAME));
rv = directory->Append(NS_LITERAL_STRING_FROM_CSTRING(LS_DIRECTORY_NAME));
if (NS_WARN_IF(NS_FAILED(rv))) {
REPORT_TELEMETRY_INIT_ERR(kQuotaExternalError, LS_Append);
return Err(rv);
@ -8921,7 +8923,7 @@ Result<UsageInfo, nsresult> QuotaClient::InitOrigin(
return Err(rv);
}
rv = file->Append(NS_LITERAL_STRING(DATA_FILE_NAME));
rv = file->Append(nsLiteralString(DATA_FILE_NAME));
if (NS_WARN_IF(NS_FAILED(rv))) {
REPORT_TELEMETRY_INIT_ERR(kQuotaExternalError, LS_Append2);
return Err(rv);
@ -9056,7 +9058,7 @@ nsresult QuotaClient::InitOriginWithoutTracking(
// though this shouldn't happen with a "good" profile, we shouldn't return an
// error here, since that would cause origin initialization to fail. We just
// warn and otherwise ignore that.
UNKNOWN_FILE_WARNING(NS_LITERAL_STRING(LS_DIRECTORY_NAME));
UNKNOWN_FILE_WARNING(NS_LITERAL_STRING_FROM_CSTRING(LS_DIRECTORY_NAME));
return NS_OK;
}

View File

@ -2080,8 +2080,8 @@ MediaManager* MediaManager::Get() {
sSingleton->mShutdownBlocker = new Blocker();
nsresult rv = media::GetShutdownBarrier()->AddBlocker(
sSingleton->mShutdownBlocker, NS_LITERAL_STRING(__FILE__), __LINE__,
u""_ns);
sSingleton->mShutdownBlocker, NS_LITERAL_STRING_FROM_CSTRING(__FILE__),
__LINE__, u""_ns);
MOZ_RELEASE_ASSERT(NS_SUCCEEDED(rv));
}
return sSingleton;

View File

@ -1063,7 +1063,7 @@ class MediaRecorder::Session : public PrincipalChangeObserver<MediaStreamTrack>,
name.AppendPrintf("MediaRecorder::Session %p shutdown", this);
mShutdownBlocker = MakeAndAddRef<Blocker>(this, name);
nsresult rv = GetShutdownBarrier()->AddBlocker(
mShutdownBlocker, NS_LITERAL_STRING(__FILE__), __LINE__,
mShutdownBlocker, NS_LITERAL_STRING_FROM_CSTRING(__FILE__), __LINE__,
u"MediaRecorder::Session: shutdown"_ns);
MOZ_RELEASE_ASSERT(NS_SUCCEEDED(rv));

View File

@ -72,7 +72,7 @@ void MediaShutdownManager::InitStatics() {
MOZ_DIAGNOSTIC_ASSERT(sInstance);
nsresult rv = GetShutdownBarrier()->AddBlocker(
sInstance, NS_LITERAL_STRING(__FILE__), __LINE__,
sInstance, NS_LITERAL_STRING_FROM_CSTRING(__FILE__), __LINE__,
u"MediaShutdownManager shutdown"_ns);
if (NS_FAILED(rv)) {
LOGW("Failed to add shutdown blocker! rv=%x", uint32_t(rv));

View File

@ -1518,7 +1518,7 @@ void MediaTrackGraphImpl::AddShutdownBlocker() {
blockerName.AppendPrintf("MediaTrackGraph %p shutdown", this);
mShutdownBlocker = MakeAndAddRef<Blocker>(this, blockerName);
nsresult rv = media::GetShutdownBarrier()->AddBlocker(
mShutdownBlocker, NS_LITERAL_STRING(__FILE__), __LINE__,
mShutdownBlocker, NS_LITERAL_STRING_FROM_CSTRING(__FILE__), __LINE__,
u"MediaTrackGraph shutdown"_ns);
MOZ_RELEASE_ASSERT(NS_SUCCEEDED(rv));
}

View File

@ -1526,7 +1526,7 @@ void GeckoMediaPluginServiceParent::ServiceUserCreated(
mServiceParents.AppendElement(aServiceParent);
if (mServiceParents.Length() == 1) {
nsresult rv = GetShutdownBarrier()->AddBlocker(
this, NS_LITERAL_STRING(__FILE__), __LINE__,
this, NS_LITERAL_STRING_FROM_CSTRING(__FILE__), __LINE__,
u"GeckoMediaPluginServiceParent shutdown"_ns);
MOZ_RELEASE_ASSERT(NS_SUCCEEDED(rv));
}

View File

@ -1087,7 +1087,7 @@ CamerasParent::CamerasParent()
RefPtr<CamerasParent> self(this);
NS_DispatchToMainThread(NewRunnableFrom([self]() {
nsresult rv = GetShutdownBarrier()->AddBlocker(
self, NS_LITERAL_STRING(__FILE__), __LINE__, u""_ns);
self, NS_LITERAL_STRING_FROM_CSTRING(__FILE__), __LINE__, u""_ns);
MOZ_RELEASE_ASSERT(NS_SUCCEEDED(rv));
// Start the thread

View File

@ -30,7 +30,7 @@ mozilla::LazyLogModule gMediaParentLog("MediaParent");
// A file in the profile dir is used to persist mOriginKeys used to anonymize
// deviceIds to be unique per origin, to avoid them being supercookies.
#define ORIGINKEYS_FILE "enumerate_devices.txt"
#define ORIGINKEYS_FILE u"enumerate_devices.txt"
#define ORIGINKEYS_VERSION "1"
namespace mozilla {
@ -181,7 +181,7 @@ class OriginKeyStore : public nsISupports {
if (NS_WARN_IF(NS_FAILED(rv))) {
return nullptr;
}
file->Append(NS_LITERAL_STRING(ORIGINKEYS_FILE));
file->Append(nsLiteralString(ORIGINKEYS_FILE));
return file.forget();
}

View File

@ -623,7 +623,8 @@ SpeechRecognition::StartRecording(RefPtr<AudioStreamTrack>& aTrack) {
mShutdownBlocker =
MakeAndAddRef<SpeechRecognitionShutdownBlocker>(this, blockerName);
RefPtr<nsIAsyncShutdownClient> shutdown = media::GetShutdownBarrier();
shutdown->AddBlocker(mShutdownBlocker, NS_LITERAL_STRING(__FILE__), __LINE__,
shutdown->AddBlocker(mShutdownBlocker,
NS_LITERAL_STRING_FROM_CSTRING(__FILE__), __LINE__,
u"SpeechRecognition shutdown"_ns);
mEndpointer.StartSession();

View File

@ -34,14 +34,14 @@ using namespace mozilla::dom;
// Event names
#define CHECKING_STR "checking"
#define ERROR_STR "error"
#define NOUPDATE_STR "noupdate"
#define DOWNLOADING_STR "downloading"
#define PROGRESS_STR "progress"
#define CACHED_STR "cached"
#define UPDATEREADY_STR "updateready"
#define OBSOLETE_STR "obsolete"
#define CHECKING_STR u"checking"
#define ERROR_STR u"error"
#define NOUPDATE_STR u"noupdate"
#define DOWNLOADING_STR u"downloading"
#define PROGRESS_STR u"progress"
#define CACHED_STR u"cached"
#define UPDATEREADY_STR u"updateready"
#define OBSOLETE_STR u"obsolete"
// To prevent abuse of the resource list for data storage, the number
// of offline urls and their length are limited.
@ -634,24 +634,24 @@ nsDOMOfflineResourceList::UpdateStateChanged(nsIOfflineCacheUpdate* aUpdate,
switch (event) {
case STATE_ERROR:
SendEvent(NS_LITERAL_STRING(ERROR_STR));
SendEvent(nsLiteralString(ERROR_STR));
break;
case STATE_CHECKING:
SendEvent(NS_LITERAL_STRING(CHECKING_STR));
SendEvent(nsLiteralString(CHECKING_STR));
break;
case STATE_NOUPDATE:
SendEvent(NS_LITERAL_STRING(NOUPDATE_STR));
SendEvent(nsLiteralString(NOUPDATE_STR));
break;
case STATE_OBSOLETE:
mStatus = OfflineResourceList_Binding::OBSOLETE;
mAvailableApplicationCache = nullptr;
SendEvent(NS_LITERAL_STRING(OBSOLETE_STR));
SendEvent(nsLiteralString(OBSOLETE_STR));
break;
case STATE_DOWNLOADING:
SendEvent(NS_LITERAL_STRING(DOWNLOADING_STR));
SendEvent(nsLiteralString(DOWNLOADING_STR));
break;
case STATE_ITEMSTARTED:
SendEvent(NS_LITERAL_STRING(PROGRESS_STR));
SendEvent(nsLiteralString(PROGRESS_STR));
break;
case STATE_ITEMCOMPLETED:
// Nothing to do here...
@ -787,9 +787,9 @@ void nsDOMOfflineResourceList::UpdateCompleted(nsIOfflineCacheUpdate* aUpdate) {
if (NS_SUCCEEDED(rv) && succeeded && !partial) {
mStatus = OfflineResourceList_Binding::IDLE;
if (isUpgrade) {
SendEvent(NS_LITERAL_STRING(UPDATEREADY_STR));
SendEvent(nsLiteralString(UPDATEREADY_STR));
} else {
SendEvent(NS_LITERAL_STRING(CACHED_STR));
SendEvent(nsLiteralString(CACHED_STR));
}
}
}

View File

@ -1952,8 +1952,9 @@ nsresult nsPluginHost::LoadPlugins() {
nsCOMPtr<nsIAsyncShutdownClient> shutdownPhase =
GetProfileChangeTeardownPhase();
if (shutdownPhase) {
rv = shutdownPhase->AddBlocker(
mPendingFinder, NS_LITERAL_STRING(__FILE__), __LINE__, u""_ns);
rv = shutdownPhase->AddBlocker(mPendingFinder,
NS_LITERAL_STRING_FROM_CSTRING(__FILE__),
__LINE__, u""_ns);
mAddedFinderShutdownBlocker = NS_SUCCEEDED(rv);
}

View File

@ -2455,7 +2455,7 @@ PluginModuleParent::AnswerNPN_SetValue_NPPVpluginRequiresAudioDeviceChanges(
// We only add the crash reporter to subprocess which have the filename
// FlashPlayerPlugin*
# define FLASH_PROCESS_PREFIX "FLASHPLAYERPLUGIN"
# define FLASH_PROCESS_PREFIX u"FLASHPLAYERPLUGIN"
static DWORD GetFlashChildOfPID(DWORD pid, HANDLE snapshot) {
PROCESSENTRY32 entry = {sizeof(entry)};
@ -2464,7 +2464,7 @@ static DWORD GetFlashChildOfPID(DWORD pid, HANDLE snapshot) {
if (entry.th32ParentProcessID == pid) {
nsString name(entry.szExeFile);
ToUpperCase(name);
if (StringBeginsWith(name, NS_LITERAL_STRING(FLASH_PROCESS_PREFIX))) {
if (StringBeginsWith(name, nsLiteralString(FLASH_PROCESS_PREFIX))) {
return entry.th32ProcessID;
}
}

View File

@ -33,8 +33,8 @@
#define PREF_PRESENTATION_DEVICE_NAME "dom.presentation.device.name"
#define SERVICE_TYPE "_presentation-ctrl._tcp"
#define PROTOCOL_VERSION_TAG "version"
#define CERT_FINGERPRINT_TAG "certFingerprint"
#define PROTOCOL_VERSION_TAG u"version"
#define CERT_FINGERPRINT_TAG u"certFingerprint"
static mozilla::LazyLogModule sMulticastDNSProviderLogModule(
"MulticastDNSDeviceProvider");
@ -310,7 +310,7 @@ nsresult MulticastDNSDeviceProvider::RegisterMDNSService() {
rv = mPresentationService->GetVersion(&version);
MOZ_ASSERT(NS_SUCCEEDED(rv));
rv = propBag->SetPropertyAsUint32(NS_LITERAL_STRING(PROTOCOL_VERSION_TAG),
rv = propBag->SetPropertyAsUint32(nsLiteralString(PROTOCOL_VERSION_TAG),
version);
MOZ_ASSERT(NS_SUCCEEDED(rv));
@ -319,7 +319,7 @@ nsresult MulticastDNSDeviceProvider::RegisterMDNSService() {
rv = mPresentationService->GetCertFingerprint(certFingerprint);
MOZ_ASSERT(NS_SUCCEEDED(rv));
rv = propBag->SetPropertyAsACString(NS_LITERAL_STRING(CERT_FINGERPRINT_TAG),
rv = propBag->SetPropertyAsACString(nsLiteralString(CERT_FINGERPRINT_TAG),
certFingerprint);
MOZ_ASSERT(NS_SUCCEEDED(rv));
}
@ -384,7 +384,7 @@ bool MulticastDNSDeviceProvider::IsCompatibleServer(
uint32_t remoteVersion;
if (NS_WARN_IF(NS_FAILED(propBag->GetPropertyAsUint32(
NS_LITERAL_STRING(PROTOCOL_VERSION_TAG), &remoteVersion)))) {
nsLiteralString(PROTOCOL_VERSION_TAG), &remoteVersion)))) {
return false;
}
@ -850,7 +850,7 @@ MulticastDNSDeviceProvider::OnServiceResolved(nsIDNSServiceInfo* aServiceInfo) {
nsAutoCString certFingerprint;
Unused << propBag->GetPropertyAsACString(
NS_LITERAL_STRING(CERT_FINGERPRINT_TAG), certFingerprint);
nsLiteralString(CERT_FINGERPRINT_TAG), certFingerprint);
uint32_t index;
if (FindDeviceById(host, index)) {

View File

@ -195,23 +195,23 @@ constexpr auto kTemporaryOriginTelemetryKey =
constexpr auto kStorageName = NS_LITERAL_STRING("storage");
constexpr auto kSQLiteSuffix = NS_LITERAL_STRING(".sqlite");
#define INDEXEDDB_DIRECTORY_NAME "indexedDB"
#define PERSISTENT_DIRECTORY_NAME "persistent"
#define PERMANENT_DIRECTORY_NAME "permanent"
#define TEMPORARY_DIRECTORY_NAME "temporary"
#define DEFAULT_DIRECTORY_NAME "default"
#define INDEXEDDB_DIRECTORY_NAME u"indexedDB"
#define PERSISTENT_DIRECTORY_NAME u"persistent"
#define PERMANENT_DIRECTORY_NAME u"permanent"
#define TEMPORARY_DIRECTORY_NAME u"temporary"
#define DEFAULT_DIRECTORY_NAME u"default"
// The name of the file that we use to load/save the last access time of an
// origin.
// XXX We should get rid of old metadata files at some point, bug 1343576.
#define METADATA_FILE_NAME ".metadata"
#define METADATA_TMP_FILE_NAME ".metadata-tmp"
#define METADATA_V2_FILE_NAME ".metadata-v2"
#define METADATA_V2_TMP_FILE_NAME ".metadata-v2-tmp"
#define METADATA_FILE_NAME u".metadata"
#define METADATA_TMP_FILE_NAME u".metadata-tmp"
#define METADATA_V2_FILE_NAME u".metadata-v2"
#define METADATA_V2_TMP_FILE_NAME u".metadata-v2-tmp"
#define WEB_APPS_STORE_FILE_NAME "webappsstore.sqlite"
#define LS_ARCHIVE_FILE_NAME "ls-archive.sqlite"
#define LS_ARCHIVE_TMP_FILE_NAME "ls-archive-tmp.sqlite"
#define WEB_APPS_STORE_FILE_NAME u"webappsstore.sqlite"
#define LS_ARCHIVE_FILE_NAME u"ls-archive.sqlite"
#define LS_ARCHIVE_TMP_FILE_NAME u"ls-archive-tmp.sqlite"
const uint32_t kLocalStorageArchiveVersion = 4;
@ -510,7 +510,7 @@ nsresult GetLocalStorageArchiveFile(const nsAString& aDirectoryPath,
nsCOMPtr<nsIFile> lsArchiveFile = lsArchiveFileOrErr.unwrap();
nsresult rv = lsArchiveFile->Append(NS_LITERAL_STRING(LS_ARCHIVE_FILE_NAME));
nsresult rv = lsArchiveFile->Append(nsLiteralString(LS_ARCHIVE_FILE_NAME));
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
@ -533,7 +533,7 @@ nsresult GetLocalStorageArchiveTmpFile(const nsAString& aDirectoryPath,
nsCOMPtr<nsIFile> lsArchiveTmpFile = lsArchiveTempFileOrErr.unwrap();
nsresult rv =
lsArchiveTmpFile->Append(NS_LITERAL_STRING(LS_ARCHIVE_TMP_FILE_NAME));
lsArchiveTmpFile->Append(nsLiteralString(LS_ARCHIVE_TMP_FILE_NAME));
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
@ -2550,7 +2550,7 @@ nsresult CreateDirectoryMetadata(nsIFile* aDirectory, int64_t aTimestamp,
return rv;
}
rv = file->Append(NS_LITERAL_STRING(METADATA_TMP_FILE_NAME));
rv = file->Append(nsLiteralString(METADATA_TMP_FILE_NAME));
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
@ -2594,7 +2594,7 @@ nsresult CreateDirectoryMetadata(nsIFile* aDirectory, int64_t aTimestamp,
return rv;
}
rv = file->RenameTo(nullptr, NS_LITERAL_STRING(METADATA_FILE_NAME));
rv = file->RenameTo(nullptr, nsLiteralString(METADATA_FILE_NAME));
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
@ -2615,7 +2615,7 @@ nsresult CreateDirectoryMetadata2(nsIFile* aDirectory, int64_t aTimestamp,
return rv;
}
rv = file->Append(NS_LITERAL_STRING(METADATA_V2_TMP_FILE_NAME));
rv = file->Append(nsLiteralString(METADATA_V2_TMP_FILE_NAME));
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
@ -2684,7 +2684,7 @@ nsresult CreateDirectoryMetadata2(nsIFile* aDirectory, int64_t aTimestamp,
return rv;
}
rv = file->RenameTo(nullptr, NS_LITERAL_STRING(METADATA_V2_FILE_NAME));
rv = file->RenameTo(nullptr, nsLiteralString(METADATA_V2_FILE_NAME));
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
@ -3984,7 +3984,7 @@ nsresult QuotaManager::Init() {
nsCOMPtr<nsIFile> baseDir = baseDirOrErr.unwrap();
nsresult rv = CloneStoragePath(
baseDir, NS_LITERAL_STRING(INDEXEDDB_DIRECTORY_NAME), mIndexedDBPath);
baseDir, nsLiteralString(INDEXEDDB_DIRECTORY_NAME), mIndexedDBPath);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
@ -3999,19 +3999,19 @@ nsresult QuotaManager::Init() {
return rv;
}
rv = CloneStoragePath(baseDir, NS_LITERAL_STRING(PERMANENT_DIRECTORY_NAME),
rv = CloneStoragePath(baseDir, nsLiteralString(PERMANENT_DIRECTORY_NAME),
mPermanentStoragePath);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
rv = CloneStoragePath(baseDir, NS_LITERAL_STRING(TEMPORARY_DIRECTORY_NAME),
rv = CloneStoragePath(baseDir, nsLiteralString(TEMPORARY_DIRECTORY_NAME),
mTemporaryStoragePath);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
rv = CloneStoragePath(baseDir, NS_LITERAL_STRING(DEFAULT_DIRECTORY_NAME),
rv = CloneStoragePath(baseDir, nsLiteralString(DEFAULT_DIRECTORY_NAME),
mDefaultStoragePath);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
@ -4939,7 +4939,7 @@ nsresult QuotaManager::GetDirectoryMetadata2(
nsCOMPtr<nsIBinaryInputStream> binaryStream;
nsresult rv =
GetBinaryInputStream(aDirectory, NS_LITERAL_STRING(METADATA_V2_FILE_NAME),
GetBinaryInputStream(aDirectory, nsLiteralString(METADATA_V2_FILE_NAME),
getter_AddRefs(binaryStream));
NS_ENSURE_SUCCESS(rv, rv);
@ -5053,7 +5053,7 @@ nsresult QuotaManager::GetDirectoryMetadata2(nsIFile* aDirectory,
nsCOMPtr<nsIBinaryInputStream> binaryStream;
nsresult rv =
GetBinaryInputStream(aDirectory, NS_LITERAL_STRING(METADATA_V2_FILE_NAME),
GetBinaryInputStream(aDirectory, nsLiteralString(METADATA_V2_FILE_NAME),
getter_AddRefs(binaryStream));
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
@ -5371,8 +5371,7 @@ QuotaManager::UpgradeFromIndexedDBDirectoryToPersistentStorageDirectory(
nsCOMPtr<nsIFile> persistentStorageDir = persistentStorageDirOrErr.unwrap();
rv = persistentStorageDir->Append(
NS_LITERAL_STRING(PERSISTENT_DIRECTORY_NAME));
rv = persistentStorageDir->Append(nsLiteralString(PERSISTENT_DIRECTORY_NAME));
NS_ENSURE_SUCCESS(rv, rv);
bool exists;
@ -5401,7 +5400,7 @@ QuotaManager::UpgradeFromIndexedDBDirectoryToPersistentStorageDirectory(
// is on different volume, but it should be rare enough that we don't have
// to worry about it.
rv = aIndexedDBDir->MoveTo(storageDir,
NS_LITERAL_STRING(PERSISTENT_DIRECTORY_NAME));
nsLiteralString(PERSISTENT_DIRECTORY_NAME));
NS_ENSURE_SUCCESS(rv, rv);
return NS_OK;
@ -5493,8 +5492,8 @@ QuotaManager::UpgradeFromPersistentStorageDirectoryToDefaultStorageDirectory(
}
// And finally rename persistent to default.
rv = aPersistentStorageDir->RenameTo(
nullptr, NS_LITERAL_STRING(DEFAULT_DIRECTORY_NAME));
rv = aPersistentStorageDir->RenameTo(nullptr,
nsLiteralString(DEFAULT_DIRECTORY_NAME));
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
@ -5872,7 +5871,7 @@ nsresult QuotaManager::MaybeRemoveLocalStorageDirectories() {
return rv;
}
rv = lsDir->Append(NS_LITERAL_STRING(LS_DIRECTORY_NAME));
rv = lsDir->Append(NS_LITERAL_STRING_FROM_CSTRING(LS_DIRECTORY_NAME));
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
@ -5951,7 +5950,7 @@ nsresult QuotaManager::CreateLocalStorageArchiveConnectionFromWebAppsStore(
nsCOMPtr<nsIFile> webAppsStoreFile = webAppsStoreFileOrErr.unwrap();
rv = webAppsStoreFile->Append(NS_LITERAL_STRING(WEB_APPS_STORE_FILE_NAME));
rv = webAppsStoreFile->Append(nsLiteralString(WEB_APPS_STORE_FILE_NAME));
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
@ -6019,7 +6018,7 @@ nsresult QuotaManager::CreateLocalStorageArchiveConnectionFromWebAppsStore(
nsCOMPtr<nsIFile> storageDir = storageDirOrErr.unwrap();
rv = webAppsStoreFile->CopyTo(storageDir,
NS_LITERAL_STRING(LS_ARCHIVE_TMP_FILE_NAME));
nsLiteralString(LS_ARCHIVE_TMP_FILE_NAME));
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
@ -6056,7 +6055,7 @@ nsresult QuotaManager::CreateLocalStorageArchiveConnectionFromWebAppsStore(
// Finally, rename ls-archive-tmp.sqlite to ls-archive.sqlite
rv = lsArchiveTmpFile->MoveTo(nullptr,
NS_LITERAL_STRING(LS_ARCHIVE_FILE_NAME));
nsLiteralString(LS_ARCHIVE_FILE_NAME));
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
@ -6392,7 +6391,7 @@ nsresult QuotaManager::EnsureStorageIsInitialized() {
nsCOMPtr<nsIFile> persistentStorageDir = persistentStorageDirOrErr.unwrap();
rv = persistentStorageDir->Append(
NS_LITERAL_STRING(PERSISTENT_DIRECTORY_NAME));
nsLiteralString(PERSISTENT_DIRECTORY_NAME));
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
@ -8516,7 +8515,7 @@ nsresult SaveOriginAccessTimeOp::DoDirectoryWork(QuotaManager& aQuotaManager) {
return rv;
}
rv = file->Append(NS_LITERAL_STRING(METADATA_V2_FILE_NAME));
rv = file->Append(nsLiteralString(METADATA_V2_FILE_NAME));
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
@ -10224,7 +10223,7 @@ nsresult PersistOp::DoDirectoryWork(QuotaManager& aQuotaManager) {
return rv;
}
rv = file->Append(NS_LITERAL_STRING(METADATA_V2_FILE_NAME));
rv = file->Append(nsLiteralString(METADATA_V2_FILE_NAME));
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
@ -10498,7 +10497,7 @@ nsresult StorageOperationBase::GetDirectoryMetadata(nsIFile* aDirectory,
nsCOMPtr<nsIBinaryInputStream> binaryStream;
nsresult rv =
GetBinaryInputStream(aDirectory, NS_LITERAL_STRING(METADATA_FILE_NAME),
GetBinaryInputStream(aDirectory, nsLiteralString(METADATA_FILE_NAME),
getter_AddRefs(binaryStream));
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
@ -10543,7 +10542,7 @@ nsresult StorageOperationBase::GetDirectoryMetadata2(
nsCOMPtr<nsIBinaryInputStream> binaryStream;
nsresult rv =
GetBinaryInputStream(aDirectory, NS_LITERAL_STRING(METADATA_V2_FILE_NAME),
GetBinaryInputStream(aDirectory, nsLiteralString(METADATA_V2_FILE_NAME),
getter_AddRefs(binaryStream));
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
@ -11401,7 +11400,7 @@ nsresult CreateOrUpgradeDirectoryMetadataHelper::MaybeUpgradeOriginDirectory(
return rv;
}
rv = metadataFile->Append(NS_LITERAL_STRING(METADATA_FILE_NAME));
rv = metadataFile->Append(nsLiteralString(METADATA_FILE_NAME));
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
@ -11602,7 +11601,7 @@ nsresult CreateOrUpgradeDirectoryMetadataHelper::ProcessOriginDirectory(
return rv;
}
rv = file->Append(NS_LITERAL_STRING(METADATA_FILE_NAME));
rv = file->Append(nsLiteralString(METADATA_FILE_NAME));
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}

View File

@ -16,23 +16,25 @@ namespace script {
// This macro is used to wrap a tracing mechanism which is scheduling events
// which are then used by the JavaScript code of test cases to track the code
// path to verify the optimizations are working as expected.
#define TRACE_FOR_TEST(elem, str) \
PR_BEGIN_MACRO \
nsresult rv = NS_OK; \
rv = script::TestingDispatchEvent(elem, NS_LITERAL_STRING(str)); \
NS_ENSURE_SUCCESS(rv, rv); \
#define TRACE_FOR_TEST(elem, str) \
PR_BEGIN_MACRO \
nsresult rv = NS_OK; \
rv = \
script::TestingDispatchEvent(elem, NS_LITERAL_STRING_FROM_CSTRING(str)); \
NS_ENSURE_SUCCESS(rv, rv); \
PR_END_MACRO
#define TRACE_FOR_TEST_BOOL(elem, str) \
PR_BEGIN_MACRO \
nsresult rv = NS_OK; \
rv = script::TestingDispatchEvent(elem, NS_LITERAL_STRING(str)); \
NS_ENSURE_SUCCESS(rv, false); \
#define TRACE_FOR_TEST_BOOL(elem, str) \
PR_BEGIN_MACRO \
nsresult rv = NS_OK; \
rv = \
script::TestingDispatchEvent(elem, NS_LITERAL_STRING_FROM_CSTRING(str)); \
NS_ENSURE_SUCCESS(rv, false); \
PR_END_MACRO
#define TRACE_FOR_TEST_NONE(elem, str) \
PR_BEGIN_MACRO \
script::TestingDispatchEvent(elem, NS_LITERAL_STRING(str)); \
#define TRACE_FOR_TEST_NONE(elem, str) \
PR_BEGIN_MACRO \
script::TestingDispatchEvent(elem, NS_LITERAL_STRING_FROM_CSTRING(str)); \
PR_END_MACRO
static nsresult TestingDispatchEvent(nsIScriptElement* aScriptElement,

View File

@ -473,15 +473,17 @@ void nsCSPContext::reportInlineViolation(
// let's report the hash error; no need to report the unsafe-inline error
// anymore.
if (!aNonce.IsEmpty()) {
observerSubject =
(aContentType == nsIContentPolicy::TYPE_SCRIPT)
? NS_LITERAL_STRING(SCRIPT_NONCE_VIOLATION_OBSERVER_TOPIC)
: NS_LITERAL_STRING(STYLE_NONCE_VIOLATION_OBSERVER_TOPIC);
observerSubject = (aContentType == nsIContentPolicy::TYPE_SCRIPT)
? NS_LITERAL_STRING_FROM_CSTRING(
SCRIPT_NONCE_VIOLATION_OBSERVER_TOPIC)
: NS_LITERAL_STRING_FROM_CSTRING(
STYLE_NONCE_VIOLATION_OBSERVER_TOPIC);
} else {
observerSubject =
(aContentType == nsIContentPolicy::TYPE_SCRIPT)
? NS_LITERAL_STRING(SCRIPT_HASH_VIOLATION_OBSERVER_TOPIC)
: NS_LITERAL_STRING(STYLE_HASH_VIOLATION_OBSERVER_TOPIC);
observerSubject = (aContentType == nsIContentPolicy::TYPE_SCRIPT)
? NS_LITERAL_STRING_FROM_CSTRING(
SCRIPT_HASH_VIOLATION_OBSERVER_TOPIC)
: NS_LITERAL_STRING_FROM_CSTRING(
STYLE_HASH_VIOLATION_OBSERVER_TOPIC);
}
nsAutoString sourceFile;
@ -706,24 +708,24 @@ nsCSPContext::GetAllowsNavigateTo(nsIURI* aURI, bool aIsFormSubmission,
* GetAllowsInline() and do not call this macro, hence we can pass 'false'
* as the argument _aParserCreated_ to allows().
*/
#define CASE_CHECK_AND_REPORT(violationType, contentPolicyType, nonceOrHash, \
keyword, observerTopic) \
case nsIContentSecurityPolicy::VIOLATION_TYPE_##violationType: \
PR_BEGIN_MACRO \
if (!mPolicies[p]->allows(nsIContentPolicy::TYPE_##contentPolicyType, \
keyword, nonceOrHash, false)) { \
nsAutoString violatedDirective; \
bool reportSample = false; \
mPolicies[p]->getDirectiveStringAndReportSampleForContentType( \
nsIContentPolicy::TYPE_##contentPolicyType, violatedDirective, \
&reportSample); \
AsyncReportViolation(aTriggeringElement, aCSPEventListener, nullptr, \
blockedContentSource, nullptr, violatedDirective, \
p, NS_LITERAL_STRING(observerTopic), aSourceFile, \
reportSample ? aScriptSample : EmptyString(), \
aLineNum, aColumnNum); \
} \
PR_END_MACRO; \
#define CASE_CHECK_AND_REPORT(violationType, contentPolicyType, nonceOrHash, \
keyword, observerTopic) \
case nsIContentSecurityPolicy::VIOLATION_TYPE_##violationType: \
PR_BEGIN_MACRO \
if (!mPolicies[p]->allows(nsIContentPolicy::TYPE_##contentPolicyType, \
keyword, nonceOrHash, false)) { \
nsAutoString violatedDirective; \
bool reportSample = false; \
mPolicies[p]->getDirectiveStringAndReportSampleForContentType( \
nsIContentPolicy::TYPE_##contentPolicyType, violatedDirective, \
&reportSample); \
AsyncReportViolation( \
aTriggeringElement, aCSPEventListener, nullptr, \
blockedContentSource, nullptr, violatedDirective, p, \
NS_LITERAL_STRING_FROM_CSTRING(observerTopic), aSourceFile, \
reportSample ? aScriptSample : EmptyString(), aLineNum, aColumnNum); \
} \
PR_END_MACRO; \
break
/**

View File

@ -1348,7 +1348,7 @@ ServiceWorkerManager::SendNotificationClickEvent(
const nsAString& aLang, const nsAString& aBody, const nsAString& aTag,
const nsAString& aIcon, const nsAString& aData,
const nsAString& aBehavior) {
return SendNotificationEvent(NS_LITERAL_STRING(NOTIFICATION_CLICK_EVENT_NAME),
return SendNotificationEvent(nsLiteralString(NOTIFICATION_CLICK_EVENT_NAME),
aOriginSuffix, aScope, aID, aTitle, aDir, aLang,
aBody, aTag, aIcon, aData, aBehavior);
}
@ -1360,7 +1360,7 @@ ServiceWorkerManager::SendNotificationCloseEvent(
const nsAString& aLang, const nsAString& aBody, const nsAString& aTag,
const nsAString& aIcon, const nsAString& aData,
const nsAString& aBehavior) {
return SendNotificationEvent(NS_LITERAL_STRING(NOTIFICATION_CLOSE_EVENT_NAME),
return SendNotificationEvent(nsLiteralString(NOTIFICATION_CLOSE_EVENT_NAME),
aOriginSuffix, aScope, aID, aTitle, aDir, aLang,
aBody, aTag, aIcon, aData, aBehavior);
}

View File

@ -1239,7 +1239,7 @@ class FetchEventRunnable : public ExtendableFunctionalEventWorkerRunnable,
mRequestCredentials(RequestCredentials::Same_origin),
mContentPolicyType(nsIContentPolicy::TYPE_INVALID),
mUploadStreamContentLength(-1),
mReferrer(NS_LITERAL_STRING(kFETCH_CLIENT_REFERRER_STR)),
mReferrer(NS_LITERAL_STRING_FROM_CSTRING(kFETCH_CLIENT_REFERRER_STR)),
mReferrerPolicy(ReferrerPolicy::_empty),
mIsNonSubresourceRequest(aIsNonSubresourceRequest) {
MOZ_ASSERT(aWorkerPrivate);

View File

@ -13,8 +13,8 @@
#include "mozilla/dom/WorkerPrivate.h"
#include "mozilla/MozPromise.h"
#define NOTIFICATION_CLICK_EVENT_NAME "notificationclick"
#define NOTIFICATION_CLOSE_EVENT_NAME "notificationclose"
#define NOTIFICATION_CLICK_EVENT_NAME u"notificationclick"
#define NOTIFICATION_CLOSE_EVENT_NAME u"notificationclose"
class nsIInterceptedChannel;
class nsIWorkerDebugger;

View File

@ -362,7 +362,7 @@ nsresult ServiceWorkerRegistrar::ReadData() {
}
}
nsresult rv = file->Append(NS_LITERAL_STRING(SERVICEWORKERREGISTRAR_FILE));
nsresult rv = file->Append(nsLiteralString(SERVICEWORKERREGISTRAR_FILE));
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
@ -763,7 +763,7 @@ void ServiceWorkerRegistrar::DeleteData() {
}
}
nsresult rv = file->Append(NS_LITERAL_STRING(SERVICEWORKERREGISTRAR_FILE));
nsresult rv = file->Append(nsLiteralString(SERVICEWORKERREGISTRAR_FILE));
if (NS_WARN_IF(NS_FAILED(rv))) {
return;
}
@ -988,7 +988,7 @@ nsresult ServiceWorkerRegistrar::WriteData(
}
}
nsresult rv = file->Append(NS_LITERAL_STRING(SERVICEWORKERREGISTRAR_FILE));
nsresult rv = file->Append(nsLiteralString(SERVICEWORKERREGISTRAR_FILE));
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
@ -1112,8 +1112,8 @@ void ServiceWorkerRegistrar::ProfileStarted() {
nsAutoString blockerName;
MOZ_ALWAYS_SUCCEEDS(GetName(blockerName));
rv = GetShutdownPhase()->AddBlocker(this, NS_LITERAL_STRING(__FILE__),
__LINE__, blockerName);
rv = GetShutdownPhase()->AddBlocker(
this, NS_LITERAL_STRING_FROM_CSTRING(__FILE__), __LINE__, blockerName);
if (NS_WARN_IF(NS_FAILED(rv))) {
return;
}

View File

@ -16,7 +16,7 @@
#include "nsString.h"
#include "nsTArray.h"
#define SERVICEWORKERREGISTRAR_FILE "serviceworker.txt"
#define SERVICEWORKERREGISTRAR_FILE u"serviceworker.txt"
#define SERVICEWORKERREGISTRAR_VERSION "8"
#define SERVICEWORKERREGISTRAR_TERMINATOR "#"
#define SERVICEWORKERREGISTRAR_TRUE "true"

View File

@ -94,9 +94,9 @@ ServiceWorkerShutdownBlocker::CreateAndRegisterOn(
RefPtr<ServiceWorkerShutdownBlocker> blocker =
new ServiceWorkerShutdownBlocker();
nsresult rv =
aShutdownBarrier->AddBlocker(blocker.get(), NS_LITERAL_STRING(__FILE__),
__LINE__, u"Service Workers shutdown"_ns);
nsresult rv = aShutdownBarrier->AddBlocker(
blocker.get(), NS_LITERAL_STRING_FROM_CSTRING(__FILE__), __LINE__,
u"Service Workers shutdown"_ns);
if (NS_WARN_IF(NS_FAILED(rv))) {
return nullptr;

View File

@ -55,7 +55,7 @@ already_AddRefed<nsIFile> GetFile() {
return nullptr;
}
file->Append(NS_LITERAL_STRING(SERVICEWORKERREGISTRAR_FILE));
file->Append(nsLiteralString(SERVICEWORKERREGISTRAR_FILE));
return file.forget();
}

View File

@ -1179,7 +1179,7 @@ nsresult OpenOp::DatabaseWork() {
return rv;
}
rv = dbDirectory->Append(NS_LITERAL_STRING(SDB_DIRECTORY_NAME));
rv = dbDirectory->Append(NS_LITERAL_STRING_FROM_CSTRING(SDB_DIRECTORY_NAME));
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
@ -1661,7 +1661,7 @@ Result<UsageInfo, nsresult> QuotaClient::GetUsageForOrigin(
MOZ_ASSERT(directory);
rv = directory->Append(NS_LITERAL_STRING(SDB_DIRECTORY_NAME));
rv = directory->Append(NS_LITERAL_STRING_FROM_CSTRING(SDB_DIRECTORY_NAME));
if (NS_WARN_IF(NS_FAILED(rv))) {
return Err(rv);
}

View File

@ -46,7 +46,8 @@ const uint32_t kWrappedKeyBufLen = 256;
const uint32_t kWrappingKeyByteLen = 128 / 8;
const uint32_t kSaltByteLen = 64 / 8;
const uint32_t kVersion1KeyHandleLen = 162;
NS_NAMED_LITERAL_STRING(kEcAlgorithm, WEBCRYPTO_NAMED_CURVE_P256);
constexpr auto kEcAlgorithm =
NS_LITERAL_STRING_FROM_CSTRING(WEBCRYPTO_NAMED_CURVE_P256);
const PRTime kOneDay = PRTime(PR_USEC_PER_SEC) * PRTime(60) // sec
* PRTime(60) // min

View File

@ -79,7 +79,7 @@ void WorkerNavigator::GetAppName(nsString& aAppName,
// We will spoof this value when 'privacy.resistFingerprinting' is true.
// See nsRFPService.h for spoofed value.
aAppName = StaticPrefs::privacy_resistFingerprinting()
? NS_LITERAL_STRING(SPOOFED_APPNAME)
? NS_LITERAL_STRING_FROM_CSTRING(SPOOFED_APPNAME)
: mProperties.mAppNameOverridden;
} else {
aAppName = mProperties.mAppName;
@ -98,7 +98,7 @@ void WorkerNavigator::GetAppVersion(nsString& aAppVersion,
// We will spoof this value when 'privacy.resistFingerprinting' is true.
// See nsRFPService.h for spoofed value.
aAppVersion = StaticPrefs::privacy_resistFingerprinting()
? NS_LITERAL_STRING(SPOOFED_APPVERSION)
? NS_LITERAL_STRING_FROM_CSTRING(SPOOFED_APPVERSION)
: mProperties.mAppVersionOverridden;
} else {
aAppVersion = mProperties.mAppVersion;
@ -116,7 +116,7 @@ void WorkerNavigator::GetPlatform(nsString& aPlatform, CallerType aCallerType,
// We will spoof this value when 'privacy.resistFingerprinting' is true.
// See nsRFPService.h for spoofed value.
aPlatform = StaticPrefs::privacy_resistFingerprinting()
? NS_LITERAL_STRING(SPOOFED_PLATFORM)
? NS_LITERAL_STRING_FROM_CSTRING(SPOOFED_PLATFORM)
: mProperties.mPlatformOverridden;
} else {
aPlatform = mProperties.mPlatform;

View File

@ -131,22 +131,23 @@ Result<nsString, nsresult> RemoteWorkerManager::GetRemoteType(
"browser.tabs.remote.separatePrivilegedMozillaWebContentProcess", false);
if (isMozExtension) {
remoteType.Assign(NS_LITERAL_STRING(EXTENSION_REMOTE_TYPE));
remoteType.Assign(NS_LITERAL_STRING_FROM_CSTRING(EXTENSION_REMOTE_TYPE));
} else if (separatePrivilegedMozilla) {
bool isPrivilegedMozilla = false;
aPrincipal->IsURIInPrefList("browser.tabs.remote.separatedMozillaDomains",
&isPrivilegedMozilla);
if (isPrivilegedMozilla) {
remoteType.Assign(NS_LITERAL_STRING(PRIVILEGEDMOZILLA_REMOTE_TYPE));
remoteType.Assign(
NS_LITERAL_STRING_FROM_CSTRING(PRIVILEGEDMOZILLA_REMOTE_TYPE));
} else {
remoteType.Assign(aWorkerType == WorkerType::WorkerTypeShared &&
contentChild
? contentChild->GetRemoteType()
: NS_LITERAL_STRING(DEFAULT_REMOTE_TYPE));
remoteType.Assign(
aWorkerType == WorkerType::WorkerTypeShared && contentChild
? contentChild->GetRemoteType()
: NS_LITERAL_STRING_FROM_CSTRING(DEFAULT_REMOTE_TYPE));
}
} else {
remoteType.Assign(NS_LITERAL_STRING(DEFAULT_REMOTE_TYPE));
remoteType.Assign(NS_LITERAL_STRING_FROM_CSTRING(DEFAULT_REMOTE_TYPE));
}
return remoteType;
@ -586,9 +587,10 @@ void RemoteWorkerManager::LaunchNewContentProcess(
nsCOMPtr<nsIRunnable> r = NS_NewRunnableFunction(
__func__, [callback = std::move(processLaunchCallback),
workerRemoteType = aData.remoteType()]() mutable {
auto remoteType = workerRemoteType.IsEmpty()
? NS_LITERAL_STRING(DEFAULT_REMOTE_TYPE)
: workerRemoteType;
auto remoteType =
workerRemoteType.IsEmpty()
? NS_LITERAL_STRING_FROM_CSTRING(DEFAULT_REMOTE_TYPE)
: workerRemoteType;
ContentParent::GetNewOrUsedBrowserProcessAsync(
/* aFrameElement = */ nullptr,

View File

@ -17,38 +17,41 @@ TEST(RemoteWorkerManager, TestMatchRemoteType)
const bool shouldMatch;
} tests[] = {
// Test exact matches between process and worker remote types.
{NS_LITERAL_STRING(DEFAULT_REMOTE_TYPE),
NS_LITERAL_STRING(DEFAULT_REMOTE_TYPE), true},
{NS_LITERAL_STRING(EXTENSION_REMOTE_TYPE),
NS_LITERAL_STRING(EXTENSION_REMOTE_TYPE), true},
{NS_LITERAL_STRING(PRIVILEGEDMOZILLA_REMOTE_TYPE),
NS_LITERAL_STRING(PRIVILEGEDMOZILLA_REMOTE_TYPE), true},
{NS_LITERAL_STRING_FROM_CSTRING(DEFAULT_REMOTE_TYPE),
NS_LITERAL_STRING_FROM_CSTRING(DEFAULT_REMOTE_TYPE), true},
{NS_LITERAL_STRING_FROM_CSTRING(EXTENSION_REMOTE_TYPE),
NS_LITERAL_STRING_FROM_CSTRING(EXTENSION_REMOTE_TYPE), true},
{NS_LITERAL_STRING_FROM_CSTRING(PRIVILEGEDMOZILLA_REMOTE_TYPE),
NS_LITERAL_STRING_FROM_CSTRING(PRIVILEGEDMOZILLA_REMOTE_TYPE), true},
// Test workers with remoteType "web" not launched on non-web or coop+coep
// processes.
{NS_LITERAL_STRING(PRIVILEGEDMOZILLA_REMOTE_TYPE),
NS_LITERAL_STRING(DEFAULT_REMOTE_TYPE), false},
{NS_LITERAL_STRING(PRIVILEGEDABOUT_REMOTE_TYPE),
NS_LITERAL_STRING(DEFAULT_REMOTE_TYPE), false},
{NS_LITERAL_STRING(EXTENSION_REMOTE_TYPE),
NS_LITERAL_STRING(DEFAULT_REMOTE_TYPE), false},
{NS_LITERAL_STRING(FILE_REMOTE_TYPE),
NS_LITERAL_STRING(DEFAULT_REMOTE_TYPE), false},
{NS_LITERAL_STRING(WITH_COOP_COEP_REMOTE_TYPE_PREFIX),
NS_LITERAL_STRING(DEFAULT_REMOTE_TYPE), false},
{NS_LITERAL_STRING_FROM_CSTRING(PRIVILEGEDMOZILLA_REMOTE_TYPE),
NS_LITERAL_STRING_FROM_CSTRING(DEFAULT_REMOTE_TYPE), false},
{NS_LITERAL_STRING_FROM_CSTRING(PRIVILEGEDABOUT_REMOTE_TYPE),
NS_LITERAL_STRING_FROM_CSTRING(DEFAULT_REMOTE_TYPE), false},
{NS_LITERAL_STRING_FROM_CSTRING(EXTENSION_REMOTE_TYPE),
NS_LITERAL_STRING_FROM_CSTRING(DEFAULT_REMOTE_TYPE), false},
{NS_LITERAL_STRING_FROM_CSTRING(FILE_REMOTE_TYPE),
NS_LITERAL_STRING_FROM_CSTRING(DEFAULT_REMOTE_TYPE), false},
{NS_LITERAL_STRING_FROM_CSTRING(WITH_COOP_COEP_REMOTE_TYPE_PREFIX),
NS_LITERAL_STRING_FROM_CSTRING(DEFAULT_REMOTE_TYPE), false},
// Test workers with remoteType "web" launched in web child processes.
{NS_LITERAL_STRING(LARGE_ALLOCATION_REMOTE_TYPE),
NS_LITERAL_STRING(DEFAULT_REMOTE_TYPE), true},
{NS_LITERAL_STRING(FISSION_WEB_REMOTE_TYPE),
NS_LITERAL_STRING(DEFAULT_REMOTE_TYPE), true},
{NS_LITERAL_STRING_FROM_CSTRING(LARGE_ALLOCATION_REMOTE_TYPE),
NS_LITERAL_STRING_FROM_CSTRING(DEFAULT_REMOTE_TYPE), true},
{NS_LITERAL_STRING_FROM_CSTRING(FISSION_WEB_REMOTE_TYPE),
NS_LITERAL_STRING_FROM_CSTRING(DEFAULT_REMOTE_TYPE), true},
// Test empty remoteType default to "web" remoteType.
{NS_LITERAL_STRING(DEFAULT_REMOTE_TYPE), EmptyString(), true},
{NS_LITERAL_STRING(WITH_COOP_COEP_REMOTE_TYPE_PREFIX), EmptyString(),
{NS_LITERAL_STRING_FROM_CSTRING(DEFAULT_REMOTE_TYPE), EmptyString(),
true},
{NS_LITERAL_STRING_FROM_CSTRING(WITH_COOP_COEP_REMOTE_TYPE_PREFIX),
EmptyString(), false},
{NS_LITERAL_STRING_FROM_CSTRING(PRIVILEGEDMOZILLA_REMOTE_TYPE),
EmptyString(), false},
{NS_LITERAL_STRING_FROM_CSTRING(EXTENSION_REMOTE_TYPE), EmptyString(),
false},
{NS_LITERAL_STRING(PRIVILEGEDMOZILLA_REMOTE_TYPE), EmptyString(), false},
{NS_LITERAL_STRING(EXTENSION_REMOTE_TYPE), EmptyString(), false},
};
for (const auto& test : tests) {

View File

@ -760,39 +760,39 @@ extern nsresult TX_ConstructEXSLTFunction(nsAtom* aName, int32_t aNamespaceID,
}
extern bool TX_InitEXSLTFunction() {
#define EXSLT_FUNCS(NS, CLASS, ...) \
{ \
int32_t nsid = txNamespaceManager::getNamespaceID(NS_LITERAL_STRING(NS)); \
if (nsid == kNameSpaceID_Unknown) { \
return false; \
} \
MOZ_FOR_EACH(EXSLT_FUNC, (nsid, CLASS, ), (__VA_ARGS__)) \
#define EXSLT_FUNCS(NS, CLASS, ...) \
{ \
int32_t nsid = txNamespaceManager::getNamespaceID(nsLiteralString(NS)); \
if (nsid == kNameSpaceID_Unknown) { \
return false; \
} \
MOZ_FOR_EACH(EXSLT_FUNC, (nsid, CLASS, ), (__VA_ARGS__)) \
}
#define EXSLT_FUNC(NS, CLASS, ...) \
descriptTable[txEXSLTType::MOZ_ARG_1 __VA_ARGS__] = { \
MOZ_ARGS_AFTER_1 __VA_ARGS__, CLASS::Create, NS};
EXSLT_FUNCS("http://exslt.org/common", txEXSLTFunctionCall,
EXSLT_FUNCS(u"http://exslt.org/common", txEXSLTFunctionCall,
(NODE_SET, 1, 1, Expr::NODESET_RESULT, nsGkAtoms::nodeSet),
(OBJECT_TYPE, 1, 1, Expr::STRING_RESULT, nsGkAtoms::objectType))
EXSLT_FUNCS("http://exslt.org/dates-and-times", txEXSLTFunctionCall,
EXSLT_FUNCS(u"http://exslt.org/dates-and-times", txEXSLTFunctionCall,
(DATE_TIME, 0, 0, Expr::STRING_RESULT, nsGkAtoms::dateTime))
EXSLT_FUNCS("http://exslt.org/math", txEXSLTFunctionCall,
EXSLT_FUNCS(u"http://exslt.org/math", txEXSLTFunctionCall,
(MAX, 1, 1, Expr::NUMBER_RESULT, nsGkAtoms::max),
(MIN, 1, 1, Expr::NUMBER_RESULT, nsGkAtoms::min),
(HIGHEST, 1, 1, Expr::NODESET_RESULT, nsGkAtoms::highest),
(LOWEST, 1, 1, Expr::NODESET_RESULT, nsGkAtoms::lowest))
EXSLT_FUNCS("http://exslt.org/regular-expressions", txEXSLTRegExFunctionCall,
EXSLT_FUNCS(u"http://exslt.org/regular-expressions", txEXSLTRegExFunctionCall,
(MATCH, 2, 3, Expr::NODESET_RESULT, nsGkAtoms::match),
(REPLACE, 4, 4, Expr::STRING_RESULT, nsGkAtoms::replace),
(TEST, 2, 3, Expr::BOOLEAN_RESULT, nsGkAtoms::test))
EXSLT_FUNCS(
"http://exslt.org/sets", txEXSLTFunctionCall,
u"http://exslt.org/sets", txEXSLTFunctionCall,
(DIFFERENCE_, 2, 2, Expr::NODESET_RESULT, nsGkAtoms::difference),
(DISTINCT, 1, 1, Expr::NODESET_RESULT, nsGkAtoms::distinct),
(HAS_SAME_NODE, 2, 2, Expr::BOOLEAN_RESULT, nsGkAtoms::hasSameNode),
@ -800,7 +800,7 @@ extern bool TX_InitEXSLTFunction() {
(LEADING, 2, 2, Expr::NODESET_RESULT, nsGkAtoms::leading),
(TRAILING, 2, 2, Expr::NODESET_RESULT, nsGkAtoms::trailing))
EXSLT_FUNCS("http://exslt.org/strings", txEXSLTFunctionCall,
EXSLT_FUNCS(u"http://exslt.org/strings", txEXSLTFunctionCall,
(CONCAT, 1, 1, Expr::STRING_RESULT, nsGkAtoms::concat),
(SPLIT, 1, 2, Expr::STRING_RESULT, nsGkAtoms::split),
(TOKENIZE, 1, 2, Expr::STRING_RESULT, nsGkAtoms::tokenize))

View File

@ -162,7 +162,7 @@ nsresult txMozillaTextOutput::createResultDocument(Document* aSourceDocument,
if (!observer) {
int32_t namespaceID;
rv = nsContentUtils::NameSpaceManager()->RegisterNameSpace(
NS_LITERAL_STRING(kTXNameSpaceURI), namespaceID);
nsLiteralString(kTXNameSpaceURI), namespaceID);
NS_ENSURE_SUCCESS(rv, rv);
mTextParent =

View File

@ -561,7 +561,7 @@ nsresult txMozillaXMLOutput::createTxWrapper() {
int32_t namespaceID;
nsresult rv = nsContentUtils::NameSpaceManager()->RegisterNameSpace(
NS_LITERAL_STRING(kTXNameSpaceURI), namespaceID);
nsLiteralString(kTXNameSpaceURI), namespaceID);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<Element> wrapper =

View File

@ -9,7 +9,7 @@
#include "txCore.h"
#include "nsAtom.h"
#define kTXNameSpaceURI "http://www.mozilla.org/TransforMiix"
#define kTXNameSpaceURI u"http://www.mozilla.org/TransforMiix"
#define kTXWrapper "transformiix:result"
class txOutputFormat;

View File

@ -964,11 +964,12 @@ bool EditorEventListener::DragEventHasSupportingData(
// Plaintext editors only support dropping text. Otherwise, HTML and files
// can be dropped as well.
DataTransfer* dataTransfer = aDragEvent->GetDataTransfer();
return dataTransfer->HasType(NS_LITERAL_STRING(kTextMime)) ||
dataTransfer->HasType(NS_LITERAL_STRING(kMozTextInternal)) ||
return dataTransfer->HasType(NS_LITERAL_STRING_FROM_CSTRING(kTextMime)) ||
dataTransfer->HasType(
NS_LITERAL_STRING_FROM_CSTRING(kMozTextInternal)) ||
(!mEditorBase->IsPlaintextEditor() &&
(dataTransfer->HasType(NS_LITERAL_STRING(kHTMLMime)) ||
dataTransfer->HasType(NS_LITERAL_STRING(kFileMime))));
(dataTransfer->HasType(NS_LITERAL_STRING_FROM_CSTRING(kHTMLMime)) ||
dataTransfer->HasType(NS_LITERAL_STRING_FROM_CSTRING(kFileMime))));
}
bool EditorEventListener::CanInsertAtDropPosition(DragEvent* aDragEvent) {

View File

@ -1545,7 +1545,7 @@ EditActionResult HTMLEditor::HandleInsertText(
// don't change my selection in subtransactions
AutoTransactionsConserveSelection dontChangeMySelection(*this);
int32_t pos = 0;
NS_NAMED_LITERAL_STRING(newlineStr, LFSTR);
constexpr auto newlineStr = NS_LITERAL_STRING_FROM_CSTRING(LFSTR);
{
AutoTrackDOMPoint tracker(RangeUpdaterRef(), &pointToInsert);

View File

@ -1193,7 +1193,7 @@ nsresult HTMLEditor::BlobReader::OnResult(const nsACString& aResult) {
EditorDOMPoint pointToInsert(mPointToInsert);
rv = MOZ_KnownLive(mHTMLEditor)
->DoInsertHTMLWithContext(stuffToPaste, EmptyString(), EmptyString(),
NS_LITERAL_STRING(kFileMime),
NS_LITERAL_STRING_FROM_CSTRING(kFileMime),
sourceDocument, pointToInsert,
mDoDeleteSelection, mIsSafe, false);
NS_WARNING_ASSERTION(NS_SUCCEEDED(rv),
@ -1392,9 +1392,9 @@ nsresult HTMLEditor::InsertObject(const nsACString& aType, nsISupports* aObject,
AutoPlaceholderBatch treatAsOneTransaction(*this);
rv = DoInsertHTMLWithContext(stuffToPaste, EmptyString(), EmptyString(),
NS_LITERAL_STRING(kFileMime), aSourceDoc,
aPointToInsert, aDoDeleteSelection, aIsSafe,
false);
NS_LITERAL_STRING_FROM_CSTRING(kFileMime),
aSourceDoc, aPointToInsert, aDoDeleteSelection,
aIsSafe, false);
NS_WARNING_ASSERTION(
NS_SUCCEEDED(rv),
"HTMLEditor::DoInsertHTMLWithContext() failed, but ignored");
@ -1572,7 +1572,8 @@ nsresult HTMLEditor::InsertFromDataTransfer(DataTransfer* aDataTransfer,
return error.StealNSResult();
}
bool hasPrivateHTMLFlavor = types->Contains(NS_LITERAL_STRING(kHTMLContext));
bool hasPrivateHTMLFlavor =
types->Contains(NS_LITERAL_STRING_FROM_CSTRING(kHTMLContext));
bool isPlaintextEditor = IsPlaintextEditor();
bool isSafe = IsSafeToInsertData(aSourceDoc);
@ -1622,12 +1623,12 @@ nsresult HTMLEditor::InsertFromDataTransfer(DataTransfer* aDataTransfer,
// If we have our private HTML flavor, we will only use the fragment
// from the CF_HTML. The rest comes from the clipboard.
nsAutoString contextString, infoString;
GetStringFromDataTransfer(
aDataTransfer, NS_LITERAL_STRING_FROM_CSTRING(kHTMLContext),
aIndex, contextString);
GetStringFromDataTransfer(aDataTransfer,
NS_LITERAL_STRING(kHTMLContext), aIndex,
contextString);
GetStringFromDataTransfer(aDataTransfer,
NS_LITERAL_STRING(kHTMLInfo), aIndex,
infoString);
NS_LITERAL_STRING_FROM_CSTRING(kHTMLInfo),
aIndex, infoString);
nsresult rv = DoInsertHTMLWithContext(
cffragment, contextString, infoString, type, aSourceDoc,
aDroppedAt, aDoDeleteSelection, isSafe);
@ -1647,9 +1648,10 @@ nsresult HTMLEditor::InsertFromDataTransfer(DataTransfer* aDataTransfer,
nsAutoString text, contextString, infoString;
GetStringFromDataTransfer(aDataTransfer, type, aIndex, text);
GetStringFromDataTransfer(aDataTransfer,
NS_LITERAL_STRING(kHTMLContext), aIndex,
contextString);
GetStringFromDataTransfer(aDataTransfer, NS_LITERAL_STRING(kHTMLInfo),
NS_LITERAL_STRING_FROM_CSTRING(kHTMLContext),
aIndex, contextString);
GetStringFromDataTransfer(aDataTransfer,
NS_LITERAL_STRING_FROM_CSTRING(kHTMLInfo),
aIndex, infoString);
if (type.EqualsLiteral(kHTMLMime)) {
nsresult rv = DoInsertHTMLWithContext(text, contextString, infoString,

View File

@ -27,7 +27,7 @@
#include "nsUnicharInputStream.h"
#include "prio.h"
#define MOZ_PERSONAL_DICT_NAME "persdict.dat"
#define MOZ_PERSONAL_DICT_NAME u"persdict.dat"
/**
* This is the most braindead implementation of a personal dictionary possible.
@ -211,7 +211,7 @@ nsresult mozPersonalDictionary::LoadInternal() {
return NS_ERROR_FAILURE;
}
rv = mFile->Append(NS_LITERAL_STRING(MOZ_PERSONAL_DICT_NAME));
rv = mFile->Append(nsLiteralString(MOZ_PERSONAL_DICT_NAME));
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
@ -339,7 +339,7 @@ NS_IMETHODIMP mozPersonalDictionary::Save() {
getter_AddRefs(theFile));
if (NS_FAILED(res)) return res;
if (!theFile) return NS_ERROR_FAILURE;
res = theFile->Append(NS_LITERAL_STRING(MOZ_PERSONAL_DICT_NAME));
res = theFile->Append(nsLiteralString(MOZ_PERSONAL_DICT_NAME));
if (NS_FAILED(res)) return res;
nsCOMPtr<nsIEventTarget> target =

View File

@ -425,8 +425,8 @@ bool GLLibraryEGL::DoEnsureInitialized(bool forceAccel,
if (LoadLibrarySystem32(L"d3dcompiler_47.dll")) break;
# ifdef MOZ_D3DCOMPILER_VISTA_DLL
if (LoadLibraryForEGLOnWindows(
NS_LITERAL_STRING(MOZ_STRINGIFY(MOZ_D3DCOMPILER_VISTA_DLL))))
if (LoadLibraryForEGLOnWindows(NS_LITERAL_STRING_FROM_CSTRING(
MOZ_STRINGIFY(MOZ_D3DCOMPILER_VISTA_DLL))))
break;
# endif

View File

@ -283,8 +283,8 @@ bool DriverCrashGuard::UpdateBaseEnvironment() {
}
// Firefox properties.
changed |=
CheckAndUpdatePref("appVersion", NS_LITERAL_STRING(MOZ_APP_VERSION));
changed |= CheckAndUpdatePref(
"appVersion", NS_LITERAL_STRING_FROM_CSTRING(MOZ_APP_VERSION));
return changed;
}

View File

@ -261,7 +261,7 @@ void ScriptPreloader::StartCacheWrite() {
Unused << NS_NewNamedThread("SaveScripts", getter_AddRefs(mSaveThread), this);
nsCOMPtr<nsIAsyncShutdownClient> barrier = GetShutdownBarrier();
barrier->AddBlocker(this, NS_LITERAL_STRING(__FILE__), __LINE__,
barrier->AddBlocker(this, NS_LITERAL_STRING_FROM_CSTRING(__FILE__), __LINE__,
EmptyString());
}

View File

@ -166,7 +166,8 @@ NetworkConnectivityService::Observe(nsISupports* aSubject, const char* aTopic,
"network:captive-portal-connectivity");
observerService->RemoveObserver(this, NS_NETWORK_LINK_TOPIC);
} else if (!strcmp(aTopic, NS_NETWORK_LINK_TOPIC) &&
!NS_LITERAL_STRING(NS_NETWORK_LINK_DATA_UNKNOWN).Equals(aData)) {
!NS_LITERAL_STRING_FROM_CSTRING(NS_NETWORK_LINK_DATA_UNKNOWN)
.Equals(aData)) {
PerformChecks();
}

View File

@ -1355,11 +1355,12 @@ bool DocumentLoadListener::MaybeTriggerProcessSwitch(
browsingContext->Group()->Toplevels().Length() == 1) {
if (IsLargeAllocationLoad(browsingContext, mChannel)) {
preferredRemoteType.Assign(
NS_LITERAL_STRING(LARGE_ALLOCATION_REMOTE_TYPE));
NS_LITERAL_STRING_FROM_CSTRING(LARGE_ALLOCATION_REMOTE_TYPE));
isLargeAllocSwitch = true;
} else if (preferredRemoteType.EqualsLiteral(
LARGE_ALLOCATION_REMOTE_TYPE)) {
preferredRemoteType.Assign(NS_LITERAL_STRING(DEFAULT_REMOTE_TYPE));
preferredRemoteType.Assign(
NS_LITERAL_STRING_FROM_CSTRING(DEFAULT_REMOTE_TYPE));
isLargeAllocSwitch = true;
}
}
@ -1371,13 +1372,13 @@ bool DocumentLoadListener::MaybeTriggerProcessSwitch(
// high-resolution timers.
nsAutoCString siteOrigin;
resultPrincipal->GetSiteOrigin(siteOrigin);
preferredRemoteType.Assign(
NS_LITERAL_STRING(WITH_COOP_COEP_REMOTE_TYPE_PREFIX));
preferredRemoteType.AssignLiteral(WITH_COOP_COEP_REMOTE_TYPE_PREFIX);
preferredRemoteType.Append(NS_ConvertUTF8toUTF16(siteOrigin));
} else if (isCOOPSwitch) {
// If we're doing a COOP switch, we do not need any affinity to the current
// remote type. Clear it back to the default value.
preferredRemoteType.Assign(NS_LITERAL_STRING(DEFAULT_REMOTE_TYPE));
preferredRemoteType.Assign(
NS_LITERAL_STRING_FROM_CSTRING(DEFAULT_REMOTE_TYPE));
}
MOZ_DIAGNOSTIC_ASSERT(!contentParent || !preferredRemoteType.IsEmpty(),
"Unexpected empty remote type!");

View File

@ -30,7 +30,7 @@
#include "nsTreeSanitizer.h"
#include "nsXPCOM.h"
#define XHTML_DIV_TAG "div xmlns=\"http://www.w3.org/1999/xhtml\""
#define XHTML_DIV_TAG u"div xmlns=\"http://www.w3.org/1999/xhtml\""
using namespace mozilla::dom;
@ -99,7 +99,7 @@ nsParserUtils::ParseFragment(const nsAString& aFragment, uint32_t aFlags,
RefPtr<DocumentFragment> fragment;
if (aIsXML) {
// XHTML
tagStack.AppendElement(NS_LITERAL_STRING(XHTML_DIV_TAG));
tagStack.AppendElement(nsLiteralString(XHTML_DIV_TAG));
rv = nsContentUtils::ParseFragmentXML(aFragment, document, tagStack, true,
aFlags, getter_AddRefs(fragment));
} else {

View File

@ -202,7 +202,7 @@ already_AddRefed<DataStorage> DataStorage::Get(DataStorageClass aFilename) {
switch (aFilename) {
#define DATA_STORAGE(_) \
case DataStorageClass::_: \
return GetFromRawFileName(NS_LITERAL_STRING(#_ ".txt"));
return GetFromRawFileName(NS_LITERAL_STRING_FROM_CSTRING(#_ ".txt"));
#include "mozilla/DataStorageList.h"
#undef DATA_STORAGE
default:
@ -233,7 +233,8 @@ void DataStorage::GetAllFileNames(nsTArray<nsString>& aItems) {
if (!sDataStorages) {
return;
}
#define DATA_STORAGE(_) aItems.AppendElement(NS_LITERAL_STRING(#_ ".txt"));
#define DATA_STORAGE(_) \
aItems.AppendElement(NS_LITERAL_STRING_FROM_CSTRING(#_ ".txt"));
#include "mozilla/DataStorageList.h"
#undef DATA_STORAGE
}
@ -274,17 +275,17 @@ void DataStorage::SetCachedStorageEntries(
// about updating the algorithm here to something more fancy if the list
// of DataStorage items grows some day.
nsTArray<psm::DataStorageEntry> entries;
#define DATA_STORAGE(_) \
{ \
psm::DataStorageEntry entry; \
entry.filename() = NS_LITERAL_STRING(#_ ".txt"); \
for (auto& e : aEntries) { \
if (entry.filename().Equals(e.filename())) { \
entry.items() = e.items().Clone(); \
break; \
} \
} \
entries.AppendElement(std::move(entry)); \
#define DATA_STORAGE(_) \
{ \
psm::DataStorageEntry entry; \
entry.filename() = NS_LITERAL_STRING_FROM_CSTRING(#_ ".txt"); \
for (auto& e : aEntries) { \
if (entry.filename().Equals(e.filename())) { \
entry.items() = e.items().Clone(); \
break; \
} \
} \
entries.AppendElement(std::move(entry)); \
}
#include "mozilla/DataStorageList.h"
#undef DATA_STORAGE

View File

@ -161,7 +161,7 @@ nsresult nsCertOverrideService::Init() {
}
nsresult rv = GetShutdownBarrier()->AddBlocker(
this, NS_LITERAL_STRING(__FILE__), __LINE__,
this, NS_LITERAL_STRING_FROM_CSTRING(__FILE__), __LINE__,
u"nsCertOverrideService shutdown"_ns);
// If that failed, we're likely getting initialized during shutdown.
NS_ENSURE_SUCCESS(rv, rv);

View File

@ -473,7 +473,7 @@ nsresult Database::Init() {
if (shutdownPhase) {
DebugOnly<nsresult> rv = shutdownPhase->AddBlocker(
static_cast<nsIAsyncShutdownBlocker*>(mClientsShutdown.get()),
NS_LITERAL_STRING(__FILE__), __LINE__, u""_ns);
NS_LITERAL_STRING_FROM_CSTRING(__FILE__), __LINE__, u""_ns);
MOZ_ASSERT(NS_SUCCEEDED(rv));
}
}
@ -486,7 +486,7 @@ nsresult Database::Init() {
if (shutdownPhase) {
DebugOnly<nsresult> rv = shutdownPhase->AddBlocker(
static_cast<nsIAsyncShutdownBlocker*>(mConnectionShutdown.get()),
NS_LITERAL_STRING(__FILE__), __LINE__, u""_ns);
NS_LITERAL_STRING_FROM_CSTRING(__FILE__), __LINE__, u""_ns);
MOZ_ASSERT(NS_SUCCEEDED(rv));
}
}

View File

@ -266,8 +266,8 @@ void test_RegisterVisitedCallback_returns_before_notifying() {
}
namespace test_observer_topic_dispatched_helpers {
#define URI_VISITED "visited"
#define URI_NOT_VISITED "not visited"
#define URI_VISITED u"visited"
#define URI_NOT_VISITED u"not visited"
#define URI_VISITED_RESOLUTION_TOPIC "visited-status-resolution"
class statusObserver final : public nsIObserver {
~statusObserver() = default;
@ -301,8 +301,8 @@ class statusObserver final : public nsIObserver {
}
// Check that we have either the visited or not visited string.
bool visited = !!NS_LITERAL_STRING(URI_VISITED).Equals(aData);
bool notVisited = !!NS_LITERAL_STRING(URI_NOT_VISITED).Equals(aData);
bool visited = !!nsLiteralString(URI_VISITED).Equals(aData);
bool notVisited = !!nsLiteralString(URI_NOT_VISITED).Equals(aData);
do_check_true(visited || notVisited);
// Check to make sure we got the state we expected.

View File

@ -902,7 +902,7 @@ void nsRFPService::MaybeCreateSpoofingKeyCodesForEnUS() {
static const SpoofingKeyboardInfo spoofingKeyboardInfoTable[] = {
#define KEY(key_, _codeNameIdx, _keyCode, _modifier) \
{KEY_NAME_INDEX_USE_STRING, \
NS_LITERAL_STRING(key_), \
NS_LITERAL_STRING_FROM_CSTRING(key_), \
{CODE_NAME_INDEX_##_codeNameIdx, _keyCode, _modifier}},
#define CONTROL(keyNameIdx_, _codeNameIdx, _keyCode) \
{KEY_NAME_INDEX_##keyNameIdx_, \

View File

@ -132,7 +132,7 @@ TEST_F(TelemetryTestFixture, ScalarString) {
// Set the test scalar to a known value.
Telemetry::ScalarSet(Telemetry::ScalarID::TELEMETRY_TEST_STRING_KIND,
NS_LITERAL_STRING(EXPECTED_STRING));
NS_LITERAL_STRING_FROM_CSTRING(EXPECTED_STRING));
// Make sure that calls of the unsupported type don't corrupt the stored value.
// Don't run this part in debug builds as that intentionally asserts.
@ -400,7 +400,7 @@ TEST_F(TelemetryTestFixture, WrongScalarOperator) {
Telemetry::ScalarSet(Telemetry::ScalarID::TELEMETRY_TEST_UNSIGNED_INT_KIND,
expectedValue);
Telemetry::ScalarSet(Telemetry::ScalarID::TELEMETRY_TEST_STRING_KIND,
NS_LITERAL_STRING(EXPECTED_STRING));
NS_LITERAL_STRING_FROM_CSTRING(EXPECTED_STRING));
Telemetry::ScalarSet(Telemetry::ScalarID::TELEMETRY_TEST_BOOLEAN_KIND, true);
TelemetryScalar::DeserializationStarted();

View File

@ -130,7 +130,7 @@ AddonContentPolicy::ShouldLoad(nsIURI* aContentLocation, nsILoadInfo* aLoadInfo,
NS_ConvertUTF8toUTF16 nameString(sourceName);
nsCOMPtr<nsISupports> context = aLoadInfo->GetLoadingContext();
LogMessage(NS_LITERAL_STRING(VERSIONED_JS_BLOCKED_MESSAGE), nameString,
LogMessage(nsLiteralString(VERSIONED_JS_BLOCKED_MESSAGE), nameString,
typeString, context);
return NS_OK;
}

View File

@ -844,7 +844,7 @@ nsXULAppInfo::EnsureContentProcess() {
if (!XRE_IsParentProcess()) return NS_ERROR_NOT_AVAILABLE;
RefPtr<ContentParent> unused = ContentParent::GetNewOrUsedBrowserProcess(
nullptr, NS_LITERAL_STRING(DEFAULT_REMOTE_TYPE));
nullptr, NS_LITERAL_STRING_FROM_CSTRING(DEFAULT_REMOTE_TYPE));
return NS_OK;
}

View File

@ -948,7 +948,7 @@ TestShellParent* GetOrCreateTestShellParent() {
// chrome mochitest where you can have multiple types of content
// processes.
RefPtr<ContentParent> parent = ContentParent::GetNewOrUsedBrowserProcess(
nullptr, NS_LITERAL_STRING(DEFAULT_REMOTE_TYPE));
nullptr, NS_LITERAL_STRING_FROM_CSTRING(DEFAULT_REMOTE_TYPE));
parent.forget(&gContentParent);
} else if (!gContentParent->IsAlive()) {
return nullptr;

View File

@ -147,7 +147,8 @@ nsresult GfxDeviceFamily::Contains(nsAString& aDeviceId) const {
// Macros for appending a device to the DeviceFamily.
#define APPEND_DEVICE(device) APPEND_DEVICE2(#device)
#define APPEND_DEVICE2(device) deviceFamily->Append(NS_LITERAL_STRING(device))
#define APPEND_DEVICE2(device) \
deviceFamily->Append(NS_LITERAL_STRING_FROM_CSTRING(device))
#define APPEND_RANGE(start, end) deviceFamily->AppendRange(start, end)
const GfxDeviceFamily* GfxDriverInfo::GetDeviceFamily(DeviceFamily id) {

View File

@ -16,8 +16,9 @@ namespace jni {
nsTArray<jni::String::LocalRef> _##name##_keys; \
nsTArray<jni::Object::LocalRef> _##name##_values;
#define GECKOBUNDLE_PUT(name, key, value) \
_##name##_keys.AppendElement(jni::StringParam(NS_LITERAL_STRING(key))); \
#define GECKOBUNDLE_PUT(name, key, value) \
_##name##_keys.AppendElement( \
jni::StringParam(NS_LITERAL_STRING_FROM_CSTRING(key))); \
_##name##_values.AppendElement(value);
#define GECKOBUNDLE_FINISH(name) \

View File

@ -431,12 +431,14 @@ nsresult nsMacUtilsImpl::GetRepoDir(nsIFile** aRepoDir) {
#if defined(MOZ_SANDBOX)
MOZ_ASSERT(mozilla::IsDevelopmentBuild());
#endif
return GetDirFromBundlePlist(NS_LITERAL_STRING(MAC_DEV_REPO_KEY), aRepoDir);
return GetDirFromBundlePlist(NS_LITERAL_STRING_FROM_CSTRING(MAC_DEV_REPO_KEY),
aRepoDir);
}
nsresult nsMacUtilsImpl::GetObjDir(nsIFile** aObjDir) {
#if defined(MOZ_SANDBOX)
MOZ_ASSERT(mozilla::IsDevelopmentBuild());
#endif
return GetDirFromBundlePlist(NS_LITERAL_STRING(MAC_DEV_OBJ_KEY), aObjDir);
return GetDirFromBundlePlist(NS_LITERAL_STRING_FROM_CSTRING(MAC_DEV_OBJ_KEY),
aObjDir);
}

View File

@ -1024,7 +1024,7 @@ nsresult nsSystemInfo::Init() {
// This version will need to be updated whenever there is a new official
// Android release. Search for "kDefaultAndroidMajorVersion" in:
// https://source.chromium.org/chromium/chromium/src/+/master:base/system/sys_info_android.cc
# define DEFAULT_ANDROID_VERSION "10.0.99"
# define DEFAULT_ANDROID_VERSION u"10.0.99"
/* static */
void nsSystemInfo::GetAndroidSystemInfo(AndroidSystemInfo* aInfo) {
@ -1052,7 +1052,7 @@ void nsSystemInfo::GetAndroidSystemInfo(AndroidSystemInfo* aInfo) {
int num_read = sscanf(NS_ConvertUTF16toUTF8(str).get(), "%d.%d.%d",
&major_version, &minor_version, &bugfix_version);
if (num_read == 0) {
aInfo->release_version() = NS_LITERAL_STRING(DEFAULT_ANDROID_VERSION);
aInfo->release_version() = nsLiteralString(DEFAULT_ANDROID_VERSION);
} else {
aInfo->release_version() = str;
}

View File

@ -316,7 +316,7 @@ static nsresult GetLowIntegrityTempBase(nsIFile** aLowIntegrityTempBase) {
return rv;
}
rv = localFile->Append(NS_LITERAL_STRING(MOZ_USER_DIR));
rv = localFile->Append(NS_LITERAL_STRING_FROM_CSTRING(MOZ_USER_DIR));
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}

View File

@ -14,6 +14,12 @@
#include "mozilla/Char16.h"
#define NS_CSTRING_LITERAL_AS_STRING_LITERAL(s) u"" s
#define NS_LITERAL_STRING_FROM_CSTRING(s) \
static_cast<const nsLiteralString&>( \
nsLiteralString(NS_CSTRING_LITERAL_AS_STRING_LITERAL(s)))
#define NS_LITERAL_STRING(s) \
static_cast<const nsLiteralString&>(nsLiteralString(u"" s))
#define NS_NAMED_LITERAL_STRING(n, s) const nsLiteralString n(u"" s)

View File

@ -251,6 +251,21 @@ class nsTStringRepr {
return EqualsASCII(aStr, N - 1);
}
// EqualsLiteral must ONLY be called with an actual literal string, or
// a char array *constant* declared without an explicit size and with an
// initializer that is a string literal or is otherwise null-terminated.
// Use EqualsASCII for other char array variables.
// (Although this method may happen to produce expected results for other
// char arrays that have bound one greater than the sequence of interest,
// such use is discouraged for reasons of readability and maintainability.)
// The template trick to acquire the array bound at compile time without
// using a macro is due to Corey Kosak, with much thanks.
template <size_t N, typename = std::enable_if_t<!std::is_same_v<
const char (&)[N], const char_type (&)[N]>>>
inline bool EqualsLiteral(const char_type (&aStr)[N]) const {
return *this == nsTLiteralString<char_type>(aStr);
}
// The LowerCaseEquals methods compare the ASCII-lowercase version of
// this string (lowercasing only ASCII uppercase characters) to some
// ASCII/Literal string. The ASCII string is *not* lowercased for