moz.build |
|
305 |
OfflineStorage.cpp |
|
3183 |
OfflineStorage.h |
A stream listener that forwards method calls to another stream listener,
while substituting the request argument with the provided channel.
Consumers are expected to call `OnStartRequest` themselves, so that their own
consumers are informed of the entire operation (which might involve e.g.
downloading the message from a remote server). Any call to `OnStartRequest`
after the first one is silently ignored.
`ReadMessageFromStore` can be called from a channel ran within an
`nsIDocShell` to render the message. The stream listener that `nsIDocShell`
calls `AsyncOpen` with expects the request used in method calls to be
channel-like (i.e. it can be QI'd as an `nsIChannel`). Additionally, we want
to use `nsIInputStreamPump` to pump the data from the message content's input
stream (which we get from the message store) into the provided stream
listener. However, the default `nsIInputStreamPump` implementation calls the
stream listener methods with itself as the request argument, but only
implements `nsIRequest` (and not `nsIChannel`), causing the operation to
fail.
Therefore we need this "proxy" listener to forward the method calls to the
listener `AsyncOpen` is originally provided with, while subsituting the
request arguments with an actual channel.
Additionally, it's a good place to check for read errors when streaming a
message to the destination, and clearing malformed messages from the offline
storage (so they can be downloaded again).
|
4760 |