We need an easy way to test and validate the Download Service. I think a good way to do this would be to add a chrome://download-internals page and add a section on the download service. This would probably have the following behavior:
(1) Can see all events going by in the form of a stream.
(2) Can see all downloads (both queued and active). This includes their state and all relevant params.
(3) Can start a download from the UI.
(4) Can pause, resume, or cancel any download from the UI.
(5) Can see the device criteria status as well as the service status.
I would build this like the following:
General Setup/Ownership of Logger:
(1) Add a ServiceLogger that exposes JSON messages. The logger has observers to be notified on new events.
(2) Add a DownloadService::GetLogger() to expose the logger.
(3) Have the internal LoggerImpl owned by the DownloadManagerService. Have it get passed into the Controller.
(4) Have the Controller notify the logger of all relevant events.
(5) Have the logger ignore those events if there are no observers.
Logger behaviors:
(1) Logger can queue up to X max messages.
(2) Logger can have both an event log (more human readable) and a JSON log. The LoggerImpl can know about download/internal because it will live there.
WebUI:
(1) To start downloads have a DemoClient or WebUIClient (where it goes depends on what we call it).
(2) Have actual WebUI pages hook onto the Client when they start as observers (or maybe the WebUI can extend Client and we just pass all calls through).
(3) Have the client hook onto a BrowserContext as UserData so that the WebUI can find it.
(4) Have the WebUI observer push the JSON/log strings through to the javascript.
Comment 1 by bugdroid1@chromium.org
, Sep 26 2017