Closed
Bug 60117
Opened 25 years ago
Closed 25 years ago
use generic startup mechanism in mozilla
Categories
(SeaMonkey :: General, defect, P1)
Tracking
(Not tracked)
RESOLVED
FIXED
mozilla0.9
People
(Reporter: alecf, Assigned: alecf)
References
Details
(Whiteboard: fix in hand)
Attachments
(3 files)
|
2.46 KB,
patch
|
Details | Diff | Splinter Review | |
|
7.40 KB,
patch
|
Details | Diff | Splinter Review | |
|
5.23 KB,
patch
|
Details | Diff | Splinter Review |
Some components need to be run at the startup of mozilla, to start new services,
etc.
We need a generic way to start up arbitrary components without requiring them to
hack into main1() as we do for things like:
- wallet
- cache prefs
- command line handlers
- appshell components
My proposal is that we have a category called "apprunner-startup" which
components register themselves in. When mozilla starts, we can automatically
enumerate these startup components, notify them that startup has begun, and
release them.
Patches forthcoming. I'll be using the nsIObserver interface that XPCOM has, to
notify components in the "apprunner-startup" category on the "apprunner-startup"
topic.
| Assignee | ||
Comment 1•25 years ago
|
||
| Assignee | ||
Comment 2•25 years ago
|
||
| Assignee | ||
Comment 3•25 years ago
|
||
I've used wallet as a first example, because with this mechanism we no longer
have to instantiate the Wallet Service in main1()
Status: NEW → ASSIGNED
Target Milestone: --- → mozilla0.9
Comment 4•25 years ago
|
||
Is it possible to add some sort of priority order to the startup components so
that component constructors can control the order in which extension components
are started?
I think we will se more and more extension components with time and there will
probably be dependencies among them.
Comment 5•25 years ago
|
||
+ nsXPIDLCString previous;
+
+ return categoryManager->AddCategoryEntry("apprunner-startup", "wallet",
+ NS_WALLETSERVICE_CONTRACTID,
+ PR_TRUE, PR_TRUE,
+ getter_Copies(previous));
Since you don't care about the value of 'previous' you might as well just pass
NULL instead. It appears to me that nsCategoryManager::AddCategoryEntry()
handles that correctly.
Comment 6•25 years ago
|
||
Nit: common "apprunner-startup" into a const char APPRUNNER_STARTUP[].
The idea of a priority can lead to pigeon hole problems, although it can scale
for a good while (if you use base 1000, e.g.). Could we not use an exact
representation of the dependencies among apprunner components? Something like
MSCOM category UUIDs and a < operator that partially orders their components?
/be
Comment 7•25 years ago
|
||
Is this mechanism loading the whole shebang at startup? I know there's a bug
somewhere the lazily instantiate wallet, I'm not sure about all the other
components ...
| Assignee | ||
Comment 8•25 years ago
|
||
add morse to the CC to get his review of the wallet stuff.
Comment 9•25 years ago
|
||
The bug about lazy initialize of wallet is bug 14889.
Cookies should probably also be on your list.
r=morse for the wallet changes.
Comment 10•25 years ago
|
||
>My proposal is that we have a category called "apprunner-startup" which
>components register themselves in. When mozilla starts, we can automatically
>enumerate these startup components, notify them that startup has begun, and
>release them.
Of course, this is precisely what nsIAppShellComponent (along with
nsAppShellService::EnumerateAndInitializeComponents) was intended to accomplish.
It predated nsIObserver and categories so the implementation differs. But the
intent is the same.
There's also overlap with nsICommandLineHandler. Maybe these should all be
merged so there's only 1 way to get a component called at startup.
One thing I'd like to see preserved: the factoring out of this logic from
main/main1. I.e., move it to
nsAppShellService::EnumerateAndInitializeComponents (or equivalent). Mostly,
that's because I have an aversion to large, monolithic functions (versus
smaller-scale, overrideable object methods).
Actually, if you just implemented a new nsIAppShellComponent and implement
Initialize with the category enumeration code and nsIObserver calls, you
wouldn't have to further hack main1 at all :-).
| Assignee | ||
Comment 11•25 years ago
|
||
yeah, my hope was to eventually roll appshell components into this mechanism...
hopefully main1().. and you're right about the commandline handler stuff - it
can probably be rolled in down the road.
Comment 12•25 years ago
|
||
What I was saying was that if most of these components should be lazily
instantiated and if lazy instantiation doesn't fit in with this, perhaps it's
not as necessary.
| Assignee | ||
Comment 13•25 years ago
|
||
this is for components that cannot be lazily instantiated.... what you're
talking about is beyond the scope of this bug.
Comment 14•25 years ago
|
||
Then my statement essentially boils down to that someone should _really_ make
sure that what's suggested here can't be lazily instatiated.
At least wallet can be apparently, so others might be as well. "Cache prefs"
sounds suspicious to me, since I wouldn't expect anything to do with the cache
to be loaded if I have a purely mailnews session that never accesses embedded
URLs.
And if it does turn out that nearly everything should be lazily instantiated, it
might be worth just changing everything to being lazy rather than doing this.
If someone who knows more about these components than me tells me everything
other than wallet must be instantiated at startup, or that there are in fact
enough examples that absolutely need to be startup instantiated, I'll be
perfectly happy. I'm just making sure this isn't for something that won't
really be needed once everything that can be is lazy.
| Assignee | ||
Comment 15•25 years ago
|
||
Here's an example: The splash screen cannot be lazily instantiated.
| Assignee | ||
Comment 16•25 years ago
|
||
add valeski.. I hope this hasn't bit-rotted but it probably has.
Comment 17•25 years ago
|
||
note: the meta-charset service wedges itself into main() as well.
Updated•25 years ago
|
Comment 18•25 years ago
|
||
While I agree with the overall plan here, the initializing of cache prefs in
particular is a matter not just of lazy initialization or ordering - it's one of
control. Seamonkey (in nsAppRunner), initializes the disk cache location to be
within the current profile dir. That also means that there is a distinct cache
dir for each profile. Some application might not want to do this - it may
instead wish to have a global cache dir shared by all profiles. If this behavior
is rolled into a hidden, automatic startup action, how is an embedding app
supposed to control this behavior?
| Assignee | ||
Comment 19•25 years ago
|
||
I think that's something that the cache implementors are going to have to fix.
Comment 20•25 years ago
|
||
This hasn't been nominated nsbeta1, I think this is too big of a task to be done
in mozilla0.9. Bumping off mozilla0.9 train.
Target Milestone: mozilla0.9 → ---
| Assignee | ||
Comment 21•25 years ago
|
||
cc'ing chak and putting back on 0.9 milestone - we've got a basic fix in hand,
it just doesn't cover all components
Target Milestone: --- → mozilla0.9
Comment 22•25 years ago
|
||
chak's stuff is in, let's get this hooked up in mozilla.
| Assignee | ||
Comment 23•25 years ago
|
||
yup, raising priority.... I'll get to this asap
adding heikki because he's got some xml extension stuff that depends on this
(updating summary slightly)
Priority: P3 → P1
Summary: need generic startup mechanism → use generic startup mechanism in mozilla
| Assignee | ||
Comment 24•25 years ago
|
||
| Assignee | ||
Comment 25•25 years ago
|
||
I need a super-reviewer and reviewer here. blizzard/jst? jag?
adding jst because heikki needs this, and figured jst would be sympathetic to
his cause :)
Whiteboard: partial fix in hand → fix in hand
| Assignee | ||
Comment 26•25 years ago
|
||
sorry, that patch also includes the removal of a bunch of totally unnecessary
casts that I had in my tree.. just makes the code more readable
Just a minor optimization opportunity, replace:
nsCOMPtr<nsIObserver> startupNotifier =
do_CreateInstance(NS_APPSTARTUPNOTIFIER_CONTRACTID, &rv);
with:
nsCOMPtr<nsIObserver>
mStartupNotifier(do_CreateInstance(NS_APPSTARTUPNOTIFIER_CONTRACTID, &rv));
This saves us from operator=() call.
Otherwise, r=heikki.
Crap, messed up with the variable names... Anyway, you get the principle: use
the constructor directly when you can, use operator= only when you must.
Comment 29•25 years ago
|
||
Heikki: the direct construction form is only slightly more efficient, and only
then on some compilers. I wouldn't go around changing assign forms to this if not
necessary.
Simon: yes, I know, and I am not saying we should go through the whole tree to
change them all. But I see no reason why we shouldn't write new code this way.
Comment 31•25 years ago
|
||
scc did some testing and the assignment form vs. the constructor form didn't
make any difference when the compiler was doing optimization.
sr=blizzard
| Assignee | ||
Comment 32•25 years ago
|
||
fix is in, as is, per blizzard's comments
Status: ASSIGNED → RESOLVED
Closed: 25 years ago
Resolution: --- → FIXED
Updated•21 years ago
|
Product: Browser → Seamonkey
You need to log in
before you can comment on or make changes to this bug.
Description
•