Snippets code from my daily experience

March 18, 2007

XPCom: download multiple files and block the execution

Filed under: firefox,mozilla,nsIWebProgressListener,xpcom — dafi @ 9:09 am

The problem is simple: you want to download a bunch of http pages and save their content into separated files but you want to wait all downloads finish before to advance to the next line of code.

Using the nsIWebProgressListener this can be accomplished easily using the same progress listener that increments a counter at every download completed.

When the counter reaches the total urls to download a callback function is called.

You can take a look at my implementation (used into ViewSourceWith) here


Create a free website or blog at