Ticket #5477: AsyncRedirect.patch

File AsyncRedirect.patch, 5.4 KB (added by mikeperry, 7 years ago)

Redirect API patch (against Firefox 13).

  • netwerk/protocol/http/HttpChannelChild.cpp

    diff --git a/netwerk/protocol/http/HttpChannelChild.cpp b/netwerk/protocol/http/HttpChannelChild.cpp
    index 4df4d51..c335fc6 100644
    a b HttpChannelChild::SetupFallbackChannel(const char *aFallbackKey) 
    11131113  DROP_DEAD();
    11141114}
    11151115
     1116// XXX: Is this the right thing to do here? Or should we have
     1117// made an nsIHTTPChannelRedirect that only nsHttpChannel implements?
     1118NS_IMETHODIMP
     1119HttpChannelChild::AsyncRedirect(nsIURI *uri)
     1120{
     1121  DROP_DEAD();
     1122}
     1123
    11161124// The next four _should_ be implemented, but we need to figure out how
    11171125// to transfer the data from the chrome process first.
    11181126
  • netwerk/protocol/http/HttpChannelChild.h

    diff --git a/netwerk/protocol/http/HttpChannelChild.h b/netwerk/protocol/http/HttpChannelChild.h
    index 43617ef..50def78 100644
    a b public: 
    110110  NS_IMETHOD GetLocalPort(PRInt32* port);
    111111  NS_IMETHOD GetRemoteAddress(nsACString& addr);
    112112  NS_IMETHOD GetRemotePort(PRInt32* port);
     113
     114  NS_IMETHOD AsyncRedirect(nsIURI *uri);
     115
    113116  // nsISupportsPriority
    114117  NS_IMETHOD SetPriority(PRInt32 value);
    115118  // nsIResumableChannel
  • netwerk/protocol/http/nsHttpChannel.cpp

    diff --git a/netwerk/protocol/http/nsHttpChannel.cpp b/netwerk/protocol/http/nsHttpChannel.cpp
    index 92f2d7d..1225b4e 100644
    a b nsHttpChannel::AsyncRedirectChannelToHttps() 
    14481448    return rv;
    14491449}
    14501450
     1451NS_IMETHODIMP
     1452nsHttpChannel::AsyncRedirect(nsIURI *newURI)
     1453{
     1454    NS_PRECONDITION(!mCallOnResume, "How did that happen?");
     1455
     1456    if (mSuspendCount) {
     1457        LOG(("Waiting until resume to do async redirect to https [this=%p]\n", this));
     1458        mCallOnResume = &nsHttpChannel::HandleAsyncRedirectChannelToHttps;
     1459        return NS_OK;
     1460    }
     1461
     1462    // XXX: Refcount OK?
     1463    nsresult rv = AsyncRedirectChannelToURI(newURI);
     1464    if (NS_FAILED(rv))
     1465        ContinueAsyncRedirectChannelToHttps(rv);
     1466
     1467    return rv;
     1468}
     1469
     1470nsresult
     1471nsHttpChannel::AsyncRedirectChannelToURI(nsCOMPtr<nsIURI> upgradedURI)
     1472{
     1473    nsresult rv = NS_OK;
     1474    LOG(("nsHttpChannel::AsyncRedirectChannelToURI()\n"));
     1475
     1476    nsCOMPtr<nsIChannel> newChannel;
     1477
     1478    nsCOMPtr<nsIIOService> ioService;
     1479    rv = gHttpHandler->GetIOService(getter_AddRefs(ioService));
     1480    NS_ENSURE_SUCCESS(rv, rv);
     1481
     1482    rv = ioService->NewChannelFromURI(upgradedURI, getter_AddRefs(newChannel));
     1483    NS_ENSURE_SUCCESS(rv, rv);
     1484
     1485    rv = SetupReplacementChannel(upgradedURI, newChannel, true, false);
     1486    NS_ENSURE_SUCCESS(rv, rv);
     1487
     1488    // Inform consumers about this fake redirect
     1489    mRedirectChannel = newChannel;
     1490    PRUint32 flags = nsIChannelEventSink::REDIRECT_PERMANENT;
     1491
     1492    PushRedirectAsyncFunc(
     1493        &nsHttpChannel::ContinueAsyncRedirectChannelToHttps);
     1494    rv = gHttpHandler->AsyncOnChannelRedirect(this, newChannel, flags);
     1495
     1496    if (NS_SUCCEEDED(rv))
     1497        rv = WaitForRedirectCallback();
     1498
     1499    if (NS_FAILED(rv)) {
     1500        AutoRedirectVetoNotifier notifier(this);
     1501        PopRedirectAsyncFunc(
     1502            &nsHttpChannel::ContinueAsyncRedirectChannelToHttps);
     1503    }
     1504
     1505    return rv;
     1506}
    14511507nsresult
    14521508nsHttpChannel::ContinueAsyncRedirectChannelToHttps(nsresult rv)
    14531509{
  • netwerk/protocol/http/nsHttpChannel.h

    diff --git a/netwerk/protocol/http/nsHttpChannel.h b/netwerk/protocol/http/nsHttpChannel.h
    index a5b7d1e..fb3b7e7 100644
    a b public: 
    138138    // nsIChannel
    139139    NS_IMETHOD GetSecurityInfo(nsISupports **aSecurityInfo);
    140140    NS_IMETHOD AsyncOpen(nsIStreamListener *listener, nsISupports *aContext);
     141    // nsIHttpChannel
     142    NS_IMETHOD AsyncRedirect(nsIURI *newURI);
    141143    // nsIHttpChannelInternal
    142144    NS_IMETHOD SetupFallbackChannel(const char *aFallbackKey);
    143145    // nsISupportsPriority
    private: 
    194196    void     HandleAsyncFallback();
    195197    nsresult ContinueHandleAsyncFallback(nsresult);
    196198    nsresult PromptTempRedirect();
     199    nsresult AsyncRedirectChannelToURI(nsCOMPtr<nsIURI>);
     200
    197201    virtual nsresult SetupReplacementChannel(nsIURI *, nsIChannel *,
    198202                                             bool preserveMethod,
    199203                                             bool forProxy);
  • netwerk/protocol/http/nsIHttpChannel.idl

    diff --git a/netwerk/protocol/http/nsIHttpChannel.idl b/netwerk/protocol/http/nsIHttpChannel.idl
    index 2d3f01a..614d2d9 100644
    a b interface nsIHttpChannel : nsIChannel 
    291291     *         has been received (before onStartRequest).
    292292     */
    293293    boolean isNoCacheResponse();
     294   
     295    void asyncRedirect(in nsIURI aNewURI);
    294296};
  • netwerk/protocol/viewsource/nsViewSourceChannel.cpp

    diff --git a/netwerk/protocol/viewsource/nsViewSourceChannel.cpp b/netwerk/protocol/viewsource/nsViewSourceChannel.cpp
    index 919c3f7..6e5c077 100644
    a b nsViewSourceChannel::IsNoCacheResponse(bool *_retval) 
    703703{
    704704    return !mHttpChannel ? NS_ERROR_NULL_POINTER :
    705705        mHttpChannel->IsNoCacheResponse(_retval);
    706 }
     706}
     707
     708// XXX: Is this the right thing to do here? Or should we have
     709// made an nsIHTTPChannelRedirect that only nsHttpChannel implements?
     710// Also, will this mean that some ViewSource requests may be non-https?
     711// Or will the mHttpChannel take care of that for us?
     712NS_IMETHODIMP
     713nsViewSourceChannel::AsyncRedirect(nsIURI *uri)
     714{
     715    return NS_ERROR_NOT_IMPLEMENTED;
     716}
     717