本文整理汇总了C++中nsACString::EqualsLiteral方法的典型用法代码示例。如果您正苦于以下问题:C++ nsACString::EqualsLiteral方法的具体用法?C++ nsACString::EqualsLiteral怎么用?C++ nsACString::EqualsLiteral使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nsACString
的用法示例。
在下文中一共展示了nsACString::EqualsLiteral方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: lock
NS_IMETHODIMP
nsCertOverrideService::ClearValidityOverride(const nsACString & aHostName, int32_t aPort)
{
if (aPort == 0 &&
aHostName.EqualsLiteral("all:temporary-certificates")) {
RemoveAllTemporaryOverrides();
return NS_OK;
}
nsAutoCString hostPort;
GetHostWithPort(aHostName, aPort, hostPort);
{
ReentrantMonitorAutoEnter lock(monitor);
mSettingsTable.RemoveEntry(hostPort.get());
Write();
}
SSL_ClearSessionCache();
return NS_OK;
}
示例2: CallListenerError
// IUDPSocketInternal interfaces
// callback while error happened in UDP socket operation
NS_IMETHODIMP NrSocketIpc::CallListenerError(const nsACString &type,
const nsACString &message,
const nsACString &filename,
uint32_t line_number,
uint32_t column_number) {
ASSERT_ON_THREAD(main_thread_);
MOZ_ASSERT(type.EqualsLiteral("onerror"));
r_log(LOG_GENERIC, LOG_ERR, "UDP socket error:%s at %s:%d:%d",
message.BeginReading(), filename.BeginReading(),
line_number, column_number);
ReentrantMonitorAutoEnter mon(monitor_);
err_ = true;
monitor_.NotifyAll();
return NS_OK;
}
示例3: SupportsMimeType
bool AndroidDecoderModule::SupportsMimeType(const nsACString& aMimeType) {
if (jni::GetAPIVersion() < 16) {
return false;
}
if (aMimeType.EqualsLiteral("video/mp4") ||
aMimeType.EqualsLiteral("video/avc")) {
return true;
}
// When checking "audio/x-wav", CreateDecoder can cause a JNI ERROR by
// Accessing a stale local reference leading to a SIGSEGV crash.
// To avoid this we check for wav types here.
if (aMimeType.EqualsLiteral("audio/x-wav") ||
aMimeType.EqualsLiteral("audio/wave; codecs=1") ||
aMimeType.EqualsLiteral("audio/wave; codecs=6") ||
aMimeType.EqualsLiteral("audio/wave; codecs=7") ||
aMimeType.EqualsLiteral("audio/wave; codecs=65534")) {
return false;
}
if ((VPXDecoder::IsVPX(aMimeType, VPXDecoder::VP8) &&
!GetFeatureStatus(nsIGfxInfo::FEATURE_VP8_HW_DECODE)) ||
(VPXDecoder::IsVPX(aMimeType, VPXDecoder::VP9) &&
!GetFeatureStatus(nsIGfxInfo::FEATURE_VP9_HW_DECODE))) {
return false;
}
// Prefer the gecko decoder for opus and vorbis; stagefright crashes
// on content demuxed from mp4.
// Not all android devices support FLAC even when they say they do.
if (OpusDataDecoder::IsOpus(aMimeType) ||
VorbisDataDecoder::IsVorbis(aMimeType) ||
aMimeType.EqualsLiteral("audio/flac")) {
SLOG("Rejecting audio of type %s", aMimeType.Data());
return false;
}
// Prefer the gecko decoder for Theora.
// Not all android devices support Theora even when they say they do.
if (TheoraDecoder::IsTheora(aMimeType)) {
SLOG("Rejecting video of type %s", aMimeType.Data());
return false;
}
return java::HardwareCodecCapabilityUtils::FindDecoderCodecInfoForMimeType(
TranslateMimeType(aMimeType));
}
示例4: switch
/* static */
const Maybe<nsCString>
GMPDecoderModule::PreferredGMP(const nsACString& aMimeType)
{
Maybe<nsCString> rv;
if (aMimeType.EqualsLiteral("audio/mp4a-latm")) {
switch (MediaPrefs::GMPAACPreferred()) {
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(kEMEKeySystemClearkey); break;
case 2: rv.emplace(kEMEKeySystemPrimetime); break;
default: break;
}
}
return rv;
}
示例5: ToNewCString
static nsresult
FetcherURLDoneCallback(nsresult aStatus,
const nsACString &aContentType,
const nsACString &aCharset,
PRInt32 totalSize,
const PRUnichar* aMsg, void *tagData)
{
nsMsgAttachmentHandler *ma = (nsMsgAttachmentHandler *) tagData;
NS_ASSERTION(ma != nsnull, "not-null mime attachment");
if (ma != nsnull)
{
ma->m_size = totalSize;
if (!aContentType.IsEmpty())
{
#ifdef XP_MACOSX
//Do not change the type if we are dealing with an encoded (e.g., appledouble or zip) file
if (!ma->mEncodedWorkingFile)
#else
// can't send appledouble on non-macs
if (!aContentType.EqualsLiteral("multipart/appledouble"))
#endif
{
PR_Free(ma->m_type);
ma->m_type = ToNewCString(aContentType);
}
}
if (!aCharset.IsEmpty())
{
PR_Free(ma->m_charset);
ma->m_charset = ToNewCString(aCharset);
}
return ma->UrlExit(aStatus, aMsg);
}
else
return NS_OK;
}
示例6: CallListenerReceivedData
// callback while receiving UDP packet
NS_IMETHODIMP NrSocketIpc::CallListenerReceivedData(const nsACString &type,
const nsACString &host,
uint16_t port, uint8_t *data,
uint32_t data_length) {
ASSERT_ON_THREAD(main_thread_);
MOZ_ASSERT(type.EqualsLiteral("ondata"));
PRNetAddr addr;
memset(&addr, 0, sizeof(addr));
{
ReentrantMonitorAutoEnter mon(monitor_);
if (PR_SUCCESS != PR_StringToNetAddr(host.BeginReading(), &addr)) {
err_ = true;
MOZ_ASSERT(false, "Failed to convert remote host to PRNetAddr");
return NS_OK;
}
// Use PR_IpAddrNull to avoid address being reset to 0.
if (PR_SUCCESS != PR_SetNetAddr(PR_IpAddrNull, addr.raw.family, port, &addr)) {
err_ = true;
MOZ_ASSERT(false, "Failed to set port in PRNetAddr");
return NS_OK;
}
}
nsAutoPtr<DataBuffer> buf(new DataBuffer(data, data_length));
RefPtr<nr_udp_message> msg(new nr_udp_message(addr, buf));
RUN_ON_THREAD(sts_thread_,
mozilla::WrapRunnable(nsRefPtr<NrSocketIpc>(this),
&NrSocketIpc::recv_callback_s,
msg),
NS_DISPATCH_NORMAL);
return NS_OK;
}
示例7: Substring
void
ConvertTextAttributeToAtkAttribute(const nsACString& aName,
const nsAString& aValue,
AtkAttributeSet** aAttributeSet)
{
// Handle attributes where atk has its own name.
const char* atkName = nullptr;
nsAutoString atkValue;
if (aName.EqualsLiteral("color")) {
// The format of the atk attribute is r,g,b and the gecko one is
// rgb(r, g, b).
atkValue = Substring(aValue, 4, aValue.Length() - 5);
atkValue.StripWhitespace();
atkName = sAtkTextAttrNames[ATK_TEXT_ATTR_FG_COLOR];
} else if (aName.EqualsLiteral("background-color")) {
// The format of the atk attribute is r,g,b and the gecko one is
// rgb(r, g, b).
atkValue = Substring(aValue, 4, aValue.Length() - 5);
atkValue.StripWhitespace();
atkName = sAtkTextAttrNames[ATK_TEXT_ATTR_BG_COLOR];
} else if (aName.EqualsLiteral("font-family")) {
atkValue = aValue;
atkName = sAtkTextAttrNames[ATK_TEXT_ATTR_FAMILY_NAME];
} else if (aName.EqualsLiteral("font-size")) {
// ATK wants the number of pixels without px at the end.
atkValue = StringHead(aValue, aValue.Length() - 2);
atkName = sAtkTextAttrNames[ATK_TEXT_ATTR_SIZE];
} else if (aName.EqualsLiteral("font-weight")) {
atkValue = aValue;
atkName = sAtkTextAttrNames[ATK_TEXT_ATTR_WEIGHT];
} else if (aName.EqualsLiteral("invalid")) {
atkValue = aValue;
atkName = sAtkTextAttrNames[ATK_TEXT_ATTR_INVALID];
}
if (atkName) {
AtkAttribute* objAttr =
static_cast<AtkAttribute*>(g_malloc(sizeof(AtkAttribute)));
objAttr->name = g_strdup(atkName);
objAttr->value = g_strdup(NS_ConvertUTF16toUTF8(atkValue).get());
*aAttributeSet = g_slist_prepend(*aAttributeSet, objAttr);
}
}
示例8: ParseUntilBlocked
nsresult
nsHtml5Parser::Parse(const nsAString& aSourceBuffer,
void* aKey,
const nsACString& aContentType,
bool aLastCall,
nsDTDMode aMode) // ignored
{
nsresult rv;
if (NS_FAILED(rv = mExecutor->IsBroken())) {
return rv;
}
if (aSourceBuffer.Length() > INT32_MAX) {
return mExecutor->MarkAsBroken(NS_ERROR_OUT_OF_MEMORY);
}
// Maintain a reference to ourselves so we don't go away
// till we're completely done. The old parser grips itself in this method.
nsCOMPtr<nsIParser> kungFuDeathGrip(this);
// Gripping the other objects just in case, since the other old grip
// required grips to these, too.
nsRefPtr<nsHtml5StreamParser> streamKungFuDeathGrip(GetStreamParser());
nsRefPtr<nsHtml5TreeOpExecutor> treeOpKungFuDeathGrip(mExecutor);
if (!mExecutor->HasStarted()) {
NS_ASSERTION(!GetStreamParser(),
"Had stream parser but document.write started life cycle.");
// This is the first document.write() on a document.open()ed document
mExecutor->SetParser(this);
mTreeBuilder->setScriptingEnabled(mExecutor->IsScriptEnabled());
bool isSrcdoc = false;
nsCOMPtr<nsIChannel> channel;
rv = GetChannel(getter_AddRefs(channel));
if (NS_SUCCEEDED(rv)) {
isSrcdoc = NS_IsSrcdocChannel(channel);
}
mTreeBuilder->setIsSrcdocDocument(isSrcdoc);
mTokenizer->start();
mExecutor->Start();
if (!aContentType.EqualsLiteral("text/html")) {
mTreeBuilder->StartPlainText();
mTokenizer->StartPlainText();
}
/*
* If you move the following line, be very careful not to cause
* WillBuildModel to be called before the document has had its
* script global object set.
*/
rv = mExecutor->WillBuildModel(eDTDMode_unknown);
NS_ENSURE_SUCCESS(rv, rv);
}
// Return early if the parser has processed EOF
if (mExecutor->IsComplete()) {
return NS_OK;
}
if (aLastCall && aSourceBuffer.IsEmpty() && !aKey) {
// document.close()
NS_ASSERTION(!GetStreamParser(),
"Had stream parser but got document.close().");
if (mDocumentClosed) {
// already closed
return NS_OK;
}
mDocumentClosed = true;
if (!mBlocked && !mInDocumentWrite) {
return ParseUntilBlocked();
}
return NS_OK;
}
// If we got this far, we are dealing with a document.write or
// document.writeln call--not document.close().
NS_ASSERTION(IsInsertionPointDefined(),
"Doc.write reached parser with undefined insertion point.");
NS_ASSERTION(!(GetStreamParser() && !aKey),
"Got a null key in a non-script-created parser");
// XXX is this optimization bogus?
if (aSourceBuffer.IsEmpty()) {
return NS_OK;
}
// This guard is here to prevent document.close from tokenizing synchronously
// while a document.write (that wrote the script that called document.close!)
// is still on the call stack.
mozilla::AutoRestore<bool> guard(mInDocumentWrite);
mInDocumentWrite = true;
// The script is identified by aKey. If there's nothing in the buffer
// chain for that key, we'll insert at the head of the queue.
// When the script leaves something in the queue, a zero-length
// key-holder "buffer" is inserted in the queue. If the same script
// leaves something in the chain again, it will be inserted immediately
// before the old key holder belonging to the same script.
//.........这里部分代码省略.........
示例9:
/* static */
bool
MP4Decoder::IsH264(const nsACString& aMimeType)
{
return aMimeType.EqualsLiteral("video/mp4") ||
aMimeType.EqualsLiteral("video/avc");
}
示例10:
bool
OmxDecoderModule::SupportsMimeType(const nsACString& aMimeType) const
{
return aMimeType.EqualsLiteral("audio/mp4a-latm");
}
示例11:
bool
AppleDecoderModule::SupportsMimeType(const nsACString& aMimeType)
{
return aMimeType.EqualsLiteral("audio/mpeg") ||
PlatformDecoderModule::SupportsMimeType(aMimeType);
}
示例12: toLog
nsresult
Http2Decompressor::OutputHeader(const nsACString &name, const nsACString &value)
{
// exclusions
if (name.EqualsLiteral("connection") ||
name.EqualsLiteral("host") ||
name.EqualsLiteral("keep-alive") ||
name.EqualsLiteral("proxy-connection") ||
name.EqualsLiteral("te") ||
name.EqualsLiteral("transfer-encoding") ||
name.EqualsLiteral("upgrade") ||
name.Equals(("accept-encoding"))) {
nsCString toLog(name);
LOG(("HTTP Decompressor illegal response header found : %s",
toLog.get()));
return NS_ERROR_ILLEGAL_VALUE;
}
// Look for upper case characters in the name.
for (const char *cPtr = name.BeginReading();
cPtr && cPtr < name.EndReading();
++cPtr) {
if (*cPtr <= 'Z' && *cPtr >= 'A') {
nsCString toLog(name);
LOG(("HTTP Decompressor upper case response header found. [%s]\n",
toLog.get()));
return NS_ERROR_ILLEGAL_VALUE;
}
}
// Look for CR OR LF in value - could be smuggling Sec 10.3
// can map to space safely
for (const char *cPtr = value.BeginReading();
cPtr && cPtr < value.EndReading();
++cPtr) {
if (*cPtr == '\r' || *cPtr== '\n') {
char *wPtr = const_cast<char *>(cPtr);
*wPtr = ' ';
}
}
// Status comes first
if (name.EqualsLiteral(":status")) {
nsAutoCString status(NS_LITERAL_CSTRING("HTTP/2.0 "));
status.Append(value);
status.AppendLiteral("\r\n");
mOutput->Insert(status, 0);
mHeaderStatus = value;
} else if (name.EqualsLiteral(":authority")) {
mHeaderHost = value;
} else if (name.EqualsLiteral(":scheme")) {
mHeaderScheme = value;
} else if (name.EqualsLiteral(":path")) {
mHeaderPath = value;
} else if (name.EqualsLiteral(":method")) {
mHeaderMethod = value;
}
// http/2 transport level headers shouldn't be gatewayed into http/1
if(*(name.BeginReading()) == ':') {
LOG(("HTTP Decompressor not gatewaying %s into http/1",
name.BeginReading()));
return NS_OK;
}
mOutput->Append(name);
mOutput->AppendLiteral(": ");
// Special handling for set-cookie according to the spec
bool isSetCookie = name.EqualsLiteral("set-cookie");
int32_t valueLen = value.Length();
nsAutoCString textValue;
for (int32_t i = 0; i < valueLen; ++i) {
if (value[i] == '\0') {
if (isSetCookie) {
LOG(("Http2Decompressor::OutputHeader %s %s", name.BeginReading(),
textValue.get()));
mOutput->Append(textValue);
textValue.Truncate(0);
mOutput->AppendLiteral("\r\n");
mOutput->Append(name);
mOutput->AppendLiteral(": ");
} else {
textValue.AppendLiteral(", ");
}
} else {
textValue.Append(value[i]);
}
}
LOG(("Http2Decompressor::OutputHeader %s %s", name.BeginReading(),
textValue.get()));
mOutput->Append(textValue);
mOutput->AppendLiteral("\r\n");
return NS_OK;
}
示例13:
// Match stock icons with names
static SHSTOCKICONID
GetStockIconIDForName(const nsACString& aStockName)
{
return aStockName.EqualsLiteral("uac-shield") ? SIID_SHIELD :
SIID_INVALID;
}
示例14: copy
NS_IMETHODIMP
nsDSURIContentListener::DoContent(const nsACString& aContentType,
bool aIsContentPreferred,
nsIRequest* aRequest,
nsIStreamListener** aContentHandler,
bool* aAbortProcess)
{
nsresult rv;
NS_ENSURE_ARG_POINTER(aContentHandler);
NS_ENSURE_TRUE(mDocShell, NS_ERROR_FAILURE);
// Check whether X-Frame-Options permits us to load this content in an
// iframe and abort the load (unless we've disabled x-frame-options
// checking).
if (!CheckFrameOptions(aRequest)) {
*aAbortProcess = true;
return NS_OK;
}
*aAbortProcess = false;
// determine if the channel has just been retargeted to us...
nsLoadFlags loadFlags = 0;
nsCOMPtr<nsIChannel> aOpenedChannel = do_QueryInterface(aRequest);
if (aOpenedChannel) {
aOpenedChannel->GetLoadFlags(&loadFlags);
}
if (loadFlags & nsIChannel::LOAD_RETARGETED_DOCUMENT_URI) {
// XXX: Why does this not stop the content too?
mDocShell->Stop(nsIWebNavigation::STOP_NETWORK);
mDocShell->SetLoadType(aIsContentPreferred ? LOAD_LINK : LOAD_NORMAL);
}
// In case of multipart jpeg request (mjpeg) we don't really want to
// create new viewer since the one we already have is capable of
// rendering multipart jpeg correctly (see bug 625012)
nsCOMPtr<nsIChannel> baseChannel;
if (nsCOMPtr<nsIMultiPartChannel> mpchan = do_QueryInterface(aRequest)) {
mpchan->GetBaseChannel(getter_AddRefs(baseChannel));
}
bool reuseCV = baseChannel && baseChannel == mExistingJPEGRequest &&
aContentType.EqualsLiteral("image/jpeg");
if (mExistingJPEGStreamListener && reuseCV) {
RefPtr<nsIStreamListener> copy(mExistingJPEGStreamListener);
copy.forget(aContentHandler);
rv = NS_OK;
} else {
rv = mDocShell->CreateContentViewer(aContentType, aRequest, aContentHandler);
if (NS_SUCCEEDED(rv) && reuseCV) {
mExistingJPEGStreamListener = *aContentHandler;
} else {
mExistingJPEGStreamListener = nullptr;
}
mExistingJPEGRequest = baseChannel;
}
if (rv == NS_ERROR_REMOTE_XUL) {
aRequest->Cancel(rv);
*aAbortProcess = true;
return NS_OK;
}
if (NS_FAILED(rv)) {
// we don't know how to handle the content
*aContentHandler = nullptr;
return rv;
}
if (loadFlags & nsIChannel::LOAD_RETARGETED_DOCUMENT_URI) {
nsCOMPtr<nsPIDOMWindowOuter> domWindow =
mDocShell ? mDocShell->GetWindow() : nullptr;
NS_ENSURE_TRUE(domWindow, NS_ERROR_FAILURE);
domWindow->Focus();
}
return NS_OK;
}
示例15: GStreamerDecoder
// Instantiates but does not initialize decoder.
static
already_AddRefed<MediaDecoder>
InstantiateDecoder(const nsACString& aType, MediaDecoderOwner* aOwner)
{
nsRefPtr<MediaDecoder> decoder;
#ifdef MOZ_FMP4
if (IsMP4SupportedType(aType)) {
decoder = new MP4Decoder();
return decoder.forget();
}
#endif
#ifdef MOZ_GSTREAMER
if (IsGStreamerSupportedType(aType)) {
decoder = new GStreamerDecoder();
return decoder.forget();
}
#endif
#ifdef MOZ_RAW
if (IsRawType(aType)) {
decoder = new RawDecoder();
return decoder.forget();
}
#endif
if (IsOggType(aType)) {
decoder = new OggDecoder();
return decoder.forget();
}
#ifdef MOZ_WAVE
if (IsWaveType(aType)) {
decoder = new WaveDecoder();
return decoder.forget();
}
#endif
#ifdef MOZ_OMX_DECODER
if (IsOmxSupportedType(aType)) {
// AMR audio is enabled for MMS, but we are discouraging Web and App
// developers from using AMR, thus we only allow AMR to be played on WebApps.
if (aType.EqualsLiteral(AUDIO_AMR) || aType.EqualsLiteral(AUDIO_3GPP)) {
dom::HTMLMediaElement* element = aOwner->GetMediaElement();
if (!element) {
return nullptr;
}
nsIPrincipal* principal = element->NodePrincipal();
if (!principal) {
return nullptr;
}
if (principal->GetAppStatus() < nsIPrincipal::APP_STATUS_PRIVILEGED) {
return nullptr;
}
}
#if ANDROID_VERSION >= 18
decoder = MediaDecoder::IsOmxAsyncEnabled()
? static_cast<MediaDecoder*>(new MediaCodecDecoder())
: static_cast<MediaDecoder*>(new MediaOmxDecoder());
#else
decoder = new MediaOmxDecoder();
#endif
return decoder.forget();
}
#endif
#ifdef NECKO_PROTOCOL_rtsp
if (IsRtspSupportedType(aType)) {
#if ANDROID_VERSION >= 18
decoder = MediaDecoder::IsOmxAsyncEnabled()
? static_cast<MediaDecoder*>(new RtspMediaCodecDecoder())
: static_cast<MediaDecoder*>(new RtspOmxDecoder());
#else
decoder = new RtspOmxDecoder();
#endif
return decoder.forget();
}
#endif
#ifdef MOZ_ANDROID_OMX
if (MediaDecoder::IsAndroidMediaEnabled() &&
GetAndroidMediaPluginHost()->FindDecoder(aType, nullptr)) {
decoder = new AndroidMediaDecoder(aType);
return decoder.forget();
}
#endif
#ifdef MOZ_WEBM
if (IsWebMType(aType)) {
decoder = new WebMDecoder();
return decoder.forget();
}
#endif
#ifdef MOZ_DIRECTSHOW
// Note: DirectShow should come before WMF, so that we prefer DirectShow's
// MP3 support over WMF's.
if (IsDirectShowSupportedType(aType)) {
decoder = new DirectShowDecoder();
return decoder.forget();
}
#endif
#ifdef MOZ_WMF
if (IsWMFSupportedType(aType)) {
decoder = new WMFDecoder();
return decoder.forget();
}
//.........这里部分代码省略.........