On Sun, 21 Oct 2007, Boris Zbarsky wrote: > Jan Wrobel wrote: > > My idea is to add following interface and make nsChannel implement it: > > This solution would make possible replacing StreamListener in the > > "on-examine-response" event with a new version that can pass content > > to original listener after checking or manipulating it (something very > > similar that converter do). > > How would the interaction between different on-examine-response > implementations > work?
If few different "on-examine-response" observers replace channel's StreamListener, a chain of listeners is created. Lets say there are two observers: observer1 and observer2. First, channel creator calls AsyncOpen(originalListener, ...) Then observer1 receives "on-examine-response" notification. It gets originalListener and replaces it with observer1Listener. observer1Listener can pass OnStartRequest, OnStopRequest, OnDataAvailable to the originalListener (it has reference to it). Next, observer2 receives "on-examine-response" notification. It gets observer1Listener, replaces it with observer2Listener and can pass calls to it. So the call chain looks like this: nsHttpChannel calls observer2Listener->OnStartRequest() it then calls observer1Listener->OnStartRequest() and it calls originalListener->OnStartRequest(). The same think happens for other calls. If there are more observers, chain is further extended. In this solution there is no way to control which observer is notified first and where in the chain it is placed. Whether this control is needed depends on the application. I think that for filters like Firekeeper it isn't at all necessary. Cheers, Jan _______________________________________________ dev-tech-network mailing list [email protected] https://lists.mozilla.org/listinfo/dev-tech-network
