diff --git a/xpcom/doc/MemoryTools.html b/xpcom/doc/MemoryTools.html deleted file mode 100644 index c3a70be36314..000000000000 --- a/xpcom/doc/MemoryTools.html +++ /dev/null @@ -1,1166 +0,0 @@ - - -
-XPCOM_MEM_BLOAT_LOG- -
-- In addition, the following variable may be set to a list of class names: -If this environment variable is set then xpcom will use the -"bloat" trackers. The bloat trackers gather data for the BloatView output -that occurs when the program exits, when about:bloat is loaded, or a call -to nsTraceRefcnt::DumpStatistics is made. -- XPCOM_MEM_LEAK_LOG -When an addref/release/ctor/dtor call is made, the data is logged -and attributed to the particular data type.
-By default enabling this environment variable will cause the BloatView -software to dump out the entire database of collected data. If all you want -to see is that data for objects that leaked, set the environment variable -XPCOM_MEM_LEAK_LOG.
-This is basically a subset of XPCOM_MEM_BLOAT_LOG, and -only shows classes that had object that were leaked, instead of statistics -for all classes.- XPCOM_MEM_REFCNT_LOG -Setting this environment variable enables refcount tracing. -- XPCOM_MEM_COMPTR_LOG -
-Only enable this for severe pain (unless you are using refcount tracing or -leaky, see below). What this does is to enable logging (to stdout) of each -and every call to addref/release without discrimination to the types involved. -The output includes mapping the call-stacks at the time of the call to symbolic -forms (on platforms that support this) and thus will be *very* *VERY* *VERY* -slow. Did I say slow? It is not as slow when using XPCOM_MEM_LOG_CLASSES -and XPCOM_MEM_LOG_OBJECTSThis environment variable enables logging of additions -and releases of objects into nsCOMPtrs. This is currently only enabled on -Linux.- XPCOM_MEM_ALLOC_LOG -For losing architectures (those that don't have stack-crawl -software written for them), xpcom supports logging at the *call site* to AddRef/Release -using the usual cpp __FILE__ and __LINE__ number macro expansion hackery. -This results in slower code, but at least you get *some* data about where -the leaks might be occurring from.- XPCOM_MEM_LEAKY_LOG -For platforms that support leaky, xpcom will endeavor -to find at run time the symbols "__log_addref" and "__log_release" and if -found, instead of doing the slow painful stack crawls at program execution -time instead it will pass the buck to the leaky software. This will allow -your program to actually run in user friendly real time, but does require -that your platform support leaky. Currently only linux supports leaky.-
XPCOM_MEM_LOG_CLASSES- -
-- You may use an object's serial number with the following variable to further -restrict the reference count tracing: -Instead of slowing to a useless, instead -you can slow to a meer crawl by using this option. When enabled, the xpcom -logging software will look for the XPCOM_MEM_LOG_CLASSES environment variable -(for platforms that support getenv). The variable contains a comma separated -list of names which will be used to compare against the type's of the objects -being logged. For example: --env XPCOM_MEM_LOG_CLASSES=nsWebShell XPCOM_MEM_REFCNT_LOG=1 -./apprunner- will show you just the AddRef/Release calls to instances of nsWebShell while -running apprunner.Note that setting XPCOM_MEM_LOG_CLASSES will also list -the serial number of each object that leaked in the "bloat log" (that -is, the file specified by the XPCOM_MEM_BLOAT_LOG variable). An object's -serial number is simply a unique number, starting at one, that is assigned -to the object when it is allocated.
XPCOM_MEM_LOG_OBJECTS- -
-- -Set this variable to a comma-separated -list of object serial number or ranges of serial number, e.g., --1,37-42,73,165
. When this is set, -along with XPCOM_MEM_LOG_CLASSES and XPCOM_MEM_REFCNT_LOG, a stack track -will be generated for only the specific objects that you list. For -example, -env XPCOM_MEM_LOG_CLASSES=nsWebShell -XPCOM_MEM_LOG_OBJECTS=2 XPCOM_MEM_REFCNT_LOG=1 ./apprunner- will dump stack traces to the console for the 2ndnsWebShell
- object that gets allocated, and nothing else.
== BloatView: ALL (cumulative) LEAK AND BLOAT STATISTICS- Here's how you interpret the columns: -
|<------Class----->|<-----Bytes------>|<----------------Objects---------------->|<--------------References-------------->|
Per-Inst Leaked Total Rem Mean StdDev Total Rem Mean StdDev
0 TOTAL 193 2480436 316271 12852 ( 5377.07 +/- 5376.38) 410590 16079 ( 2850.93 +/- 2849.79)
1 StyleSetImpl 32 0 8 0 ( 3.88 +/- 3.15) 6304 0 ( 7.18 +/- 6.63)
2 SinkContext 32 0 19 0 ( 1.87 +/- 1.04) 0 0 ( 0.00 +/- 0.00)
3 nsXPCClasses 12 0 2 0 ( 1.00 +/- 0.71) 41 0 ( 5.57 +/- 4.98)
4 NameSpaceURIKey 8 72 158 9 ( 8.16 +/- 7.62) 0 0 ( 0.00 +/- 0.00)
5 nsSupportsArray 36 11304 2581 314 ( 477.13 +/- 476.53) 9223 314 ( 579.23 +/- 578.64)
6 nsView 96 0 57 0 ( 27.64 +/- 26.98) 0 0 ( 0.00 +/- 0.00)
7 nsEnderDocumentObser 12 0 1 0 ( 0.50 +/- 0.87) 1 0 ( 0.50 +/- 0.87)
bloatlogs/all-1999-10-16-010302.txt -(a complete log resulting from the about:bloat command)- -
-bloatlogs/new-1999-10-16-010423.txt (an incremental -log resulting from the about:bloat?new command)
You can view one or more bloat logs -in your browser by running the following program:
- -- -perl
-mozilla/tools/memory/bloattable.pl
log1 log2 - ... logn>
htmlfile
This will produce an HTML file that -contains a table such as:
- -Name | -File | -Date | -
---|---|---|
blank | -blank.txt | -Tue Aug 29 14:17:40 2000 | -
mozilla | -mozilla.txt | -Tue Aug 29 14:18:42 2000 | -
yahoo | -yahoo.txt | -Tue Aug 29 14:19:32 2000 | -
netscape | -netscape.txt | -Tue Aug 29 14:20:14 2000 | -
The numbers do not include malloc
-'d data such as string contents.
Click on a column heading to sort -by that column. Click on a class name to see details for that class.
- -Class Name | -Instance -Size |
- Bytes allocated | -Bytes allocated but not freed | -||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
blank | -mozilla | -yahoo | -netscape | -Total | -blank | -mozilla | -yahoo | -netscape | -Total | -||
TOTAL | -- |
- - |
- - |
- - |
- - |
- - |
- +1754408 | -+432556 | -+179828 | -+404184 | -2770976 | -
nsStr | -20 | -+6261600 | -+3781900 | -+1120920 | -+1791340 | -12955760 | -+222760 | -+48760 | -+13280 | -+76160 | -360960 | -
nsHashKey | -8 | -+610568 | -+1842400 | -+2457872 | -+1134592 | -6045432 | -+32000 | -+536 | -+568 | -+1216 | -34320 | -
nsTextTransformer | -548 | -+8220 | -+469088 | -+1414936 | -+1532756 | -3425000 | -0 | -0 | -0 | -0 | -0 | -
nsStyleContextData | -736 | -+259808 | -+325312 | -+489440 | -+338560 | -1413120 | -+141312 | -+220800 | --11040 | -+94944 | -446016 | -
nsLineLayout | -1100 | -+2200 | -+225500 | -+402600 | -+562100 | -1192400 | -0 | -0 | -0 | -0 | -0 | -
nsLocalFile | -424 | -+558832 | -+19928 | -+1696 | -+1272 | -581728 | -+72080 | -+1272 | -+424 | --424 | -73352 | -
The first set of columns, Bytes -allocated, shows the amount of memory allocated for the first log file -(blank.txt), the difference between the first log file and the -second (mozilla.txt), the difference between the second log file - and the third (yahoo.txt), the difference between the third log -file and the fourth (netscape.txt), and the total amount of memory -allocated in the fourth log file. These columns provide an idea of how hard -the memory allocator has to work, but they do not indicate the size of the -working set.
- -The second set of columns, Bytes -allocated but not freed, shows the net memory gain or loss by subtracting -the amount of memory freed from the amount allocated.
- -The Show Objects and Show -References buttons show the same statistics but counting objects or AddRef'd -references rather than bytes.
- -perl mozilla/tools/tinderbox/bloatdiff.pl -<previous-log> <current-log>- This will give you output of the form: -
- This "delta report" shows the leak offenders, sorted from most leaks to fewest. -The delta numbers show the percentage change between runs for the amount -of leaks and amount of bloat (negative numbers are -better!). The bloat number is a metric determined by multiplying the -total number of objects allocated of a given class by the class size. Note -that although this isn't necessarily the amount of memory consumed at any -given time, it does give an indication of how much memory we're consuming. -The more memory in general, the worse the performance and footprint. The -percentage 99999.99% will show up indicating an "infinite" amount of leakage. -This happens when something that didn't leak before is now leaking. -Bloat/Leak Delta Report-
Current file: dist/win32_D.OBJ/bin/bloatlogs/all-1999-10-22-133450.txt
Previous file: dist/win32_D.OBJ/bin/bloatlogs/all-1999-10-16-010302.txt
--------------------------------------------------------------------------
CLASS LEAKS delta BLOAT delta
--------------------------------------------------------------------------
TOTAL 6113530 2.79% 67064808 9.18%
StyleContextImpl 265440 81.19% 283584 -26.99%
CToken 236500 17.32% 306676 20.64%
nsStr 217760 14.94% 5817060 7.63%
nsXULAttribute 113048 -70.92% 113568 -71.16%
LiteralImpl 53280 26.62% 75840 19.40%
nsXULElement 51648 0.00% 51648 0.00%
nsProfile 51224 0.00% 51224 0.00%
nsFrame 47568 -26.15% 48096 -50.49%
CSSDeclarationImpl 42984 0.67% 43488 0.67%
warren | - L
- C - L:-3 - B:+21 |
-
Hmmm. Warren checked in and the
-number of leaks went down by 3%. (Yes!) But the amount of bloat went up by
-21%. (Ouch!) This probably should be investigated further. Sometimes bloat
-can go up because new features were added that just take up more memory (or
-if the set of test URLs were changed, and the activity is different from
-last time), but in general we'd like to see both of these numbers continue
-to go down. You can look at the end of the log (by clicking on the L) to
-see the bloat statistics and delta report for a breakdown of what actually
-happened.
-
Refcount tracing is used to capture stack traces of AddRef and -Release calls to use with the Refcount Balancer. It is best to set the -XPCOM_MEM_REFCNT_LOG environment variable to point to a file when using -it.
- -See Refcount -Balancer for more information. Also see the tutorial on -finding leaks of XPCOM objects.
- ----- Base ---- ---- Incr ---- ----- Difference ---- -Type Count Bytes Count Bytes Count Bytes %Total -TOTAL 48942 4754774 76136 6566453 27194 1811679 100.00 -nsTokenAllocator 17 110007 60 388260 43 278253 15.36 -nsImageGTK 476 2197708 341 2366564 -135 168856 9.32 -nsMemCacheRecord 843 45767 2328 124767 1485 79000 4.36 -nsTextNode 209 11704 1614 90384 1405 78680 4.34 -HTMLAttributesImpl 482 14288 2824 88400 2342 74112 4.09 -nsScanner 58 76824 94 146300 36 69476 3.83 -nsScriptError 253 25070 842 91548 589 66478 3.67 -nsHTMLDocument.mReferrer 177 21550 691 85460 514 63910 3.53 -nsHTMLValue 139 7846 1215 68734 1076 60888 3.36 -HTMLContentSink 6 4816 12 57782 6 52966 2.92-
setenv LD_PRELOAD ../lib/libleaky.so -(assumes you execute apprunner/viewer in the dist/bin directory)- Then run the viewer or the apprunner and run your test. Then exit it. The -result will be some large file in your current directory called "malloc-log" -and a small file called "malloc-map". If these aren't there then somethings -wrong. -
-setenv LIBMALLOC_LOG 8 (tells leaky to log addref/release calls)
-setenv XPCOM_MEM_LEAKY_LOG 1 (use leaky)
-setenv XPCOM_MEM_LOG_CLASSES "a,b,c" (the list of types you care about)
If it works properly, then you -now have the tracing data for the problem you are chasing in malloc-log. -Use leaky to convert it to human readable form and debug away:
-leaky -dRq <viewer|apprunner> -malloc-log > /tmp/log- Leaky used to require c++filt, but now it does it itself. With the -R option, -leaky will only log the refcnts that actually leaked (those that didn't go -to zero). -
LD_PRELOAD -- -Set this to the -pathname to libleaky.so if you are using leaky to track memory operations.- LIBMALLOC_LOG -Set this to "8" -to enable leaky to track addref/release calls that are logged by xpcom. Note -that you must set bit 8 in xpcomrefcnt to connect xpcom's tracing to leakys -tracing.-
nsWebShell 0x81189f8 Release 5- -
nsWebShell::Release(void)+0x59
nsCOMPtr<nsIContentViewerContainer>::~nsCOMPtr(void)+0x34
nsChannelListener::OnStartRequest(nsIChannel *, nsISupports *)+0x550
nsFileChannel::OnStartRequest(nsIChannel *, nsISupports *)+0x7b
nsOnStartRequestEvent::HandleEvent(void)+0x46
nsStreamListenerEvent::HandlePLEvent(PLEvent *)+0x62
PL_HandleEvent+0x57
PL_ProcessPendingEvents+0x90
nsEventQueueImpl::ProcessPendingEvents(void)+0x1d
nsAppShell::SetDispatchListener(nsDispatchListener *)+0x3e
gdk_get_show_events+0xbb
g_io_add_watch+0xaa
g_get_current_time+0x136
g_get_current_time+0x6f1
g_main_run+0x81
gtk_main+0xb9
nsAppShell::Run(void)+0x245
nsAppShell::Run(void)+0xc7a92ede
nsAppShell::Run(void)+0xc7a9317c
__libc_start_main+0xeb
Here is what you see -when you use the leaky tool to dump out addref/release leaks:
-addref -082cccc8 0 00000001 --> CViewSourceHTML::AddRef(void) -CViewSourceHTML::QueryInterface(nsID &, void **) NS_NewViewSourceHTML(nsIDTD -**) .LM708 GetSharedObjects(void) nsParser::RegisterDTD(nsIDTD *) RDFXMLDataSourceImpl::Refresh(int) -nsChromeRegistry::InitRegistry(void) nsChromeProtocolHandler::NewChannel(char -*, nsIURI *, nsILoadGroup *, nsIEventSinkGetter *, nsIChannel **) nsIOService::NewChannelFromURI(char -*, nsIURI *, nsILoadGroup *, nsIEventSinkGetter *, nsIChannel **) NS_OpenURI(nsIChannel -**, nsIURI *, nsILoadGroup *, nsIEventSinkGetter *) NS_OpenURI(nsIInputStream -**, nsIURI *) CSSLoaderImpl::LoadSheet(URLKey &, SheetLoadData *) CSSLoaderImpl::LoadChildSheet(nsICSSStyleSheet -*, nsIURI *, nsString &, int, int) CSSParserImpl::ProcessImport(int &, -nsString &, nsString &) CSSParserImpl::ParseImportRule(int &) -CSSParserImpl::ParseAtRule(int &) CSSParserImpl::Parse(nsIUnicharInputStream -*, nsIURI *, nsICSSStyleSheet *&) CSSLoaderImpl::ParseSheet(nsIUnicharInputStream -*, SheetLoadData *, int &, nsICSSStyleSheet *&) CSSLoaderImpl::LoadAgentSheet(nsIURI -*, nsICSSStyleSheet *&, int &, void (*)(nsICSSStyleSheet *, void *), -void *) nsLayoutModule::Initialize(void) nsLayoutModule::GetClassObject(nsIComponentManager -*, nsID &, nsID &, void **) nsNativeComponentLoader::GetFactoryFromModule(nsDll -*, nsID &, nsIFactory **) nsNativeComponentLoader::GetFactory(nsID &, -char *, char *, nsIFactory **) .LM1381 nsComponentManagerImpl::FindFactory(nsID -&, nsIFactory **) nsComponentManagerImpl::CreateInstance(nsID &, nsISupports -*, nsID &, void **) nsComponentManager::CreateInstance(nsID &, nsISupports -*, nsID &, void **) RDFXMLDataSourceImpl::Refresh(int) nsChromeRegistry::InitRegistry(void) -nsChromeProtocolHandler::NewChannel(char *, nsIURI *, nsILoadGroup *, nsIEventSinkGetter -*, nsIChannel **) nsIOService::NewChannelFromURI(char *, nsIURI *, nsILoadGroup -*, nsIEventSinkGetter *, nsIChannel **) NS_OpenURI(nsIChannel **, nsIURI -*, nsILoadGroup *, nsIEventSinkGetter *) nsDocumentBindInfo::Bind(nsIURI *, -nsILoadGroup *, nsIInputStream *, unsigned short *) nsDocLoaderImpl::LoadDocument(nsIURI -*, char *, nsIContentViewerContainer *, nsIInputStream *, nsISupports *, unsigned -int, unsigned int, unsigned short *) nsWebShell::DoLoadURL(nsIURI *, char -*, nsIInputStream *, unsigned int, unsigned int, unsigned short *) nsWebShell::LoadURI(nsIURI -*, char *, nsIInputStream *, int, unsigned int, unsigned int, nsISupports -*, unsigned short *) nsWebShell::LoadURL(unsigned short *, char *, nsIInputStream -*, int, unsigned int, unsigned int, nsISupports *, unsigned short *) nsWebShell::LoadURL(unsigned -short *, nsIInputStream *, int, unsigned int, unsigned int, nsISupports *, -unsigned short *) nsWebShellWindow::Initialize(nsIWebShellWindow *, nsIAppShell -*, nsIURI *, int, int, nsIXULWindowCallbacks *, int, int, nsWidgetInitData -&) nsAppShellService::JustCreateTopWindow(nsIWebShellWindow *, nsIURI -*, int, int, unsigned int, nsIXULWindowCallbacks *, int, int, nsIWebShellWindow -**) nsAppShellService::CreateTopLevelWindow(nsIWebShellWindow *, nsIURI *, -int, int, unsigned int, nsIXULWindowCallbacks *, int, int, nsIWebShellWindow -**) OpenChromURL(char *, int, int) HandleBrowserStartup(nsICmdLineService -*, nsIPref *, int) DoCommandLines(nsICmdLineService *, int) main1(int, char -**) main __libc_start_main
--
FORCE_BUILD_REFCNT_LOGGING- -
-- The remaining discussion assumes that one way or another that xpcom has been -built with refcnt/memory logging enabled. -If this -is defined then regardless of the type of build, refcnt logging (and related -memory debugging) will be enabled in the build.- NO_BUILD_REFCNT_LOGGING -If this -is defined then regardless of the type of build or of the setting of the -FORCE_BUILD_REFCNT_LOGGING, no refcnt logging will be enabled and no memory -debugging will be enabled. This variable overrides FORCE_BUILD_REFCNT_LOGGING.-
If your object -is not an xpcom object then some manual editing is in order. The following -sample code shows what must be done:
--MOZ_DECL_CTOR_COUNTER(MyType) -- Now currently the MOZ_DECL_CTOR_COUNTER expands to nothing so your code will -compile if you forget to add it; however, we reserve the right to change -that so please put it in. -MyType::MyType() -
-
- { -
- -MOZ_COUNT_CTOR(MyType);
- } -MyType::~MyType() -
-
- { -
- -MOZ_COUNT_DTOR(MyType);
- }
- NS_IMPL_ADDREF
- has this additional line in it:
-NS_LOG_ADDREF(this, mRefCnt, #_class, sizeof(*this));- What this is doing is logging the addref call using xpcom's nsTraceRefcnt -class. The implementation of that macro is:
-#define NS_LOG_ADDREF(_p, _rc, _type, _size) \- Which as you can see just passes the buck to nsTraceRefcnt. nsTraceRefcnt -implements the logging support and will track addref/release/ctor/dtor calls -in a database that it builds up as the program is executing. In a similar -manner, NS_IMPL_RELEASE uses NS_LOG_RELEASE which uses nsTraceRefcnt::LogRelease. -
- -nsTraceRefcnt::LogAddRef((_p), (_rc), (_type), (PRUint32) (_size))
For the -MOZ_DECL_CTOR_COUNTER, MOZ_COUNT_CTOR and MOZ_COUNT_DTOR macros the expansion -boils down to calls to nsTraceRefcnt::LogCtor and nsTraceRefcnt::LogDtor calls. -Again, the type of the object is passed in as well as the sizeof of all the -data type.
--#define MOZ_COUNT_CTOR(_type) -\- - - diff --git a/xpcom/doc/ObjectModel.html b/xpcom/doc/ObjectModel.html deleted file mode 100644 index 396ac4ec7d71..000000000000 --- a/xpcom/doc/ObjectModel.html +++ /dev/null @@ -1,117 +0,0 @@ - - - - - -
- -PR_BEGIN_MACRO -\
- - nsTraceRefcnt::LogCtor((void*)this, #_type, sizeof(*this)); \ -
- -PR_END_MACRO --#define MOZ_COUNT_DTOR(_type) -\
-
- -PR_BEGIN_MACRO -\
- - nsTraceRefcnt::LogDtor((void*)this, #_type, sizeof(*this)); \ -
- -PR_END_MACRO
inline nsbool Equals(const nsID& other) const {
-
return
-
(((PRUint32*) &m0)[0] == ((PRUint32*)
-&other.m0)[0]) &&
-
(((PRUint32*) &m0)[1] == ((PRUint32*)
-&other.m0)[1]) &&
-
(((PRUint32*) &m0)[2] == ((PRUint32*)
-&other.m0)[2]) &&
-
(((PRUint32*) &m0)[3] == ((PRUint32*)
-&other.m0)[3]);
-
}
-
};
The following symbols are defined for standard error return values from -QueryInterface and from factory procedures: -
// Standard "it worked" return value
-
#define NS_OK 0
-
-
// Some standard error codes we use
-
#define NS_ERROR_BASE ((nsresult) 0xC1F30000)
-
#define NS_ERROR_OUT_OF_MEMORY (NS_ERROR_BASE + 0)
-
#define NS_ERROR_NO_AGGREGATION (NS_ERROR_BASE + 1)
-
#define NS_NOINTERFACE ((nqresult) 0x80004002L)
+XPCOM documentation can be found at
-
-
-
-
-
-
-TODO List for XPCOM
Suresh Duddi
Task | - -Priority | - -Owner | - -MileStone complete/Status | -
---|---|---|---|
Move xpcom from using NR_*() functions (modules/libreg) to nsIRegistry
-(xpcom/src/nsRegistry.cpp)
-
|
-
-P2 | - -Nick Ambrose <nicka87@hotmail.com> | - -3/22/1999 started
- 3/27/1999 Patch submitted - 3/30/1999 landing - DONE |
-
RegisterFactory() and RegisterComponent(..persist=0) ignoring CONTRACTID. -Needs Fix. | - -P1 | - -Nick Ambrose <nicka87@hotmail.com> | - -4/6/1999 started
- 4/7/1999 Patch submitted - 4/12/1999 Patch Checked in - DONE |
-
Startup components: Some components need to be created at startup. -Have a framework for them. | - -P1 | - -Suresh Duddi | - -- |
nsIRegistry access via Javascript. | - -P1 | - -- - | IDL of nsIRegistry will fix this says John -Bandhauer | -
API changes: Remove all pathlist. XPCOM should support only -paths. | - -P1 | - -Suresh Duddi | - -4/2/1999 Checked in
- DONE |
-
Fix xpcom from being initialized before main from static variables. | - -P1 | - -Suresh Duddi | - -3/22/1999 Started.
- - checked in a fixed xpcom initialization sequence. - - Now got to fix all code statically calling it. I know Netlib does. - - 4/1/1999 Fixed netlib on unix from static intialization. WIN is left. |
-
Path handling: Use nsFileSpec instead of file path names. Char * pathnames
-are not intl, and cannot be stored in the registry. Plus that wont support
-mac aliases.
-
|
-
-P1 | - -Suresh Duddi
- Robert Churchill |
-
-3/24/1999 started
- Blocked on deciding which solution to pick. |
-
Registry dump utility (regExport exists on windows) and about:registry -(or) better yet an rdf data source for the registry. | - -P3 | - -Suresh Duddi | - -4/5/1999 Fixed regExport to accurately dump the registry on win and
-unix.
- - regExport needs to be compiled on the mac. |
-
Replace use of nsVector (PL_Vector) with nsISupportsArray | - -P3 | - -- - | - |
PATH argument to NSRegisterSelf() and NSUnregisterSelf() to be a nsISupports | - -P1 | - -- - | - |
Code Cleanup:
-
|
-
-P3 | - -Nick Ambrose <nicka87@hotmail.com> | - -4/1/1999 started
- 4/5/1999 Patch submitted and checked in - DONE |
-
Performance
-
|
-
-P1 | - -Nick Ambrose <nicka87@hotmail.com> | - -4/1/1999 started
- 4/5/1999 Patch submitted and checked in - DONE |
-
Factories: Use previously created factories for object creation instead
-of creating the factory everytime the object needs to be created.
-
|
-
-P2 | - -- - | - |
nsIAllocator: wrap it in a static api | - -P2 | - -John Bandhauer | - -3/31/1999 started
- 4/2/1999 Check in - DONE |
-
Component | - -Leaks fixing by... | - -Status (nsIModule conversion) | -
---|---|---|
bin/Components/ | -||
caps.dll | - -rjc | - -DONE | -
chardet.dll | - -kipp | - -DONE | -
history.dll | - -dp | - -DONE | -
jsloader.dll | - -kipp | - -DONE | -
lwbrk.dll | - -kipp | - -DONE | -
necko.dll | - -kipp | - -DONE | -
necko_resource.dll | - -kipp | - -DONE | -
necko_file.dll | - -kipp | - -DONE | -
nsgif.dll | - -kipp | - -DONE | -
nslocale.dll | - -cata | - -DONE | -
mimetype.dll | - -rjc | - -DONE | -
oji.dll | - -rjc | - -DONE | -
profile.dll | - -dp | - -DONE | -
raptorhtml.dll | - -kipp | - -DONE | -
raptorview.dll | - -dp | - -DONE (doesnt cache factory) | -
rdf.dll | - -kipp | - -DONE | -
uconv.dll | - -cata | - -DONE | -
ucvlatin.dll | - -cata | - -DONE | -
ucharuti.dll | - -ftang | - -DONE | -
xpc3250.dll | - -kipp | - -DONE | -
xppref32.dll | - -dp | - -DONE | -
bin/ | -||
jsdom.dll | - -- - | - |
raptorhtmlpars.dll | - -vidur | - -DONE | -
raptorgfxwin.dll | - -- - | - |
raptorweb.dll | - -- - | - |
raptorplugin.dll | - -- - | - |
raptorwidget.dll | - -- - | - |
Component | - -Leaks fixing by... | - -Status (nsIModule conversion) | -
---|---|---|
addrbook.dll | - -alecf | - -DONE | -
bookmarks.dll | - -rjc | - -DONE | -
brprof.dll | - -XXX | - -rjc says: This should be removed from build. See bug # 13732 | -
chrome.dll | - -neeti | - -DONE | -
cnvts.dll | - -morse | - -DONE | -
cookie.dll | - -neeti | - -DONE | -
directory.dll | - -rjc | - -DONE | -
emitter.dll | - -alecf | - -DONE | -
ender.dll | - -morse | - -DONE | -
eventloop.dll | - -XXX - Don't do this | - -- |
intlcmpt.dll | - -cata | - -DONE | -
jar50.dll | - -neeti | - -DONE | -
jsurl.dll | - -morse | - -DONE | -
mime.dll | - -mscott | - -DONE | -
mork.dll | - -bienvenu | - -DONE | -
mozbrwsr.dll | - -alecf | - -DONE | -
mozfind.dll | - -alecf | - -DONE | -
mozucth.dll | - -alecf | - -DONE | -
mozxfer.dll | - -alecf | - -DONE | -
msgbase.dll | - -putterman | - -DONE | -
msgcompo.dll | - -alecf | - -DONE | -
msgdb.dll | - -bienvenu | - -DONE | -
msgimap.dll | - -mscott | - -DONE | -
msglocal.dll | - -mscott | - -DONE | -
msgnews.dll | - -alecf | - -DONE | -
nativeapp.dll | - -XXX - Don't do this | - -- |
necko_about.dll | - -kipp | - -DONE | -
necko_data.dll | - -kipp | - -DONE | -
necko_ftp.dll | - -kipp | - -DONE | -
necko_http.dll | - -kipp | - -DONE | -
nsjpg.dll | - -kipp | - -DONE | -
nspng.dll | - -kipp | - -DONE | -
nsprefm.dll | - -neeti | - -DONE | -
nsxpi.dll | - -neeti | - -DONE | -
pics.dll | - -neeti | - -DONE | -
prefwind.dll | - -alecf | - -DONE | -
rdfdomds.dll | - -neeti | - -DONE | -
regviewer.dll | - -neeti | - -DONE | -
related.dll | - -rjc | - -DONE | -
sample.dll | - --sample- Don't do this one. | - -- |
search.dll | - -rjc | - -DONE | -
stremcnv.dll | - -morse | - -DONE | -
strres.dll | - -cata | - -DONE | -
txmgr.dll | - -morse | - -DONE | -
txtsvc.dll | - -morse | - -DONE | -
ucvcn.dll | - -cata | - -DONE | -
ucvja.dll | - -cata | - -DONE | -
ucvko.dll | - -cata | - -DONE | -
ucvtw.dll | - -cata | - -DONE | -
ucvtw2.dll | - -cata | - -DONE | -
vcard.dll | - -XXX - Don't do this | - -- |
wallet.dll | - -neeti | - -DONE | -
wlltvwrs.dll | - -neeti | - -DONE | -
xpctest.dll | - -neeti | - -DONE | -
xpiflash.dll | - -neeti | - -DONE | -
nsIClassInfo
OverviewnsIClassInfo
?
- QueryInterface
rules?nsIClassInfo
?
- nsIClassInfo
is an interface that provides information
-about a specific implementation class, to wit:
To get the nsIClassInfo
object for the implementation behind
- a given interface, simply QueryInterface
for the nsIClassInfo
- interface:
C++:- -
-nsCOMPtr<nsIClassInfo> info = do_QueryInterface(ifacePtr);
-
- JavaScript:
-var info = ifacePtr.QueryInterface(Components.interfaces.nsIClassInfo);
It's important to note that this will usually return a singleton
- object: there often exists only one nsIClassInfo implementation for
-all implementations of a given class. This is very important, because it
-means that you can't QueryInterface
back to the original object,
-no matter how hard you try.
QueryInterface
rules?Quite. As discussed in
- bug 67699, though, it's a reasonable concession to make in order
-to avoid an additional vtbl entry on every class that wants to export
- nsIClassInfo
data.
-
The language helpers are basically hooks for alternate language bindings -to use for providing language-specific wrapping and manipulation behaviour, -without adding code to every wrapped object. In - bug 67669, jband tells us what XPConnect does with the language helpers:
- --- See bug 67699 - for more interesting discussion about pluggable language helpers and decoupling -them from specific wrapped classes. - - -When wrapping an object xpconnect QIs the object for its classinfo -(say 'foo'). If it has seen that foo classinfo pointer before then it knows -that this object is a foo and it can reuse all the info is knows about foo -objects. If it has never seen foo it will gather info (such as the JS helper) -and remember that for future wrappings of foo objects.
-Assuming that the foo helper tells xpconnect to not bother QI'ing -each foo instance for a per instance helper (or if the instances don't respond -to QI for the helper) then the same foo helper is used on all calls from -JS relating to the foo instances.
-What you may be missing is that methods on the helper (nsIXPCScriptable -in the xpconnect case) *all* receive a pointer to the instance wrapper when -called. I.e. the helper methods have an explicit 'self' param. This allows -the helper to customize its response for each method call without requiring -a helper per instance.
-
Why, yes, it is useful. To provide nsIClassInfo
- data for your class, you need to ensure that it returns an nsIClassInfo
- -implementing object when it is QueryInterface
d for
- nsIClassInfo
. Simple enough, but it can be even simpler through
- the use of a handful of helper macros/functions. Choose your own adventure:
nsModuleComponentInfo
.First, make sure that your class has the nsIClassInfo
- helpers, by changing the NS_IMPL_ISUPPORTS
line:
- -NS_IMPL_ISUPPORTS2(nsSampleImpl, nsISample, nsIOther)
-
becomes
- -- -NS_IMPL_ISUPPORTS2_CI(nsSampleImpl, nsISample, nsIOther)
-
This will provide an implementation of a helper function, named
- nsSampleImpl_GetInterfacesHelper
, which handles the processing
- of nsIClassInfo::getInterfaces
.
Next, in your module code, use NS_DECL_CLASSINFO
to
- provide the rest of the per-class infrastructure (a global pointer into
-which to stash the nsIClassInfo
object, and an extern declaration
- of the interfaces-helper, in case it's defined in another file):
- -NS_DECL_CLASSINFO(nsSampleImpl)
-
You'll need one of these lines for each nsIClassInfo
- -supporting class represented in your nsModuleComponentInfo
- array.
Lastly, fill in the appropriate members of nsModuleComponentInfo
- to wire everything up:
- -static nsModuleComponentInfo components[] =
-{
-{
- "Sample Component", NS_SAMPLE_CID, NS_SAMPLE_CONTRACTID, -
- nsSampleImplConstructor,
-nsSampleRegistrationProc,
-nsSampleUnregistrationProc,
-nsnull /* no factory destructor */,
-NS_CI_INTERFACE_GETTER_NAME(nsSampleImpl), - /* interface getter */
-nsnull /* no language helper */,
-&NS_CLASSINFO_NAME(nsSampleImpl), - /* global class-info pointer */
-0 /* no class flags */
- }
-};
-
If you want to add a callback which provides language-helper
- objects, replace the last nsnull
with your callback. See the
-
- nsIClassInfo
IDL file for details on language helpers and
-other esoterica.
Note: the details of these macros may change
-slightly over the next week or so, as we refine a system for using table-driven
-QI and sharing data between QI and the class-info calls.
-
You need some utility macros, don't ya? We're working
- on it. (You should really use the generic factory and module, though.
- See
- nsUConvModule.cpp for an example of how to use nsModuleComponentInfo
- and the generic modules even when you have highly-custom registration
-requirements.)
Interface flattening is a way to present multiple interfaces
-of the same object to a language binding, without requiring explicit
-QueryInterface
calls. Consider the following interfaces and
-an object obj
that implements both of them:
---
interface nsIFoo : nsISupports {
- void fooMeth(in string message);
-};-
interface nsIBar : nsISupports {
- void barMeth(in PRUint32 meaning);
-};
You could use the following code to call both fooMeth and
-barMeth without any QueryInterface:
-
obj.fooMeth("welcome to foo");
-obj.barMeth(42);
- Pretty, no? Pretty, yes.
-There are also intricacies related to conflicting method
-names and the difference between interface sets that are part of a contract's
-promise and those which are simply artifacts of the implementation, but they're
-beyond the scope of this overview.
-
-
Interface | - -Contract betwen the implementation and usage. A pure virtual abstract -base class with no data members. eg. nsIZip | -
IID | - -Interface ID {xxxxx-xxx-xxx-xxxxxx} a unique number that identifies -the Interface being talked about | -
nsISupports | - -The mother of all interfaces. All interfaces ultimately inherit from -this. Provides refcounting. The IID and definition has been carefully choosen -so as to be binary compatible with COM. | -
Component | - -An implementation of a set of interfaces identified by a CLSID | -
Object | - -An instance of a Component | -
CLSID | - -Component ID {xxxxx-xxx-xxx-xxxxxx} a unique number that identifies -a component | -
Module | - -A packaging of a set of Components (ie) a DLL | -
Factory | - -An object whose sole purpose is creation of objects of a particular -component. There exists only one factory for every Component (CLSID). The -IID and definition has been carefully choosen so as to be binary compatible -with COM. nsIFactory | -
ClassObject | - -Same object as factory. | -
ContractID | - -A String name for a Component. | -
ComponentManager | - -Central Object of XPCOM that provides API for object creation and management. | -
ServiceManager | - -A singleton manager. Holds and manages singleton references to objects -for application. Going to be merged with the componentmanager. | -
Service | - -A singleton object within an application. | -
Registry | - -A hierarchical attribute-value pair storage. | -
XPIDL | - -Cross Platform Interface Definition Language. Language for expressing -interfaces. | -
Typelib | - -A storage for meta information about interfaces. Interfaces expressed -in IDL have their meta information maintained in Typelib automatically. | -
XPConnect | - -Ability to call c++ implementations of interfaces expressed in IDL -from javascript and viceversa. | -
NS_IF_RELEASE(obj); -- -It should be noted that release and addref are directly talking to the -object with no intermediaries. The macro NS_*_RELEASE() set the object -to NULL.
Registration involves: -
The module registers with the componentmanager every {CLSID, ContractID}
-it implements with a call to nsIComponentManager::RegisterComponentSpec()
-These registrations are stored in the registry. Hence the next time around,
-the module is loaded not at startup but only when the first object that
-is implemented by a component in the module is created.
-
e.g Registration of GIF Decoder nsGIFModule.cpp -
DO NOT CONVERT YOUR COMPONENT TO nsIModule yet. We are working on -the sample code which will make the conversion process even simpler.
Every module implements a CanUnload() function that returns -a boolean of whether the module can be unloaded. This implies that the -module needs to be counting all outstanding object and return PR_TRUE only -if there are no outstanding objects served from within the module. -- -Unloading happens either on a Timer or on an explicit call to nsComponentManager::FreeLibraries(). -The general logic is: -
-
-No assumptions can be made that the module will be unloaded if nsIModule::CanUnload() -returns PR_TRUE. It is guaranteed that if nsIModule::CanUnload() returns -PR_FALSE, the module will not be unloaded.- -PRBool unloadable = module->CanUnload()
- -- -if (unloadable && marked for unload)
- --
- -- -Unload()
-- -if (unloadable && not mark for unload)
- --
-- -mark for unload
-
Nothing but a persistent hiearchical store of attribute value -pairs. It is the use of the registry by XPCOM that is very interesting. -Physical location of the registry is in the <exedir>/component.reg -- -The xpcom hierarchy of the registry is considered to be opaque to components. -Use the nsIComponentManager Api to register as opposed to meddling with -the xpcom hierarchy in the registry directly. -
mozregistry.dat is NOT the component registry. It is the application -(apprunner) registry.
Previously module definition was scattered across many exported -functions from a dll. -- -
NSGetFactory( -), NSCanUnload( -), NSRegisterSelf( -), NSUnregisterSelf( -) -
Now these are combined into a nsIModule -Please continue to use the old method until sample code using nsIModule -is available.
ServiceManager is a an object that holds instances to objects -in a cache and manages them. It uses the ComponentManager to create an -instance the first time an object is queried for. Lifetime of the instance -is currently the lifetime of the app. We are working on what is required -here and how to control the lifetime. Possbily merging ServiceManager with -the ComponentManager. -- -From the components perspective there is nothing it does special to -behave as a service. The application controls the creation of services -by its usage or call to nsServiceManager::GetService() .Some components -that want to enforce being a service return cached instances on nsComponentManager::CreateInstance() -. -We are working on a more elegant syntax and semantics for this. Post suggestions -to newsgroup netscape.public.mozilla.xpcom (or Email mozilla-xpcom@mozilla.org) -with suggestions.
CLSID is a number identifying a specific implementation. -- -ContractID is a like a pointer to a CLSID. It is an opaque string to xpcom.It -is used for two purposes. -
-
-NOTE: Only Clients that are adamant about the use of a specific implementation -need to create instances using CLSID. -- -Implementation independence for clients: @mozilla.org/registry;1
- -
The CLSID associating itself to a ContractID can be changed. Hence if a -new implementation with a new CLSID superceeds an older implementation, -the client wont be tied to the older implementation if it uses the ContractID. -- -CLSID switching: @mozilla.org/image/decoder;1?type=image/gif
- -
A client wants to create different objects based on a switch (the mimetype -for the case of imagedecoders). A Contractid is formed with a concatenation -of a BASE_CONTRACTID and the switch (mimetype) and an instance of that created. -Components, when registering, associate their CLSID to specific contractids.We encourage use of ContractID. This works well in the scriptable world -too. -
We are working on a ContractID syntax.
-
nsComponentManager -- -
nsServiceManager
No restrictions. You can call any function from the static -classes nsComponentManager and nsServiceManager. XPCOM will do the right -thing to initialize itself at both places. -- -Autoregistration() can happen only after Init_XPCOM() is called since -the registy might be required by SelfRegister() functions of the dlls and -it is only in Init_XPCOM() do we create register the RegistryFactory() -with the ComponentManager.
Init_XPCOM() -- ---Now the hard problem is when to trigger Init_XPCOM() There are two static -objects nsComponentManager and nsServiceManager. Any function in either -of them can be called first. Today nsServiceManager::GetService() is the -first one that gets called. All the members of the static nsServiceManager -use the NS_GetGlobalServiceManager() to get to the global service manager. -All members of the static nsComponentManager use the NS_GetGlobalComponentManager() -to get to the global component manager. Hence if we trigger Init_XPCOM() -from both NS_GetGlobalComponentManager() and NS_GetGlobalServiceManager() -we will be safe.-create the global service manager - --create the global component manager and register as service with the global -service manager - --RegisterFactory(...RegistryFactory...) Register the RegistryFactory -with the component manager so that new registry objects can be created. -
No. The nsIRegistry is designed to be lightweight access to -the registry. Consumers who need to access the registry should use the -component manager to create the their own registry access object. This -is required because the open() call is supported by the nsIRegistry() and -if we maintain a global registry arbitrating which registry file is opened -is going to be a major headach. -- -The ContractID for the registry will be @mozilla.org/registry;1 -
ComponentManager is the only way for -component creation. ComponentManager always uses the component's factory -to create the component instance. Clients (code that calls CreateInstance() -to create and use a component) call the ComponentManager to create instances. -Components (the code that implemented NSRegisterSelf()) calls the ComponentManager -to register itself and gets called when a Client wants to instantiate a -component. -- -ServiceManager is a convinience for getting singleton -components, components for which only one instance stays alive for the -entire application e.g Netlib. It enforces only one of a kind of a component -to exist. Hence the notion of getting a service not creating one. (as opposed -to the notion of Creating instances with the componentManager). ServiceManager -is a convenience because components can technically force singletonism -by making their factory return the same instance if one was created already. -The other big use of ServiceManager is the (still unimplemented) notion -of Shutting down a service. -
Client -
-
-Component -- -When does a client use the service manager vs -component manager
- -
When a client knows that the component that they -are trying to instantiate is a singleton, they need to call service manager -instead of component manager. Clients dont have to worry about calling -the ComponentManager at all in this case. The ServiceManager will take -care of creating the instance if the first one doesn't exist already. -
-- -When does a client use the Component Manager as -opposed to Service Manager
- -
When a client wants a private instance of a component, -they call the Component Manager. From the Clients point of view, a new -xpcom object creation happens everytime they call CreateInstance() Anything -else is an implementation detail that the Client need not worry about. -
-- -How does a Client know that they have to instantiate -a singleton
- -
For now, the Client just has to know. There is -no way of telling which component is a Service and which isn't. In fact, -in todays xpcom (Mar 1999) any component can be accessed as a Service. -Use your judgement until there is a proper method or service manager is -eliminated. There is nothing even in the code that detects Services from -Instances. -Need a solution for this. Email suggestion -to warren@netscape.com, -dp@netscape.com -
-
-- -Can a component enforce use only as a Service
- -
No. The notion of the ServiceManager is available -only to Clients. -Note that at some points when a component wants -another component, it actually behaves as a client and hence follows the -rules of the Client above to either CreateInstance() or GetService() the -needed component. -
Workaround: -If however a component wants only one of its instances to exist and cannot -ensure that Clients understand well enough only to use the Service Manager -to get it, it can implement singletonism in its factory. Basically the -factory on first instance creation should hang on to the instance. On subsequence -instance creations, addref the instance it is holding to and return that -instead creating a new one. -
-
- -
E.g preferences does this. Code sample -at -nsPref.cpp -nsPrefFactory::CreateInstance() and nsPref.cpp -nsPref::GetInstance() With this implementation, whether Clients get -to it by calling nsIServiceManager::GetService() or nsIComponentManager::CreateInstance(), -the same object will be returned hence guaranteeing singletonism.- -Should a component do anything at creation to -become a Service
- -
No. Again, the notion of a ServiceManager is -available only to Clients. -
-- -Can a component advertise that it is a service -so clients can use it as one
- -
No. There isn't a way other than a comment in the interface of the -header file.
ClassID or CLSID is the unique indentification of a component. -It is a structure of huge numbers generated by using uuidgen on a windows -box. It is represented as a string in documentation as {108d75a0-bab5-11d2-96c4-0060b0fb9956} -- -ContractID is the string identification of an implementation of a component -the client is looking for. The representation takes a URI syntax. Eg. @mozilla.org/network/protocol;1?description=Http Protocol Handler&name=http -
Some simplify this to, ContractID is a more readable string form of a CLSID. -That is acceptable on the periphery. The ContractID is a Client thing. Components -register with component manager to claim that they are the implementation -for a ContractID. A component can register to be the implementation for multiple -ContractIDs (not implemented yet). -Client -
-
-Component -- -Should CreateInstance() calls use ContractID or CLSID
- -
ContractID is what Clients should use to CreateInstances. Clients should -not even know about the CLSID unless they are hell bent on creating a particular -implementation of a component.-
-- -Should Components register with both a CID and ContractID
- -
Absolutely.
--Generating a log from xpcom: -Since components are dynamically loaded only on demand, debugging -them could be a hard. Here are some tips to debugging components. --Windows: VC5.0 VC6.0 -
Include your component library in the Project->Settings, Additional -Dll. drop down. After that breakpoints can be enabled.-Unix: gdb ---Mac: Codewarrior --
- -- -Let the program run until you are sure that your component is loaded. Type -Control-C. Now all symbols from your component will be available in gdb. -Put your breakpoints and restart the app. Gdb will complain that it cannot -set the breakpoint, and that it is temporarily disabling it, but when the -*.so is loaded, the breakpoint is enabled automatically. - <Eric -Van Der Poel>
--
- -- -I think typing "dir components" (assuming you're in dist/bin) will also -allow you to see the symbols in your stack the first time. - <Alec -Flett>
--
-- -Using XPCOM_BREAK_ON_LOAD environment variable:
- -
gdb> set env XPCOM_BREAK_ON_LOAD "necko:rdf" -
gdb> r -This will cause xpcom to break in the debugger after loading any dll -with substrings necko or rdf in them. At this point, -you could instruct the debugger to load the dll symbols and set breakpoint. -
gdb> sha libnecko.so -
gdb> b nsFunctionInNeckoJust open the appropriate .xSYM file in the debugger; the debugger -will target the library when the application is run. - <Simon -Fraser>-
XPCOM provides log output. To enable the logging: -- -[unix] --Start your application after setting the above environment variables. Debug -log from xpcom would be in the file xpcom.log
setenv NSPR_LOG_MODULES nsComponentManager:5 -
setenv NSPR_LOG_FILE xpcom.log -[win] -
set NSPR_LOG_MODULES=nsComponentManager:5 -
set NSPR_LOG_FILE=xpcom.log
xpcom/doc/xpcom-log-analyze.sh -is a script that does analysis of the xpcom log and prints out useful statistics -in html format. Usage is: -- -xpcom-log-analyze.sh < xpcom.log > xpcom-log.html --
Internally XPCOM maps the passed in CONTRACTID to a CID and then the CID -maps into a DLL name. XPCOM loads the DLL assuming the dynamic loading -mechanism to create a factory. Then, asks the factory to create a particular -instance. Here are roughly the steps involved: -
RegisterComponentWithType(const nsCID &aClass,
-
-const char *aClassName,
-
-const char *aContractID,
-
-const char *aComponentType,
-
-const char *aComponentLocation,
-
-PRBool aReplace,
-
-PRBool aPersist);
-
-
-
*
-ContractID syntax might change
-
-
Dynamic object registration in XPCOM is achieved by interaction of the -following components: -
Profiles are a notion of the app (navigator) and xpcom has nothing to -do with it. The app will store app specific data in a Data-Registry that -will be stored under the user's home directory. -
XPCOM will use the following registry hierarchy: -
ROOTKEY_COMMON -- -
Common -
Classes -
-CLSID -
-{108d75a0-bab5-11d2-96c4-0060b0fb9956} --InprocServer (S) = /home/dp/dist/bin/components/libnfs-protocol.so --ContractID (S) = @mozilla.org/network-protocol;1?type=nfs --ClassName (S) = NFS Protocol -Handler -@mozilla.org/network-protocol;1?type=nfs -
-CLSID (S) = {108d75a0-bab5-11d2-96c4-0060b0fb9956} -Software -
Netscape -
-XPCOM -
-VersionString (S) -= alpha0.20 --/home/dp/dist/bin/components/libnfs-protocol.so -
-ComponentsCount (Int) = 1 -
-FileSize (Int) -= 78965 -
-LastModTimeStamp (S) = Wed -Feb 24 11:24:06 PST 1999 --Events -
-Startup -
-{108d75a0-bab5-11d2-96c4-0060b0fb9956} -
-{17894983-ab78-8d75-a0bb-511d296c4006} --Shutdown -
-{748958ea-abab-511d-296c-40060b0fb995} -
-{45617894-983a-b788-d75a-0bab11d296c4} -
Let us consider some more examples: -
The ContractID for these would look like -
The above semantics would let ContractID be an extensible mechanism that
-could be searched on multiple ways. And
-
query on a contractid should match only whatever was passed in. So a query
-for
-
@mozilla.org/plugin;1?type=image/gif should pass for the contractid
-specified above. We could extend this
-
mechanism with wildcards, but I dont want to go there yet... :-)
-
-
Some dlls have components that want to be created on certain events -namely Startup, Shutdown (for now). Example is xpinstall. -
RegisterComponentForEvent(..., RegisterationTime when, ...) --exists for this purpose. When an application wants to Fire the particular -event, it calls -
RegisterFactoryForEvent(..., RegistrationTime when,...)
nsComponentManager::FireEvent(RegistrationTime when)-ComponentManager will look for components that are registered to be created -on these events and do the following for each of the components: -
-- --No more hacking in calls to nsIRepository::RegisterFactory() - --No need to know the CLSID of components that you want to instantiate. Component -creation can happen like this - -
nsIRepository::CreateInstance("@mozilla.org/network-protocol;1?type=nfs", -NULL, kProtocolIID, &result); -
instead of -nsIRepository::CreateInstance(NFS_PROTOCOL_CID, NULL, domIID, -&result);
Component Users
-
\n"; - -# Objects created with a histogram - print "\n"; - PrintArray(@dll_loaded); - print "
\n"; - -# Passed contractid calls - print "\n"; - @sorted_key = SortKeyByValue(%objects); - foreach $cid (@sorted_key) - { - printf("%5d %s [%s]\n", $objects{$cid}, $cid, $contractid_map{$cid}); - } - print "
\n"; - - -# ======================================================================== -# Error analysis -# ======================================================================== - print "\n"; - @sorted_key = SortKeyByValue(%contractid_passed); - foreach $contractid (@sorted_key) - { - printf("%5d %s\n", $contractid_passed{$contractid}, $contractid); - } - print "
\n"; - -# ContractIDToClassID() FAILED with a histogram - print "\n"; - @sorted_key = SortKeyByValue(%objects_failed); - foreach $cid (@sorted_key) - { - printf("%5d %s [%s]\n", $objects_failed{$cid}, $cid, $contractid_map{$cid}); - } - print "
\n"; - -# end the html listing - print "\n"; -} - - -sub PrintArray() -{ - my(@array) = @_; - for ($i=0; $i<@array; $i++) - { - print "$array[$i]\n"; - } -} - -# -# Sort a given hash by reverse numeric order of value -# return the sorted keylist -# -sub SortKeyByValue() -{ - my(%hash) = @_; - my(@sorted_keys) = sort { $hash{$b} <=> $hash{$a} } keys %hash; - return @sorted_keys; -} diff --git a/xpcom/doc/xpcom-log-analyze.sh b/xpcom/doc/xpcom-log-analyze.sh deleted file mode 100755 index 8e60286eeb51..000000000000 --- a/xpcom/doc/xpcom-log-analyze.sh +++ /dev/null @@ -1,105 +0,0 @@ -#!/bin/sh - -# -# Shell script to analyze the xpcom log file -# -# Usage: xpcom-log-analize.sh [\n"; - @sorted_key = SortKeyByValue(%contractid_failed); - foreach $contractid (@sorted_key) - { - printf("%5d %s\n", $contractid_failed{$contractid}, $contractid); - } - print "
" - -# Objects created with a histogram -n=`grep -i 'createinstance.*succeeded' ${logfile} | wc -l` -echo "" -grep ': loading' $logfile -echo "
" - -# Number of RegisterFactory -n=`grep 'RegisterFactory' $logfile | wc -l` -echo "" -grep -i 'createinstance.*succeeded' ${logfile} | sort | uniq -c | sort -nr -echo "
" - -# Number of RegisterComponentCommon. -# XXX Order them by dllname -n=`grep 'RegisterComponentCommon({' $logfile | wc -l` -echo "" -grep 'RegisterFactory' $logfile -echo "
" - -# Number of succeeded calls to ContractIDToClassID() with histogram -n=`grep -i 'contractidtoclassid.*}' $logfile | wc -l` -echo "" -grep 'RegisterComponentCommon({' $logfile -echo "
" - - -# ======================================================================== -# Error analysis -# ======================================================================== -echo "" -grep -i 'contractidtoclassid.*}' $logfile | sort | uniq -c | sort -nr -echo "
" - -# ContractIDToClassID() FAILED with a histogram -n=`grep 'ContractIDToClassID.*FAILED' $logfile | wc -l` -echo "" -grep 'CreateInstance.*FAILED' $logfile -echo "
" - -# -# Cleanup -echo "" diff --git a/xpcom/doc/xpcom-standalone.html b/xpcom/doc/xpcom-standalone.html deleted file mode 100644 index 5f7919595cf9..000000000000 --- a/xpcom/doc/xpcom-standalone.html +++ /dev/null @@ -1,142 +0,0 @@ - - - - - - - - - -" -grep 'ContractIDToClassID.*FAILED' $logfile | sort | uniq -c | sort -nr -echo "
-
Get out your decoder rings kids! -
Having a basic understanding of COM is only the first
-
step. To get CMonkey code to build and run,
-
you need to translate your COM ideas into Netscape
-
speak.
-
Feel free to add to this document or change incorrect info.
-
Hopefully more info and more examples will help new
-
people reach XPCOM nirvana more quickly.
-
To mentally translate XPCOM to COM.
-
-
vanilla COM | - -XPCOM | -
IUnknown | - -nsISupports | -
IClassFactory | - -nsIFactory | -
virtual void _stdcall | - -NS_IMETHOD | -
interface ID = IID | - -nsID = nsIID = IID | -
class ID = CLSID | - -nsCID = CID | -
Not too difficult.
-
But wait. There's more.
-
-------------------------------------------
-
Why don't those classes have AddRef? -
Actually, those classes do have AddRef. It is hidden
-
in a macro. There are alot of macros that are alot of help
-
once you know :
-
1) They exist.
-
2) Where they are defined. (They aren't always mnemonic
-or onomatipeic.
-
-You might want to print them out.)
-
mozilla/xpcom/public/nsCom.h
-
-mozilla/xpcom/public/nsISupports.h
-
3)What they are
-
-Here's a short list to give you an idea of what you've been missing.
-
-The include files listed above are the real reference.
-
4) A quick way to expand pesky macros:
-
-For macros in foo.cpp, 'make foo.i'
-
This
-will pump the foo.cpp file through C preprocessing
-
-and expand all the macros for you. The output can be
-
-hard to read, but if you search for unique strings
-
-in the area you aredebugging, you can navigate
-
-the file pretty easily.
-
-(thanks to hshaw@netscape.com)
-
-
-
-
Netscape MACRO | - -Expansion of macro | -
NSADDREF(factoryinstname) | - -Factory->AddRef(); | -
NS_IMETHOD | - -virtual nsresult __stdcall | -
NS_INIT_REFCNT() | - -mRefCnt = 0 | -
NS_INIT_ISUPPORTS() | - -NS_INIT_REFCNT() | -
NS_DECL_ISUPPORTS | - -public:
- NS_IMETHOD QueryInterface(REFNSIID -aIID, - -void** aInstancePtr); - NS_IMETHOD_(nsrefcnt) -AddRef(void); - NS_IMETHOD_(nsrefcnt) -Release(void); - protected: - nsrefcnt mRefCnt; |
-
Useful Links to COM Documents: -
XPCOM Page
-
nsCOMPtr
-
Coding
-Conventions
-
Getting BAMmed
-
How to COM
-
Modularization
-Techniques
-
C++
-Portability Guide
-
NGLayout
-
-
-
-
-