From 03c791f19f7c0e9fe05cc73746b058b65f7e36d2 Mon Sep 17 00:00:00 2001 From: Phil Ringnalda Date: Tue, 13 Mar 2012 22:11:55 -0700 Subject: [PATCH] Back out 9899522b6ad9 (bug 664163) --- netwerk/protocol/http/HttpChannelChild.cpp | 41 ++++++++--- netwerk/protocol/http/HttpChannelChild.h | 4 ++ netwerk/protocol/http/HttpChannelParent.cpp | 11 +-- netwerk/test/unit/test_traceable_channel.js | 76 ++++----------------- 4 files changed, 52 insertions(+), 80 deletions(-) diff --git a/netwerk/protocol/http/HttpChannelChild.cpp b/netwerk/protocol/http/HttpChannelChild.cpp index 7b8320b6aff..4df4d51f61a 100644 --- a/netwerk/protocol/http/HttpChannelChild.cpp +++ b/netwerk/protocol/http/HttpChannelChild.cpp @@ -287,18 +287,10 @@ HttpChannelChild::OnStartRequest(const nsHttpResponseHead& responseHead, getter_AddRefs(mSecurityInfo)); } - // Sanity check: we should have either set both remote/local socket addresses - // or neither of them. - if (selfAddr.raw.family != peerAddr.raw.family) { - NS_RUNTIMEABORT("Child: socket has multiple address families!"); - } - mIsFromCache = isFromCache; mCacheEntryAvailable = cacheEntryAvailable; mCacheExpirationTime = cacheExpirationTime; mCachedCharset = cachedCharset; - mSelfAddr = selfAddr; - mPeerAddr = peerAddr; AutoEventEnqueuer ensureSerialDispatch(mEventQ); @@ -321,6 +313,9 @@ HttpChannelChild::OnStartRequest(const nsHttpResponseHead& responseHead, rv = ApplyContentConversions(); if (NS_FAILED(rv)) Cancel(rv); + + mSelfAddr = selfAddr; + mPeerAddr = peerAddr; } class TransportAndDataEvent : public ChannelEvent @@ -1118,6 +1113,36 @@ HttpChannelChild::SetupFallbackChannel(const char *aFallbackKey) DROP_DEAD(); } +// The next four _should_ be implemented, but we need to figure out how +// to transfer the data from the chrome process first. + +NS_IMETHODIMP +HttpChannelChild::GetRemoteAddress(nsACString & _result) +{ + return NS_ERROR_NOT_AVAILABLE; +} + +NS_IMETHODIMP +HttpChannelChild::GetRemotePort(PRInt32 * _result) +{ + NS_ENSURE_ARG_POINTER(_result); + return NS_ERROR_NOT_AVAILABLE; +} + +NS_IMETHODIMP +HttpChannelChild::GetLocalAddress(nsACString & _result) +{ + return NS_ERROR_NOT_AVAILABLE; +} + +NS_IMETHODIMP +HttpChannelChild::GetLocalPort(PRInt32 * _result) +{ + NS_ENSURE_ARG_POINTER(_result); + return NS_ERROR_NOT_AVAILABLE; +} + + //----------------------------------------------------------------------------- // HttpChannelChild::nsICacheInfoChannel //----------------------------------------------------------------------------- diff --git a/netwerk/protocol/http/HttpChannelChild.h b/netwerk/protocol/http/HttpChannelChild.h index f9f7c2e0003..43617ef5589 100644 --- a/netwerk/protocol/http/HttpChannelChild.h +++ b/netwerk/protocol/http/HttpChannelChild.h @@ -106,6 +106,10 @@ public: bool aMerge); // nsIHttpChannelInternal NS_IMETHOD SetupFallbackChannel(const char *aFallbackKey); + NS_IMETHOD GetLocalAddress(nsACString& addr); + NS_IMETHOD GetLocalPort(PRInt32* port); + NS_IMETHOD GetRemoteAddress(nsACString& addr); + NS_IMETHOD GetRemotePort(PRInt32* port); // nsISupportsPriority NS_IMETHOD SetPriority(PRInt32 value); // nsIResumableChannel diff --git a/netwerk/protocol/http/HttpChannelParent.cpp b/netwerk/protocol/http/HttpChannelParent.cpp index 1fc1a69bb25..ee901cce07f 100644 --- a/netwerk/protocol/http/HttpChannelParent.cpp +++ b/netwerk/protocol/http/HttpChannelParent.cpp @@ -450,15 +450,6 @@ HttpChannelParent::OnStartRequest(nsIRequest *aRequest, nsISupports *aContext) } nsHttpChannel *httpChan = static_cast(mChannel.get()); - - // Sanity check: we should have either set both remote/local socket addresses - // or neither of them. - PRNetAddr selfAddr = httpChan->GetSelfAddr(); - PRNetAddr peerAddr = httpChan->GetPeerAddr(); - if (selfAddr.raw.family != peerAddr.raw.family) { - NS_RUNTIMEABORT("Parent: socket has multiple address families!"); - } - if (mIPCClosed || !SendOnStartRequest(responseHead ? *responseHead : nsHttpResponseHead(), !!responseHead, @@ -466,7 +457,7 @@ HttpChannelParent::OnStartRequest(nsIRequest *aRequest, nsISupports *aContext) isFromCache, mCacheDescriptor ? true : false, expirationTime, cachedCharset, secInfoSerialization, - selfAddr, peerAddr)) + httpChan->GetSelfAddr(), httpChan->GetPeerAddr())) { return NS_ERROR_UNEXPECTED; } diff --git a/netwerk/test/unit/test_traceable_channel.js b/netwerk/test/unit/test_traceable_channel.js index 164d65f4c46..a62b8a2c92b 100644 --- a/netwerk/test/unit/test_traceable_channel.js +++ b/netwerk/test/unit/test_traceable_channel.js @@ -22,42 +22,14 @@ TracingListener.prototype = { request.QueryInterface(Components.interfaces.nsIHttpChannelInternal); - var localAddr = "unknown"; - var localPort = "unknown"; - var remoteAddr = "unknown"; - var remotePort = "unknown"; - try { - localAddr = request.localAddress; - dump("got local address\n"); - } catch(e) { - dump("couldn't get local address\n"); - } - try { - localPort = request.localPort; - dump("got local port\n"); - } catch(e) { - dump("couldn't get local port\n"); - } - try { - remoteAddr = request.remoteAddress; - dump("got remote address\n"); - } catch(e) { - dump("couldn't get remote address\n"); - } - try { - remotePort = request.remotePort; - dump("got remote port\n"); - } catch(e) { - dump("couldn't get remote port\n"); - } - - do_check_eq(localAddr, "127.0.0.1"); - do_check_eq(localPort > 0, true); - do_check_eq(remoteAddr, "127.0.0.1"); - do_check_eq(remotePort, 4444); - - request.QueryInterface(Components.interfaces.nsISupportsPriority); - request.priority = Ci.nsISupportsPriority.PRIORITY_LOW; +// local/remote addresses broken in e10s: disable for now +/* + do_check_eq(request.localAddress, "127.0.0.1"); + do_check_eq(request.localPort > 0, true); + do_check_neq(request.localPort, 4444); + do_check_eq(request.remoteAddress, "127.0.0.1"); + do_check_eq(request.remotePort, 4444); +*/ // Make sure listener can't be replaced after OnStartRequest was called. request.QueryInterface(Components.interfaces.nsITraceableChannel); @@ -91,10 +63,9 @@ TracingListener.prototype = { input.close(); } catch (e) { dump("TracingListener.onStopRequest swallowing exception: " + e + "\n"); + } finally { + httpserver.stop(do_test_finished); } - - // we're the last OnStopRequest called by the nsIStreamListenerTee - run_next_test(); }, QueryInterface: function(iid) { @@ -164,37 +135,18 @@ function make_channel(url) { // Check if received body is correctly modified. function channel_finished(request, input, ctx) { - // No-op: since the nsIStreamListenerTee calls the observer's OnStopRequest - // after this, we call run_next_test() there -} - -// needs to be global or it'll go out of scope before it observes request -var observer = new HttpResponseExaminer(); - -var testRuns = 1; // change this to >1 to run test multiple times -var iteration = 1; - -function run_next_test() { - if (iteration > testRuns) { - dump("Shutting down\n"); - httpserver.stop(do_test_finished); - return; - } - if (iteration > 1) { - dump("^^^ test iteration=" + iteration + "\n"); - } - var channel = make_channel("http://localhost:4444/testdir"); - channel.asyncOpen(new ChannelListener(channel_finished), null); - iteration++; + httpserver.stop(do_test_finished); } function run_test() { + var observer = new HttpResponseExaminer(); observer.register(); httpserver = new nsHttpServer(); httpserver.registerPathHandler("/testdir", test_handler); httpserver.start(4444); - run_next_test(); + var channel = make_channel("http://localhost:4444/testdir"); + channel.asyncOpen(new ChannelListener(channel_finished), null); do_test_pending(); }