Dne torek, 24. julij 2012 16:17:27 UTC+2 je oseba Boris Zbarsky napisala: > On 7/24/12 6:54 AM, justSomeGuy wrote: > > MyListener *myListener = new MyListener; > > rv = traceableChannel->SetNewListener(myListener, > getter_AddRefs(myListener->mListener)); //I put the > nsCOMPtr<nsIStreamListener> mListener; into the implementation of > nsIStreamListener > > As a side note, this seems to pass in myListener when it has a 0 > refcount, which seems like a really bad idea. myListener should be an > nsCOMPtr. >
I tried it as an nsCOMPtr too. Didn't make a difference. But thank you for the note I will change it. It is also there as a comment because i didn't know which one is better to use. > Your MyListener class implements QueryInterface to nsIStreamListener and > nsIRequestObserver? > > -Boris MyListener implements QueryInterface to nsIStreamListener and nsIRequestObserver too. Here is the code: /* Header file */ class MyListener: public nsIStreamListener { public: MyListener(void); NS_DECL_ISUPPORTS NS_DECL_NSISTREAMLISTENER NS_DECL_NSIREQUESTOBSERVER nsCOMPtr<nsIStreamListener> mListener; private: ~MyListener(void); }; /* Implementation file */ NS_IMPL_ISUPPORTS2(Crypt_o_niteListener, nsIRequestObserver, nsIStreamListener) MyListener::MyListener() { ... } MyListener::~MyListener() { ... } NS_IMETHODIMP MyListener::OnStartRequest(nsIRequest *aRequest, nsISupports *aContext) { ... } NS_IMETHODIMP MyListener::OnDataAvailable(nsIRequest *aRequest, nsISupports *aContext, nsIInputStream *aInputStream, PRUint32 aOffset, PRUint32 aCount) { ... } NS_IMETHODIMP MyListener::OnStopRequest(nsIRequest *aRequest, nsISupports *aContext, nsresult aStatusCode) { ... } _______________________________________________ dev-platform mailing list dev-platform@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-platform