Dmitry Dartz wrote: (no need to crosspost, m.d.embedding is fine for this discussion).
1) Old profile management that was available in Mozilla 1.7.x, is not available anymore in 1.8.x and by default Makefiles are run with MOZ_SINGLE_PROFILE=1 defined, leaving us with those pretty ugly profdirserviceprovider_s and profdirserviceprovidersa_s
The whole "what is a profile and how do I deal with them as an embedder" question has been blown way out of proportion. A profile is just a directory to store settings in, and a couple of notifications that tells gecko 1) to start using the profile and 2) to stop using the profile.
The Mozilla trunk contains a frozen (dynamically linked) profile API for embedders (XRE_LockProfile and relatives). On older branches embedders will have to make do like they always have using profdirserviceprovidersa_s or custom-rolled code that does basically the same thing.
2) currently profdirserviceprovider is quite a broken stuff and below the reasons why I think so: 2a) It has no interfaces (oh well it has nsISupports but nothing else) and all calls to its Register() or Shutdown() methods are done against C++ class, not interface. What's about reference counting and other really good things offered by XPCOM? By working with C++ class you simply bypass them. That's UGLY thing #1.
That's not ugly, that's just C++. And you can and should be reference-counting your nsProfileDirServiceProvider* just like any other thing (don't ever delete it directly).
2c) profdirserviceprovider has no clear way for its shutdown. Although it has public Shutdown() method, it's not clear when to call it. If I do not call it at all, mainthread clamins that there are remained references to when XPCOM (with its glue) is shutted down and profdirserviceprovider as you might guess remains in memory (causing leaks, of course). If I call it immediately before NS_TermEmbedding(), it will trigger assertion "nsNSSComponent relies on profile manager to wait for synchronous shutdown of all network activity" if network was used. So it looks like current profdirserviceprovider does not issue PROFILE_CHANGE_NET_TEARDOWN_TOPIC when needed. Needless to say that much more nad things happen if Shutdown() called much before NS_TermEmbedding(). That's UGLY thing #3.
The Shutdown() method is pretty clearly documented in the header file. You need to call it before shutting down XPCOM. If there are bugs about not shutting down properly (not doing NET_TEARDOWN or whatnot), please file and fix them.
2d) in Register() method, profdirserviceprovider registers itself in NS_DIRECTORY_SERVICE (see directoryService->RegisterProvider), but does not unregister itself during Shutdown() and it causes leaks too. Leaks are always UGLY things.
It shouldn't need to unregister itself, the directory service will release it during the shutdown process.
3) Nothing is said that FireFox 1.5 distro (at least under Windows) can't be reused by any embedding application, but that's it because there are no components available as standalone dlls, almost all are linked statically into firefox.exe. Nothing bad, but should be noted somehow on the web. BTW people asked about it on this group but no replies.
Nobody ever claimed it *could* be used. Of course it can't, because it's statically linked and doesn't expose any useful embedding APIs. XULRunner is the recommended application framework for all embedders; it exposes real embedding APIs in C/C++ and Java, and we've spent a significant amount of time documenting that is is the target for embedded uses of gecko.
--BDS _______________________________________________ dev-embedding mailing list [email protected] https://lists.mozilla.org/listinfo/dev-embedding
