diff --git a/netwerk/protocol/http/nsCORSListenerProxy.cpp b/netwerk/protocol/http/nsCORSListenerProxy.cpp index b1054891e562..ab210f1fbde6 100644 --- a/netwerk/protocol/http/nsCORSListenerProxy.cpp +++ b/netwerk/protocol/http/nsCORSListenerProxy.cpp @@ -1290,13 +1290,13 @@ nsCORSListenerProxy::RemoveFromCorsPreflightCache(nsIURI* aURI, } nsresult -NS_StartCORSPreflight(nsIChannel* aRequestChannel, - nsIStreamListener* aListener, - nsIPrincipal* aPrincipal, - nsICorsPreflightCallback* aCallback, - bool aWithCredentials, - nsTArray& aUnsafeHeaders, - nsIChannel** aPreflightChannel) +nsCORSListenerProxy::StartCORSPreflight(nsIChannel* aRequestChannel, + nsIStreamListener* aListener, + nsIPrincipal* aPrincipal, + nsICorsPreflightCallback* aCallback, + bool aWithCredentials, + nsTArray& aUnsafeHeaders, + nsIChannel** aPreflightChannel) { *aPreflightChannel = nullptr; diff --git a/netwerk/protocol/http/nsCORSListenerProxy.h b/netwerk/protocol/http/nsCORSListenerProxy.h index 947d3e7a8ad6..246cd27e7b20 100644 --- a/netwerk/protocol/http/nsCORSListenerProxy.h +++ b/netwerk/protocol/http/nsCORSListenerProxy.h @@ -24,18 +24,10 @@ class nsIPrincipal; class nsINetworkInterceptController; class nsICorsPreflightCallback; -nsresult -NS_StartCORSPreflight(nsIChannel* aRequestChannel, - nsIStreamListener* aListener, - nsIPrincipal* aPrincipal, - nsICorsPreflightCallback* aCallback, - bool aWithCredentials, - nsTArray& aACUnsafeHeaders, - nsIChannel** aPreflightChannel); - namespace mozilla { namespace net { class HttpChannelParent; +class nsHttpChannel; } } @@ -55,11 +47,6 @@ public: nsCORSListenerProxy(nsIStreamListener* aOuter, nsIPrincipal* aRequestingPrincipal, bool aWithCredentials); - nsCORSListenerProxy(nsIStreamListener* aOuter, - nsIPrincipal* aRequestingPrincipal, - bool aWithCredentials, - const nsCString& aPreflightMethod, - const nsTArray& aPreflightHeaders); NS_DECL_ISUPPORTS NS_DECL_NSIREQUESTOBSERVER @@ -81,10 +68,26 @@ public: private: // Only HttpChannelParent can call RemoveFromCorsPreflightCache friend class mozilla::net::HttpChannelParent; + // Only nsHttpChannel can invoke CORS preflights + friend class mozilla::net::nsHttpChannel; static void RemoveFromCorsPreflightCache(nsIURI* aURI, nsIPrincipal* aRequestingPrincipal); + nsCORSListenerProxy(nsIStreamListener* aOuter, + nsIPrincipal* aRequestingPrincipal, + bool aWithCredentials, + const nsCString& aPreflightMethod, + const nsTArray& aPreflightHeaders); + + static nsresult StartCORSPreflight(nsIChannel* aRequestChannel, + nsIStreamListener* aListener, + nsIPrincipal* aPrincipal, + nsICorsPreflightCallback* aCallback, + bool aWithCredentials, + nsTArray& aACUnsafeHeaders, + nsIChannel** aPreflightChannel); + ~nsCORSListenerProxy(); nsresult UpdateChannel(nsIChannel* aChannel, DataURIHandling aAllowDataURI); diff --git a/netwerk/protocol/http/nsHttpChannel.cpp b/netwerk/protocol/http/nsHttpChannel.cpp index 8019da29438a..fca4f62a9b65 100644 --- a/netwerk/protocol/http/nsHttpChannel.cpp +++ b/netwerk/protocol/http/nsHttpChannel.cpp @@ -453,10 +453,12 @@ nsHttpChannel::ContinueConnect() if (!mIsCorsPreflightDone && mRequireCORSPreflight && mInterceptCache != INTERCEPTED) { nsCOMPtr preflightChannel; - nsresult rv = NS_StartCORSPreflight(this, mListener, - mPreflightPrincipal, this, - mWithCredentials, mUnsafeHeaders, - getter_AddRefs(preflightChannel)); + nsresult rv = + nsCORSListenerProxy::StartCORSPreflight(this, mListener, + mPreflightPrincipal, this, + mWithCredentials, + mUnsafeHeaders, + getter_AddRefs(preflightChannel)); return rv; }