From bug 526207 comment 33 et seq.: (Zack Weinberg) > There is now an HttpChannelChild class that also needs to provide > implementations of the new nsIHttpChannelInternal methods, but I > don't know if it needs to implement them for reals or if it can get > away with always returning NS_ERROR_NOT_AVAILABLE. (If you try to > compile this patch as is you'll get a bunch of "cannot create > instance of abstract class" errors.) (Josh Matthews) > If there's any chance that an extension will want retrieve the > values of the new attributes in a content process, we'll need to > have some way of transferring them from the parent to the child. > The drop-dead simple way is to add a couple of synchronous IPDL > getters, but it would probably be nicer to move the implementation > and C++ members to BaseHttpChannel and simply forward the values > from the parent to the child when they're first set in > OnTransportStatus. > > Presuming they're available by the time OnStartRequest is called, it > would be a simple matter to add them to the mass of values being > passed from parent to child there. Of course, we'll need to > serialize PRNetAddr by hand. Sigh. (Zack Weinberg) > I don't know how to do any of the above (this would be my first time > ever having to do something with the IPC layer), and with the schedule > being what it is, I'm rather inclined to just stub them in > HttpChannelChild for now and file a new bug. This is that new bug.
This would be a really good, well-scoped bug for anyone interested in learning how cross-process Firefox works. I think the best way to implement the required functions is to move nsHttpChannel::Get(Local|Remote)(Address|Port) and nsHttpChannel::m(Self|Peer)Addr to BaseHttpChannel so both parent and child channels display the same behaviour. Then in HttpChannelParent::OnStartRequest, we need to serialize mSelfAddr and mPeerAddr and send them to the child (netwerk/protocol/http/PHttpChannel.ipdl will require modification). If anyone's picking this up, feel free to contact me for further help/advice.
6 years ago
Created attachment 526744 [details] [diff] [review] patch v1
Comment on attachment 526744 [details] [diff] [review] patch v1 This will be +r with the following issues addressed: Fewer, bigger IPDL messages are better than multiple smaller ones (each message could cause a context switch and other messaging overheads--see bug 561694 for example). So let's get rid of the UpdateAddresses IPDL message, and send its data as part of OnStartRequest. Unless there's some reason we shouldn't (but I don't see one). > friend class HttpChannelParent; Why do we need the friend relationship with HttpBaseChannel? > /* We've been tricked by some socket family we don't know about! */ +1 for excellent comment.
(In reply to comment #3) > Comment on attachment 526744 [details] [diff] [review] > patch v1 > > This will be +r with the following issues addressed: > > Fewer, bigger IPDL messages are better than multiple smaller ones (each message > could cause a context switch and other messaging overheads--see bug 561694 for > example). So let's get rid of the UpdateAddresses IPDL message, and send its > data as part of OnStartRequest. Unless there's some reason we shouldn't (but I > don't see one). That's easy enough to do. Consider it done once we hash out what's below. > > friend class HttpChannelParent; > > Why do we need the friend relationship with HttpBaseChannel? HttpChannelParent doesn't derive from HttpBaseChannel, so to be able to get the data to send to the child, I needed to get access somehow to those members in the base channel. I didn't see any methods that gave me that information, so it was either this, or make HttpChannelParent inherit from HttpBaseChannel, and have a bunch of unimplemented methods. I chose the former, but will happily update to do the latter (or something else, if you prefer).
There's a third way: add some 'public' (but not XPCOM) methods, GetSelfAddr and GetPeerAddr (might as well have them return references, for efficiency). Public, non-XPCOM methods can only be accessed by other necko files (not plugins, etc). But that's perfect for this use. (There's a section in nsHttpChannel.h of other such methods that's marked "for internal necko use only": put them there.) I prefer this to the friend def (or god forbid, inheritance), because it keeps more encapsulation. So far we've managed to make e10s necko really look like a 'client' of original necko, and I'd like to keep it that way.
Created attachment 528871 [details] [diff] [review] patch v2 New and improved, now with 100% less friend and ipdl message adding!
I tried pushing this to cedar, but it doesn't compile on Windows, most obviously because: 'local' : is not a member of 'PRNetAddr' so I backed it out.
Created attachment 530050 [details] [diff] [review] patch v3 Let's try this again... now with fixes for windows building!
Comment on attachment 530050 [details] [diff] [review] patch v3 Pushing to try (sorry Boris, I did that for the last patch too but didn't get the results before you pushed to cedar: this time I'll wait for try results before marking checkin-needed). The code to handle the AF_LOCAL and AF_UNSPEC addresses isn't really needed (we don't ship around Unix domain sockets or raw sockets in the necko code), but does no harm, so that's fine. One nit: please throw up a new version of the patch that converts the code you moved to HttpBaseChannel to 2 space indenting.
Created attachment 530174 [details] [diff] [review] patch v3.1 Fixes whitespace. Carry forward r+
try is green.
Ugh--how did we land this w/o a test? There wasn't any code in our unit_ipc directory that used these AFAICT. I discovered that these aren't working while checking in a unit_ipc test for bug 646373. To reproduce: Reenable the request.localAddress, etc, accesses in netwerk/unit/test_traceable_channel.js (I've commented them out for now to get that bug landed) run "make check-one SOLO_FILE=test_traceable_channel_wrap.js" The test fails (with very unhelpful error msg)
Part of the issue is that the logic that sets the HttpChannelChild's mSelfAddr/mPeerAddr is done *after* calling listener->OnStartRequest. It needs to be before that call so OnStartReq can access the fields. But there's something else weird going on: I can't seem to access most nsIHttpChannelInternal fields from xpcshell. See bug 659251.
This patch also didn't remove the stubs from HttpChannelChild that all return NS_ERROR_NOT_AVAILABLE.
Created attachment 539125 [details] [diff] [review] Fix getlocal functions Removed masking stub function from child, moves mSelf|Peer init to before client OnStart is called. Add a check for SetPriority too, for good measure (not tested by any other xpcshell tests).
Hmm, curious as to whether the assumptions in the test that remoteHost == 127.0.0.1 are going to wash on mobile xpcshell testing. Pushed to try to find out. http://tbpl.mozilla.org/?tree=Tryfirstname.lastname@example.org&rev=36d9608635ea
Comment on attachment 539125 [details] [diff] [review] Fix getlocal functions Review of attachment 539125 [details] [diff] [review]: -----------------------------------------------------------------
Try seems happy. Landing fixup as bug 664163. Since original patch in this bug has stuck, marking FIXED.