зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1348462 - Use a process-unique uint64 instead of a uuid for request context ids r=mcmanus
--HG-- extra : rebase_source : 84541f78eeec1a5e202c12b57131ede9834f687a
This commit is contained in:
Родитель
c19b596225
Коммит
89c508224f
|
@ -6,7 +6,7 @@
|
|||
|
||||
#include "nsAutoPtr.h"
|
||||
#include "nsIObserverService.h"
|
||||
#include "nsIUUIDGenerator.h"
|
||||
#include "nsIXULRuntime.h"
|
||||
#include "nsServiceManagerUtils.h"
|
||||
#include "nsThreadUtils.h"
|
||||
#include "RequestContextService.h"
|
||||
|
@ -26,12 +26,11 @@ public:
|
|||
NS_DECL_THREADSAFE_ISUPPORTS
|
||||
NS_DECL_NSIREQUESTCONTEXT
|
||||
|
||||
explicit RequestContext(const nsID& id);
|
||||
explicit RequestContext(const uint64_t id);
|
||||
private:
|
||||
virtual ~RequestContext();
|
||||
|
||||
nsID mID;
|
||||
char mCID[NSID_LENGTH];
|
||||
uint64_t mID;
|
||||
Atomic<uint32_t> mBlockingTransactionCount;
|
||||
nsAutoPtr<SpdyPushCache> mSpdyCache;
|
||||
nsCString mUserAgentOverride;
|
||||
|
@ -39,11 +38,10 @@ private:
|
|||
|
||||
NS_IMPL_ISUPPORTS(RequestContext, nsIRequestContext)
|
||||
|
||||
RequestContext::RequestContext(const nsID& aID)
|
||||
: mBlockingTransactionCount(0)
|
||||
RequestContext::RequestContext(const uint64_t aID)
|
||||
: mID(aID)
|
||||
, mBlockingTransactionCount(0)
|
||||
{
|
||||
mID = aID;
|
||||
mID.ToProvidedString(mCID);
|
||||
}
|
||||
|
||||
RequestContext::~RequestContext()
|
||||
|
@ -89,7 +87,7 @@ RequestContext::SetSpdyPushCache(mozilla::net::SpdyPushCache *aSpdyPushCache)
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
RequestContext::GetID(nsID *outval)
|
||||
RequestContext::GetID(uint64_t *outval)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(outval);
|
||||
*outval = mID;
|
||||
|
@ -117,10 +115,14 @@ RequestContextService *RequestContextService::sSelf = nullptr;
|
|||
NS_IMPL_ISUPPORTS(RequestContextService, nsIRequestContextService, nsIObserver)
|
||||
|
||||
RequestContextService::RequestContextService()
|
||||
: mNextRCID(1)
|
||||
{
|
||||
MOZ_ASSERT(!sSelf, "multiple rcs instances!");
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
sSelf = this;
|
||||
|
||||
nsCOMPtr<nsIXULRuntime> runtime = do_GetService("@mozilla.org/xre/runtime;1");
|
||||
runtime->GetProcessID(&mRCIDNamespace);
|
||||
}
|
||||
|
||||
RequestContextService::~RequestContextService()
|
||||
|
@ -165,7 +167,7 @@ RequestContextService::Create(nsISupports *aOuter, const nsIID& aIID, void **aRe
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
RequestContextService::GetRequestContext(const nsID& rcID, nsIRequestContext **rc)
|
||||
RequestContextService::GetRequestContext(const uint64_t rcID, nsIRequestContext **rc)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
NS_ENSURE_ARG_POINTER(rc);
|
||||
|
@ -187,15 +189,7 @@ RequestContextService::NewRequestContext(nsIRequestContext **rc)
|
|||
NS_ENSURE_ARG_POINTER(rc);
|
||||
*rc = nullptr;
|
||||
|
||||
nsresult rv;
|
||||
if (!mUUIDGen) {
|
||||
mUUIDGen = do_GetService("@mozilla.org/uuid-generator;1", &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
nsID rcID;
|
||||
rv = mUUIDGen->GenerateUUIDInPlace(&rcID);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
uint64_t rcID = ((static_cast<uint64_t>(mRCIDNamespace) << 32) & 0xFFFFFFFF00000000LL) | mNextRCID++;
|
||||
|
||||
nsCOMPtr<nsIRequestContext> newSC = new RequestContext(rcID);
|
||||
mTable.Put(rcID, newSC);
|
||||
|
@ -205,7 +199,7 @@ RequestContextService::NewRequestContext(nsIRequestContext **rc)
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
RequestContextService::RemoveRequestContext(const nsID& rcID)
|
||||
RequestContextService::RemoveRequestContext(const uint64_t rcID)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
mTable.Remove(rcID);
|
||||
|
|
|
@ -12,8 +12,6 @@
|
|||
#include "nsIObserver.h"
|
||||
#include "nsIRequestContext.h"
|
||||
|
||||
class nsIUUIDGenerator;
|
||||
|
||||
namespace mozilla {
|
||||
namespace net {
|
||||
|
||||
|
@ -37,8 +35,9 @@ private:
|
|||
|
||||
static RequestContextService *sSelf;
|
||||
|
||||
nsInterfaceHashtable<nsIDHashKey, nsIRequestContext> mTable;
|
||||
nsCOMPtr<nsIUUIDGenerator> mUUIDGen;
|
||||
nsInterfaceHashtable<nsUint64HashKey, nsIRequestContext> mTable;
|
||||
uint32_t mRCIDNamespace;
|
||||
uint32_t mNextRCID;
|
||||
};
|
||||
|
||||
} // ::mozilla::net
|
||||
|
|
|
@ -81,7 +81,7 @@ interface nsILoadGroup : nsIRequest
|
|||
* Context for managing things like js/css connection blocking,
|
||||
* and per-tab connection grouping.
|
||||
*/
|
||||
[noscript] readonly attribute nsID requestContextID;
|
||||
[noscript] readonly attribute unsigned long long requestContextID;
|
||||
|
||||
/**
|
||||
* The set of load flags that will be added to all new requests added to
|
||||
|
|
|
@ -30,7 +30,7 @@ interface nsIRequestContext : nsISupports
|
|||
/**
|
||||
* A unique identifier for this request context
|
||||
*/
|
||||
[noscript] readonly attribute nsID ID;
|
||||
[noscript] readonly attribute unsigned long long ID;
|
||||
|
||||
/**
|
||||
* Number of active blocking transactions associated with this context
|
||||
|
@ -81,7 +81,7 @@ interface nsIRequestContextService : nsISupports
|
|||
/**
|
||||
* Get an existing request context from its ID
|
||||
*/
|
||||
nsIRequestContext getRequestContext(in nsIDRef id);
|
||||
nsIRequestContext getRequestContext(in unsigned long long id);
|
||||
|
||||
/**
|
||||
* Create a new request context
|
||||
|
@ -91,5 +91,5 @@ interface nsIRequestContextService : nsISupports
|
|||
/**
|
||||
* Remove an existing request context from its ID
|
||||
*/
|
||||
void removeRequestContext(in nsIDRef id);
|
||||
void removeRequestContext(in unsigned long long id);
|
||||
};
|
||||
|
|
|
@ -127,17 +127,11 @@ nsLoadGroup::~nsLoadGroup()
|
|||
mDefaultLoadRequest = nullptr;
|
||||
|
||||
if (mRequestContext) {
|
||||
nsID rcid;
|
||||
uint64_t rcid;
|
||||
mRequestContext->GetID(&rcid);
|
||||
|
||||
if (IsNeckoChild() && gNeckoChild) {
|
||||
char rcid_str[NSID_LENGTH];
|
||||
rcid.ToProvidedString(rcid_str);
|
||||
|
||||
nsCString rcid_nscs;
|
||||
rcid_nscs.AssignASCII(rcid_str);
|
||||
|
||||
gNeckoChild->SendRemoveRequestContext(rcid_nscs);
|
||||
gNeckoChild->SendRemoveRequestContext(rcid);
|
||||
} else {
|
||||
mRequestContextService->RemoveRequestContext(rcid);
|
||||
}
|
||||
|
@ -703,7 +697,7 @@ nsLoadGroup::SetNotificationCallbacks(nsIInterfaceRequestor *aCallbacks)
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsLoadGroup::GetRequestContextID(nsID *aRCID)
|
||||
nsLoadGroup::GetRequestContextID(uint64_t *aRCID)
|
||||
{
|
||||
if (!mRequestContext) {
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
|
|
|
@ -121,7 +121,7 @@ struct HttpChannelOpenArgs
|
|||
OptionalHttpResponseHead synthesizedResponseHead;
|
||||
nsCString synthesizedSecurityInfoSerialization;
|
||||
uint32_t cacheKey;
|
||||
nsCString requestContextID;
|
||||
uint64_t requestContextID;
|
||||
OptionalCorsPreflightArgs preflightArgs;
|
||||
uint32_t initialRwin;
|
||||
bool blockAuthPrompt;
|
||||
|
|
|
@ -908,7 +908,7 @@ NeckoParent::RecvPredReset()
|
|||
}
|
||||
|
||||
mozilla::ipc::IPCResult
|
||||
NeckoParent::RecvRemoveRequestContext(const nsCString& rcid)
|
||||
NeckoParent::RecvRemoveRequestContext(const uint64_t& rcid)
|
||||
{
|
||||
nsCOMPtr<nsIRequestContextService> rcsvc =
|
||||
do_GetService("@mozilla.org/network/request-context-service;1");
|
||||
|
@ -916,9 +916,7 @@ NeckoParent::RecvRemoveRequestContext(const nsCString& rcid)
|
|||
return IPC_OK();
|
||||
}
|
||||
|
||||
nsID id;
|
||||
id.Parse(rcid.BeginReading());
|
||||
rcsvc->RemoveRequestContext(id);
|
||||
rcsvc->RemoveRequestContext(rcid);
|
||||
|
||||
return IPC_OK();
|
||||
}
|
||||
|
|
|
@ -227,7 +227,7 @@ protected:
|
|||
const OriginAttributes& aOriginAttributes) override;
|
||||
virtual mozilla::ipc::IPCResult RecvPredReset() override;
|
||||
|
||||
virtual mozilla::ipc::IPCResult RecvRemoveRequestContext(const nsCString& rcid) override;
|
||||
virtual mozilla::ipc::IPCResult RecvRemoveRequestContext(const uint64_t& rcid) override;
|
||||
|
||||
/* Throttler messages */
|
||||
virtual mozilla::ipc::IPCResult RecvIncreaseThrottlePressure() override;
|
||||
|
|
|
@ -116,7 +116,7 @@ parent:
|
|||
nsString password, nsString domain);
|
||||
async OnAuthCancelled(uint64_t callbackId, bool userCancel);
|
||||
|
||||
async RemoveRequestContext(nsCString rcid);
|
||||
async RemoveRequestContext(uint64_t rcid);
|
||||
|
||||
async PAltDataOutputStream(nsCString type, PHttpChannel channel);
|
||||
|
||||
|
|
|
@ -199,6 +199,7 @@ HttpBaseChannel::HttpBaseChannel()
|
|||
, mTransferSize(0)
|
||||
, mDecodedBodySize(0)
|
||||
, mEncodedBodySize(0)
|
||||
, mRequestContextID(0)
|
||||
, mContentWindowId(0)
|
||||
, mTopLevelOuterContentWindowId(0)
|
||||
, mRequireCORSPreflight(false)
|
||||
|
@ -218,7 +219,6 @@ HttpBaseChannel::HttpBaseChannel()
|
|||
#endif
|
||||
mSelfAddr.raw.family = PR_AF_UNSPEC;
|
||||
mPeerAddr.raw.family = PR_AF_UNSPEC;
|
||||
mRequestContextID.Clear();
|
||||
}
|
||||
|
||||
HttpBaseChannel::~HttpBaseChannel()
|
||||
|
@ -2123,7 +2123,7 @@ HttpBaseChannel::RedirectTo(nsIURI *targetURI)
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HttpBaseChannel::GetRequestContextID(nsID *aRCID)
|
||||
HttpBaseChannel::GetRequestContextID(uint64_t *aRCID)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aRCID);
|
||||
*aRCID = mRequestContextID;
|
||||
|
@ -2131,7 +2131,7 @@ HttpBaseChannel::GetRequestContextID(nsID *aRCID)
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HttpBaseChannel::SetRequestContextID(const nsID aRCID)
|
||||
HttpBaseChannel::SetRequestContextID(uint64_t aRCID)
|
||||
{
|
||||
mRequestContextID = aRCID;
|
||||
return NS_OK;
|
||||
|
@ -3824,9 +3824,7 @@ HttpBaseChannel::GetThrottleQueue(nsIInputChannelThrottleQueue** aQueue)
|
|||
bool
|
||||
HttpBaseChannel::EnsureRequestContextID()
|
||||
{
|
||||
nsID nullID;
|
||||
nullID.Clear();
|
||||
if (!mRequestContextID.Equals(nullID)) {
|
||||
if (mRequestContextID) {
|
||||
// Already have a request context ID, no need to do the rest of this work
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -194,11 +194,11 @@ public:
|
|||
NS_IMETHOD GetResponseStatusText(nsACString& aValue) override;
|
||||
NS_IMETHOD GetRequestSucceeded(bool *aValue) override;
|
||||
NS_IMETHOD RedirectTo(nsIURI *newURI) override;
|
||||
NS_IMETHOD GetRequestContextID(nsID *aRCID) override;
|
||||
NS_IMETHOD GetRequestContextID(uint64_t *aRCID) override;
|
||||
NS_IMETHOD GetTransferSize(uint64_t *aTransferSize) override;
|
||||
NS_IMETHOD GetDecodedBodySize(uint64_t *aDecodedBodySize) override;
|
||||
NS_IMETHOD GetEncodedBodySize(uint64_t *aEncodedBodySize) override;
|
||||
NS_IMETHOD SetRequestContextID(const nsID aRCID) override;
|
||||
NS_IMETHOD SetRequestContextID(uint64_t aRCID) override;
|
||||
NS_IMETHOD GetIsMainDocumentChannel(bool* aValue) override;
|
||||
NS_IMETHOD SetIsMainDocumentChannel(bool aValue) override;
|
||||
NS_IMETHOD GetProtocolVersion(nsACString & aProtocolVersion) override;
|
||||
|
@ -587,7 +587,7 @@ protected:
|
|||
// The network interface id that's associated with this channel.
|
||||
nsCString mNetworkInterfaceId;
|
||||
|
||||
nsID mRequestContextID;
|
||||
uint64_t mRequestContextID;
|
||||
bool EnsureRequestContextID();
|
||||
|
||||
// ID of the top-level document's inner window this channel is being
|
||||
|
|
|
@ -2416,9 +2416,7 @@ HttpChannelChild::ContinueAsyncOpen()
|
|||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
EnsureRequestContextID();
|
||||
char rcid[NSID_LENGTH];
|
||||
mRequestContextID.ToProvidedString(rcid);
|
||||
openArgs.requestContextID().AssignASCII(rcid);
|
||||
openArgs.requestContextID() = mRequestContextID;
|
||||
|
||||
char chid[NSID_LENGTH];
|
||||
mChannelId.ToProvidedString(chid);
|
||||
|
|
|
@ -321,7 +321,7 @@ HttpChannelParent::DoAsyncOpen( const URIParams& aURI,
|
|||
const OptionalHttpResponseHead& aSynthesizedResponseHead,
|
||||
const nsCString& aSecurityInfoSerialization,
|
||||
const uint32_t& aCacheKey,
|
||||
const nsCString& aRequestContextID,
|
||||
const uint64_t& aRequestContextID,
|
||||
const OptionalCorsPreflightArgs& aCorsPreflightArgs,
|
||||
const uint32_t& aInitialRwin,
|
||||
const bool& aBlockAuthPrompt,
|
||||
|
@ -577,9 +577,7 @@ HttpChannelParent::DoAsyncOpen( const URIParams& aURI,
|
|||
}
|
||||
}
|
||||
|
||||
nsID requestContextID;
|
||||
requestContextID.Parse(aRequestContextID.BeginReading());
|
||||
mChannel->SetRequestContextID(requestContextID);
|
||||
mChannel->SetRequestContextID(aRequestContextID);
|
||||
|
||||
mSuspendAfterSynthesizeResponse = aSuspendAfterSynthesizeResponse;
|
||||
|
||||
|
|
|
@ -139,7 +139,7 @@ protected:
|
|||
const OptionalHttpResponseHead& aSynthesizedResponseHead,
|
||||
const nsCString& aSecurityInfoSerialization,
|
||||
const uint32_t& aCacheKey,
|
||||
const nsCString& aRequestContextID,
|
||||
const uint64_t& aRequestContextID,
|
||||
const OptionalCorsPreflightArgs& aCorsPreflightArgs,
|
||||
const uint32_t& aInitialRwin,
|
||||
const bool& aBlockAuthPrompt,
|
||||
|
|
|
@ -289,13 +289,13 @@ NullHttpChannel::RedirectTo(nsIURI *aNewURI)
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
NullHttpChannel::GetRequestContextID(nsID *_retval)
|
||||
NullHttpChannel::GetRequestContextID(uint64_t *_retval)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
NullHttpChannel::SetRequestContextID(const nsID rcID)
|
||||
NullHttpChannel::SetRequestContextID(uint64_t rcID)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
|
|
@ -447,7 +447,7 @@ interface nsIHttpChannel : nsIChannel
|
|||
/**
|
||||
* Identifies the request context for this load.
|
||||
*/
|
||||
[noscript, must_use] attribute nsID requestContextID;
|
||||
[noscript, must_use] attribute uint64_t requestContextID;
|
||||
|
||||
/**
|
||||
* Unique ID of the channel, shared between parent and child. Needed if
|
||||
|
|
|
@ -1002,14 +1002,14 @@ nsViewSourceChannel::RedirectTo(nsIURI *uri)
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsViewSourceChannel::GetRequestContextID(nsID *_retval)
|
||||
nsViewSourceChannel::GetRequestContextID(uint64_t *_retval)
|
||||
{
|
||||
return !mHttpChannel ? NS_ERROR_NULL_POINTER :
|
||||
mHttpChannel->GetRequestContextID(_retval);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsViewSourceChannel::SetRequestContextID(const nsID rcid)
|
||||
nsViewSourceChannel::SetRequestContextID(uint64_t rcid)
|
||||
{
|
||||
return !mHttpChannel ? NS_ERROR_NULL_POINTER :
|
||||
mHttpChannel->SetRequestContextID(rcid);
|
||||
|
|
Загрузка…
Ссылка в новой задаче