On 13/03/2012 2.54, Josh Matthews wrote:
> Per-window private browsing is coming
> (
https://wiki.mozilla.org/Per-window_Private_Browsing), and certain
> things in the platform require changing to support the new architecture.
> Since the download manager is shared among other products, I've been
> asked to start a conversation about my proposed changes so that
> interested parties can provide input.
Thanks for starting the conversation, and for the clear overview of
one of the possible API changes we could implement.
We know that we need to change the API to accommodate per-window private
browsing, and I'd also add that we're planning to improve the Download
Manager back-end performance by making it asynchronous. This probably
requires some API changes as well, so this is a good time to discuss.
What we should create in this phase is a sort of "compatibility plan"
for the evolution of the Download Manager back-end. So the first phase
is understanding the consumers of the current API and their needs.
So far, I've collected this list of consumers on bug 722859:
- The Downloads window allows viewing and handling downloads globally.
- The same does the Firefox Downloads Panel (coming soon).
- addDownload is called in a few places (e.g. uriloader/exthandler).
- Probably, some add-ons add new downloads, some can manipulate them.
Callek added two interesting elements:
- SeaMonkey uses a very customized UI for the Download Manager based
on the API so far exposed.
- Private Browsing is currently disableable and SeaMonkey does not
currently ship with Private Browsing turned on at all.
Thus, we'll certainly end up with at least three different interactions
with downloads in different products, and as Robert mentioned, some
add-ons might want to support all of them at the same time (fully or
partially):
- SeaMonkey current: no private browsing.
- Firefox current: global private browsing.
- Firefox future: per-window private browsing.
Current consumers handle the first two cases with the same API. We
should try and make it simple to continue to support those two cases.
But we must make sure that, when per-window private browsing is added,
existing consumers (either core or third-party, default-to-compatible
add-ons) don't cause private-mode downloads to leak into
non-private-mode areas. In particular:
*Adding new user-visible downloads*
This can currently be done using either the addDownload method or
indirectly through nsITransfer (used by Save As). This is the
easiest use case and I guess many add-ons do just this (as opposed
to doing full download management).
To check that the consumer is aware of whether the window from which
the download is initiated is in private mode or not, we should break
the ability to call the current form of addDownload, at least in cases
where per-window PBM is enabled. I've not thought about nsITransfer
but we should probably do the same there.
We can choose to keep the current API available as-is for the
"no private browsing" or "global private browsing" cases.
*Manipulating downloads*
The API for managing downloads currently includes nsIDownloadManager,
nsIDownload, and a set of related, global observer notifications.
nsIDownloadManager provides access to the underlying SQLite database,
which is essential for getting the list of downloads.
We could keep compatibility with the current API, also when per-window
PBM is enabled. But, unless we conclude that we can mix private-mode and
non-private-mode downloads in the same list (thoughts on this?), we
should ensure that existing consumers have access to non-private-mode
downloads only. This _might_ mean that the global observer
notifications should be sent for public downloads only.
Consumers that are aware of per-window private browsing, on the other
hand, should be able to access the two download lists concurrently.
There are also a few more thoughts to add:
- We might want to add a fully-asynchronous API that doesn't require
the user interface to query the database directly (as Josh already
mentioned).
- The Firefox Downloads Panel doesn't need to persist the full
download history across sessions anymore. Only active downloads
are kept. A SQLite database is overkill for that. We could store
the data in the session restore file, or other places, to improve
the performance of starting and managing a download.
- With the need to display two different download views concurrently,
we might consider to use an interface that is not a singleton.
- We are considering the benefits of de-XPCOMifying the management
interface and the notifications. The Downloads Panel already uses
a set of JavaScript model objects that represent downloads.
With all of this in mind, let's discuss what we think are the most
important requirements, and brainstorm about possible designs for
a revised Download Manager back-end. The changes Josh outlined
probably match most of the expectations above, though we've not
talked about performance improvements and other changes yet.
Thoughts?
Cheers,
Paolo