本文整理汇总了C++中nsCString::EqualsLiteral方法的典型用法代码示例。如果您正苦于以下问题:C++ nsCString::EqualsLiteral方法的具体用法?C++ nsCString::EqualsLiteral怎么用?C++ nsCString::EqualsLiteral使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nsCString
的用法示例。
在下文中一共展示了nsCString::EqualsLiteral方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PurgeExpired
bool
nsPreflightCache::CacheEntry::CheckRequest(const nsCString& aMethod,
const nsTArray<nsCString>& aHeaders)
{
PurgeExpired(TimeStamp::NowLoRes());
if (!aMethod.EqualsLiteral("GET") && !aMethod.EqualsLiteral("POST")) {
uint32_t i;
for (i = 0; i < mMethods.Length(); ++i) {
if (aMethod.Equals(mMethods[i].token))
break;
}
if (i == mMethods.Length()) {
return false;
}
}
for (uint32_t i = 0; i < aHeaders.Length(); ++i) {
uint32_t j;
for (j = 0; j < mHeaders.Length(); ++j) {
if (aHeaders[i].Equals(mHeaders[j].token,
nsCaseInsensitiveCStringComparator())) {
break;
}
}
if (j == mHeaders.Length()) {
return false;
}
}
return true;
}
示例2: PurgeExpired
PRBool
nsPreflightCache::CacheEntry::CheckRequest(const nsCString& aMethod,
const nsTArray<nsCString>& aHeaders)
{
PurgeExpired(PR_Now());
if (!aMethod.EqualsLiteral("GET") && !aMethod.EqualsLiteral("POST")) {
PRUint32 i;
for (i = 0; i < mMethods.Length(); ++i) {
if (aMethod.Equals(mMethods[i].token))
break;
}
if (i == mMethods.Length()) {
return PR_FALSE;
}
}
for (PRUint32 i = 0; i < aHeaders.Length(); ++i) {
PRUint32 j;
for (j = 0; j < mHeaders.Length(); ++j) {
if (aHeaders[i].Equals(mHeaders[j].token,
nsCaseInsensitiveCStringComparator())) {
break;
}
}
if (j == mHeaders.Length()) {
return PR_FALSE;
}
}
return PR_TRUE;
}
示例3:
static bool
ShouldDownscaleDuringDecode(const nsCString& aMimeType)
{
return aMimeType.EqualsLiteral(IMAGE_JPEG) ||
aMimeType.EqualsLiteral(IMAGE_JPG) ||
aMimeType.EqualsLiteral(IMAGE_PJPEG);
}
示例4: ConfigWebRtcLog
void ConfigWebRtcLog(uint32_t trace_mask, nsCString &aLogFile, nsCString &aAECLogDir, bool multi_log)
{
if (gWebRtcTraceLoggingOn) {
return;
}
nsCString logFile;
nsCString aecLogDir;
#if defined(XP_WIN)
// Use the Windows TEMP environment variable as part of the default location.
const char *temp_dir = PR_GetEnv("TEMP");
if (!temp_dir) {
logFile.Assign(default_log);
} else {
logFile.Assign(temp_dir);
logFile.Append('/');
aecLogDir = logFile;
logFile.Append(default_log);
}
#elif defined(ANDROID)
#ifdef WEBRTC_GONK
// Special case: use callback to log through logcat.
logFile.Assign("logcat");
#else
// Special case: use callback to pipe to NSPR logging.
logFile.Assign("nspr");
#endif
// for AEC, force the user to specify a directory
aecLogDir.Assign("/dev/null");
#else
// UNIX-like place for the others
logFile.Assign("/tmp/");
aecLogDir = logFile;
logFile.Append(default_log);
#endif
if (aLogFile.IsEmpty()) {
aLogFile = logFile;
}
if (aAECLogDir.IsEmpty()) {
aAECLogDir = aecLogDir;
}
webrtc::Trace::set_level_filter(trace_mask);
webrtc::Trace::set_aec_debug_filename(aAECLogDir.get());
if (trace_mask != 0) {
if (aLogFile.EqualsLiteral("nspr")) {
webrtc::Trace::SetTraceCallback(&gWebRtcCallback);
#ifdef WEBRTC_GONK
} else if (aLogFile.EqualsLiteral("logcat")) {
webrtc::Trace::SetTraceCallback(&gWebRtcLogcatCallback);
#endif
} else {
webrtc::Trace::SetTraceFile(aLogFile.get(), multi_log);
}
}
return;
}
示例5:
bool
Volume::BoolConfigValue(const nsCString& aConfigValue, bool& aBoolValue)
{
if (aConfigValue.EqualsLiteral("1") ||
aConfigValue.LowerCaseEqualsLiteral("true")) {
aBoolValue = true;
return true;
}
if (aConfigValue.EqualsLiteral("0") ||
aConfigValue.LowerCaseEqualsLiteral("false")) {
aBoolValue = false;
return true;
}
return false;
}
示例6: BadImage
/* static */ already_AddRefed<Image>
ImageFactory::CreateImage(nsIRequest* aRequest,
ProgressTracker* aProgressTracker,
const nsCString& aMimeType,
ImageURL* aURI,
bool aIsMultiPart,
uint32_t aInnerWindowId)
{
MOZ_ASSERT(gfxPrefs::SingletonExists(),
"Pref observers should have been initialized already");
// Compute the image's initialization flags.
uint32_t imageFlags = ComputeImageFlags(aURI, aMimeType, aIsMultiPart);
// Select the type of image to create based on MIME type.
if (aMimeType.EqualsLiteral(IMAGE_SVG_XML)) {
nsCOMPtr<nsIChannel> channel(do_QueryInterface(aRequest));
if (!NS_SVGEnabledForChannel(channel)) {
// SVG is disabled. We must return an image object that is marked
// "bad", but we want to avoid invoking the VectorImage class (SVG code),
// so we return a PNG with the error flag set.
nsRefPtr<RasterImage> badImage = new RasterImage(aProgressTracker, aURI);
(void)badImage->Init(IMAGE_PNG, Image::INIT_FLAG_NONE);
return BadImage(badImage);
}
return CreateVectorImage(aRequest, aProgressTracker, aMimeType,
aURI, imageFlags, aInnerWindowId);
} else {
return CreateRasterImage(aRequest, aProgressTracker, aMimeType,
aURI, imageFlags, aInnerWindowId);
}
}
示例7: ConfigWebRtcLog
void ConfigWebRtcLog(uint32_t trace_mask, nsCString &aLogFile, nsCString &aAECLogDir, bool multi_log)
{
if (gWebRtcTraceLoggingOn) {
return;
}
nsCString logFile;
nsCString aecLogDir;
#if defined(XP_WIN)
// Use the Windows TEMP environment variable as part of the default location.
const char *temp_dir = PR_GetEnv("TEMP");
if (!temp_dir) {
logFile.Assign(default_log);
} else {
logFile.Assign(temp_dir);
logFile.Append('/');
aecLogDir = logFile;
logFile.Append(default_log);
}
#elif defined(ANDROID)
// Special case: use callback to pipe to NSPR logging.
logFile.Assign("nspr");
// for AEC, force the user to specify a directory
aecLogDir.Assign("/dev/null");
#else
// UNIX-like place for the others
logFile.Assign("/tmp/");
aecLogDir = logFile;
logFile.Append(default_log);
#endif
if (aLogFile.IsEmpty()) {
aLogFile = logFile;
}
if (aAECLogDir.IsEmpty()) {
aAECLogDir = aecLogDir;
}
webrtc::Trace::set_level_filter(trace_mask);
webrtc::Trace::set_aec_debug_filename(aAECLogDir.get());
if (trace_mask != 0) {
if (aLogFile.EqualsLiteral("nspr")) {
webrtc::Trace::SetTraceCallback(&gWebRtcCallback);
} else {
webrtc::Trace::SetTraceFile(aLogFile.get(), multi_log);
}
}
#if !defined(MOZILLA_EXTERNAL_LINKAGE)
if (XRE_GetProcessType() == GeckoProcessType_Default) {
// Capture the final choices for the trace settings.
mozilla::Preferences::SetCString("media.webrtc.debug.log_file", aLogFile);
mozilla::Preferences::SetCString("media.webrtc.debug.aec_log_dir", aAECLogDir);
}
#endif
return;
}
示例8:
nsresult
nsPlatformCharset::VerifyCharset(nsCString &aCharset)
{
// fast path for UTF-8. Most platform uses UTF-8 as charset now.
if (aCharset.EqualsLiteral("UTF-8")) {
return NS_OK;
}
nsresult res;
//
// get the convert manager
//
nsCOMPtr <nsICharsetConverterManager> charsetConverterManager;
charsetConverterManager = do_GetService(NS_CHARSETCONVERTERMANAGER_CONTRACTID, &res);
if (NS_FAILED(res))
return res;
//
// check if we can get an input converter
//
nsCOMPtr <nsIUnicodeEncoder> enc;
res = charsetConverterManager->GetUnicodeEncoder(aCharset.get(), getter_AddRefs(enc));
if (NS_FAILED(res)) {
NS_ERROR("failed to create encoder");
return res;
}
//
// check if we can get an output converter
//
nsCOMPtr <nsIUnicodeDecoder> dec;
res = charsetConverterManager->GetUnicodeDecoder(aCharset.get(), getter_AddRefs(dec));
if (NS_FAILED(res)) {
NS_ERROR("failed to create decoder");
return res;
}
//
// check if we recognize the charset string
//
nsCAutoString result;
res = charsetConverterManager->GetCharsetAlias(aCharset.get(), result);
if (NS_FAILED(res)) {
return res;
}
//
// return the preferred string
//
aCharset.Assign(result);
return NS_OK;
}
示例9: if
nsresult
nsChromeRegistryContent::GetBaseURIFromPackage(const nsCString& aPackage,
const nsCString& aProvider,
const nsCString& aPath,
nsIURI* *aResult)
{
PackageEntry* entry;
if (!mPackagesHash.Get(aPackage, &entry)) {
return NS_ERROR_FAILURE;
}
*aResult = nsnull;
if (aProvider.EqualsLiteral("locale")) {
*aResult = entry->localeBaseURI;
}
else if (aProvider.EqualsLiteral("skin")) {
*aResult = entry->skinBaseURI;
}
else if (aProvider.EqualsLiteral("content")) {
*aResult = entry->contentBaseURI;
}
return NS_OK;
}
示例10: ConfigWebRtcLog
void ConfigWebRtcLog(uint32_t trace_mask, nsCString &aLogFile, nsCString &aAECLogDir, bool multi_log)
{
if (gWebRtcTraceLoggingOn) {
return;
}
#if defined(ANDROID)
// Special case: use callback to pipe to NSPR logging.
aLogFile.Assign(default_log_name);
// For AEC, do not use a default value: force the user to specify a directory.
if (aAECLogDir.IsEmpty()) {
aAECLogDir.Assign(default_tmp_dir);
}
#else
if (aLogFile.IsEmpty() || aAECLogDir.IsEmpty()) {
nsCOMPtr<nsIFile> tempDir;
nsresult rv = NS_GetSpecialDirectory(NS_OS_TEMP_DIR, getter_AddRefs(tempDir));
if (NS_SUCCEEDED(rv)) {
if (aAECLogDir.IsEmpty()) {
tempDir->GetNativePath(aAECLogDir);
}
if (aLogFile.IsEmpty()) {
tempDir->AppendNative(default_log_name);
tempDir->GetNativePath(aLogFile);
}
}
}
#endif
webrtc::Trace::set_level_filter(trace_mask);
webrtc::Trace::set_aec_debug_filename(aAECLogDir.get());
if (trace_mask != 0) {
if (aLogFile.EqualsLiteral("nspr")) {
webrtc::Trace::SetTraceCallback(&gWebRtcCallback);
} else {
webrtc::Trace::SetTraceFile(aLogFile.get(), multi_log);
}
}
#if !defined(MOZILLA_EXTERNAL_LINKAGE)
if (XRE_IsParentProcess()) {
// Capture the final choices for the trace settings.
mozilla::Preferences::SetCString("media.webrtc.debug.log_file", aLogFile);
mozilla::Preferences::SetCString("media.webrtc.debug.aec_log_dir", aAECLogDir);
}
#endif
return;
}
示例11: CreateVectorImage
/* static */ already_AddRefed<Image>
ImageFactory::CreateImage(nsIRequest* aRequest,
imgStatusTracker* aStatusTracker,
const nsCString& aMimeType,
ImageURL* aURI,
bool aIsMultiPart,
uint32_t aInnerWindowId)
{
MOZ_ASSERT(gInitializedPrefCaches,
"Pref observers should have been initialized already");
// Compute the image's initialization flags.
uint32_t imageFlags = ComputeImageFlags(aURI, aIsMultiPart);
// Select the type of image to create based on MIME type.
if (aMimeType.EqualsLiteral(IMAGE_SVG_XML)) {
return CreateVectorImage(aRequest, aStatusTracker, aMimeType,
aURI, imageFlags, aInnerWindowId);
} else {
return CreateRasterImage(aRequest, aStatusTracker, aMimeType,
aURI, imageFlags, aInnerWindowId);
}
}
示例12: CreateVectorImage
/* static */ already_AddRefed<Image>
ImageFactory::CreateImage(nsIRequest* aRequest,
imgStatusTracker* aStatusTracker,
const nsCString& aMimeType,
nsIURI* aURI,
bool aIsMultiPart,
uint32_t aInnerWindowId)
{
// Register our pref observers if we haven't yet.
if (MOZ_UNLIKELY(!gInitializedPrefCaches))
InitPrefCaches();
// Compute the image's initialization flags.
uint32_t imageFlags = ComputeImageFlags(aURI, aIsMultiPart);
// Select the type of image to create based on MIME type.
if (aMimeType.EqualsLiteral(IMAGE_SVG_XML)) {
return CreateVectorImage(aRequest, aStatusTracker, aMimeType,
aURI, imageFlags, aInnerWindowId);
} else {
return CreateRasterImage(aRequest, aStatusTracker, aMimeType,
aURI, imageFlags, aInnerWindowId);
}
}
示例13: methodTokens
nsresult
nsCORSPreflightListener::CheckPreflightRequestApproved(nsIRequest* aRequest)
{
nsresult status;
nsresult rv = aRequest->GetStatus(&status);
NS_ENSURE_SUCCESS(rv, rv);
NS_ENSURE_SUCCESS(status, status);
// Test that things worked on a HTTP level
nsCOMPtr<nsIHttpChannel> http = do_QueryInterface(aRequest);
nsCOMPtr<nsIHttpChannelInternal> internal = do_QueryInterface(aRequest);
NS_ENSURE_STATE(internal);
bool succeedded;
rv = http->GetRequestSucceeded(&succeedded);
if (NS_FAILED(rv) || !succeedded) {
LogBlockedRequest(aRequest, "CORSPreflightDidNotSucceed", nullptr);
return NS_ERROR_DOM_BAD_URI;
}
nsAutoCString headerVal;
// The "Access-Control-Allow-Methods" header contains a comma separated
// list of method names.
http->GetResponseHeader(NS_LITERAL_CSTRING("Access-Control-Allow-Methods"),
headerVal);
bool foundMethod = mPreflightMethod.EqualsLiteral("GET") ||
mPreflightMethod.EqualsLiteral("HEAD") ||
mPreflightMethod.EqualsLiteral("POST");
nsCCharSeparatedTokenizer methodTokens(headerVal, ',');
while(methodTokens.hasMoreTokens()) {
const nsDependentCSubstring& method = methodTokens.nextToken();
if (method.IsEmpty()) {
continue;
}
if (!NS_IsValidHTTPToken(method)) {
LogBlockedRequest(aRequest, "CORSInvalidAllowMethod",
NS_ConvertUTF8toUTF16(method).get());
return NS_ERROR_DOM_BAD_URI;
}
foundMethod |= mPreflightMethod.Equals(method);
}
if (!foundMethod) {
LogBlockedRequest(aRequest, "CORSMethodNotFound", nullptr);
return NS_ERROR_DOM_BAD_URI;
}
// The "Access-Control-Allow-Headers" header contains a comma separated
// list of header names.
http->GetResponseHeader(NS_LITERAL_CSTRING("Access-Control-Allow-Headers"),
headerVal);
nsTArray<nsCString> headers;
nsCCharSeparatedTokenizer headerTokens(headerVal, ',');
while(headerTokens.hasMoreTokens()) {
const nsDependentCSubstring& header = headerTokens.nextToken();
if (header.IsEmpty()) {
continue;
}
if (!NS_IsValidHTTPToken(header)) {
LogBlockedRequest(aRequest, "CORSInvalidAllowHeader",
NS_ConvertUTF8toUTF16(header).get());
return NS_ERROR_DOM_BAD_URI;
}
headers.AppendElement(header);
}
for (uint32_t i = 0; i < mPreflightHeaders.Length(); ++i) {
if (!headers.Contains(mPreflightHeaders[i],
nsCaseInsensitiveCStringArrayComparator())) {
LogBlockedRequest(aRequest, "CORSMissingAllowHeaderFromPreflight",
NS_ConvertUTF8toUTF16(mPreflightHeaders[i]).get());
return NS_ERROR_DOM_BAD_URI;
}
}
return NS_OK;
}
示例14: ConfigWebRtcLog
void ConfigWebRtcLog(mozilla::LogLevel level, uint32_t trace_mask,
nsCString &aLogFile, bool multi_log)
{
if (gWebRtcTraceLoggingOn) {
return;
}
#if defined(ANDROID)
// Special case: use callback to pipe to NSPR logging.
aLogFile.Assign(default_log_name);
#else
rtc::LoggingSeverity log_level;
switch (level) {
case mozilla::LogLevel::Verbose:
log_level = rtc::LoggingSeverity::LS_VERBOSE;
break;
case mozilla::LogLevel::Debug:
case mozilla::LogLevel::Info:
log_level = rtc::LoggingSeverity::LS_INFO;
break;
case mozilla::LogLevel::Warning:
log_level = rtc::LoggingSeverity::LS_WARNING;
break;
case mozilla::LogLevel::Error:
log_level = rtc::LoggingSeverity::LS_ERROR;
break;
case mozilla::LogLevel::Disabled:
log_level = rtc::LoggingSeverity::LS_NONE;
break;
default:
MOZ_ASSERT(false);
break;
}
rtc::LogMessage::LogToDebug(log_level);
if (level != mozilla::LogLevel::Disabled) {
// always capture LOG(...) << ... logging in webrtc.org code to nspr logs
if (!sSink) {
sSink = new LogSinkImpl();
rtc::LogMessage::AddLogToStream(sSink, log_level);
// it's ok if this leaks to program end
}
} else if (sSink) {
rtc::LogMessage::RemoveLogToStream(sSink);
sSink = nullptr;
}
webrtc::Trace::set_level_filter(trace_mask);
if (trace_mask != 0) {
// default WEBRTC_TRACE logs to a rotating file, but allow redirecting to nspr
// XXX always redirect in e10s if the sandbox blocks file access, or somehow proxy
if (aLogFile.EqualsLiteral("nspr") || aLogFile.EqualsLiteral("moz_log")) {
rtc::LogMessage::SetLogToStderr(false);
webrtc::Trace::SetTraceCallback(&gWebRtcCallback);
} else {
rtc::LogMessage::SetLogToStderr(true);
webrtc::Trace::SetTraceFile(aLogFile.get(), multi_log);
}
} else {
rtc::LogMessage::SetLogToStderr(false);
}
if (aLogFile.IsEmpty()) {
nsCOMPtr<nsIFile> tempDir;
nsresult rv = NS_GetSpecialDirectory(NS_OS_TEMP_DIR, getter_AddRefs(tempDir));
if (NS_SUCCEEDED(rv)) {
tempDir->AppendNative(default_log_name);
#ifdef XP_WIN
// WebRTC wants a path encoded in the native charset, not UTF-8.
nsAutoString logFile;
tempDir->GetPath(logFile);
NS_CopyUnicodeToNative(logFile, aLogFile);
#else
tempDir->GetNativePath(aLogFile);
#endif
}
}
#endif
if (XRE_IsParentProcess()) {
// Capture the final choice for the trace setting.
mozilla::Preferences::SetCString("media.webrtc.debug.log_file", aLogFile);
}
}
示例15: StrToBool
bool nsMsgFilterList::StrToBool(nsCString &str) {
return str.EqualsLiteral("yes");
}