本文整理汇总了C++中NS_RELEASE函数的典型用法代码示例。如果您正苦于以下问题:C++ NS_RELEASE函数的具体用法?C++ NS_RELEASE怎么用?C++ NS_RELEASE使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NS_RELEASE函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: NS_ENSURE_ARG_POINTER
NS_IMETHODIMP nsMsgThread::GetRootHdr(int32_t *resultIndex, nsIMsgDBHdr **result)
{
NS_ENSURE_ARG_POINTER(result);
*result = nullptr;
nsresult rv = NS_OK;
if (m_threadRootKey != nsMsgKey_None)
{
rv = GetChildHdrForKey(m_threadRootKey, result, resultIndex);
if (NS_SUCCEEDED(rv) && *result)
{
// check that we're really the root key.
nsMsgKey parentKey;
(*result)->GetThreadParent(&parentKey);
if (parentKey == nsMsgKey_None)
return rv;
NS_RELEASE(*result);
}
#ifdef DEBUG_David_Bienvenu
printf("need to reset thread root key\n");
#endif
uint32_t numChildren;
nsMsgKey threadParentKey = nsMsgKey_None;
GetNumChildren(&numChildren);
for (uint32_t childIndex = 0; childIndex < numChildren; childIndex++)
{
nsCOMPtr <nsIMsgDBHdr> curChild;
rv = GetChildHdrAt(childIndex, getter_AddRefs(curChild));
if (NS_SUCCEEDED(rv) && curChild)
{
nsMsgKey parentKey;
curChild->GetThreadParent(&parentKey);
if (parentKey == nsMsgKey_None)
{
curChild->GetMessageKey(&threadParentKey);
if (*result)
{
NS_WARNING("two top level msgs, not good");
continue;
}
SetThreadRootKey(threadParentKey);
if (resultIndex)
*resultIndex = childIndex;
NS_ADDREF(*result = curChild);
ReparentMsgsWithInvalidParent(numChildren, threadParentKey);
// return NS_OK;
}
}
}
}
if (!*result)
{
// if we can't get the thread root key, we'll just get the first hdr.
// there's a bug where sometimes we weren't resetting the thread root key
// when removing the thread root key.
if (resultIndex)
*resultIndex = 0;
rv = GetChildHdrAt(0, result);
}
if (!*result)
return rv;
// Check that the thread id of the message is this thread.
nsMsgKey threadId = nsMsgKey_None;
(void)(*result)->GetThreadId(&threadId);
if (threadId != m_threadKey)
(*result)->SetThreadId(m_threadKey);
return rv;
}
开发者ID:MoonchildProductions,项目名称:FossaMail,代码行数:71,代码来源:nsMsgThread.cpp
示例2: LOG
//
// Always set *identityInvalid == FALSE here. This
// will prevent the browser from popping up the authentication
// prompt window. Because GSSAPI does not have an API
// for fetching initial credentials (ex: A Kerberos TGT),
// there is no correct way to get the users credentials.
//
NS_IMETHODIMP
nsHttpNegotiateAuth::ChallengeReceived(nsIHttpAuthenticableChannel *authChannel,
const char *challenge,
bool isProxyAuth,
nsISupports **sessionState,
nsISupports **continuationState,
bool *identityInvalid)
{
nsIAuthModule *module = (nsIAuthModule *) *continuationState;
*identityInvalid = false;
if (module)
return NS_OK;
nsresult rv;
nsCOMPtr<nsIURI> uri;
rv = authChannel->GetURI(getter_AddRefs(uri));
if (NS_FAILED(rv))
return rv;
uint32_t req_flags = nsIAuthModule::REQ_DEFAULT;
nsAutoCString service;
if (isProxyAuth) {
if (!TestBoolPref(kNegotiateAuthAllowProxies)) {
LOG(("nsHttpNegotiateAuth::ChallengeReceived proxy auth blocked\n"));
return NS_ERROR_ABORT;
}
nsCOMPtr<nsIProxyInfo> proxyInfo;
authChannel->GetProxyInfo(getter_AddRefs(proxyInfo));
NS_ENSURE_STATE(proxyInfo);
proxyInfo->GetHost(service);
}
else {
bool allowed = TestNonFqdn(uri) ||
TestPref(uri, kNegotiateAuthTrustedURIs);
if (!allowed) {
LOG(("nsHttpNegotiateAuth::ChallengeReceived URI blocked\n"));
return NS_ERROR_ABORT;
}
bool delegation = TestPref(uri, kNegotiateAuthDelegationURIs);
if (delegation) {
LOG((" using REQ_DELEGATE\n"));
req_flags |= nsIAuthModule::REQ_DELEGATE;
}
rv = uri->GetAsciiHost(service);
if (NS_FAILED(rv))
return rv;
}
LOG((" service = %s\n", service.get()));
//
// The correct service name for IIS servers is "HTTP/f.q.d.n", so
// construct the proper service name for passing to "gss_import_name".
//
// TODO: Possibly make this a configurable service name for use
// with non-standard servers that use stuff like "khttp/f.q.d.n"
// instead.
//
service.Insert("[email protected]", 0);
const char *contractID;
if (TestBoolPref(kNegotiateAuthSSPI)) {
LOG((" using negotiate-sspi\n"));
contractID = NS_AUTH_MODULE_CONTRACTID_PREFIX "negotiate-sspi";
}
else {
LOG((" using negotiate-gss\n"));
contractID = NS_AUTH_MODULE_CONTRACTID_PREFIX "negotiate-gss";
}
rv = CallCreateInstance(contractID, &module);
if (NS_FAILED(rv)) {
LOG((" Failed to load Negotiate Module \n"));
return rv;
}
rv = module->Init(service.get(), req_flags, nullptr, nullptr, nullptr);
if (NS_FAILED(rv)) {
NS_RELEASE(module);
return rv;
}
*continuationState = module;
return NS_OK;
//.........这里部分代码省略.........
开发者ID:AshishNamdev,项目名称:mozilla-central,代码行数:101,代码来源:nsHttpNegotiateAuth.cpp
示例3: GetOriginatingURI
nsresult
ThirdPartyUtil::GetFirstPartyURIInternal(nsIChannel *aChannel,
nsIDocument *aDoc,
bool aLogErrors,
nsIURI **aOutput)
{
nsresult rv = NS_ERROR_NULL_POINTER;
nsCOMPtr<nsIURI> srcURI;
if (!aOutput)
return rv;
*aOutput = nullptr;
if (!aChannel && aDoc) {
aChannel = aDoc->GetChannel();
}
// If aChannel is specified or available, use the official route
// for sure
if (aChannel) {
rv = GetOriginatingURI(aChannel, aOutput);
aChannel->GetURI(getter_AddRefs(srcURI));
if (NS_SUCCEEDED(rv) && *aOutput) {
// At this point, about: and chrome: URLs have been mapped to file: or
// jar: URLs. Try to recover the original URL.
nsAutoCString scheme;
nsresult rv2 = (*aOutput)->GetScheme(scheme);
NS_ENSURE_SUCCESS(rv2, rv2);
if (scheme.Equals("file") || scheme.Equals("jar")) {
nsCOMPtr<nsIURI> originalURI;
rv2 = aChannel->GetOriginalURI(getter_AddRefs(originalURI));
if (NS_SUCCEEDED(rv2) && originalURI) {
NS_RELEASE(*aOutput);
NS_ADDREF(*aOutput = originalURI);
}
}
}
}
// If the channel was missing, closed or broken, try the
// window hierarchy directly.
//
// This might fail to work for first-party loads themselves, but
// we don't need this codepath for that case.
if (NS_FAILED(rv) && aDoc) {
nsCOMPtr<nsIDOMWindow> top;
nsCOMPtr<nsIDOMDocument> topDDoc;
nsIURI *docURI = nullptr;
srcURI = aDoc->GetDocumentURI();
if (aDoc->GetWindow()) {
aDoc->GetWindow()->GetTop(getter_AddRefs(top));
top->GetDocument(getter_AddRefs(topDDoc));
nsCOMPtr<nsIDocument> topDoc(do_QueryInterface(topDDoc));
docURI = topDoc->GetOriginalURI();
if (docURI) {
// Give us a mutable URI and also addref
rv = NS_EnsureSafeToReturn(docURI, aOutput);
}
} else {
// XXX: Chrome callers (such as NoScript) can end up here
// through getImageData/canvas usage with no document state
// (no Window and a document URI of about:blank). Propogate
// rv fail (by doing nothing), and hope caller recovers.
}
if (*aOutput)
rv = NS_OK;
}
if (*aOutput && !SchemeIsWhiteListed(*aOutput)) {
// If URI scheme is not whitelisted and the URI lacks a hostname, force a
// failure.
nsAutoCString host;
rv = (*aOutput)->GetHost(host);
if (NS_SUCCEEDED(rv) && (host.Length() == 0)) {
rv = NS_ERROR_FAILURE;
}
}
// Log failure to error console.
if (aLogErrors && NS_FAILED(rv)) {
nsCOMPtr<nsIConsoleService> console
(do_GetService(NS_CONSOLESERVICE_CONTRACTID));
if (console) {
nsCString spec;
nsCString srcSpec("unknown");
if (srcURI)
srcURI->GetSpec(srcSpec);
if (*aOutput)
(*aOutput)->GetSpec(spec);
if (spec.Length() > 0) {
nsPrintfCString msg("getFirstPartyURI failed for %s: no host in first party URI %s",
srcSpec.get(), spec.get()); // TODO: L10N
console->LogStringMessage(NS_ConvertUTF8toUTF16(msg).get());
} else {
//.........这里部分代码省略.........
开发者ID:Acidburn0zzz,项目名称:tor-browser,代码行数:101,代码来源:ThirdPartyUtil.cpp
示例4: NS_ASSERTION
// static
nsresult
nsXPCWrappedJS::GetNewOrUsed(XPCCallContext& ccx,
JSObject* aJSObj,
REFNSIID aIID,
nsISupports* aOuter,
nsXPCWrappedJS** wrapperResult)
{
JSObject2WrappedJSMap* map;
JSObject* rootJSObj;
nsXPCWrappedJS* root = nsnull;
nsXPCWrappedJS* wrapper = nsnull;
nsXPCWrappedJSClass* clazz = nsnull;
XPCJSRuntime* rt = ccx.GetRuntime();
JSBool release_root = false;
map = rt->GetWrappedJSMap();
if (!map) {
NS_ASSERTION(map,"bad map");
return NS_ERROR_FAILURE;
}
nsXPCWrappedJSClass::GetNewOrUsed(ccx, aIID, &clazz);
if (!clazz)
return NS_ERROR_FAILURE;
// from here on we need to return through 'return_wrapper'
// always find the root JSObject
rootJSObj = clazz->GetRootJSObject(ccx, aJSObj);
if (!rootJSObj)
goto return_wrapper;
// look for the root wrapper, and if found, hold the map lock until
// we've added our ref to prevent another thread from destroying it
// under us
{ // scoped lock
XPCAutoLock lock(rt->GetMapLock());
root = map->Find(rootJSObj);
if (root) {
if ((nsnull != (wrapper = root->Find(aIID))) ||
(nsnull != (wrapper = root->FindInherited(aIID)))) {
NS_ADDREF(wrapper);
goto return_wrapper;
}
}
}
if (!root) {
// build the root wrapper
if (rootJSObj == aJSObj) {
// the root will do double duty as the interface wrapper
wrapper = root = new nsXPCWrappedJS(ccx, aJSObj, clazz, nsnull,
aOuter);
if (!root)
goto return_wrapper;
{ // scoped lock
#if DEBUG_xpc_leaks
printf("Created nsXPCWrappedJS %p, JSObject is %p\n",
(void*)wrapper, (void*)aJSObj);
#endif
XPCAutoLock lock(rt->GetMapLock());
map->Add(root);
}
if (!CheckMainThreadOnly(root)) {
XPCAutoLock lock(rt->GetMapLock());
map->Remove(root);
wrapper = NULL;
}
goto return_wrapper;
} else {
// just a root wrapper
nsXPCWrappedJSClass* rootClazz = nsnull;
nsXPCWrappedJSClass::GetNewOrUsed(ccx, NS_GET_IID(nsISupports),
&rootClazz);
if (!rootClazz)
goto return_wrapper;
root = new nsXPCWrappedJS(ccx, rootJSObj, rootClazz, nsnull, aOuter);
NS_RELEASE(rootClazz);
if (!root)
goto return_wrapper;
release_root = true;
{ // scoped lock
#if DEBUG_xpc_leaks
printf("Created nsXPCWrappedJS %p, JSObject is %p\n",
(void*)root, (void*)rootJSObj);
#endif
XPCAutoLock lock(rt->GetMapLock());
map->Add(root);
}
if (!CheckMainThreadOnly(root)) {
XPCAutoLock lock(rt->GetMapLock());
//.........这里部分代码省略.........
开发者ID:krellian,项目名称:mozilla-central,代码行数:101,代码来源:XPCWrappedJS.cpp
示例5: NS_ENSURE_ARG_POINTER
NS_IMETHODIMP
nsMsgBrkMBoxStore::GetNewMsgOutputStream(nsIMsgFolder *aFolder,
nsIMsgDBHdr **aNewMsgHdr,
bool *aReusable,
nsIOutputStream **aResult)
{
NS_ENSURE_ARG_POINTER(aFolder);
NS_ENSURE_ARG_POINTER(aNewMsgHdr);
NS_ENSURE_ARG_POINTER(aReusable);
NS_ENSURE_ARG_POINTER(aResult);
#ifdef _DEBUG
NS_ASSERTION(m_streamOutstandingFolder != aFolder, "didn't finish prev msg");
m_streamOutstandingFolder = aFolder;
#endif
*aReusable = true;
nsCOMPtr<nsIFile> mboxFile;
aFolder->GetFilePath(getter_AddRefs(mboxFile));
nsCOMPtr<nsIMsgDatabase> db;
aFolder->GetMsgDatabase(getter_AddRefs(db));
if (!db && !*aNewMsgHdr)
NS_WARNING("no db, and no message header");
bool exists;
mboxFile->Exists(&exists);
if (!exists)
mboxFile->Create(nsIFile::NORMAL_FILE_TYPE, 0600);
nsCString URI;
aFolder->GetURI(URI);
nsresult rv;
nsCOMPtr<nsISeekableStream> seekable;
if (m_outputStreams.Get(URI, aResult))
{
seekable = do_QueryInterface(*aResult, &rv);
NS_ENSURE_SUCCESS(rv, rv);
rv = seekable->Seek(nsISeekableStream::NS_SEEK_END, 0);
if (NS_FAILED(rv))
{
m_outputStreams.Remove(URI);
NS_RELEASE(*aResult);
}
}
if (!*aResult)
{
rv = MsgGetFileStream(mboxFile, aResult);
NS_ASSERTION(NS_SUCCEEDED(rv), "failed opening offline store for output");
if (NS_FAILED(rv))
printf("failed opening offline store for %s\n", URI.get());
NS_ENSURE_SUCCESS(rv, rv);
seekable = do_QueryInterface(*aResult, &rv);
NS_ENSURE_SUCCESS(rv, rv);
rv = seekable->Seek(nsISeekableStream::NS_SEEK_END, 0);
NS_ENSURE_SUCCESS(rv, rv);
m_outputStreams.Put(URI, *aResult);
}
int64_t filePos;
seekable->Tell(&filePos);
if (db && !*aNewMsgHdr)
{
// if mbox is close to 4GB, auto-assign the msg key.
nsMsgKey key = filePos > 0xFFFFFF00 ? nsMsgKey_None : (nsMsgKey) filePos;
db->CreateNewHdr(key, aNewMsgHdr);
}
if (*aNewMsgHdr)
{
char storeToken[100];
PR_snprintf(storeToken, sizeof(storeToken), "%lld", filePos);
(*aNewMsgHdr)->SetMessageOffset(filePos);
(*aNewMsgHdr)->SetStringProperty("storeToken", storeToken);
}
return rv;
}
开发者ID:dualsky,项目名称:FossaMail,代码行数:72,代码来源:nsMsgBrkMBoxStore.cpp
示例6: GetJNIEnv
//.........这里部分代码省略.........
rv = GetIIDForMethodParam(mIInfo, aMethodInfo, aParamInfo,
aParamInfo.GetType().TagPart(), aMethodIndex,
aDispatchParams, PR_FALSE, iid);
if (NS_FAILED(rv))
break;
// If the requested interface is nsIWeakReference, then we look for or
// create a stub for the nsISupports interface. Then we create a weak
// reference from that stub.
PRBool isWeakRef;
if (iid.Equals(NS_GET_IID(nsIWeakReference))) {
isWeakRef = PR_TRUE;
iid = NS_GET_IID(nsISupports);
} else {
isWeakRef = PR_FALSE;
}
rv = JavaObjectToNativeInterface(env, java_obj, iid, &xpcom_obj);
if (NS_FAILED(rv))
break;
rv = ((nsISupports*) xpcom_obj)->QueryInterface(iid, &xpcom_obj);
if (NS_FAILED(rv))
break;
// If the function expects a weak reference, then we need to
// create it here.
if (isWeakRef) {
nsISupports* isupports = (nsISupports*) xpcom_obj;
nsCOMPtr<nsISupportsWeakReference> supportsweak =
do_QueryInterface(isupports);
if (supportsweak) {
nsWeakPtr weakref;
supportsweak->GetWeakReference(getter_AddRefs(weakref));
NS_RELEASE(isupports);
xpcom_obj = weakref;
NS_ADDREF((nsISupports*) xpcom_obj);
} else {
xpcom_obj = nsnull;
}
}
}
// For 'inout' params, if the resulting xpcom value is different than the
// one passed in, then we must release the incoming xpcom value.
nsISupports** variant = static_cast<nsISupports**>(aVariant.val.p);
if (aParamInfo.IsIn() && *variant) {
nsCOMPtr<nsISupports> in = do_QueryInterface(*variant);
nsCOMPtr<nsISupports> out = do_QueryInterface((nsISupports*) xpcom_obj);
if (in != out) {
NS_RELEASE(*variant);
}
}
*(static_cast<void**>(aVariant.val.p)) = xpcom_obj;
}
break;
case nsXPTType::T_ASTRING:
case nsXPTType::T_DOMSTRING:
{
NS_PRECONDITION(aParamInfo.IsDipper(), "string argument is not dipper");
if (!aParamInfo.IsDipper()) {
rv = NS_ERROR_UNEXPECTED;
break;
}
开发者ID:bringhurst,项目名称:vbox,代码行数:66,代码来源:nsJavaXPTCStub.cpp
示例7: NS_InitEmbedding
NS_METHOD
NS_InitEmbedding(nsILocalFile *mozBinDirectory,
nsIDirectoryServiceProvider *appFileLocProvider,
nsStaticModuleInfo const *aStaticComponents,
PRUint32 aStaticComponentCount)
{
nsresult rv;
// Reentrant calls to this method do nothing except increment a counter
sInitCounter++;
if (sInitCounter > 1)
return NS_OK;
// Initialise XPCOM
#ifdef HACK_AROUND_NONREENTRANT_INITXPCOM
// Can't call NS_InitXPCom more than once or things go boom!
if (!sXPCOMInitializedFlag)
#endif
{
// Initialise XPCOM
rv = NS_InitXPCOM3(&sServiceManager, mozBinDirectory, appFileLocProvider,
aStaticComponents, aStaticComponentCount);
NS_ENSURE_SUCCESS(rv, rv);
#ifdef HACK_AROUND_NONREENTRANT_INITXPCOM
sXPCOMInitializedFlag = PR_TRUE;
sXPCOMCleanupHack.mCleanOnExit = PR_TRUE;
#endif
}
// Register components
if (!sRegistryInitializedFlag)
{
#ifdef DEBUG
nsIComponentRegistrar *registrar;
rv = sServiceManager->QueryInterface(NS_GET_IID(nsIComponentRegistrar),
(void **) ®istrar);
if (NS_FAILED(rv))
{
NS_WARNING("Could not QI to registrar");
return rv;
}
rv = registrar->AutoRegister(nsnull);
if (NS_FAILED(rv))
{
NS_WARNING("Could not AutoRegister");
}
else
{
// If the application is using an GRE, then, auto register components
// in the GRE directory as well.
//
// The application indicates that it's using an GRE by returning a
// valid nsIFile when queried (via appFileLocProvider) for the
// NS_GRE_DIR atom as shown below
if (appFileLocProvider)
{
nsIFile *greDir = nsnull;
PRBool persistent = PR_TRUE;
appFileLocProvider->GetFile(NS_GRE_DIR, &persistent,
&greDir);
if (greDir)
{
rv = registrar->AutoRegister(greDir);
if (NS_FAILED(rv))
NS_WARNING("Could not AutoRegister GRE components");
NS_RELEASE(greDir);
}
}
}
NS_RELEASE(registrar);
if (NS_FAILED(rv))
return rv;
#endif
sRegistryInitializedFlag = PR_TRUE;
}
nsIComponentManager *compMgr;
rv = sServiceManager->QueryInterface(NS_GET_IID(nsIComponentManager),
(void **) &compMgr);
if (NS_FAILED(rv))
return rv;
nsIObserver *startupNotifier;
rv = compMgr->CreateInstanceByContractID(NS_APPSTARTUPNOTIFIER_CONTRACTID,
NULL,
NS_GET_IID(nsIObserver),
(void **) &startupNotifier);
NS_RELEASE(compMgr);
if (NS_FAILED(rv))
return rv;
startupNotifier->Observe(nsnull, APPSTARTUP_TOPIC, nsnull);
NS_RELEASE(startupNotifier);
#ifdef HACK_AROUND_THREADING_ISSUES
// XXX force certain objects to be created on the main thread
nsIStringBundleService *bundleService;
rv = sServiceManager->GetServiceByContractID(NS_STRINGBUNDLE_CONTRACTID,
//.........这里部分代码省略.........
开发者ID:EdgarChen,项目名称:mozilla-cvs-history,代码行数:101,代码来源:nsEmbedAPI.cpp
示例8: TestSecurityManager
static void
TestSecurityManager(JSContext* jscontext, JSObject* glob, nsIXPConnect* xpc)
{
const char* t;
jsval rval;
JSBool success = JS_TRUE;
MySecMan* sm = new MySecMan();
nsTestXPCFoo* foo = new nsTestXPCFoo();
if(!sm || ! foo)
{
success = JS_FALSE;
printf("FAILED to create object!\n");
goto sm_test_done;
}
rval = JSVAL_FALSE;
JS_SetProperty(jscontext, glob, "failed", &rval);
printf("Individual SecurityManager tests...\n");
if(NS_FAILED(xpc->SetSecurityManagerForJSContext(jscontext, sm,
nsIXPCSecurityManager::HOOK_ALL)))
{
success = JS_FALSE;
printf("SetSecurityManagerForJSContext FAILED!\n");
goto sm_test_done;
}
printf(" build wrapper with veto: TEST NOT RUN\n");
/*
// This test is broken because xpconnect now detects that this is a
// call from native code and lets it succeed without calling the security manager
sm->SetMode(MySecMan::VETO_ALL);
printf(" build wrapper with veto: ");
if(NS_SUCCEEDED(xpc->WrapNative(jscontext, glob, foo, NS_GET_IID(nsITestXPCFoo2), &wrapper)))
{
success = JS_FALSE;
printf("FAILED\n");
NS_RELEASE(wrapper);
}
else
{
printf("passed\n");
}
*/
sm->SetMode(MySecMan::OK_ALL);
printf(" build wrapper no veto: ");
nsIXPConnectJSObjectHolder* holder;
if(NS_SUCCEEDED(xpc->WrapNative(jscontext, glob, foo,
NS_GET_IID(nsITestXPCFoo2), &holder)))
{
printf("passed\n");
JSObject* obj;
if(NS_SUCCEEDED(holder->GetJSObject(&obj)))
{
rval = OBJECT_TO_JSVAL(obj);
JS_SetProperty(jscontext, glob, "foo", &rval);
}
NS_RELEASE(holder);
}
else
{
success = JS_FALSE;
printf("FAILED\n");
}
sm->SetMode(MySecMan::OK_ALL);
printf(" getService no veto: ");
t = "try{Components.classes['@mozilla.org/js/xpc/XPConnect;1'].getService(); print('passed');}catch(e){failed = true; print('FAILED');}";
JS_EvaluateScript(jscontext, glob, t, strlen(t), "builtin", 1, &rval);
sm->SetMode(MySecMan::VETO_ALL);
printf(" getService with veto: ");
t = "try{Components.classes['@mozilla.org/js/xpc/XPConnect;1'].getService(); failed = true; print('FAILED');}catch(e){print('passed');}";
JS_EvaluateScript(jscontext, glob, t, strlen(t), "builtin", 1, &rval);
sm->SetMode(MySecMan::OK_ALL);
printf(" createInstance no veto: ");
t = "try{Components.classes['@mozilla.org/js/xpc/ID;1'].createInstance(Components.interfaces.nsIJSID); print('passed');}catch(e){failed = true; print('FAILED');}";
JS_EvaluateScript(jscontext, glob, t, strlen(t), "builtin", 1, &rval);
sm->SetMode(MySecMan::VETO_ALL);
printf(" getService with veto: ");
t = "try{Components.classes['@mozilla.org/js/xpc/ID;1'].createInstance(Components.interfaces.nsIJSID); failed = true; print('FAILED');}catch(e){print('passed');}";
JS_EvaluateScript(jscontext, glob, t, strlen(t), "builtin", 1, &rval);
sm->SetMode(MySecMan::OK_ALL);
printf(" call method no veto: ");
t = "try{foo.Test2(); print(' : passed');}catch(e){failed = true; print(' : FAILED');}";
JS_EvaluateScript(jscontext, glob, t, strlen(t), "builtin", 1, &rval);
sm->SetMode(MySecMan::VETO_ALL);
printf(" call method with veto: ");
t = "try{foo.Test2(); failed = true; print(' : FAILED');}catch(e){print(' : passed');}";
JS_EvaluateScript(jscontext, glob, t, strlen(t), "builtin", 1, &rval);
//.........这里部分代码省略.........
开发者ID:jdahlin,项目名称:jslint,代码行数:101,代码来源:TestXPC.cpp
示例9: NS_ASSERTION
NS_IMETHODIMP
nsInternetCiter::Rewrap(const nsAString& aInString,
PRUint32 aWrapCol, PRUint32 aFirstLineOffset,
PRBool aRespectNewlines,
nsAString& aOutString)
{
// There shouldn't be returns in this string, only dom newlines.
// Check to make sure:
#ifdef DEBUG
PRInt32 cr = aInString.FindChar(PRUnichar('\r'));
NS_ASSERTION((cr < 0), "Rewrap: CR in string gotten from DOM!\n");
#endif /* DEBUG */
aOutString.Truncate();
nsCOMPtr<nsILineBreaker> lineBreaker;
nsILineBreakerFactory *lf;
nsresult rv;
rv = CallGetService(NS_LWBRK_CONTRACTID, &lf);
if (NS_SUCCEEDED(rv))
{
nsAutoString lbarg;
lf->GetBreaker(lbarg, getter_AddRefs(lineBreaker));
NS_RELEASE(lf);
}
// Loop over lines in the input string, rewrapping each one.
PRUint32 length;
PRUint32 posInString = 0;
PRUint32 outStringCol = 0;
PRUint32 citeLevel = 0;
const nsPromiseFlatString &tString = PromiseFlatString(aInString);
length = tString.Length();
#ifdef DEBUG_wrapping
int loopcount = 0;
#endif
while (posInString < length)
{
#ifdef DEBUG_wrapping
printf("Outer loop: '%s'\n",
NS_LossyConvertUCS2toASCII(Substring(tString, posInString,
length-posInString)).get());
printf("out string is now: '%s'\n",
NS_LossyConvertUCS2toASCII(aOutString).get());
#endif
// Get the new cite level here since we're at the beginning of a line
PRUint32 newCiteLevel = 0;
while (posInString < length && tString[posInString] == gt)
{
++newCiteLevel;
++posInString;
while (posInString < length && tString[posInString] == space)
++posInString;
}
if (posInString >= length)
break;
// Special case: if this is a blank line, maintain a blank line
// (retain the original paragraph breaks)
if (tString[posInString] == nl && !aOutString.IsEmpty())
{
if (aOutString.Last() != nl)
aOutString.Append(nl);
AddCite(aOutString, newCiteLevel);
aOutString.Append(nl);
++posInString;
outStringCol = 0;
continue;
}
// If the cite level has changed, then start a new line with the
// new cite level (but if we're at the beginning of the string,
// don't bother).
if (newCiteLevel != citeLevel && posInString > newCiteLevel+1
&& outStringCol != 0)
{
BreakLine(aOutString, outStringCol, 0);
}
citeLevel = newCiteLevel;
// Prepend the quote level to the out string if appropriate
if (outStringCol == 0)
{
AddCite(aOutString, citeLevel);
outStringCol = citeLevel + (citeLevel ? 1 : 0);
}
// If it's not a cite, and we're not at the beginning of a line in
// the output string, add a space to separate new text from the
// previous text.
else if (outStringCol > citeLevel)
{
aOutString.Append(space);
++outStringCol;
}
// find the next newline -- don't want to go farther than that
PRInt32 nextNewline = tString.FindChar(nl, posInString);
//.........这里部分代码省略.........
开发者ID:rn10950,项目名称:RetroZilla,代码行数:101,代码来源:nsInternetCiter.cpp
示例10: dbgOut1
BOOL CPlugin::init(HWND hWndParent)
{
dbgOut1("CPlugin::init()");
nsISupports * sm = NULL;
nsIPrefBranch * prefBranch = NULL;
PRBool bSendUrls = PR_FALSE; // default to false if problem getting pref
// note that Mozilla will add reference, so do not forget to release
NPN_GetValue(NULL, NPNVserviceManager, &sm);
// do a QI on the service manager we get back to ensure it's the one we are expecting
if(sm) {
sm->QueryInterface(NS_GET_IID(nsIServiceManager), (void**)&gServiceManager);
NS_RELEASE(sm);
}
if (gServiceManager) {
// get service using its contract id and use it to allocate the memory
gServiceManager->GetServiceByContractID(NS_PREFSERVICE_CONTRACTID,
NS_GET_IID(nsIPrefBranch),
(void **)&prefBranch);
if(prefBranch) {
prefBranch->GetBoolPref("application.use_ns_plugin_finder", &bSendUrls);
NS_RELEASE(prefBranch);
}
}
m_bSmartUpdate = bSendUrls;
if(!m_bHidden)
{
assert(IsWindow(hWndParent));
if(IsWindow(hWndParent))
m_hWndParent = hWndParent;
RECT rcParent;
GetClientRect(m_hWndParent, &rcParent);
CreateWindow(szNullPluginWindowClassName,
"NULL Plugin",
WS_CHILD,
0,0, rcParent.right, rcParent.bottom,
m_hWndParent,
(HMENU)NULL,
m_hInst,
(LPVOID)this);
assert(m_hWnd != NULL);
if((m_hWnd == NULL) || (!IsWindow(m_hWnd)))
return FALSE;
UpdateWindow(m_hWnd);
ShowWindow(m_hWnd, SW_SHOW);
}
if(IsNewMimeType((LPSTR)m_pNPMIMEType) || m_bHidden)
showGetPluginDialog();
return TRUE;
}
开发者ID:MozillaOnline,项目名称:gecko-dev,代码行数:61,代码来源:plugin.cpp
示例11: GetMDBFactory
nsresult nsMsgFolderCache::OpenMDB(const nsACString& dbName, PRBool exists)
{
nsresult ret=NS_OK;
nsCOMPtr<nsIMdbFactory> mdbFactory;
GetMDBFactory(getter_AddRefs(mdbFactory));
if (mdbFactory)
{
ret = mdbFactory->MakeEnv(nsnull, &m_mdbEnv);
if (NS_SUCCEEDED(ret))
{
nsIMdbThumb *thumb = nsnull;
nsIMdbHeap* dbHeap = 0;
mdb_bool dbFrozen = mdbBool_kFalse; // not readonly, we want modifiable
if (m_mdbEnv)
m_mdbEnv->SetAutoClear(PR_TRUE);
if (exists)
{
mdbOpenPolicy inOpenPolicy;
mdb_bool canOpen;
mdbYarn outFormatVersion;
nsIMdbFile* oldFile = 0;
ret = mdbFactory->OpenOldFile(m_mdbEnv, dbHeap, nsCString(dbName).get(),
dbFrozen, &oldFile);
if ( oldFile )
{
if (NS_SUCCEEDED(ret))
{
ret = mdbFactory->CanOpenFilePort(m_mdbEnv, oldFile, // file to investigate
&canOpen, &outFormatVersion);
if (NS_SUCCEEDED(ret) && canOpen)
{
inOpenPolicy.mOpenPolicy_ScopePlan.mScopeStringSet_Count = 0;
inOpenPolicy.mOpenPolicy_MinMemory = 0;
inOpenPolicy.mOpenPolicy_MaxLazy = 0;
ret = mdbFactory->OpenFileStore(m_mdbEnv, NULL, oldFile, &inOpenPolicy,
&thumb);
}
else
ret = NS_MSG_ERROR_FOLDER_SUMMARY_OUT_OF_DATE;
}
NS_RELEASE(oldFile); // always release our file ref, store has own
}
}
if (NS_SUCCEEDED(ret) && thumb)
{
mdb_count outTotal; // total somethings to do in operation
mdb_count outCurrent; // subportion of total completed so far
mdb_bool outDone = PR_FALSE; // is operation finished?
mdb_bool outBroken; // is operation irreparably dead and broken?
do
{
ret = thumb->DoMore(m_mdbEnv, &outTotal, &outCurrent, &outDone, &outBroken);
if (ret != 0)
{// mork isn't really doing NS errors yet.
outDone = PR_TRUE;
break;
}
}
while (NS_SUCCEEDED(ret) && !outBroken && !outDone);
// m_mdbEnv->ClearErrors(); // ### temporary...
if (NS_SUCCEEDED(ret) && outDone)
{
ret = mdbFactory->ThumbToOpenStore(m_mdbEnv, thumb, &m_mdbStore);
if (NS_SUCCEEDED(ret) && m_mdbStore)
ret = InitExistingDB();
}
#ifdef DEBUG_bienvenu1
DumpContents();
#endif
}
else // ### need error code saying why open file store failed
{
nsIMdbFile* newFile = 0;
ret = mdbFactory->CreateNewFile(m_mdbEnv, dbHeap, nsCString(dbName).get(), &newFile);
if ( newFile )
{
if (NS_SUCCEEDED(ret))
{
mdbOpenPolicy inOpenPolicy;
inOpenPolicy.mOpenPolicy_ScopePlan.mScopeStringSet_Count = 0;
inOpenPolicy.mOpenPolicy_MinMemory = 0;
inOpenPolicy.mOpenPolicy_MaxLazy = 0;
ret = mdbFactory->CreateNewFileStore(m_mdbEnv, dbHeap,
newFile, &inOpenPolicy, &m_mdbStore);
if (NS_SUCCEEDED(ret))
ret = InitNewDB();
}
NS_RELEASE(newFile); // always release our file ref, store has own
}
}
NS_IF_RELEASE(thumb);
}
}
return ret;
//.........这里部分代码省略.........
开发者ID:binoc-software,项目名称:mozilla-cvs,代码行数:101,代码来源:nsMsgFolderCache.cpp
示例12: NS_ASSERTION
XPCCallContext::~XPCCallContext()
{
// do cleanup...
bool shouldReleaseXPC = false;
if (mXPCContext) {
mXPCContext->SetCallingLangType(mPrevCallerLanguage);
#ifdef DEBUG
XPCCallContext* old = mThreadData->SetCallContext(mPrevCallContext);
NS_ASSERTION(old == this, "bad pop from per thread data");
#else
(void) mThreadData->SetCallContext(mPrevCallContext);
#endif
shouldReleaseXPC = mPrevCallContext == nsnull;
}
// NB: Needs to happen before the context stack pop.
if (mJSContext && mCallerLanguage == NATIVE_CALLER)
JS_EndRequest(mJSContext);
if (mContextPopRequired) {
XPCJSContextStack* stack = mThreadData->GetJSContextStack();
NS_ASSERTION(stack, "bad!");
if (stack) {
#ifdef DEBUG
JSContext* poppedCX;
nsresult rv = stack->Pop(&poppedCX);
NS_ASSERTION(NS_SUCCEEDED(rv) && poppedCX == mJSContext, "bad pop");
#else
(void) stack->Pop(nsnull);
#endif
}
}
if (mJSContext) {
if (mDestroyJSContextInDestructor) {
#ifdef DEBUG_xpc_hacker
printf("!xpc - doing deferred destruction of JSContext @ %p\n",
mJSContext);
#endif
NS_ASSERTION(!mThreadData->GetJSContextStack() ||
!mThreadData->GetJSContextStack()->
DEBUG_StackHasJSContext(mJSContext),
"JSContext still in threadjscontextstack!");
JS_DestroyContext(mJSContext);
}
}
#ifdef DEBUG
for (PRUint32 i = 0; i < XPCCCX_STRING_CACHE_SIZE; ++i) {
NS_ASSERTION(!mScratchStrings[i].mInUse, "Uh, string wrapper still in use!");
}
#endif
if (shouldReleaseXPC && mXPC)
NS_RELEASE(mXPC);
}
开发者ID:krad-radio,项目名称:mozilla-krad,代码行数:61,代码来源:XPCCallContext.cpp
示例13: arena
//.........这里部分代码省略.........
}
// just in case we'll need to authenticate to the db -jp //
privateKey->wincx = m_ctx;
/*
* Create a subject public key info from the public key.
*/
spkInfo = SECKEY_CreateSubjectPublicKeyInfo(publicKey);
if ( !spkInfo ) {
goto loser;
}
/*
* Now DER encode the whole subjectPublicKeyInfo.
*/
srv = DER_Encode(arena.get(), &spkiItem, CERTSubjectPublicKeyInfoTemplate,
spkInfo);
if (srv != SECSuccess) {
goto loser;
}
/*
* set up the PublicKeyAndChallenge data structure, then DER encode it
*/
pkac.spki = spkiItem;
pkac.challenge.len = aChallenge.Length();
pkac.challenge.data = (unsigned char *)ToNewCString(aChallenge);
if (!pkac.challenge.data) {
rv = NS_ERROR_OUT_OF_MEMORY;
goto loser;
}
srv = DER_Encode(arena.get(), &pkacItem, CERTPublicKeyAndChallengeTemplate,
&pkac);
if (srv != SECSuccess) {
goto loser;
}
/*
* now sign the DER encoded PublicKeyAndChallenge
*/
srv = SEC_DerSignData(arena.get(), &signedItem, pkacItem.data, pkacItem.len,
privateKey, algTag);
if (srv != SECSuccess) {
goto loser;
}
/*
* Convert the signed public key and challenge into base64/ascii.
*/
keystring = UniquePORTString(
BTOA_DataToAscii(signedItem.data, signedItem.len));
if (!keystring) {
rv = NS_ERROR_OUT_OF_MEMORY;
goto loser;
}
CopyASCIItoUTF16(keystring.get(), aOutPublicKey);
rv = NS_OK;
GatherKeygenTelemetry(keyGenMechanism, keysize, keyparamsString);
loser:
if (srv != SECSuccess) {
if ( privateKey ) {
PK11_DestroyTokenObject(privateKey->pkcs11Slot,privateKey->pkcs11ID);
}
if ( publicKey ) {
PK11_DestroyTokenObject(publicKey->pkcs11Slot,publicKey->pkcs11ID);
}
}
if ( spkInfo ) {
SECKEY_DestroySubjectPublicKeyInfo(spkInfo);
}
if ( publicKey ) {
SECKEY_DestroyPublicKey(publicKey);
}
if ( privateKey ) {
SECKEY_DestroyPrivateKey(privateKey);
}
if (slot) {
PK11_FreeSlot(slot);
}
if (KeygenRunnable) {
NS_RELEASE(KeygenRunnable);
}
if (keyparamsString) {
free(keyparamsString);
}
if (pkac.challenge.data) {
free(pkac.challenge.data);
}
// If params is non-null and doesn't point to rsaParams, it was allocated
// in decode_ec_params. We have to free this memory.
if (params && params != &rsaParams) {
SECITEM_FreeItem(static_cast<SECItem*>(params), true);
params = nullptr;
}
return rv;
}
开发者ID:brendandahl,项目名称:positron,代码行数:101,代码来源:nsKeygenHandler.cpp
示例14: IMPORT_LOG0
bool OutlookSettings::DoImport(nsIMsgAccount **aAccount)
{
nsCOMPtr<nsIWindowsRegKey> key;
nsresult rv = OutlookSettings::FindAccountsKey(getter_AddRefs(key));
if (NS_FAILED(rv)) {
IMPORT_LOG0("*** Error finding Outlook registry account keys\n");
return false;
}
nsCOMPtr<nsIMsgAccountManager> accMgr =
do_GetService(NS_MSGACCOUNTMANAGER_CONTRACTID, &rv);
if (NS_FAILED(rv)) {
IMPORT_LOG0("*** Failed to create a account manager!\n");
return false;
}
nsAutoString defMailName;
rv = GetDefaultMailAccountName(defMailName);
uint32_t childCount;
key->GetChildCount(&childCount);
uint32_t accounts = 0;
uint32_t popCount = 0;
for (uint32_t i = 0; i < childCount; i++) {
nsAutoString keyName;
key->GetChildName(i, keyName);
nsCOMPtr<nsIWindowsRegKey> subKey;
rv = key->OpenChild(keyName,
nsIWindowsRegKey::ACCESS_QUERY_VALUE,
getter_AddRefs(subKey));
if (NS_FAILED(rv))
continue;
// Get the values for this account.
nsAutoCString nativeKeyName;
NS_CopyUnicodeToNative(keyName, nativeKeyName);
IMPORT_LOG1("Opened Outlook account: %s\n", nativeKeyName.get());
nsCOMPtr<nsIMsgAccount> account;
nsAutoString value;
rv = subKey->ReadStringValue(NS_LITERAL_STRING("IMAP Server"), value);
if (NS_SUCCEEDED(rv) &&
DoIMAPServer(accMgr, subKey, value, getter_AddRefs(account)))
accounts++;
rv = subKey->ReadStringValue(NS_LITERAL_STRING("POP3 Server"), value);
if (NS_SUCCEEDED(rv) &&
DoPOP3Server(accMgr, subKey, value, getter_AddRefs(account))) {
popCount++;
accounts++;
if (aAccount && account) {
// If we created a mail account, get rid of it since
// we have 2 POP accounts!
if (popCount > 1)
NS_RELEASE(*aAccount);
else
NS_ADDREF(*aAccount = account);
}
}
// Is this the default account?
if (account && keyName.Equals(defMailName))
accMgr->SetDefaultAccount(account);
}
// Now save the new acct info to pref file.
rv = accMgr->SaveAccountInfo();
NS_ASSERTION(NS_SUCCEEDED(rv), "Can't save account info to pref file");
return accounts != 0;
}
开发者ID:aleth,项目名称:releases-comm-central,代码行数:72,代码来源:nsOutlookSettings.cpp
示例15: NS_RELEASE
nsAppShellWindowEnumerator::~nsAppShellWindowEnumerator()
{
mWindowMediator->RemoveEnumerator(this);
NS_RELEASE(mWindowMediator);
}
开发者ID:abhishekvp,项目名称:gecko-dev,代码行数:5,代码来源:nsAppShellWindowEnumerator.cpp
示例16: LOG
void
nsHttpTransaction::Close(nsresult reason)
{
LOG(("nsHttpTransaction::Close [this=%x reason=%x]\n", this, reason));
NS_ASSERTION(PR_GetCurrentThread() == gSocketThread, "wrong thread");
if (mClosed) {
LOG((" already closed\n"));
return;
}
mTimings.responseEnd = mozilla::TimeStamp::Now();
if (mActivityDistributor) {
// report the reponse is complete if not already reported
if (!mResponseIsComplete)
mActivityDistributor->ObserveActivity(
mChannel,
NS_HTTP_ACTIVITY_TYPE_HTTP_TRANSACTION,
NS_HTTP_ACTIVITY_SUBTYPE_RESPONSE_COMPLETE,
PR_Now(),
static_cast<PRUint64>(mContentRead),
EmptyCString());
// report that this transaction is closing
mActivityDistributor->ObserveActivity(
mChannel,
NS_HTTP_ACTIVITY_TYPE_HTTP_TRANSACTION,
NS_HTTP_ACTIVITY_SUBTYPE_TRANSACTION_CLOSE,
PR_Now(), LL_ZERO, EmptyCString());
}
// we must no longer reference the connection! find out if the
// connection was being reused before letting it go.
PRBool connReused = PR_FALSE;
if (mConnection)
connReused = mConnection->IsReused();
mConnected =
|
请发表评论