Bug 558490: Infrastructure needed to support SetPriority in HttpChannelChild. a=jduell, r=dwitte

This commit is contained in:
Jason Duell 2010-04-10 21:53:35 -07:00
Родитель a3674174c8
Коммит 32978fb1fc
9 изменённых файлов: 62 добавлений и 51 удалений

Просмотреть файл

@ -50,6 +50,7 @@ namespace net {
HttpBaseChannel::HttpBaseChannel()
: mStatus(NS_OK)
, mLoadFlags(LOAD_NORMAL)
, mPriority(PRIORITY_NORMAL)
, mCaps(0)
, mRedirectionLimit(gHttpHandler->RedirectionLimit())
, mIsPending(PR_FALSE)
@ -141,12 +142,13 @@ HttpBaseChannel::Init(nsIURI *aURI,
// HttpBaseChannel::nsISupports
//-----------------------------------------------------------------------------
NS_IMPL_ISUPPORTS_INHERITED4(HttpBaseChannel,
NS_IMPL_ISUPPORTS_INHERITED5(HttpBaseChannel,
nsHashPropertyBag,
nsIRequest,
nsIChannel,
nsIHttpChannel,
nsIHttpChannelInternal)
nsIHttpChannelInternal,
nsISupportsPriority);
//-----------------------------------------------------------------------------
// HttpBaseChannel::nsIRequest
@ -800,6 +802,23 @@ HttpBaseChannel::SetForceAllowThirdPartyCookie(PRBool aForce)
return NS_OK;
}
//-----------------------------------------------------------------------------
// HttpBaseChannel::nsISupportsPriority
//-----------------------------------------------------------------------------
NS_IMETHODIMP
HttpBaseChannel::GetPriority(PRInt32 *value)
{
*value = mPriority;
return NS_OK;
}
NS_IMETHODIMP
HttpBaseChannel::AdjustPriority(PRInt32 delta)
{
return SetPriority(mPriority + delta);
}
//------------------------------------------------------------------------------
}

Просмотреть файл

@ -52,6 +52,7 @@
#include "nsIHttpChannelInternal.h"
#include "nsIProgressEventSink.h"
#include "nsIURI.h"
#include "nsISupportsPriority.h"
#define DIE_WITH_ASYNC_OPEN_MSG() \
do { \
@ -84,6 +85,7 @@ namespace net {
class HttpBaseChannel : public nsHashPropertyBag
, public nsIHttpChannel
, public nsIHttpChannelInternal
, public nsISupportsPriority
{
public:
NS_DECL_ISUPPORTS_INHERITED
@ -148,6 +150,10 @@ public:
NS_IMETHOD GetForceAllowThirdPartyCookie(PRBool *aForce);
NS_IMETHOD SetForceAllowThirdPartyCookie(PRBool aForce);
// nsISupportsPriority
NS_IMETHOD GetPriority(PRInt32 *value);
NS_IMETHOD AdjustPriority(PRInt32 delta);
protected:
nsCOMPtr<nsIURI> mURI;
nsCOMPtr<nsIURI> mOriginalURI;
@ -169,6 +175,7 @@ protected:
nsresult mStatus;
PRUint32 mLoadFlags;
PRInt16 mPriority;
PRUint8 mCaps;
PRUint8 mRedirectionLimit;

Просмотреть файл

@ -237,10 +237,7 @@ HttpChannelChild::AsyncOpen(nsIStreamListener *listener, nsISupports *aContext)
this->AddRef();
// TODO: Combine constructor and AsyncOpen to save one IPC msg
if (!gNeckoChild->SendPHttpChannelConstructor(this)) {
// TODO: currently means "this" has been deleted! bug 529693
DROP_DEAD();
}
gNeckoChild->SendPHttpChannelConstructor(this);
mListener = listener;
mListenerContext = aContext;
@ -278,17 +275,11 @@ HttpChannelChild::AsyncOpen(nsIStreamListener *listener, nsISupports *aContext)
mReferrer->GetOriginCharset(referrerCharset);
}
if (!SendAsyncOpen(mSpec, charset, originalSpec, originalCharset,
docSpec, docCharset, referrerSpec, referrerCharset,
mLoadFlags, mRequestHeaders, mRequestHead.Method(),
mRedirectionLimit, mAllowPipelining,
mForceAllowThirdPartyCookie)) {
// IPDL error: our destructor will be called automatically
// -- TODO: verify that that's the case :)
mListener = 0;
mListenerContext = 0;
return NS_ERROR_FAILURE;
}
SendAsyncOpen(mSpec, charset, originalSpec, originalCharset, docSpec,
docCharset, referrerSpec, referrerCharset, mLoadFlags,
mRequestHeaders, mRequestHead.Method(), mPriority,
mRedirectionLimit, mAllowPipelining,
mForceAllowThirdPartyCookie);
mIsPending = PR_TRUE;
mWasOpened = PR_TRUE;
@ -500,21 +491,16 @@ HttpChannelChild::GetEntityID(nsACString& aEntityID)
// HttpChannelChild::nsISupportsPriority
//-----------------------------------------------------------------------------
NS_IMETHODIMP
HttpChannelChild::GetPriority(PRInt32 *aPriority)
{
DROP_DEAD();
}
NS_IMETHODIMP
HttpChannelChild::SetPriority(PRInt32 aPriority)
{
DROP_DEAD();
}
NS_IMETHODIMP
HttpChannelChild::AdjustPriority(PRInt32 delta)
{
DROP_DEAD();
PRInt16 newValue = CLAMP(aPriority, PR_INT16_MIN, PR_INT16_MAX);
if (mPriority == newValue)
return NS_OK;
mPriority = newValue;
if (mWasOpened)
SendSetPriority(mPriority);
return NS_OK;
}
//-----------------------------------------------------------------------------

Просмотреть файл

@ -57,7 +57,6 @@
#include "nsIUploadChannel.h"
#include "nsIUploadChannel2.h"
#include "nsIResumableChannel.h"
#include "nsISupportsPriority.h"
#include "nsIProxiedChannel.h"
#include "nsITraceableChannel.h"
@ -81,7 +80,6 @@ class HttpChannelChild : public PHttpChannelChild
, public nsIUploadChannel2
, public nsIEncodedChannel
, public nsIResumableChannel
, public nsISupportsPriority
, public nsIProxiedChannel
, public nsITraceableChannel
, public nsIApplicationCacheChannel
@ -93,7 +91,6 @@ public:
NS_DECL_NSIUPLOADCHANNEL2
NS_DECL_NSIENCODEDCHANNEL
NS_DECL_NSIRESUMABLECHANNEL
NS_DECL_NSISUPPORTSPRIORITY
NS_DECL_NSIPROXIEDCHANNEL
NS_DECL_NSITRACEABLECHANNEL
NS_DECL_NSIAPPLICATIONCACHECONTAINER
@ -121,6 +118,8 @@ public:
PRBool aMerge);
// nsIHttpChannelInternal
NS_IMETHOD SetupFallbackChannel(const char *aFallbackKey);
// nsISupportsPriority
NS_IMETHOD SetPriority(PRInt32 value);
protected:
bool RecvOnStartRequest(const nsHttpResponseHead& responseHead);

Просмотреть файл

@ -42,6 +42,7 @@
#include "nsHttpChannel.h"
#include "nsHttpHandler.h"
#include "nsNetUtil.h"
#include "nsISupportsPriority.h"
namespace mozilla {
namespace net {
@ -85,6 +86,7 @@ HttpChannelParent::RecvAsyncOpen(const nsCString& uriSpec,
const PRUint32& loadFlags,
const RequestHeaderTuples& requestHeaders,
const nsHttpAtom& requestMethod,
const PRUint16& priority,
const PRUint8& redirectionLimit,
const PRBool& allowPipelining,
const PRBool& forceAllowThirdPartyCookie)
@ -146,6 +148,8 @@ HttpChannelParent::RecvAsyncOpen(const nsCString& uriSpec,
// httpChan->SetNotificationCallbacks(this);
httpChan->SetRequestMethod(nsDependentCString(requestMethod.get()));
if (priority != nsISupportsPriority::PRIORITY_NORMAL)
httpChan->SetPriority(priority);
httpChan->SetRedirectionLimit(redirectionLimit);
httpChan->SetAllowPipelining(allowPipelining);
httpChan->SetForceAllowThirdPartyCookie(forceAllowThirdPartyCookie);
@ -157,6 +161,13 @@ HttpChannelParent::RecvAsyncOpen(const nsCString& uriSpec,
return true;
}
bool
HttpChannelParent::RecvSetPriority(const PRUint16& priority)
{
// FIXME: bug XXX: once we figure out how to keep a ref to the nsHttpChannel,
// call SetPriority on it here.
return true;
}
//-----------------------------------------------------------------------------
// HttpChannelParent::nsIRequestObserver

Просмотреть файл

@ -76,9 +76,12 @@ protected:
const PRUint32& loadFlags,
const RequestHeaderTuples& requestHeaders,
const nsHttpAtom& requestMethod,
const PRUint16& priority,
const PRUint8& redirectionLimit,
const PRBool& allowPipelining,
const PRBool& forceAllowThirdPartyCookie);
virtual bool RecvSetPriority(const PRUint16& priority);
};
} // namespace net

Просмотреть файл

@ -72,10 +72,13 @@ parent:
PRUint32 loadFlags,
RequestHeaderTuples requestHeaders,
nsHttpAtom requestMethod,
PRUint16 priority,
PRUint8 redirectionLimit,
PRBool allowPipelining,
PRBool forceAllowThirdPartyCookie);
SetPriority(PRUint16 priority);
child:
OnStartRequest(nsHttpResponseHead responseHead);

Просмотреть файл

@ -81,7 +81,6 @@ static NS_DEFINE_CID(kStreamListenerTeeCID, NS_STREAMLISTENERTEE_CID);
nsHttpChannel::nsHttpChannel()
: mLogicalOffset(0)
, mPriority(PRIORITY_NORMAL)
, mCacheAccess(0)
, mPostID(0)
, mRequestTime(0)
@ -4332,13 +4331,6 @@ nsHttpChannel::GetContentEncodings(nsIUTF8StringEnumerator** aEncodings)
// nsHttpChannel::nsISupportsPriority
//-----------------------------------------------------------------------------
NS_IMETHODIMP
nsHttpChannel::GetPriority(PRInt32 *value)
{
*value = mPriority;
return NS_OK;
}
NS_IMETHODIMP
nsHttpChannel::SetPriority(PRInt32 value)
{
@ -4351,12 +4343,6 @@ nsHttpChannel::SetPriority(PRInt32 value)
return NS_OK;
}
NS_IMETHODIMP
nsHttpChannel::AdjustPriority(PRInt32 delta)
{
return SetPriority(mPriority + delta);
}
//-----------------------------------------------------------------------------
// nsHttpChannel::nsIProtocolProxyCallback
//-----------------------------------------------------------------------------

Просмотреть файл

@ -61,7 +61,6 @@
#include "nsIStringEnumerator.h"
#include "nsIPrompt.h"
#include "nsIResumableChannel.h"
#include "nsISupportsPriority.h"
#include "nsIProtocolProxyCallback.h"
#include "nsICancelable.h"
#include "nsIProxiedChannel.h"
@ -86,7 +85,6 @@ class nsHttpChannel : public HttpBaseChannel
, public nsIEncodedChannel
, public nsITransportEventSink
, public nsIResumableChannel
, public nsISupportsPriority
, public nsIProtocolProxyCallback
, public nsIProxiedChannel
, public nsITraceableChannel
@ -104,7 +102,6 @@ public:
NS_DECL_NSIENCODEDCHANNEL
NS_DECL_NSITRANSPORTEVENTSINK
NS_DECL_NSIRESUMABLECHANNEL
NS_DECL_NSISUPPORTSPRIORITY
NS_DECL_NSIPROTOCOLPROXYCALLBACK
NS_DECL_NSIPROXIEDCHANNEL
NS_DECL_NSITRACEABLECHANNEL
@ -128,6 +125,8 @@ public:
NS_IMETHOD AsyncOpen(nsIStreamListener *listener, nsISupports *aContext);
// nsIHttpChannelInternal
NS_IMETHOD SetupFallbackChannel(const char *aFallbackKey);
// nsISupportsPriority
NS_IMETHOD SetPriority(PRInt32 value);
public: /* internal necko use only */
typedef void (nsHttpChannel:: *nsAsyncCallback)(void);
@ -266,8 +265,6 @@ private:
nsRefPtr<nsHttpTransaction> mTransaction;
PRUint64 mLogicalOffset;
PRInt16 mPriority;
nsCString mUserSetCookieHeader;
// cache specific data