mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 03:15:11 +00:00
Bug 1294616 - Somewhat improve the string performance by defining string literals whose length is known at compile time. r=cpearce
MozReview-Commit-ID: LAlqMDtGQN7 --HG-- extra : rebase_source : 4f2cdc9cb9ee7e4dd024d47dad329304f6ba70ae extra : source : 6db22a524b1452fc50bf56535e7c619a8441dcfe
This commit is contained in:
parent
35df0a4ddc
commit
d13f41c2a0
@ -40,9 +40,9 @@ using mozilla::CheckedUint32;
|
||||
namespace mozilla {
|
||||
|
||||
// EME Key System String.
|
||||
static const char* const kEMEKeySystemClearkey = "org.w3.clearkey";
|
||||
static const char* const kEMEKeySystemWidevine = "com.widevine.alpha";
|
||||
static const char* const kEMEKeySystemPrimetime = "com.adobe.primetime";
|
||||
static NS_NAMED_LITERAL_CSTRING(kEMEKeySystemClearkey, "org.w3.clearkey");
|
||||
static NS_NAMED_LITERAL_CSTRING(kEMEKeySystemWidevine, "com.widevine.alpha");
|
||||
static NS_NAMED_LITERAL_CSTRING(kEMEKeySystemPrimetime, "com.adobe.primetime");
|
||||
|
||||
/**
|
||||
* ReentrantMonitorConditionallyEnter
|
||||
|
@ -135,13 +135,13 @@ CopyArrayBufferViewOrArrayBufferData(const dom::ArrayBufferViewOrArrayBuffer& aB
|
||||
nsString
|
||||
KeySystemToGMPName(const nsAString& aKeySystem)
|
||||
{
|
||||
if (aKeySystem.EqualsASCII(kEMEKeySystemPrimetime)) {
|
||||
if (!CompareUTF8toUTF16(kEMEKeySystemPrimetime, aKeySystem)) {
|
||||
return NS_LITERAL_STRING("gmp-eme-adobe");
|
||||
}
|
||||
if (aKeySystem.EqualsASCII(kEMEKeySystemClearkey)) {
|
||||
if (!CompareUTF8toUTF16(kEMEKeySystemClearkey, aKeySystem)) {
|
||||
return NS_LITERAL_STRING("gmp-clearkey");
|
||||
}
|
||||
if (aKeySystem.EqualsASCII(kEMEKeySystemWidevine)) {
|
||||
if (!CompareUTF8toUTF16(kEMEKeySystemWidevine, aKeySystem)) {
|
||||
return NS_LITERAL_STRING("gmp-widevinecdm");
|
||||
}
|
||||
MOZ_ASSERT(false, "We should only call this for known GMPs");
|
||||
@ -151,7 +151,7 @@ KeySystemToGMPName(const nsAString& aKeySystem)
|
||||
bool
|
||||
IsClearkeyKeySystem(const nsAString& aKeySystem)
|
||||
{
|
||||
return aKeySystem.EqualsASCII(kEMEKeySystemClearkey);
|
||||
return !CompareUTF8toUTF16(kEMEKeySystemClearkey, aKeySystem);
|
||||
}
|
||||
|
||||
} // namespace mozilla
|
||||
|
@ -191,7 +191,7 @@ MediaKeySystemAccess::IsGMPPresentOnDisk(const nsAString& aKeySystem,
|
||||
bool isPresent = true;
|
||||
|
||||
#if XP_WIN
|
||||
if (aKeySystem.EqualsASCII(kEMEKeySystemPrimetime)) {
|
||||
if (!CompareUTF8toUTF16(kEMEKeySystemPrimetime, aKeySystem)) {
|
||||
if (!AdobePluginDLLExists(aVersion)) {
|
||||
NS_WARNING("Adobe EME plugin disappeared from disk!");
|
||||
aOutMessage = NS_LITERAL_CSTRING("Adobe DLL was expected to be on disk but was not");
|
||||
@ -276,12 +276,12 @@ MediaKeySystemAccess::GetKeySystemStatus(const nsAString& aKeySystem,
|
||||
return MediaKeySystemStatus::Error;
|
||||
}
|
||||
|
||||
if (aKeySystem.EqualsASCII(kEMEKeySystemClearkey)) {
|
||||
if (!CompareUTF8toUTF16(kEMEKeySystemClearkey, aKeySystem)) {
|
||||
return EnsureMinCDMVersion(mps, aKeySystem, aMinCdmVersion, aOutMessage, aOutCdmVersion);
|
||||
}
|
||||
|
||||
if (Preferences::GetBool("media.gmp-eme-adobe.visible", false)) {
|
||||
if (aKeySystem.EqualsASCII(kEMEKeySystemPrimetime)) {
|
||||
if (!CompareUTF8toUTF16(kEMEKeySystemPrimetime, aKeySystem)) {
|
||||
if (!Preferences::GetBool("media.gmp-eme-adobe.enabled", false)) {
|
||||
aOutMessage = NS_LITERAL_CSTRING("Adobe EME disabled");
|
||||
return MediaKeySystemStatus::Cdm_disabled;
|
||||
@ -298,7 +298,7 @@ MediaKeySystemAccess::GetKeySystemStatus(const nsAString& aKeySystem,
|
||||
}
|
||||
|
||||
if (Preferences::GetBool("media.gmp-widevinecdm.visible", false)) {
|
||||
if (aKeySystem.EqualsASCII(kEMEKeySystemWidevine)) {
|
||||
if (!CompareUTF8toUTF16(kEMEKeySystemWidevine, aKeySystem)) {
|
||||
#ifdef XP_WIN
|
||||
// Win Vista and later only.
|
||||
if (!IsVistaOrLater()) {
|
||||
@ -563,7 +563,7 @@ CanDecryptAndDecode(mozIGeckoMediaPluginService* aGMPService,
|
||||
// the Adobe GMP's unencrypted AAC decoding path being used to
|
||||
// decode content decrypted by the Widevine CDM.
|
||||
if (codec == GMP_CODEC_AAC &&
|
||||
aKeySystem.EqualsASCII(kEMEKeySystemWidevine) &&
|
||||
!CompareUTF8toUTF16(kEMEKeySystemWidevine, aKeySystem) &&
|
||||
!WMFDecoderModule::HasAAC()) {
|
||||
if (aDiagnostics) {
|
||||
aDiagnostics->SetKeySystemIssue(
|
||||
@ -1130,7 +1130,7 @@ GetSupportedConfig(mozIGeckoMediaPluginService* aGMPService,
|
||||
#if defined(XP_WIN)
|
||||
// Widevine CDM doesn't include an AAC decoder. So if WMF can't decode AAC,
|
||||
// and a codec wasn't specified, be conservative and reject the MediaKeys request.
|
||||
if (aKeySystem.mKeySystem.EqualsASCII(kEMEKeySystemWidevine) &&
|
||||
if (!CompareUTF8toUTF16(kEMEKeySystemWidevine, aKeySystem.mKeySystem) &&
|
||||
(aCandidate.mAudioCapabilities.IsEmpty() ||
|
||||
aCandidate.mVideoCapabilities.IsEmpty()) &&
|
||||
!WMFDecoderModule::HasAAC()) {
|
||||
|
@ -142,8 +142,8 @@ MediaKeySystemAccessManager::Request(DetailedPromise* aPromise,
|
||||
|
||||
if ((status == MediaKeySystemStatus::Cdm_not_installed ||
|
||||
status == MediaKeySystemStatus::Cdm_insufficient_version) &&
|
||||
(keySystem.EqualsASCII(kEMEKeySystemPrimetime) ||
|
||||
keySystem.EqualsASCII(kEMEKeySystemWidevine))) {
|
||||
(!CompareUTF8toUTF16(kEMEKeySystemPrimetime, keySystem) ||
|
||||
!CompareUTF8toUTF16(kEMEKeySystemWidevine, keySystem))) {
|
||||
// These are cases which could be resolved by downloading a new(er) CDM.
|
||||
// When we send the status to chrome, chrome's GMPProvider will attempt to
|
||||
// download or update the CDM. In AwaitInstall() we add listeners to wait
|
||||
|
@ -899,7 +899,7 @@ GMPParent::ReadGMPInfoFile(nsIFile* aFile)
|
||||
// Adobe GMP doesn't work without SSE2. Check the tags to see if
|
||||
// the decryptor is for the Adobe GMP, and refuse to load it if
|
||||
// SSE2 isn't supported.
|
||||
if (cap.mAPITags.Contains(nsCString(kEMEKeySystemPrimetime)) &&
|
||||
if (cap.mAPITags.Contains(kEMEKeySystemPrimetime) &&
|
||||
!mozilla::supports_sse2()) {
|
||||
return GenericPromise::CreateAndReject(NS_ERROR_FAILURE, __func__);
|
||||
}
|
||||
@ -956,11 +956,11 @@ GMPParent::ParseChromiumManifest(nsString aJSON)
|
||||
video.mAPITags.AppendElement(NS_LITERAL_CSTRING("h264"));
|
||||
video.mAPITags.AppendElement(NS_LITERAL_CSTRING("vp8"));
|
||||
video.mAPITags.AppendElement(NS_LITERAL_CSTRING("vp9"));
|
||||
video.mAPITags.AppendElement(nsCString(kEMEKeySystemWidevine));
|
||||
video.mAPITags.AppendElement(kEMEKeySystemWidevine);
|
||||
mCapabilities.AppendElement(Move(video));
|
||||
|
||||
GMPCapability decrypt(NS_LITERAL_CSTRING(GMP_API_DECRYPTOR));
|
||||
decrypt.mAPITags.AppendElement(nsCString(kEMEKeySystemWidevine));
|
||||
decrypt.mAPITags.AppendElement(kEMEKeySystemWidevine);
|
||||
mCapabilities.AppendElement(Move(decrypt));
|
||||
|
||||
MOZ_ASSERT(mName.EqualsLiteral("widevinecdm"));
|
||||
|
@ -110,8 +110,8 @@ WidevineAdapter::GMPGetAPI(const char* aAPIName,
|
||||
|
||||
auto cdm = reinterpret_cast<cdm::ContentDecryptionModule*>(
|
||||
create(cdm::ContentDecryptionModule::kVersion,
|
||||
kEMEKeySystemWidevine,
|
||||
strlen(kEMEKeySystemWidevine),
|
||||
kEMEKeySystemWidevine.get(),
|
||||
kEMEKeySystemWidevine.Length(),
|
||||
&GetCdmHost,
|
||||
decryptor));
|
||||
if (!cdm) {
|
||||
|
@ -142,7 +142,7 @@ HasGMPFor(const nsACString& aAPI,
|
||||
StaticMutex sGMPCodecsMutex;
|
||||
|
||||
struct GMPCodecs {
|
||||
const char* mKeySystem;
|
||||
const nsLiteralCString mKeySystem;
|
||||
bool mHasAAC;
|
||||
bool mHasH264;
|
||||
bool mHasVP8;
|
||||
@ -164,16 +164,16 @@ GMPDecoderModule::UpdateUsableCodecs()
|
||||
for (GMPCodecs& gmp : sGMPCodecs) {
|
||||
gmp.mHasAAC = HasGMPFor(NS_LITERAL_CSTRING(GMP_API_AUDIO_DECODER),
|
||||
NS_LITERAL_CSTRING("aac"),
|
||||
nsDependentCString(gmp.mKeySystem));
|
||||
gmp.mKeySystem);
|
||||
gmp.mHasH264 = HasGMPFor(NS_LITERAL_CSTRING(GMP_API_VIDEO_DECODER),
|
||||
NS_LITERAL_CSTRING("h264"),
|
||||
nsDependentCString(gmp.mKeySystem));
|
||||
gmp.mKeySystem);
|
||||
gmp.mHasVP8 = HasGMPFor(NS_LITERAL_CSTRING(GMP_API_VIDEO_DECODER),
|
||||
NS_LITERAL_CSTRING("vp8"),
|
||||
nsDependentCString(gmp.mKeySystem));
|
||||
NS_LITERAL_CSTRING("vp8"),
|
||||
gmp.mKeySystem);
|
||||
gmp.mHasVP9 = HasGMPFor(NS_LITERAL_CSTRING(GMP_API_VIDEO_DECODER),
|
||||
NS_LITERAL_CSTRING("vp9"),
|
||||
nsDependentCString(gmp.mKeySystem));
|
||||
NS_LITERAL_CSTRING("vp9"),
|
||||
gmp.mKeySystem);
|
||||
}
|
||||
}
|
||||
|
||||
@ -195,16 +195,16 @@ GMPDecoderModule::PreferredGMP(const nsACString& aMimeType)
|
||||
Maybe<nsCString> rv;
|
||||
if (aMimeType.EqualsLiteral("audio/mp4a-latm")) {
|
||||
switch (MediaPrefs::GMPAACPreferred()) {
|
||||
case 1: rv.emplace(nsCString(kEMEKeySystemClearkey)); break;
|
||||
case 2: rv.emplace(nsCString(kEMEKeySystemPrimetime)); break;
|
||||
case 1: rv.emplace(kEMEKeySystemClearkey); break;
|
||||
case 2: rv.emplace(kEMEKeySystemPrimetime); break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
|
||||
if (MP4Decoder::IsH264(aMimeType)) {
|
||||
switch (MediaPrefs::GMPH264Preferred()) {
|
||||
case 1: rv.emplace(nsCString(kEMEKeySystemClearkey)); break;
|
||||
case 2: rv.emplace(nsCString(kEMEKeySystemPrimetime)); break;
|
||||
case 1: rv.emplace(kEMEKeySystemClearkey); break;
|
||||
case 2: rv.emplace(kEMEKeySystemPrimetime); break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
@ -223,7 +223,7 @@ GMPDecoderModule::SupportsMimeType(const nsACString& aMimeType,
|
||||
(MP4Decoder::IsH264(aMimeType) && gmp.mHasH264) ||
|
||||
(VPXDecoder::IsVP8(aMimeType) && gmp.mHasVP8) ||
|
||||
(VPXDecoder::IsVP9(aMimeType) && gmp.mHasVP9)) &&
|
||||
(aGMP.isNothing() || aGMP.value().EqualsASCII(gmp.mKeySystem))) {
|
||||
(aGMP.isNothing() || aGMP.value().Equals(gmp.mKeySystem))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user