本文整理汇总了C++中NS_InitXPCOM2函数的典型用法代码示例。如果您正苦于以下问题:C++ NS_InitXPCOM2函数的具体用法?C++ NS_InitXPCOM2怎么用?C++ NS_InitXPCOM2使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NS_InitXPCOM2函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: init
nsresult init()
{
nsresult rv = NS_InitXPCOM2(nsnull, nsnull, nsnull);
if (NS_FAILED(rv))
return rv;
return CallGetService(kCharsetConverterManagerCID, &ccMan);
}
开发者ID:lofter2011,项目名称:Icefox,代码行数:7,代码来源:nsTestUConv.cpp
示例2: main
int
main(int argc, char* argv[])
{
nsresult rv;
{
nsCOMPtr<nsIFile> topDir;
nsCOMPtr<nsIServiceManager> servMan;
rv = NS_InitXPCOM2(getter_AddRefs(servMan), nsnull, nsnull);
if (NS_FAILED(rv)) return -1;
if (argc > 1 && argv[1] != nsnull)
{
char* pathStr = argv[1];
NS_NewNativeLocalFile(nsDependentCString(pathStr), false, getter_AddRefs(topDir));
}
if (!topDir)
{
printf("No Top Dir\n");
return -1;
}
PRInt32 startTime = PR_IntervalNow();
LoopInDir(topDir);
PRInt32 endTime = PR_IntervalNow();
printf("\nTime: %d\n", PR_IntervalToMilliseconds(endTime - startTime));
} // this scopes the nsCOMPtrs
// no nsCOMPtrs are allowed to be alive when you call NS_ShutdownXPCOM
rv = NS_ShutdownXPCOM(nsnull);
NS_ASSERTION(NS_SUCCEEDED(rv), "NS_ShutdownXPCOM failed");
return 0;
}
开发者ID:lofter2011,项目名称:Icefox,代码行数:35,代码来源:nsIFileEnumerator.cpp
示例3: main
int
main(int argc, char* argv[])
{
nsresult rv;
{
nsCOMPtr<nsIServiceManager> servMan;
NS_InitXPCOM2(getter_AddRefs(servMan), nullptr, nullptr);
nsCOMPtr<nsIComponentRegistrar> registrar = do_QueryInterface(servMan);
NS_ASSERTION(registrar, "Null nsIComponentRegistrar");
if (registrar)
registrar->AutoRegister(nullptr);
NS_ASSERTION(NS_SUCCEEDED(rv), "AutoregisterComponents failed");
if (argc < 2) {
printf("usage: %s resource://foo/<path-to-resolve>\n", argv[0]);
return -1;
}
rv = SetupMapping();
NS_ASSERTION(NS_SUCCEEDED(rv), "SetupMapping failed");
if (NS_FAILED(rv)) return rv;
rv = TestOpenInputStream(argv[1]);
NS_ASSERTION(NS_SUCCEEDED(rv), "TestOpenInputStream failed");
rv = TestAsyncRead(argv[1]);
NS_ASSERTION(NS_SUCCEEDED(rv), "TestAsyncRead failed");
} // this scopes the nsCOMPtrs
// no nsCOMPtrs are allowed to be alive when you call NS_ShutdownXPCOM
rv = NS_ShutdownXPCOM(nullptr);
NS_ASSERTION(NS_SUCCEEDED(rv), "NS_ShutdownXPCOM failed");
return rv;
}
开发者ID:AtulKumar2,项目名称:gecko-dev,代码行数:34,代码来源:TestRes.cpp
示例4: main
int main(int argc, char** argv) {
NS_InitXPCOM2(nsnull, nsnull, nsnull);
// --------------------------------------------
printf("Test Line Break\n");
PRBool lbok ;
PRBool wbok ;
lbok =TestWordBreaker();
if(lbok)
printf("Line Break Test\nOK\n");
else
printf("Line Break Test\nFailed\n");
wbok = TestLineBreaker();
if(wbok)
printf("Word Break Test\nOK\n");
else
printf("Word Break Test\nFailed\n");
SampleWordBreakUsage();
// --------------------------------------------
printf("Finish All The Test Cases\n");
if(lbok && wbok)
printf("Line/Word Break Test\nOK\n");
else
printf("Line/Word Break Test\nFailed\n");
return 0;
}
开发者ID:rn10950,项目名称:RetroZilla,代码行数:33,代码来源:TestLineBreak.cpp
示例5: main
int
main(int argc, char **argv)
{
if (PR_GetEnv("MOZ_BREAK_ON_MAIN"))
NS_BREAK();
if (argc < 5) {
fprintf(stderr, "USAGE: TestIncrementalDownload <url> <file> <chunksize> <interval-in-seconds>\n");
return -1;
}
nsresult rv = NS_InitXPCOM2(nullptr, nullptr, nullptr);
if (NS_FAILED(rv))
return -1;
int32_t chunkSize = atoi(argv[3]);
int32_t interval = atoi(argv[4]);
rv = DoIncrementalFetch(argv[1], argv[2], chunkSize, interval);
if (NS_FAILED(rv))
fprintf(stderr, "ERROR: DoIncrementalFetch failed [%x]\n",
static_cast<uint32_t>(rv));
NS_ShutdownXPCOM(nullptr);
return 0;
}
开发者ID:stormandsun,项目名称:firefox,代码行数:26,代码来源:TestIncrementalDownload.cpp
示例6: main
int main(int argc, char** argv)
{
if (argc <= 1) {
puts("nrun <contractid>");
return EXIT_FAILURE;
}
const char* contract_id = argv[1];
// initialize XPCOM
nsresult rv = NS_InitXPCOM2(nsnull, nsnull, nsnull);
if (NS_FAILED(rv)) {
printf("XPCOM initialization failed: [%x]\n", rv);
return EXIT_FAILURE;
}
// check for new components
nsComponentManager::AutoRegister(nsIComponentManager::NS_Startup, nsnull);
// run the application
run(contract_id);
// shut down and go home
NS_ShutdownXPCOM(nsnull);
return EXIT_SUCCESS;
}
开发者ID:chadaustin,项目名称:naikai,代码行数:26,代码来源:nrun.cpp
示例7: main
//----------------------------------------------------------------------
int main(int argc, char **argv)
{
/* I need this to free shared memory in case of a crash */
signal(SIGTERM, abnormal_exit_handler);
signal(SIGQUIT, abnormal_exit_handler);
signal(SIGINT, abnormal_exit_handler);
signal(SIGHUP, abnormal_exit_handler);
signal(SIGSEGV, abnormal_exit_handler);
signal(SIGILL, abnormal_exit_handler);
signal(SIGABRT, abnormal_exit_handler);
// Initialize XPCOM
nsresult rv = NS_InitXPCOM2(nsnull, nsnull, nsnull);
NS_ASSERTION(NS_SUCCEEDED(rv), "NS_InitXPCOM failed");
if (NS_SUCCEEDED(rv)) {
// The toolkit service in mozilla will look in the environment
// to determine which toolkit to use. Yes, it is a dumb hack to
// force it here, but we have no choice because of toolkit specific
// code linked into the viewer.
putenv("MOZ_TOOLKIT=photon");
gTheApp = new nsNativeViewerApp();
gTheApp->Initialize(argc, argv);
gTheApp->Run();
delete gTheApp;
// Shutdown XPCOM
rv = NS_ShutdownXPCOM(nsnull);
NS_ASSERTION(NS_SUCCEEDED(rv), "NS_ShutdownXPCOM failed");
}
return 0;
}
开发者ID:rn10950,项目名称:RetroZilla,代码行数:35,代码来源:nsPhMain.cpp
示例8: main
int
main(int argc, char* argv[])
{
{
NS_InitXPCOM2(nullptr, nullptr, nullptr);
nsCOMPtr<nsIPrefBranch> prefs(do_GetService(NS_PREFSERVICE_CONTRACTID));
if (!prefs) {
return -1;
}
// When NSS initializes, it attempts to get some localized strings.
// As a result, OS X and Windows flip out if this isn't set.
// (This isn't done automatically since this test doesn't have a
// lot of the other boilerplate components that would otherwise
// keep the certificate db alive longer than we want it to.)
nsresult rv = prefs->SetBoolPref("intl.locale.matchOS", true);
if (NS_FAILED(rv)) {
return -1;
}
nsCOMPtr<nsIX509CertDB> certdb(do_GetService(NS_X509CERTDB_CONTRACTID));
if (!certdb) {
return -1;
}
} // this scopes the nsCOMPtrs
// no nsCOMPtrs are allowed to be alive when you call NS_ShutdownXPCOM
NS_ShutdownXPCOM(nullptr);
return 0;
}
开发者ID:Andrel322,项目名称:gecko-dev,代码行数:27,代码来源:TestCertDB.cpp
示例9: main
int main(int argc, char** argv)
{
if (argc < 2) {
fprintf(stderr, "%s [FILE]...\n", argv[0]);
}
nsresult rv = NS_InitXPCOM2(nullptr, nullptr, nullptr);
if (NS_FAILED(rv))
return (int)rv;
int res = 0;
for (int i = 1; i < argc; ++i) {
const char *filename = argv[i];
printf("\nParsing %s.\n", filename);
nsCOMPtr<nsIURI> uri = FileToURI(filename, &rv);
if (rv == NS_ERROR_OUT_OF_MEMORY) {
fprintf(stderr, "Out of memory.\n");
return 1;
}
if (uri)
res = ParseCSSFile(uri);
}
NS_ShutdownXPCOM(nullptr);
return res;
}
开发者ID:hideakihata,项目名称:mozilla-central.fgv,代码行数:28,代码来源:ParseCSS.cpp
示例10: main
int main(int argc, char** argv) {
nsresult rv = NS_InitXPCOM2(nullptr, nullptr, nullptr);
if (NS_FAILED(rv)) {
printf("NS_InitXPCOM2 failed\n");
return 1;
}
// --------------------------------------------
TestCaseConversion();
// --------------------------------------------
FuzzCaseConversion();
// --------------------------------------------
TestEntityConversion(nsIEntityConverter::html40);
// --------------------------------------------
TestSaveAsCharset();
// --------------------------------------------
TestNormalization();
// --------------------------------------------
printf("Finish All The Test Cases\n");
return 0;
}
开发者ID:AshishNamdev,项目名称:mozilla-central,代码行数:33,代码来源:UnicharSelfTest.cpp
示例11: main
int
main(int argc, char* argv[])
{
nsresult rv = NS_OK;
// Start up XPCOM
rv = NS_InitXPCOM2(nsnull, nsnull, nsnull);
if (NS_FAILED(rv)) return rv;
/**
* Create event queue for this thread
*/
nsCOMPtr<nsIEventQueueService> eventQService =
do_GetService(kEventQueueServiceCID, &rv);
if (NS_FAILED(rv)) goto error_exit;
eventQService->GetThreadEventQueue(NS_CURRENT_THREAD, getter_AddRefs(gEventQ));
/**
* Test Cache
*/
TestMemoryObjectCache();
error_exit:
gEventQ = nsnull;
eventQService = nsnull;
NS_ShutdownXPCOM(nsnull);
printf("XPCOM shut down.\n\n");
return rv;
}
开发者ID:rn10950,项目名称:RetroZilla,代码行数:33,代码来源:TestCacheService.cpp
示例12: main
int main(int argc, char **argv)
{
if (test_common_init(&argc, &argv) != 0)
return -1;
nsresult rv;
#if defined(PR_LOGGING)
gTestLog = PR_NewLogModule("Test");
#endif
rv = NS_InitXPCOM2(nullptr, nullptr, nullptr);
if (NS_FAILED(rv))
return rv;
rv = RunTest();
if (NS_FAILED(rv))
LOG(("RunTest failed [rv=%x]\n", rv));
LOG(("sleeping main thread for 2 seconds...\n"));
PR_Sleep(PR_SecondsToInterval(2));
NS_ShutdownXPCOM(nullptr);
return 0;
}
开发者ID:AshishNamdev,项目名称:mozilla-central,代码行数:25,代码来源:TestIOThreads.cpp
示例13: main
void main(int argc, char* argv[])
{
nsresult rv;
nsIServiceManager* servMgr;
rv = NS_InitXPCOM2(&servMgr, NULL, NULL);
NS_ASSERTION(NS_SUCCEEDED(rv), "NS_InitXPCOM failed");
// try loading a component and releasing it to see if it leaks
if (argc > 1 && argv[1] != nsnull) {
char* cidStr = argv[1];
nsISupports* obj = nsnull;
if (cidStr[0] == '{') {
nsCID cid;
cid.Parse(cidStr);
rv = CallCreateInstance(cid, &obj);
}
else {
// contractID case:
rv = CallCreateInstance(cidStr, &obj);
}
if (NS_SUCCEEDED(rv)) {
printf("Successfully created %s\n", cidStr);
NS_RELEASE(obj);
}
else {
printf("Failed to create %s (%x)\n", cidStr, rv);
}
}
rv = NS_ShutdownXPCOM(servMgr);
NS_ASSERTION(NS_SUCCEEDED(rv), "NS_ShutdownXPCOM failed");
}
开发者ID:lofter2011,项目名称:Icefox,代码行数:32,代码来源:TestShutdown.cpp
示例14: main
int
main(int argc, char** argv)
{
nsresult rv;
if (argc < 2) {
fprintf(stderr, "usage: %s <url> [<poll-interval>]\n", argv[0]);
return 1;
}
rv = NS_InitXPCOM2(nsnull, nsnull, nsnull);
if (NS_FAILED(rv)) {
fprintf(stderr, "NS_InitXPCOM2 failed\n");
return 1;
}
// Create a stream data source and initialize it on argv[1], which
// is hopefully a "file:" URL. (Actually, we can do _any_ kind of
// URL, but only a "file:" URL will be written back to disk.)
nsCOMPtr<nsIRDFDataSource> ds = do_CreateInstance(kRDFXMLDataSourceCID, &rv);
if (NS_FAILED(rv)) {
NS_ERROR("unable to create RDF/XML data source");
return rv;
}
nsCOMPtr<nsIRDFRemoteDataSource> remote = do_QueryInterface(ds);
if (! remote)
return NS_ERROR_UNEXPECTED;
rv = remote->Init(argv[1]);
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to initialize data source");
if (NS_FAILED(rv)) return rv;
// The do_QI() on the pointer is a hack to make sure that the new
// object gets AddRef()-ed.
nsCOMPtr<nsIRDFObserver> observer = do_QueryInterface(new Observer);
if (! observer)
return NS_ERROR_OUT_OF_MEMORY;
rv = ds->AddObserver(observer);
if (NS_FAILED(rv)) return rv;
while (1) {
// Okay, this should load the XML file...
rv = remote->Refresh(PR_TRUE);
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to open datasource");
if (NS_FAILED(rv)) return rv;
if (argc <= 2)
break;
PRInt32 pollinterval = atol(argv[2]);
if (! pollinterval)
break;
PR_Sleep(PR_SecondsToInterval(pollinterval));
}
return NS_OK;
}
开发者ID:Akin-Net,项目名称:mozilla-central,代码行数:60,代码来源:rdfpoll.cpp
示例15: InitXPCOM_Impl
nsresult
InitXPCOM_Impl(JNIEnv* env, jobject aMozBinDirectory,
jobject aAppFileLocProvider, jobject* aResult)
{
nsresult rv;
// create an nsILocalFile from given java.io.File
nsCOMPtr<nsIFile> directory;
if (aMozBinDirectory) {
rv = File_to_nsILocalFile(env, aMozBinDirectory, getter_AddRefs(directory));
NS_ENSURE_SUCCESS(rv, rv);
}
// create nsAppFileLocProviderProxy from given Java object
nsCOMPtr<nsIDirectoryServiceProvider> provider;
if (aAppFileLocProvider) {
rv = NS_NewAppFileLocProviderProxy(aAppFileLocProvider,
getter_AddRefs(provider));
NS_ENSURE_SUCCESS(rv, rv);
}
// init XPCOM
nsCOMPtr<nsIServiceManager> servMan;
rv = NS_InitXPCOM2(getter_AddRefs(servMan), directory, provider);
NS_ENSURE_SUCCESS(rv, rv);
// create Java proxy for service manager returned by NS_InitXPCOM2
return NativeInterfaceToJavaObject(env, servMan, NS_GET_IID(nsIServiceManager),
nullptr, aResult);
}
开发者ID:my2iu,项目名称:Mozilla-JavaXPCom,代码行数:30,代码来源:nsJavaInterfaces.cpp
示例16: main
int main(int argc, char **argv)
{
if (test_common_init(&argc, &argv) != 0)
return -1;
if (argc < 2) {
printf("usage: %s <url>\n", argv[0]);
return -1;
}
gTestLog = PR_NewLogModule("Test");
nsresult rv = NS_InitXPCOM2(nullptr, nullptr, nullptr);
if (NS_FAILED(rv))
return -1;
{
nsCOMPtr<nsIURI> uri;
rv = NS_NewURI(getter_AddRefs(uri), nsDependentCString(argv[1]));
if (NS_FAILED(rv))
return -1;
nsCOMPtr<nsIScriptSecurityManager> secman =
do_GetService(NS_SCRIPTSECURITYMANAGER_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv, -1);
nsCOMPtr<nsIPrincipal> systemPrincipal;
rv = secman->GetSystemPrincipal(getter_AddRefs(systemPrincipal));
NS_ENSURE_SUCCESS(rv, -1);
nsCOMPtr<nsIChannel> chan;
rv = NS_NewChannel(getter_AddRefs(chan),
uri,
systemPrincipal,
nsILoadInfo::SEC_NORMAL,
nsIContentPolicy::TYPE_OTHER);
if (NS_FAILED(rv))
return -1;
nsCOMPtr<nsIStreamLoaderObserver> observer = new MyStreamLoaderObserver();
if (!observer)
return -1;
nsCOMPtr<nsIStreamLoader> loader;
rv = NS_NewStreamLoader(getter_AddRefs(loader), observer);
if (NS_FAILED(rv))
return -1;
rv = chan->AsyncOpen(loader, nullptr);
if (NS_FAILED(rv))
return -1;
PumpEvents();
} // this scopes the nsCOMPtrs
// no nsCOMPtrs are allowed to be alive when you call NS_ShutdownXPCOM
NS_ShutdownXPCOM(nullptr);
return 0;
}
开发者ID:lgarner,项目名称:mozilla-central,代码行数:58,代码来源:TestStreamLoader.cpp
示例17: main
int
main(int argc, char **argv)
{
if (NS_FAILED(NS_InitXPCOM2(nullptr, nullptr, nullptr)))
return -1;
RunTests();
NS_ShutdownXPCOM(nullptr);
return 0;
}
开发者ID:abhishekvp,项目名称:gecko-dev,代码行数:9,代码来源:TestThreadPool.cpp
示例18: main
int main(int argc, char **argv)
{
if (test_common_init(&argc, &argv) != 0)
return -1;
int sleepLen = 10; // default: 10 seconds
if (argc == 1) {
printf("usage: TestDNS [-N] hostname1 [hostname2 ...]\n");
return -1;
}
{
nsCOMPtr<nsIServiceManager> servMan;
NS_InitXPCOM2(getter_AddRefs(servMan), nullptr, nullptr);
nsCOMPtr<nsPIDNSService> dns = do_GetService(NS_DNSSERVICE_CONTRACTID);
if (!dns)
return -1;
if (argv[1][0] == '-') {
sleepLen = atoi(argv[1]+1);
argv++;
argc--;
}
for (int j=0; j<2; ++j) {
for (int i=1; i<argc; ++i) {
// assume non-ASCII input is given in the native charset
nsAutoCString hostBuf;
if (IsAscii(argv[i]))
hostBuf.Assign(argv[i]);
else
hostBuf = NS_ConvertUTF16toUTF8(NS_ConvertASCIItoUTF16(argv[i]));
nsCOMPtr<nsIDNSListener> listener = new myDNSListener(argv[i], i);
nsCOMPtr<nsICancelable> req;
nsresult rv = dns->AsyncResolve(hostBuf,
nsIDNSService::RESOLVE_CANONICAL_NAME,
listener, nullptr, getter_AddRefs(req));
if (NS_FAILED(rv))
printf("### AsyncResolve failed [rv=%x]\n",
static_cast<uint32_t>(rv));
}
printf("main thread sleeping for %d seconds...\n", sleepLen);
PR_Sleep(PR_SecondsToInterval(sleepLen));
}
printf("shutting down main thread...\n");
dns->Shutdown();
}
NS_ShutdownXPCOM(nullptr);
return 0;
}
开发者ID:AshishNamdev,项目名称:mozilla-central,代码行数:57,代码来源:TestDNS.cpp
示例19: main
int main(int argc, char **argv)
{
nsresult rv;
if (argc == 1) {
printf("usage: TestHttp <url>\n");
return -1;
}
{
nsCOMPtr<nsIServiceManager> servMan;
NS_InitXPCOM2(getter_AddRefs(servMan), nullptr, nullptr);
nsCOMPtr<nsIComponentRegistrar> registrar = do_QueryInterface(servMan);
NS_ASSERTION(registrar, "Null nsIComponentRegistrar");
if (registrar)
registrar->AutoRegister(nullptr);
// Create the Event Queue for this thread...
nsCOMPtr<nsIEventQueueService> eqs =
do_GetService(kEventQueueServiceCID, &rv);
RETURN_IF_FAILED(rv, "do_GetService(EventQueueService)");
rv = eqs->CreateMonitoredThreadEventQueue();
RETURN_IF_FAILED(rv, "CreateMonitoredThreadEventQueue");
rv = eqs->GetThreadEventQueue(NS_CURRENT_THREAD, &gEventQ);
RETURN_IF_FAILED(rv, "GetThreadEventQueue");
nsCOMPtr<nsIURI> uri;
nsCOMPtr<nsIChannel> chan;
nsCOMPtr<nsIStreamListener> listener = new MyListener();
nsCOMPtr<nsIInterfaceRequestor> callbacks = new MyNotifications();
rv = NS_NewURI(getter_AddRefs(uri), argv[1]);
RETURN_IF_FAILED(rv, "NS_NewURI");
rv = NS_NewChannel(getter_AddRefs(chan),
uri,
nsContentUtils::GetSystemPrincipal(),
nsILoadInfo::SEC_NORMAL,
nsIContentPolicy::TYPE_OTHER);
RETURN_IF_FAILED(rv, "NS_OpenURI");
rv = chan->AsyncOpen(listener, nullptr);
RETURN_IF_FAILED(rv, "AsyncOpen");
while (gKeepRunning)
gEventQ->ProcessPendingEvents();
printf(">>> done\n");
} // this scopes the nsCOMPtrs
// no nsCOMPtrs are allowed to be alive when you call NS_ShutdownXPCOM
rv = NS_ShutdownXPCOM(nullptr);
NS_ASSERTION(NS_SUCCEEDED(rv), "NS_ShutdownXPCOM failed");
return 0;
}
开发者ID:Andrel322,项目名称:gecko-dev,代码行数:56,代码来源:TestHttp.cpp
示例20: StartXPCOM
extern "C" int
StartXPCOM(nsIServiceManager** srvmgr)
{
nsresult res = NS_InitXPCOM2(srvmgr, 0, 0);
if (NS_SUCCEEDED(res)) {
extern nsIInterfaceInfoManager *infomgr;
infomgr = XPTI_GetInterfaceInfoManager();
}
return res;
}
开发者ID:EdgarChen,项目名称:mozilla-cvs-history,代码行数:10,代码来源:xpcom-core.cpp
注:本文中的NS_InitXPCOM2函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论