Thanks for your reply,

Getting started in modifying code in mail-news which has UI ramifications, so I'm trying to understand the model by which JS
calls through to XPCOM components.

Good for you! most people jump in and then ask questions ;)

Guilty as charged.


It appears that events in the UI are handled using a thread pool,
thus allowing multiple events to be handled simultaneously. Is this
correct?

No. All JS events are handled on the main (UI) thread. However, we have a policy that you may not call an XPCOM method from the UI thread which might block on network activity, etc. So the networking layer uses helper threads which perform the actual networking activity. These threads proxy progress notifications back to the main thread.

I guess I don't see this happening though. In msgHdrViewOverlay.js:851, it is calling into the nsIMessenger interface on the SaveAttachment call [ messenger.SaveAttachment(...) == nsMessenger::SaveAttachment(...) ].


(Note: this question is applicable for any component, messenger is just the one I'm studying at the moment)

This method in nsMessenger immediately opens a modal file picker dialog so that you can select the location to save the attachment. However while that thread is waiting with the dialog open for you to pick a file, you can go back to the main window and do the same thing again, thus having 2 file picker dialogs open simultaneously, both for the same action.

If the main UI thread is blocked by the first file picker dialog being still open, why is the UI still responding to me when I go and do the same action again?

If I am going to create a long running event in response to UI
action (e.g. causing a message to be downloaded from IMAP if not in
the cache), can I do it in the message handler (e.g. nsIMessenger::SaveAllAttachments) or should I definitely spawn the task into the url listener style of callbacks (e.g. what SaveAllAttachments currently does).

You should definitely move direct network calls off the main thread. Try posting to npm.netlib (I have cc'ed this post) to figure out whether there is code in the networking library that does this automatically, or whether you need to manually setup a worker thread.

There seems to be a wealth of code there already to download and process messages and attachments. I doubt that I will have to create anything particularly new here. At the moment I'm just studying the way that SaveAllAttachments works.


Regards,
Brodie

_______________________________________________
Mozilla-netlib mailing list
[EMAIL PROTECTED]
http://mail.mozilla.org/listinfo/mozilla-netlib

Reply via email to