本文整理汇总了C++中nsACString::IsEmpty方法的典型用法代码示例。如果您正苦于以下问题:C++ nsACString::IsEmpty方法的具体用法?C++ nsACString::IsEmpty怎么用?C++ nsACString::IsEmpty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nsACString
的用法示例。
在下文中一共展示了nsACString::IsEmpty方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
nsresult
SpdyInformation::GetNPNVersionIndex(const nsACString &npnString,
uint8_t *result)
{
if (npnString.IsEmpty())
return NS_ERROR_FAILURE;
if (npnString.Equals(VersionString[0]))
*result = Version[0];
else if (npnString.Equals(VersionString[1]))
*result = Version[1];
else
return NS_ERROR_FAILURE;
return NS_OK;
}
示例2:
nsresult
SpdyInformation::GetNPNVersionIndex(const nsACString &npnString,
uint8_t *result)
{
if (npnString.IsEmpty())
return NS_ERROR_FAILURE;
for (uint32_t index = 0; index < kCount; ++index) {
if (npnString.Equals(VersionString[index])) {
*result = Version[index];
return NS_OK;
}
}
return NS_ERROR_FAILURE;
}
示例3: mURI
IndexedDatabaseManager::AsyncUsageRunnable::AsyncUsageRunnable(
nsIURI* aURI,
const nsACString& aOrigin,
nsIIndexedDatabaseUsageCallback* aCallback)
: mURI(aURI),
mOrigin(aOrigin),
mCallback(aCallback),
mUsage(0),
mFileUsage(0),
mCanceled(0)
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
NS_ASSERTION(aURI, "Null pointer!");
NS_ASSERTION(!aOrigin.IsEmpty(), "Empty origin!");
NS_ASSERTION(aCallback, "Null pointer!");
}
示例4: LoadContext
nsresult
nsUrlClassifierStreamUpdater::FetchUpdate(nsIURI *aUpdateUrl,
const nsACString & aRequestBody,
const nsACString & aStreamTable,
const nsACString & aServerMAC)
{
nsresult rv;
uint32_t loadFlags = nsIChannel::INHIBIT_CACHING |
nsIChannel::LOAD_BYPASS_CACHE;
rv = NS_NewChannel(getter_AddRefs(mChannel), aUpdateUrl, nullptr, nullptr, this,
loadFlags);
NS_ENSURE_SUCCESS(rv, rv);
mBeganStream = false;
// If aRequestBody is empty, construct it for the test.
if (!aRequestBody.IsEmpty()) {
rv = AddRequestBody(aRequestBody);
NS_ENSURE_SUCCESS(rv, rv);
}
// Set the appropriate content type for file/data URIs, for unit testing
// purposes.
// This is only used for testing and should be deleted.
bool match;
if ((NS_SUCCEEDED(aUpdateUrl->SchemeIs("file", &match)) && match) ||
(NS_SUCCEEDED(aUpdateUrl->SchemeIs("data", &match)) && match)) {
mChannel->SetContentType(NS_LITERAL_CSTRING("application/vnd.google.safebrowsing-update"));
}
// Create a custom LoadContext for SafeBrowsing, so we can use callbacks on
// the channel to query the appId which allows separation of safebrowsing
// cookies in a separate jar.
nsCOMPtr<nsIInterfaceRequestor> sbContext =
new mozilla::LoadContext(NECKO_SAFEBROWSING_APP_ID);
rv = mChannel->SetNotificationCallbacks(sbContext);
NS_ENSURE_SUCCESS(rv, rv);
// Make the request
rv = mChannel->AsyncOpen(this, nullptr);
NS_ENSURE_SUCCESS(rv, rv);
mStreamTable = aStreamTable;
mServerMAC = aServerMAC;
return NS_OK;
}
示例5: scope
nsresult
nsDOMStoragePersistentDB::EnsureQuotaUsageLoaded(const nsACString& aQuotaKey)
{
if (aQuotaKey.IsEmpty() || mQuotaUseByUncached.Get(aQuotaKey, nullptr)) {
return NS_OK;
} else if (mWasRemoveAllCalled || mIsRemoveAllPending) {
mQuotaUseByUncached.Put(aQuotaKey, 0);
return NS_OK;
}
Telemetry::AutoTimer<Telemetry::LOCALDOMSTORAGE_FETCH_QUOTA_USE_MS> timer;
// Fetch information about all the scopes belonging to this site
nsCOMPtr<mozIStorageStatement> stmt;
stmt = mReadStatements.GetCachedStatement(
"SELECT scope, SUM(LENGTH(key) + LENGTH(value)) "
"FROM ( "
"SELECT scope, key, value FROM webappsstore2 "
"WHERE scope LIKE :quotaKey"
") "
"GROUP BY scope"
);
NS_ENSURE_STATE(stmt);
mozStorageStatementScoper scope(stmt);
nsresult rv = stmt->BindUTF8StringByName(NS_LITERAL_CSTRING("quotaKey"),
aQuotaKey + NS_LITERAL_CSTRING("%"));
NS_ENSURE_SUCCESS(rv, rv);
int32_t uncachedSize = 0;
bool exists;
while (NS_SUCCEEDED(rv = stmt->ExecuteStep(&exists)) && exists) {
nsAutoCString scopeName;
rv = stmt->GetUTF8String(0, scopeName);
NS_ENSURE_SUCCESS(rv, rv);
int32_t quotaUsage;
rv = stmt->GetInt32(1, "aUsage);
NS_ENSURE_SUCCESS(rv, rv);
if (!mCache.IsScopeCached(scopeName)) {
uncachedSize += quotaUsage;
}
}
mQuotaUseByUncached.Put(aQuotaKey, uncachedSize);
return NS_OK;
}
示例6: ReportError
void nsJAR::ReportError(const nsACString &aFilename, int16_t errorCode)
{
//-- Generate error message
nsAutoString message;
message.AssignLiteral("Signature Verification Error: the signature on ");
if (!aFilename.IsEmpty())
AppendASCIItoUTF16(aFilename, message);
else
message.AppendLiteral("this .jar archive");
message.AppendLiteral(" is invalid because ");
switch(errorCode)
{
case JAR_NOT_SIGNED:
message.AppendLiteral("the archive did not contain a valid PKCS7 signature.");
break;
case JAR_INVALID_SIG:
message.AppendLiteral("the digital signature (*.RSA) file is not a valid signature of the signature instruction file (*.SF).");
break;
case JAR_INVALID_UNKNOWN_CA:
message.AppendLiteral("the certificate used to sign this file has an unrecognized issuer.");
break;
case JAR_INVALID_MANIFEST:
message.AppendLiteral("the signature instruction file (*.SF) does not contain a valid hash of the MANIFEST.MF file.");
break;
case JAR_INVALID_ENTRY:
message.AppendLiteral("the MANIFEST.MF file does not contain a valid hash of the file being verified.");
break;
case JAR_NO_MANIFEST:
message.AppendLiteral("the archive did not contain a manifest.");
break;
default:
message.AppendLiteral("of an unknown problem.");
}
// Report error in JS console
nsCOMPtr<nsIConsoleService> console(do_GetService("@mozilla.org/consoleservice;1"));
if (console)
{
console->LogStringMessage(message.get());
}
#ifdef DEBUG
char* messageCstr = ToNewCString(message);
if (!messageCstr) return;
fprintf(stderr, "%s\n", messageCstr);
nsMemory::Free(messageCstr);
#endif
}
示例7: CreateException
bool
Throw(JSContext* aCx, nsresult aRv, const nsACString& aMessage)
{
if (aRv == NS_ERROR_UNCATCHABLE_EXCEPTION) {
// Nuke any existing exception on aCx, to make sure we're uncatchable.
JS_ClearPendingException(aCx);
return false;
}
if (JS_IsExceptionPending(aCx)) {
// Don't clobber the existing exception.
return false;
}
CycleCollectedJSRuntime* runtime = CycleCollectedJSRuntime::Get();
nsCOMPtr<nsIException> existingException = runtime->GetPendingException();
// Make sure to clear the pending exception now. Either we're going to reuse
// it (and we already grabbed it), or we plan to throw something else and this
// pending exception is no longer relevant.
runtime->SetPendingException(nullptr);
// Ignore the pending exception if we have a non-default message passed in.
if (aMessage.IsEmpty() && existingException) {
nsresult nr;
if (NS_SUCCEEDED(existingException->GetResult(&nr)) &&
aRv == nr) {
// Reuse the existing exception.
if (!ThrowExceptionObject(aCx, existingException)) {
// If we weren't able to throw an exception we're
// most likely out of memory
JS_ReportOutOfMemory(aCx);
}
return false;
}
}
RefPtr<Exception> finalException = CreateException(aCx, aRv, aMessage);
MOZ_ASSERT(finalException);
if (!ThrowExceptionObject(aCx, finalException)) {
// If we weren't able to throw an exception we're
// most likely out of memory
JS_ReportOutOfMemory(aCx);
}
return false;
}
示例8: mAlgorithmType
SRIMetadata::SRIMetadata(const nsACString& aToken)
: mAlgorithmType(SRIMetadata::UNKNOWN_ALGORITHM), mEmpty(false)
{
MOZ_ASSERT(!aToken.IsEmpty()); // callers should check this first
SRIMETADATALOG(("SRIMetadata::SRIMetadata, aToken='%s'",
PromiseFlatCString(aToken).get()));
int32_t hyphen = aToken.FindChar('-');
if (hyphen == -1) {
SRIMETADATAERROR(("SRIMetadata::SRIMetadata, invalid (no hyphen)"));
return; // invalid metadata
}
// split the token into its components
mAlgorithm = Substring(aToken, 0, hyphen);
uint32_t hashStart = hyphen + 1;
if (hashStart >= aToken.Length()) {
SRIMETADATAERROR(("SRIMetadata::SRIMetadata, invalid (missing digest)"));
return; // invalid metadata
}
int32_t question = aToken.FindChar('?');
if (question == -1) {
mHashes.AppendElement(Substring(aToken, hashStart,
aToken.Length() - hashStart));
} else {
MOZ_ASSERT(question > 0);
if (static_cast<uint32_t>(question) <= hashStart) {
SRIMETADATAERROR(("SRIMetadata::SRIMetadata, invalid (options w/o digest)"));
return; // invalid metadata
}
mHashes.AppendElement(Substring(aToken, hashStart,
question - hashStart));
}
if (mAlgorithm.EqualsLiteral("sha256")) {
mAlgorithmType = nsICryptoHash::SHA256;
} else if (mAlgorithm.EqualsLiteral("sha384")) {
mAlgorithmType = nsICryptoHash::SHA384;
} else if (mAlgorithm.EqualsLiteral("sha512")) {
mAlgorithmType = nsICryptoHash::SHA512;
}
SRIMETADATALOG(("SRIMetadata::SRIMetadata, hash='%s'; alg='%s'",
mHashes[0].get(), mAlgorithm.get()));
}
示例9: key
//--------------------------------------------------------------
NS_IMETHODIMP nsCharsetAlias2::GetPreferred(const nsACString& aAlias,
nsACString& oResult)
{
if (aAlias.IsEmpty()) return NS_ERROR_NULL_POINTER;
NS_TIMELINE_START_TIMER("nsCharsetAlias2:GetPreferred");
// Delay loading charsetalias.properties by hardcoding the most
// frequent aliases. Note that it's possible to recur in to this
// function *while loading* charsetalias.properties (see bug 190951),
// so we might have an |mDelegate| already that isn't valid yet, but
// the load is guaranteed to be "UTF-8" so things will be OK.
for (PRUint32 index = 0; index < NS_ARRAY_LENGTH(kAliases); index++) {
if (aAlias.LowerCaseEqualsASCII(kAliases[index][0])) {
oResult.Assign(nsDependentCString(kAliases[index][1],
NS_PTR_TO_UINT32(kAliases[index][2])));
NS_TIMELINE_STOP_TIMER("nsCharsetAlias2:GetPreferred");
return NS_OK;
}
}
oResult.Truncate();
if(!mDelegate) {
//load charsetalias.properties string bundle with all remaining aliases
// we may need to protect the following section with a lock so we won't call the
// 'new nsGREResProperties' from two different threads
mDelegate = new nsGREResProperties( NS_LITERAL_CSTRING("charsetalias.properties") );
NS_ASSERTION(mDelegate, "cannot create nsGREResProperties");
if(nsnull == mDelegate)
return NS_ERROR_OUT_OF_MEMORY;
}
NS_TIMELINE_STOP_TIMER("nsCharsetAlias2:GetPreferred");
NS_TIMELINE_MARK_TIMER("nsCharsetAlias2:GetPreferred");
nsCAutoString key(aAlias);
ToLowerCase(key);
// hack for now, have to fix nsGREResProperties, but we can't until
// string bundles use UTF8 keys
nsAutoString result;
nsresult rv = mDelegate->Get(NS_ConvertASCIItoUTF16(key), result);
LossyAppendUTF16toASCII(result, oResult);
return rv;
}
示例10: PatternMatchesOrigin
// static
bool
IndexedDatabaseManager::TabContextMayAccessOrigin(const TabContext& aContext,
const nsACString& aOrigin)
{
NS_ASSERTION(!aOrigin.IsEmpty(), "Empty origin!");
// If aContext is for a browser element, it's allowed only to access other
// browser elements. But if aContext is not for a browser element, it may
// access both browser and non-browser elements.
nsAutoCString pattern;
QuotaManager::GetOriginPatternStringMaybeIgnoreBrowser(
aContext.OwnOrContainingAppId(),
aContext.IsBrowserElement(),
pattern);
return PatternMatchesOrigin(pattern, aOrigin);
}
示例11: GetSessionInfo
NS_IMETHODIMP
PresentationService::SendSessionBinaryMsg(const nsAString& aSessionId,
uint8_t aRole,
const nsACString& aData) {
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(!aData.IsEmpty());
MOZ_ASSERT(!aSessionId.IsEmpty());
MOZ_ASSERT(aRole == nsIPresentationService::ROLE_CONTROLLER ||
aRole == nsIPresentationService::ROLE_RECEIVER);
RefPtr<PresentationSessionInfo> info = GetSessionInfo(aSessionId, aRole);
if (NS_WARN_IF(!info)) {
return NS_ERROR_NOT_AVAILABLE;
}
return info->SendBinaryMsg(aData);
}
示例12: Initialize
nsresult nsNPAPIPluginInstance::Initialize(nsNPAPIPlugin *aPlugin, nsPluginInstanceOwner* aOwner, const nsACString& aMIMEType)
{
PROFILER_LABEL_FUNC(js::ProfileEntry::Category::OTHER);
PLUGIN_LOG(PLUGIN_LOG_NORMAL, ("nsNPAPIPluginInstance::Initialize this=%p\n",this));
NS_ENSURE_ARG_POINTER(aPlugin);
NS_ENSURE_ARG_POINTER(aOwner);
mPlugin = aPlugin;
mOwner = aOwner;
if (!aMIMEType.IsEmpty()) {
mMIMEType = ToNewCString(aMIMEType);
}
return Start();
}
示例13: ArrayLength
static nsresult
ConvertLocaleToCharsetUsingDeprecatedConfig(const nsACString& locale,
nsACString& oResult)
{
if (!(locale.IsEmpty())) {
nsCAutoString localeKey;
localeKey.AssignLiteral("locale.all.");
localeKey.Append(locale);
if (NS_SUCCEEDED(nsUConvPropertySearch::SearchPropertyValue(kUnixCharsets,
ArrayLength(kUnixCharsets), localeKey, oResult))) {
return NS_OK;
}
}
NS_ERROR("unable to convert locale to charset using deprecated config");
oResult.AssignLiteral("ISO-8859-1");
return NS_SUCCESS_USING_FALLBACK_LOCALE;
}
示例14: key
//--------------------------------------------------------------
NS_IMETHODIMP nsCharsetAlias2::GetPreferred(const nsACString& aAlias,
nsACString& oResult)
{
if (aAlias.IsEmpty()) return NS_ERROR_NULL_POINTER;
NS_TIMELINE_START_TIMER("nsCharsetAlias2:GetPreferred");
nsCAutoString key(aAlias);
ToLowerCase(key);
nsresult rv = nsUConvPropertySearch::SearchPropertyValue(kAliases,
NS_ARRAY_LENGTH(kAliases), key, oResult);
NS_TIMELINE_STOP_TIMER("nsCharsetAlias2:GetPreferred");
NS_TIMELINE_MARK_TIMER("nsCharsetAlias2:GetPreferred");
return rv;
}
示例15: SetChannelRestart
NS_IMETHODIMP sbTagLibChannelFileIOManager::SetChannelRestart(
const nsACString &aChannelID,
PRBool aRestart)
{
sbTagLibChannelFileIOManager::Channel *pChannel;
nsresult rv;
/* Validate parameters. */
NS_ENSURE_FALSE(aChannelID.IsEmpty(), NS_ERROR_INVALID_ARG);
/* Set the channel restart flag. */
rv = GetChannel(aChannelID, &pChannel);
NS_ENSURE_SUCCESS(rv, rv);
pChannel->restart = aRestart;
return (NS_OK);
}