本文整理汇总了C++中nsAutoCString类的典型用法代码示例。如果您正苦于以下问题:C++ nsAutoCString类的具体用法?C++ nsAutoCString怎么用?C++ nsAutoCString使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了nsAutoCString类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SetStorageKey
static void
SetStorageKey(nsAutoCString& storageKey, nsCString& hostname, uint32_t aType)
{
storageKey = hostname;
switch (aType) {
case nsISiteSecurityService::HEADER_HSTS:
storageKey.AppendLiteral(":HSTS");
break;
case nsISiteSecurityService::HEADER_HPKP:
storageKey.AppendLiteral(":HPKP");
break;
default:
NS_ASSERTION(false, "SSS:SetStorageKey got invalid type");
}
}
示例2: fprintf
/* static */ void
nsBaseWidget::debug_DumpPaintEvent(FILE * aFileOut,
nsIWidget * aWidget,
const nsIntRegion & aRegion,
const nsAutoCString & aWidgetName,
int32_t aWindowID)
{
NS_ASSERTION(nullptr != aFileOut,"cmon, null output FILE");
NS_ASSERTION(nullptr != aWidget,"cmon, the widget is null");
if (!debug_GetCachedBoolPref("nglayout.debug.paint_dumping"))
return;
nsIntRect rect = aRegion.GetBounds();
fprintf(aFileOut,
"%4d PAINT widget=%p name=%-12s id=0x%-6x bounds-rect=%3d,%-3d %3d,%-3d",
_GetPrintCount(),
(void *) aWidget,
aWidgetName.get(),
aWindowID,
rect.x, rect.y, rect.width, rect.height
);
fprintf(aFileOut,"\n");
}
示例3: tempString
/* static */ void
nsBaseWidget::debug_DumpEvent(FILE * aFileOut,
nsIWidget * aWidget,
nsGUIEvent * aGuiEvent,
const nsAutoCString & aWidgetName,
int32_t aWindowID)
{
if (aGuiEvent->message == NS_MOUSE_MOVE)
{
if (!debug_GetCachedBoolPref("nglayout.debug.motion_event_dumping"))
return;
}
if (aGuiEvent->message == NS_MOUSE_ENTER ||
aGuiEvent->message == NS_MOUSE_EXIT)
{
if (!debug_GetCachedBoolPref("nglayout.debug.crossing_event_dumping"))
return;
}
if (!debug_GetCachedBoolPref("nglayout.debug.event_dumping"))
return;
NS_LossyConvertUTF16toASCII tempString(debug_GuiEventToString(aGuiEvent).get());
fprintf(aFileOut,
"%4d %-26s widget=%-8p name=%-12s id=0x%-6x refpt=%d,%d\n",
_GetPrintCount(),
tempString.get(),
(void *) aWidget,
aWidgetName.get(),
aWindowID,
aGuiEvent->refPoint.x,
aGuiEvent->refPoint.y);
}
示例4: PR_GetEnv
bool
GeckoChildProcessHost::PerformAsyncLaunch(std::vector<std::string> aExtraOpts, base::ProcessArchitecture arch)
{
// If NSPR log files are not requested, we're done.
const char* origNSPRLogName = PR_GetEnv("NSPR_LOG_FILE");
const char* origMozLogName = PR_GetEnv("MOZ_LOG_FILE");
if (!origNSPRLogName && !origMozLogName) {
return PerformAsyncLaunchInternal(aExtraOpts, arch);
}
++mChildCounter;
// remember original value so we can restore it.
// - Note: this code is not called re-entrantly, nor are restoreOrig*LogName
// or mChildCounter touched by any other thread, so this is safe.
static nsAutoCString restoreOrigNSPRLogName;
static nsAutoCString restoreOrigMozLogName;
if (origNSPRLogName) {
if (restoreOrigNSPRLogName.IsEmpty()) {
restoreOrigNSPRLogName.AssignLiteral("NSPR_LOG_FILE=");
restoreOrigNSPRLogName.Append(origNSPRLogName);
}
SetChildLogName("NSPR_LOG_FILE=", origNSPRLogName);
}
if (origMozLogName) {
if (restoreOrigMozLogName.IsEmpty()) {
restoreOrigMozLogName.AssignLiteral("MOZ_LOG_FILE=");
restoreOrigMozLogName.Append(origMozLogName);
}
SetChildLogName("MOZ_LOG_FILE=", origMozLogName);
}
bool retval = PerformAsyncLaunchInternal(aExtraOpts, arch);
// Revert to original value
if (origNSPRLogName) {
PR_SetEnv(restoreOrigNSPRLogName.get());
}
if (origMozLogName) {
PR_SetEnv(restoreOrigMozLogName.get());
}
return retval;
}
示例5: GetNSSProfilePath
static nsresult
GetNSSProfilePath(nsAutoCString& aProfilePath)
{
aProfilePath.Truncate();
const char* dbDirOverride = getenv("MOZPSM_NSSDBDIR_OVERRIDE");
if (dbDirOverride && strlen(dbDirOverride) > 0) {
MOZ_LOG(gPIPNSSLog, LogLevel::Debug,
("Using specified MOZPSM_NSSDBDIR_OVERRIDE as NSS DB dir: %s\n",
dbDirOverride));
aProfilePath.Assign(dbDirOverride);
return NS_OK;
}
nsCOMPtr<nsIFile> profileFile;
nsresult rv = NS_GetSpecialDirectory(NS_APP_USER_PROFILE_50_DIR,
getter_AddRefs(profileFile));
if (NS_FAILED(rv)) {
NS_WARNING("NSS will be initialized without a profile directory. "
"Some things may not work as expected.");
return NS_OK;
}
#if defined(XP_WIN)
// Native path will drop Unicode characters that cannot be mapped to system's
// codepage, using short (canonical) path as workaround.
nsCOMPtr<nsILocalFileWin> profileFileWin(do_QueryInterface(profileFile));
if (!profileFileWin) {
MOZ_LOG(gPIPNSSLog, LogLevel::Error,
("Could not get nsILocalFileWin for profile directory.\n"));
return NS_ERROR_FAILURE;
}
rv = profileFileWin->GetNativeCanonicalPath(aProfilePath);
#else
rv = profileFile->GetNativePath(aProfilePath);
#endif
if (NS_FAILED(rv)) {
MOZ_LOG(gPIPNSSLog, LogLevel::Error,
("Could not get native path for profile directory.\n"));
return rv;
}
MOZ_LOG(gPIPNSSLog, LogLevel::Debug,
("NSS profile at '%s'\n", aProfilePath.get()));
return NS_OK;
}
示例6: nsMsgI18NFileSystemCharset
// Charset used by the file system.
const char * nsMsgI18NFileSystemCharset()
{
/* Get a charset used for the file. */
static nsAutoCString fileSystemCharset;
if (fileSystemCharset.IsEmpty())
{
nsresult rv;
nsCOMPtr <nsIPlatformCharset> platformCharset = do_GetService(NS_PLATFORMCHARSET_CONTRACTID, &rv);
if (NS_SUCCEEDED(rv)) {
rv = platformCharset->GetCharset(kPlatformCharsetSel_FileName,
fileSystemCharset);
}
if (NS_FAILED(rv))
fileSystemCharset.Assign("ISO-8859-1");
}
return fileSystemCharset.get();
}
示例7: GetHostPortKey
static nsresult
GetHostPortKey(TransportSecurityInfo* infoObject, nsAutoCString &result)
{
nsresult rv;
result.Truncate();
nsXPIDLCString hostName;
rv = infoObject->GetHostName(getter_Copies(hostName));
NS_ENSURE_SUCCESS(rv, rv);
int32_t port;
rv = infoObject->GetPort(&port);
NS_ENSURE_SUCCESS(rv, rv);
result.Assign(hostName);
result.Append(':');
result.AppendInt(port);
return NS_OK;
}
示例8: pref
bool nsDefaultURIFixup::IsDomainWhitelisted(const nsAutoCString aAsciiHost,
const uint32_t aDotLoc)
{
if (sDNSFirstForSingleWords) {
return true;
}
// Check if this domain is whitelisted as an actual
// domain (which will prevent a keyword query)
// NB: any processing of the host here should stay in sync with
// code in the front-end(s) that set the pref.
nsAutoCString pref("browser.fixup.domainwhitelist.");
if (aDotLoc == aAsciiHost.Length() - 1) {
pref.Append(Substring(aAsciiHost, 0, aAsciiHost.Length() - 1));
} else {
pref.Append(aAsciiHost);
}
return Preferences::GetBool(pref.get(), false);
}
示例9: canonicalizeBase
static inline bool
canonicalizeBase(nsAutoCString &spec,
nsACString &out)
{
nsAutoCString greBase, appBase;
nsresult rv = mozilla::Omnijar::GetURIString(mozilla::Omnijar::GRE, greBase);
if (NS_FAILED(rv) || !greBase.Length())
return false;
rv = mozilla::Omnijar::GetURIString(mozilla::Omnijar::APP, appBase);
if (NS_FAILED(rv))
return false;
bool underGre = !greBase.Compare(spec.get(), false, greBase.Length());
bool underApp = appBase.Length() &&
!appBase.Compare(spec.get(), false, appBase.Length());
if (!underGre && !underApp)
return false;
/**
* At this point, if both underGre and underApp are true, it can be one
* of the two following cases:
* - the GRE directory points to a subdirectory of the APP directory,
* meaning spec points under GRE.
* - the APP directory points to a subdirectory of the GRE directory,
* meaning spec points under APP.
* Checking the GRE and APP path length is enough to know in which case
* we are.
*/
if (underGre && underApp && greBase.Length() < appBase.Length())
underGre = false;
out.Append("/resource/");
out.Append(baseName[underGre ? mozilla::Omnijar::GRE : mozilla::Omnijar::APP]);
out.Append(Substring(spec, underGre ? greBase.Length() : appBase.Length()));
return true;
}
示例10: NS_IMPL_CYCLE_COLLECTION_CLASS
mScopeObject = aScopeObject;
}
NS_IMPL_CYCLE_COLLECTION_CLASS(nsJSEventListener)
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsJSEventListener)
if (tmp->mScopeObject) {
tmp->mScopeObject = nullptr;
mozilla::DropJSObjects(tmp);
NS_IMPL_CYCLE_COLLECTION_UNLINK(mContext)
}
tmp->mHandler.ForgetHandler();
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INTERNAL(nsJSEventListener)
if (MOZ_UNLIKELY(cb.WantDebugInfo()) && tmp->mEventName) {
nsAutoCString name;
name.AppendLiteral("nsJSEventListener handlerName=");
name.Append(
NS_ConvertUTF16toUTF8(nsDependentAtomString(tmp->mEventName)).get());
cb.DescribeRefCountedNode(tmp->mRefCnt.get(), name.get());
} else {
NS_IMPL_CYCLE_COLLECTION_DESCRIBE(nsJSEventListener, tmp->mRefCnt.get())
}
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mContext)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_RAWPTR(mHandler.Ptr())
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(nsJSEventListener)
NS_IMPL_CYCLE_COLLECTION_TRACE_JS_MEMBER_CALLBACK(mScopeObject)
NS_IMPL_CYCLE_COLLECTION_TRACE_END
示例11: PrintError
void nsTestLog::PrintError(const char * aCall, const char * aMessage)
{
const char * trace = mTrace.get();
printf("ERROR at %s%s reason: %s.\n", trace, aCall, aMessage);
}
示例12: DelTrace
void nsTestLog::DelTrace(const char * aTrace)
{
mTrace.Truncate(mTrace.Length() - strlen(aTrace) - strlen(kTraceDelimiter));
}
示例13: AddTrace
void nsTestLog::AddTrace(const char * aTrace)
{
mTrace.Append(aTrace);
mTrace.Append(kTraceDelimiter);
}