Leonid Romanov wrote:

>Hi!
>I need to implement additional "standard" JavaScript class for making http
>requests. SpiderMonkey will run as part of embedded browser and I prefer
>to implement it inside libmozjs.so, without messing with XPConnect. For
>class's users request will look as synchronous, however user can specify
>timeout for it, so implementation should be asynchronous.
>
>My plan is following: implement full blown StreamListener, then, inside my
>JavaScript class method implementation:
>
>  eventQService->PushThreadEventQueue(getter_AddRefs(mEventQueue)); 
>  ...
>  mChannel->AsyncOpen(mMyListener, nsnull); 
>  ...
>  while (mRunEventLoop) {
>    mEventQueue->ProcessPendingEvents();
>    // timeout stuff using PR_IntervalNow()
>  }
>  ...
>  eventQService->PopThreadEventQueue(mEventQueue);
>
>The big question is: will such aproach work at all? If so, are there any 
>pitfalls which I should be aware of? For example, should I process all 
>pending events from current event queue before pushing my own? 
>Any useful sources from Mozilla's tree to look (so far I'm only found 
>nsXMLHttpRequest.cpp)? Docs?
>
>P.S. I'm not too skilful with threads :(
>
I don't think you should be avoiding XPConnect, or hacking "inside 
libmozjs.so".  Especially if you're new to threads.

Why not use XPCOM properly, and from the right library in the embedded 
browser?

Anyway, I'm setting followup-to: m.netlib for advice from the Necko gurus.

/be

>
>
>Thanks in advance. 
>Leonid.
>



Reply via email to