diff options
author | wolfbeast <mcwerewolf@gmail.com> | 2018-11-07 12:47:12 +0100 |
---|---|---|
committer | wolfbeast <mcwerewolf@gmail.com> | 2018-11-07 12:47:12 +0100 |
commit | 8240fb9c736f91044cabbdde8c537b179fc4921e (patch) | |
tree | 49a4cc8dc683cf955d61b6618ad471860554ccb5 /netwerk | |
parent | f9e04b54c2ccbc1f8e24b511003de09b4565193c (diff) | |
parent | 5c83a18cde404b5c0c9fba1d35f003d951ea32e2 (diff) | |
download | UXP-8240fb9c736f91044cabbdde8c537b179fc4921e.tar UXP-8240fb9c736f91044cabbdde8c537b179fc4921e.tar.gz UXP-8240fb9c736f91044cabbdde8c537b179fc4921e.tar.lz UXP-8240fb9c736f91044cabbdde8c537b179fc4921e.tar.xz UXP-8240fb9c736f91044cabbdde8c537b179fc4921e.zip |
Merge branch 'master' into Pale_Moon-release
# Conflicts:
# application/palemoon/config/version.txt
Diffstat (limited to 'netwerk')
36 files changed, 337 insertions, 702 deletions
diff --git a/netwerk/base/nsIOService.cpp b/netwerk/base/nsIOService.cpp index e13541acf..435294315 100644 --- a/netwerk/base/nsIOService.cpp +++ b/netwerk/base/nsIOService.cpp @@ -789,7 +789,9 @@ nsIOService::NewChannelFromURIWithProxyFlagsInternal(nsIURI* aURI, // creating a new channel by calling NewChannel(). if (NS_FAILED(rv)) { rv = handler->NewChannel(aURI, getter_AddRefs(channel)); - NS_ENSURE_SUCCESS(rv, rv); + if (NS_FAILED(rv)) { + return rv; + } // The protocol handler does not implement NewChannel2, so // maybe we need to wrap the channel (see comment in MaybeWrap // function). diff --git a/netwerk/base/nsNetUtilInlines.h b/netwerk/base/nsNetUtilInlines.h index 7003814d5..b831ec2e7 100644 --- a/netwerk/base/nsNetUtilInlines.h +++ b/netwerk/base/nsNetUtilInlines.h @@ -224,7 +224,9 @@ NS_NewChannelInternal(nsIChannel **outChannel, aUri, aLoadInfo, getter_AddRefs(channel)); - NS_ENSURE_SUCCESS(rv, rv); + if (NS_FAILED(rv)) { + return rv; + } if (aLoadGroup) { rv = channel->SetLoadGroup(aLoadGroup); diff --git a/netwerk/base/nsSocketTransportService2.cpp b/netwerk/base/nsSocketTransportService2.cpp index 72afdc9e1..739388b0f 100644 --- a/netwerk/base/nsSocketTransportService2.cpp +++ b/netwerk/base/nsSocketTransportService2.cpp @@ -471,9 +471,6 @@ nsSocketTransportService::Poll(uint32_t *interval, PRIntervalTime ts = PR_IntervalNow(); TimeStamp pollStart; - if (mTelemetryEnabledPref) { - pollStart = TimeStamp::NowLoRes(); - } SOCKET_LOG((" timeout = %i milliseconds\n", PR_IntervalToMilliseconds(pollTimeout))); @@ -481,10 +478,6 @@ nsSocketTransportService::Poll(uint32_t *interval, PRIntervalTime passedInterval = PR_IntervalNow() - ts; - if (mTelemetryEnabledPref && !pollStart.IsNull()) { - *pollDuration = TimeStamp::NowLoRes() - pollStart; - } - SOCKET_LOG((" ...returned after %i milliseconds\n", PR_IntervalToMilliseconds(passedInterval))); @@ -858,20 +851,9 @@ nsSocketTransportService::Run() // make sure the pseudo random number generator is seeded on this thread srand(static_cast<unsigned>(PR_Now())); - // For the calculation of the duration of the last cycle (i.e. the last for-loop - // iteration before shutdown). - TimeStamp startOfCycleForLastCycleCalc; - int numberOfPendingEventsLastCycle; - - // For measuring of the poll iteration duration without time spent blocked - // in poll(). - TimeStamp pollCycleStart; // Time blocked in poll(). TimeDuration singlePollDuration; - // For calculating the time needed for a new element to run. - TimeStamp startOfIteration; - TimeStamp startOfNextIteration; int numberOfPendingEvents; // If there is too many pending events queued, we will run some poll() @@ -883,18 +865,9 @@ nsSocketTransportService::Run() bool pendingEvents = false; numberOfPendingEvents = 0; - numberOfPendingEventsLastCycle = 0; - if (mTelemetryEnabledPref) { - startOfCycleForLastCycleCalc = TimeStamp::NowLoRes(); - startOfNextIteration = TimeStamp::NowLoRes(); - } pollDuration = 0; do { - if (mTelemetryEnabledPref) { - pollCycleStart = TimeStamp::NowLoRes(); - } - DoPollIteration(&singlePollDuration); mRawThread->HasPendingEvents(&pendingEvents); @@ -909,15 +882,6 @@ nsSocketTransportService::Run() } else { mServingPendingQueue = true; } - - if (mTelemetryEnabledPref) { - startOfIteration = startOfNextIteration; - // Everything that comes after this point will - // be served in the next iteration. If no even - // arrives, startOfNextIteration will be reset at the - // beginning of each for-loop. - startOfNextIteration = TimeStamp::NowLoRes(); - } } TimeStamp eventQueueStart = TimeStamp::NowLoRes(); do { diff --git a/netwerk/base/nsUDPSocket.cpp b/netwerk/base/nsUDPSocket.cpp index 24f3954cb..445b62d9c 100644 --- a/netwerk/base/nsUDPSocket.cpp +++ b/netwerk/base/nsUDPSocket.cpp @@ -770,12 +770,6 @@ nsUDPSocket::CloseSocket() // If shutdown last to long, let the socket leak and do not close it. UDPSOCKET_LOG(("Intentional leak")); } else { - - PRIntervalTime closeStarted = 0; - if (gSocketTransportService->IsTelemetryEnabledAndNotSleepPhase()) { - closeStarted = PR_IntervalNow(); - } - PR_Close(mFD); } mFD = nullptr; diff --git a/netwerk/cache/nsCacheEntryDescriptor.cpp b/netwerk/cache/nsCacheEntryDescriptor.cpp index 64765f8aa..35ea22d55 100644 --- a/netwerk/cache/nsCacheEntryDescriptor.cpp +++ b/netwerk/cache/nsCacheEntryDescriptor.cpp @@ -43,7 +43,7 @@ public: nsresult status = NS_OK; { - nsCacheServiceAutoLock lock(LOCK_TELEM(NSASYNCDOOMEVENT_RUN)); + nsCacheServiceAutoLock lock; if (mDescriptor->mCacheEntry) { status = nsCacheService::gService->DoomEntry_Internal( @@ -113,7 +113,7 @@ nsCacheEntryDescriptor::GetClientID(char ** result) { NS_ENSURE_ARG_POINTER(result); - nsCacheServiceAutoLock lock(LOCK_TELEM(NSCACHEENTRYDESCRIPTOR_GETCLIENTID)); + nsCacheServiceAutoLock lock; if (!mCacheEntry) return NS_ERROR_NOT_AVAILABLE; return ClientIDFromCacheKey(*(mCacheEntry->Key()), result); @@ -124,7 +124,7 @@ NS_IMETHODIMP nsCacheEntryDescriptor::GetDeviceID(char ** aDeviceID) { NS_ENSURE_ARG_POINTER(aDeviceID); - nsCacheServiceAutoLock lock(LOCK_TELEM(NSCACHEENTRYDESCRIPTOR_GETDEVICEID)); + nsCacheServiceAutoLock lock; if (!mCacheEntry) return NS_ERROR_NOT_AVAILABLE; const char* deviceID = mCacheEntry->GetDeviceID(); @@ -141,7 +141,7 @@ nsCacheEntryDescriptor::GetDeviceID(char ** aDeviceID) NS_IMETHODIMP nsCacheEntryDescriptor::GetKey(nsACString &result) { - nsCacheServiceAutoLock lock(LOCK_TELEM(NSCACHEENTRYDESCRIPTOR_GETKEY)); + nsCacheServiceAutoLock lock; if (!mCacheEntry) return NS_ERROR_NOT_AVAILABLE; return ClientKeyFromCacheKey(*(mCacheEntry->Key()), result); @@ -152,7 +152,7 @@ NS_IMETHODIMP nsCacheEntryDescriptor::GetFetchCount(int32_t *result) { NS_ENSURE_ARG_POINTER(result); - nsCacheServiceAutoLock lock(LOCK_TELEM(NSCACHEENTRYDESCRIPTOR_GETFETCHCOUNT)); + nsCacheServiceAutoLock lock; if (!mCacheEntry) return NS_ERROR_NOT_AVAILABLE; *result = mCacheEntry->FetchCount(); @@ -164,7 +164,7 @@ NS_IMETHODIMP nsCacheEntryDescriptor::GetLastFetched(uint32_t *result) { NS_ENSURE_ARG_POINTER(result); - nsCacheServiceAutoLock lock(LOCK_TELEM(NSCACHEENTRYDESCRIPTOR_GETLASTFETCHED)); + nsCacheServiceAutoLock lock; if (!mCacheEntry) return NS_ERROR_NOT_AVAILABLE; *result = mCacheEntry->LastFetched(); @@ -176,7 +176,7 @@ NS_IMETHODIMP nsCacheEntryDescriptor::GetLastModified(uint32_t *result) { NS_ENSURE_ARG_POINTER(result); - nsCacheServiceAutoLock lock(LOCK_TELEM(NSCACHEENTRYDESCRIPTOR_GETLASTMODIFIED)); + nsCacheServiceAutoLock lock; if (!mCacheEntry) return NS_ERROR_NOT_AVAILABLE; *result = mCacheEntry->LastModified(); @@ -188,7 +188,7 @@ NS_IMETHODIMP nsCacheEntryDescriptor::GetExpirationTime(uint32_t *result) { NS_ENSURE_ARG_POINTER(result); - nsCacheServiceAutoLock lock(LOCK_TELEM(NSCACHEENTRYDESCRIPTOR_GETEXPIRATIONTIME)); + nsCacheServiceAutoLock lock; if (!mCacheEntry) return NS_ERROR_NOT_AVAILABLE; *result = mCacheEntry->ExpirationTime(); @@ -199,7 +199,7 @@ nsCacheEntryDescriptor::GetExpirationTime(uint32_t *result) NS_IMETHODIMP nsCacheEntryDescriptor::SetExpirationTime(uint32_t expirationTime) { - nsCacheServiceAutoLock lock(LOCK_TELEM(NSCACHEENTRYDESCRIPTOR_SETEXPIRATIONTIME)); + nsCacheServiceAutoLock lock; if (!mCacheEntry) return NS_ERROR_NOT_AVAILABLE; mCacheEntry->SetExpirationTime(expirationTime); @@ -211,7 +211,7 @@ nsCacheEntryDescriptor::SetExpirationTime(uint32_t expirationTime) NS_IMETHODIMP nsCacheEntryDescriptor::IsStreamBased(bool *result) { NS_ENSURE_ARG_POINTER(result); - nsCacheServiceAutoLock lock(LOCK_TELEM(NSCACHEENTRYDESCRIPTOR_ISSTREAMBASED)); + nsCacheServiceAutoLock lock; if (!mCacheEntry) return NS_ERROR_NOT_AVAILABLE; *result = mCacheEntry->IsStreamData(); @@ -221,7 +221,7 @@ NS_IMETHODIMP nsCacheEntryDescriptor::IsStreamBased(bool *result) NS_IMETHODIMP nsCacheEntryDescriptor::GetPredictedDataSize(int64_t *result) { NS_ENSURE_ARG_POINTER(result); - nsCacheServiceAutoLock lock(LOCK_TELEM(NSCACHEENTRYDESCRIPTOR_GETPREDICTEDDATASIZE)); + nsCacheServiceAutoLock lock; if (!mCacheEntry) return NS_ERROR_NOT_AVAILABLE; *result = mCacheEntry->PredictedDataSize(); @@ -231,7 +231,7 @@ NS_IMETHODIMP nsCacheEntryDescriptor::GetPredictedDataSize(int64_t *result) NS_IMETHODIMP nsCacheEntryDescriptor::SetPredictedDataSize(int64_t predictedSize) { - nsCacheServiceAutoLock lock(LOCK_TELEM(NSCACHEENTRYDESCRIPTOR_SETPREDICTEDDATASIZE)); + nsCacheServiceAutoLock lock; if (!mCacheEntry) return NS_ERROR_NOT_AVAILABLE; mCacheEntry->SetPredictedDataSize(predictedSize); @@ -241,7 +241,7 @@ NS_IMETHODIMP nsCacheEntryDescriptor::SetPredictedDataSize(int64_t NS_IMETHODIMP nsCacheEntryDescriptor::GetDataSize(uint32_t *result) { NS_ENSURE_ARG_POINTER(result); - nsCacheServiceAutoLock lock(LOCK_TELEM(NSCACHEENTRYDESCRIPTOR_GETDATASIZE)); + nsCacheServiceAutoLock lock; if (!mCacheEntry) return NS_ERROR_NOT_AVAILABLE; const char* val = mCacheEntry->GetMetaDataElement("uncompressed-len"); @@ -258,7 +258,7 @@ NS_IMETHODIMP nsCacheEntryDescriptor::GetDataSize(uint32_t *result) NS_IMETHODIMP nsCacheEntryDescriptor::GetStorageDataSize(uint32_t *result) { NS_ENSURE_ARG_POINTER(result); - nsCacheServiceAutoLock lock(LOCK_TELEM(NSCACHEENTRYDESCRIPTOR_GETSTORAGEDATASIZE)); + nsCacheServiceAutoLock lock; if (!mCacheEntry) return NS_ERROR_NOT_AVAILABLE; *result = mCacheEntry->DataSize(); @@ -270,7 +270,7 @@ NS_IMETHODIMP nsCacheEntryDescriptor::GetStorageDataSize(uint32_t *result) nsresult nsCacheEntryDescriptor::RequestDataSizeChange(int32_t deltaSize) { - nsCacheServiceAutoLock lock(LOCK_TELEM(NSCACHEENTRYDESCRIPTOR_REQUESTDATASIZECHANGE)); + nsCacheServiceAutoLock lock; if (!mCacheEntry) return NS_ERROR_NOT_AVAILABLE; nsresult rv; @@ -288,7 +288,7 @@ nsCacheEntryDescriptor::RequestDataSizeChange(int32_t deltaSize) NS_IMETHODIMP nsCacheEntryDescriptor::SetDataSize(uint32_t dataSize) { - nsCacheServiceAutoLock lock(LOCK_TELEM(NSCACHEENTRYDESCRIPTOR_SETDATASIZE)); + nsCacheServiceAutoLock lock; if (!mCacheEntry) return NS_ERROR_NOT_AVAILABLE; // XXX review for signed/unsigned math errors @@ -317,7 +317,7 @@ nsCacheEntryDescriptor::OpenInputStream(uint32_t offset, nsIInputStream ** resul nsInputStreamWrapper* cacheInput = nullptr; { - nsCacheServiceAutoLock lock(LOCK_TELEM(NSCACHEENTRYDESCRIPTOR_OPENINPUTSTREAM)); + nsCacheServiceAutoLock lock; if (!mCacheEntry) return NS_ERROR_NOT_AVAILABLE; if (!mCacheEntry->IsStreamData()) return NS_ERROR_CACHE_DATA_IS_NOT_STREAM; @@ -352,7 +352,7 @@ nsCacheEntryDescriptor::OpenOutputStream(uint32_t offset, nsIOutputStream ** res nsOutputStreamWrapper* cacheOutput = nullptr; { - nsCacheServiceAutoLock lock(LOCK_TELEM(NSCACHEENTRYDESCRIPTOR_OPENOUTPUTSTREAM)); + nsCacheServiceAutoLock lock; if (!mCacheEntry) return NS_ERROR_NOT_AVAILABLE; if (!mCacheEntry->IsStreamData()) return NS_ERROR_CACHE_DATA_IS_NOT_STREAM; @@ -390,7 +390,7 @@ NS_IMETHODIMP nsCacheEntryDescriptor::GetCacheElement(nsISupports ** result) { NS_ENSURE_ARG_POINTER(result); - nsCacheServiceAutoLock lock(LOCK_TELEM(NSCACHEENTRYDESCRIPTOR_GETCACHEELEMENT)); + nsCacheServiceAutoLock lock; if (!mCacheEntry) return NS_ERROR_NOT_AVAILABLE; if (mCacheEntry->IsStreamData()) return NS_ERROR_CACHE_DATA_IS_STREAM; @@ -402,7 +402,7 @@ nsCacheEntryDescriptor::GetCacheElement(nsISupports ** result) NS_IMETHODIMP nsCacheEntryDescriptor::SetCacheElement(nsISupports * cacheElement) { - nsCacheServiceAutoLock lock(LOCK_TELEM(NSCACHEENTRYDESCRIPTOR_SETCACHEELEMENT)); + nsCacheServiceAutoLock lock; if (!mCacheEntry) return NS_ERROR_NOT_AVAILABLE; if (mCacheEntry->IsStreamData()) return NS_ERROR_CACHE_DATA_IS_STREAM; @@ -423,7 +423,7 @@ NS_IMETHODIMP nsCacheEntryDescriptor::GetStoragePolicy(nsCacheStoragePolicy *result) { NS_ENSURE_ARG_POINTER(result); - nsCacheServiceAutoLock lock(LOCK_TELEM(NSCACHEENTRYDESCRIPTOR_GETSTORAGEPOLICY)); + nsCacheServiceAutoLock lock; if (!mCacheEntry) return NS_ERROR_NOT_AVAILABLE; *result = mCacheEntry->StoragePolicy(); @@ -434,7 +434,7 @@ nsCacheEntryDescriptor::GetStoragePolicy(nsCacheStoragePolicy *result) NS_IMETHODIMP nsCacheEntryDescriptor::SetStoragePolicy(nsCacheStoragePolicy policy) { - nsCacheServiceAutoLock lock(LOCK_TELEM(NSCACHEENTRYDESCRIPTOR_SETSTORAGEPOLICY)); + nsCacheServiceAutoLock lock; if (!mCacheEntry) return NS_ERROR_NOT_AVAILABLE; // XXX validate policy against session? @@ -461,7 +461,7 @@ NS_IMETHODIMP nsCacheEntryDescriptor::GetFile(nsIFile ** result) { NS_ENSURE_ARG_POINTER(result); - nsCacheServiceAutoLock lock(LOCK_TELEM(NSCACHEENTRYDESCRIPTOR_GETFILE)); + nsCacheServiceAutoLock lock; if (!mCacheEntry) return NS_ERROR_NOT_AVAILABLE; return nsCacheService::GetFileForEntry(mCacheEntry, result); @@ -472,7 +472,7 @@ NS_IMETHODIMP nsCacheEntryDescriptor::GetSecurityInfo(nsISupports ** result) { NS_ENSURE_ARG_POINTER(result); - nsCacheServiceAutoLock lock(LOCK_TELEM(NSCACHEENTRYDESCRIPTOR_GETSECURITYINFO)); + nsCacheServiceAutoLock lock; if (!mCacheEntry) return NS_ERROR_NOT_AVAILABLE; *result = mCacheEntry->SecurityInfo(); @@ -484,7 +484,7 @@ nsCacheEntryDescriptor::GetSecurityInfo(nsISupports ** result) NS_IMETHODIMP nsCacheEntryDescriptor::SetSecurityInfo(nsISupports * securityInfo) { - nsCacheServiceAutoLock lock(LOCK_TELEM(NSCACHEENTRYDESCRIPTOR_SETSECURITYINFO)); + nsCacheServiceAutoLock lock; if (!mCacheEntry) return NS_ERROR_NOT_AVAILABLE; mCacheEntry->SetSecurityInfo(securityInfo); @@ -496,7 +496,7 @@ nsCacheEntryDescriptor::SetSecurityInfo(nsISupports * securityInfo) NS_IMETHODIMP nsCacheEntryDescriptor::Doom() { - nsCacheServiceAutoLock lock(LOCK_TELEM(NSCACHEENTRYDESCRIPTOR_DOOM)); + nsCacheServiceAutoLock lock; if (!mCacheEntry) return NS_ERROR_NOT_AVAILABLE; return nsCacheService::DoomEntry(mCacheEntry); @@ -506,7 +506,7 @@ nsCacheEntryDescriptor::Doom() NS_IMETHODIMP nsCacheEntryDescriptor::DoomAndFailPendingRequests(nsresult status) { - nsCacheServiceAutoLock lock(LOCK_TELEM(NSCACHEENTRYDESCRIPTOR_DOOMANDFAILPENDINGREQUESTS)); + nsCacheServiceAutoLock lock; if (!mCacheEntry) return NS_ERROR_NOT_AVAILABLE; return NS_ERROR_NOT_IMPLEMENTED; @@ -544,7 +544,7 @@ nsCacheEntryDescriptor::AsyncDoom(nsICacheListener *listener) NS_IMETHODIMP nsCacheEntryDescriptor::MarkValid() { - nsCacheServiceAutoLock lock(LOCK_TELEM(NSCACHEENTRYDESCRIPTOR_MARKVALID)); + nsCacheServiceAutoLock lock; if (!mCacheEntry) return NS_ERROR_NOT_AVAILABLE; nsresult rv = nsCacheService::ValidateEntry(mCacheEntry); @@ -559,7 +559,7 @@ nsCacheEntryDescriptor::Close() nsTArray<RefPtr<nsInputStreamWrapper> > inputWrappers; { - nsCacheServiceAutoLock lock(LOCK_TELEM(NSCACHEENTRYDESCRIPTOR_CLOSE)); + nsCacheServiceAutoLock lock; if (!mCacheEntry) return NS_ERROR_NOT_AVAILABLE; // Make sure no other stream can be opened @@ -585,7 +585,7 @@ nsCacheEntryDescriptor::Close() inputWrappers.Clear(); - nsCacheServiceAutoLock lock(LOCK_TELEM(NSCACHEENTRYDESCRIPTOR_CLOSE)); + nsCacheServiceAutoLock lock; if (!mCacheEntry) return NS_ERROR_NOT_AVAILABLE; // XXX perhaps closing descriptors should clear/sever transports @@ -604,7 +604,7 @@ nsCacheEntryDescriptor::GetMetaDataElement(const char *key, char **result) NS_ENSURE_ARG_POINTER(key); *result = nullptr; - nsCacheServiceAutoLock lock(LOCK_TELEM(NSCACHEENTRYDESCRIPTOR_GETMETADATAELEMENT)); + nsCacheServiceAutoLock lock; NS_ENSURE_TRUE(mCacheEntry, NS_ERROR_NOT_AVAILABLE); const char *value; @@ -624,7 +624,7 @@ nsCacheEntryDescriptor::SetMetaDataElement(const char *key, const char *value) { NS_ENSURE_ARG_POINTER(key); - nsCacheServiceAutoLock lock(LOCK_TELEM(NSCACHEENTRYDESCRIPTOR_SETMETADATAELEMENT)); + nsCacheServiceAutoLock lock; NS_ENSURE_TRUE(mCacheEntry, NS_ERROR_NOT_AVAILABLE); // XXX allow null value, for clearing key? @@ -639,7 +639,7 @@ nsCacheEntryDescriptor::SetMetaDataElement(const char *key, const char *value) NS_IMETHODIMP nsCacheEntryDescriptor::VisitMetaData(nsICacheMetaDataVisitor * visitor) { - nsCacheServiceAutoLock lock(LOCK_TELEM(NSCACHEENTRYDESCRIPTOR_VISITMETADATA)); + nsCacheServiceAutoLock lock; // XXX check callers, we're calling out of module NS_ENSURE_ARG_POINTER(visitor); if (!mCacheEntry) return NS_ERROR_NOT_AVAILABLE; @@ -667,7 +667,7 @@ nsCacheEntryDescriptor::nsInputStreamWrapper::Release() } if (desc) - nsCacheService::Lock(LOCK_TELEM(NSINPUTSTREAMWRAPPER_RELEASE)); + nsCacheService::Lock(); nsrefcnt count; NS_PRECONDITION(0 != mRefCnt, "dup release"); @@ -709,7 +709,7 @@ nsInputStreamWrapper::LazyInit() if (!mDescriptor) return NS_ERROR_NOT_AVAILABLE; - nsCacheServiceAutoLock lock(LOCK_TELEM(NSINPUTSTREAMWRAPPER_LAZYINIT)); + nsCacheServiceAutoLock lock; nsCacheAccessMode mode; nsresult rv = mDescriptor->GetAccessGranted(&mode); @@ -755,7 +755,7 @@ nsInputStreamWrapper::CloseInternal() return; } - nsCacheServiceAutoLock lock(LOCK_TELEM(NSINPUTSTREAMWRAPPER_CLOSEINTERNAL)); + nsCacheServiceAutoLock lock; if (mDescriptor) { mDescriptor->mInputWrappers.RemoveElement(this); @@ -859,8 +859,7 @@ nsCacheEntryDescriptor::nsDecompressInputStreamWrapper::Release() } if (desc) - nsCacheService::Lock(LOCK_TELEM( - NSDECOMPRESSINPUTSTREAMWRAPPER_RELEASE)); + nsCacheService::Lock(); nsrefcnt count; NS_PRECONDITION(0 != mRefCnt, "dup release"); @@ -1049,7 +1048,7 @@ nsCacheEntryDescriptor::nsOutputStreamWrapper::Release() } if (desc) - nsCacheService::Lock(LOCK_TELEM(NSOUTPUTSTREAMWRAPPER_RELEASE)); + nsCacheService::Lock(); nsrefcnt count; NS_PRECONDITION(0 != mRefCnt, "dup release"); @@ -1089,7 +1088,7 @@ nsOutputStreamWrapper::LazyInit() if (!mDescriptor) return NS_ERROR_NOT_AVAILABLE; - nsCacheServiceAutoLock lock(LOCK_TELEM(NSOUTPUTSTREAMWRAPPER_LAZYINIT)); + nsCacheServiceAutoLock lock; nsCacheAccessMode mode; nsresult rv = mDescriptor->GetAccessGranted(&mode); @@ -1163,7 +1162,7 @@ nsOutputStreamWrapper::CloseInternal() return; } - nsCacheServiceAutoLock lock(LOCK_TELEM(NSOUTPUTSTREAMWRAPPER_CLOSEINTERNAL)); + nsCacheServiceAutoLock lock; if (mDescriptor) { mDescriptor->mOutputWrapper = nullptr; @@ -1279,7 +1278,7 @@ nsCacheEntryDescriptor::nsCompressOutputStreamWrapper::Release() } if (desc) - nsCacheService::Lock(LOCK_TELEM(NSCOMPRESSOUTPUTSTREAMWRAPPER_RELEASE)); + nsCacheService::Lock(); nsrefcnt count; NS_PRECONDITION(0 != mRefCnt, "dup release"); diff --git a/netwerk/cache/nsCacheService.cpp b/netwerk/cache/nsCacheService.cpp index 97b1a71c8..4b08614b8 100644 --- a/netwerk/cache/nsCacheService.cpp +++ b/netwerk/cache/nsCacheService.cpp @@ -211,7 +211,7 @@ public: NS_IMETHOD Notify(nsITimer* aTimer) override { if (nsCacheService::gService) { - nsCacheServiceAutoLock autoLock(LOCK_TELEM(NSSETDISKSMARTSIZECALLBACK_NOTIFY)); + nsCacheServiceAutoLock autoLock; nsCacheService::gService->SetDiskSmartSize_Locked(); nsCacheService::gService->mSmartSizeTimer = nullptr; } @@ -295,7 +295,7 @@ public: } NS_IMETHOD Run() override { - nsCacheServiceAutoLock autoLock(LOCK_TELEM(NSBLOCKONCACHETHREADEVENT_RUN)); + nsCacheServiceAutoLock autoLock; CACHE_LOG_DEBUG(("nsBlockOnCacheThreadEvent [%p]\n", this)); nsCacheService::gService->mNotified = true; nsCacheService::gService->mCondVar.Notify(); @@ -988,7 +988,7 @@ public: NS_ASSERTION(mRequest->mListener, "Sync OpenCacheEntry() posted to background thread!"); - nsCacheServiceAutoLock lock(LOCK_TELEM(NSPROCESSREQUESTEVENT_RUN)); + nsCacheServiceAutoLock lock; rv = nsCacheService::gService->ProcessRequest(mRequest, false, nullptr); @@ -1189,7 +1189,7 @@ nsCacheService::Shutdown() nsCOMPtr<nsIFile> parentDir; { - nsCacheServiceAutoLock lock(LOCK_TELEM(NSCACHESERVICE_SHUTDOWN)); + nsCacheServiceAutoLock lock; NS_ASSERTION(mInitialized, "can't shutdown nsCacheService unless it has been initialized."); if (!mInitialized) @@ -1204,7 +1204,7 @@ nsCacheService::Shutdown() UnregisterWeakMemoryReporter(this); { - nsCacheServiceAutoLock lock(LOCK_TELEM(NSCACHESERVICE_SHUTDOWN)); + nsCacheServiceAutoLock lock; NS_ASSERTION(mInitialized, "Bad state"); mInitialized = false; @@ -1363,7 +1363,7 @@ nsCacheService::EvictEntriesForClient(const char * clientID, new EvictionNotifierRunnable(NS_ISUPPORTS_CAST(nsICacheService*, this)); NS_DispatchToMainThread(r); - nsCacheServiceAutoLock lock(LOCK_TELEM(NSCACHESERVICE_EVICTENTRIESFORCLIENT)); + nsCacheServiceAutoLock lock; nsresult res = NS_OK; if (storagePolicy == nsICache::STORE_ANYWHERE || @@ -1412,7 +1412,7 @@ nsCacheService::IsStorageEnabledForPolicy(nsCacheStoragePolicy storagePolicy, bool * result) { if (gService == nullptr) return NS_ERROR_NOT_AVAILABLE; - nsCacheServiceAutoLock lock(LOCK_TELEM(NSCACHESERVICE_ISSTORAGEENABLEDFORPOLICY)); + nsCacheServiceAutoLock lock; *result = gService->IsStorageEnabledForPolicy_Locked(storagePolicy); return NS_OK; @@ -1466,7 +1466,7 @@ nsresult nsCacheService::VisitEntriesInternal(nsICacheVisitor *visitor) { NS_ENSURE_ARG_POINTER(visitor); - nsCacheServiceAutoLock lock(LOCK_TELEM(NSCACHESERVICE_VISITENTRIES)); + nsCacheServiceAutoLock lock; if (!(mEnableDiskDevice || mEnableMemoryDevice)) return NS_ERROR_NOT_AVAILABLE; @@ -1548,7 +1548,7 @@ NS_IMETHODIMP nsCacheService::GetCacheIOTarget(nsIEventTarget * *aCacheIOTarget) // read from the main thread without the lock. This is useful to prevent // blocking the main thread on other cache operations. if (!NS_IsMainThread()) { - Lock(LOCK_TELEM(NSCACHESERVICE_GETCACHEIOTARGET)); + Lock(); } nsresult rv; @@ -1940,7 +1940,7 @@ nsCacheService::ProcessRequest(nsCacheRequest * request, // XXX this is probably wrong... Unlock(); rv = request->WaitForValidation(); - Lock(LOCK_TELEM(NSCACHESERVICE_PROCESSREQUEST)); + Lock(); } PR_REMOVE_AND_INIT_LINK(request); @@ -2052,7 +2052,7 @@ nsCacheService::OpenCacheEntry(nsCacheSession * session, } else { - nsCacheServiceAutoLock lock(LOCK_TELEM(NSCACHESERVICE_OPENCACHEENTRY)); + nsCacheServiceAutoLock lock; rv = gService->ProcessRequest(request, true, result); // delete requests that have completed @@ -2353,14 +2353,14 @@ nsCacheService::OnProfileShutdown() } { - nsCacheServiceAutoLock lock(LOCK_TELEM(NSCACHESERVICE_ONPROFILESHUTDOWN)); + nsCacheServiceAutoLock lock; gService->mClearingEntries = true; gService->DoomActiveEntries(nullptr); } gService->CloseAllStreams(); - nsCacheServiceAutoLock lock(LOCK_TELEM(NSCACHESERVICE_ONPROFILESHUTDOWN)); + nsCacheServiceAutoLock lock; gService->ClearDoomList(); // Make sure to wait for any pending cache-operations before @@ -2399,7 +2399,7 @@ nsCacheService::OnProfileChanged() CACHE_LOG_DEBUG(("nsCacheService::OnProfileChanged")); - nsCacheServiceAutoLock lock(LOCK_TELEM(NSCACHESERVICE_ONPROFILECHANGED)); + nsCacheServiceAutoLock lock; gService->mEnableDiskDevice = gService->mObserver->DiskCacheEnabled(); gService->mEnableOfflineDevice = gService->mObserver->OfflineCacheEnabled(); @@ -2453,7 +2453,7 @@ void nsCacheService::SetDiskCacheEnabled(bool enabled) { if (!gService) return; - nsCacheServiceAutoLock lock(LOCK_TELEM(NSCACHESERVICE_SETDISKCACHEENABLED)); + nsCacheServiceAutoLock lock; gService->mEnableDiskDevice = enabled; } @@ -2462,7 +2462,7 @@ void nsCacheService::SetDiskCacheCapacity(int32_t capacity) { if (!gService) return; - nsCacheServiceAutoLock lock(LOCK_TELEM(NSCACHESERVICE_SETDISKCACHECAPACITY)); + nsCacheServiceAutoLock lock; if (gService->mDiskDevice) { gService->mDiskDevice->SetCapacity(capacity); @@ -2475,7 +2475,7 @@ void nsCacheService::SetDiskCacheMaxEntrySize(int32_t maxSize) { if (!gService) return; - nsCacheServiceAutoLock lock(LOCK_TELEM(NSCACHESERVICE_SETDISKCACHEMAXENTRYSIZE)); + nsCacheServiceAutoLock lock; if (gService->mDiskDevice) { gService->mDiskDevice->SetMaxEntrySize(maxSize); @@ -2486,7 +2486,7 @@ void nsCacheService::SetMemoryCacheMaxEntrySize(int32_t maxSize) { if (!gService) return; - nsCacheServiceAutoLock lock(LOCK_TELEM(NSCACHESERVICE_SETMEMORYCACHEMAXENTRYSIZE)); + nsCacheServiceAutoLock lock; if (gService->mMemoryDevice) { gService->mMemoryDevice->SetMaxEntrySize(maxSize); @@ -2497,7 +2497,7 @@ void nsCacheService::SetOfflineCacheEnabled(bool enabled) { if (!gService) return; - nsCacheServiceAutoLock lock(LOCK_TELEM(NSCACHESERVICE_SETOFFLINECACHEENABLED)); + nsCacheServiceAutoLock lock; gService->mEnableOfflineDevice = enabled; } @@ -2505,7 +2505,7 @@ void nsCacheService::SetOfflineCacheCapacity(int32_t capacity) { if (!gService) return; - nsCacheServiceAutoLock lock(LOCK_TELEM(NSCACHESERVICE_SETOFFLINECACHECAPACITY)); + nsCacheServiceAutoLock lock; if (gService->mOfflineDevice) { gService->mOfflineDevice->SetCapacity(capacity); @@ -2522,7 +2522,7 @@ nsCacheService::SetMemoryCache() CACHE_LOG_DEBUG(("nsCacheService::SetMemoryCache")); - nsCacheServiceAutoLock lock(LOCK_TELEM(NSCACHESERVICE_SETMEMORYCACHE)); + nsCacheServiceAutoLock lock; gService->mEnableMemoryDevice = gService->mObserver->MemoryCacheEnabled(); @@ -2638,23 +2638,6 @@ nsCacheService::Lock() } void -nsCacheService::Lock(mozilla::Telemetry::ID mainThreadLockerID) -{ - mozilla::Telemetry::ID lockerID; - mozilla::Telemetry::ID generalID; - - if (NS_IsMainThread()) { - lockerID = mainThreadLockerID; - generalID = mozilla::Telemetry::CACHE_SERVICE_LOCK_WAIT_MAINTHREAD_2; - } else { - lockerID = mozilla::Telemetry::HistogramCount; - generalID = mozilla::Telemetry::CACHE_SERVICE_LOCK_WAIT_2; - } - - nsCacheService::Lock(); -} - -void nsCacheService::Unlock() { gService->mLock.AssertCurrentThreadOwns(); @@ -2933,7 +2916,7 @@ nsCacheService::CloseAllStreams() nsTArray<RefPtr<nsCacheEntryDescriptor::nsOutputStreamWrapper> > outputs; { - nsCacheServiceAutoLock lock(LOCK_TELEM(NSCACHESERVICE_CLOSEALLSTREAMS)); + nsCacheServiceAutoLock lock; nsTArray<nsCacheEntry*> entries; @@ -3056,7 +3039,7 @@ nsCacheService::LogCacheStatistics() nsresult nsCacheService::SetDiskSmartSize() { - nsCacheServiceAutoLock lock(LOCK_TELEM(NSCACHESERVICE_SETDISKSMARTSIZE)); + nsCacheServiceAutoLock lock; if (!gService) return NS_ERROR_NOT_AVAILABLE; @@ -3175,8 +3158,7 @@ nsCacheService::CollectReports(nsIHandleReportCallback* aHandleReport, { size_t disk = 0; if (mDiskDevice) { - nsCacheServiceAutoLock - lock(LOCK_TELEM(NSCACHESERVICE_DISKDEVICEHEAPSIZE)); + nsCacheServiceAutoLock lock; disk = mDiskDevice->SizeOfIncludingThis(DiskCacheDeviceMallocSizeOf); } diff --git a/netwerk/cache/nsCacheService.h b/netwerk/cache/nsCacheService.h index 1751d4875..95816cfe5 100644 --- a/netwerk/cache/nsCacheService.h +++ b/netwerk/cache/nsCacheService.h @@ -371,9 +371,6 @@ private: * nsCacheServiceAutoLock ******************************************************************************/ -#define LOCK_TELEM(x) \ - (::mozilla::Telemetry::CACHE_SERVICE_LOCK_WAIT_MAINTHREAD_##x) - // Instantiate this class to acquire the cache service lock for a particular // execution scope. class nsCacheServiceAutoLock { @@ -381,9 +378,6 @@ public: nsCacheServiceAutoLock() { nsCacheService::Lock(); } - explicit nsCacheServiceAutoLock(mozilla::Telemetry::ID mainThreadLockerID) { - nsCacheService::Lock(mainThreadLockerID); - } ~nsCacheServiceAutoLock() { nsCacheService::Unlock(); } diff --git a/netwerk/cache2/CacheEntry.cpp b/netwerk/cache2/CacheEntry.cpp index b79bf7373..51e441aa7 100644 --- a/netwerk/cache2/CacheEntry.cpp +++ b/netwerk/cache2/CacheEntry.cpp @@ -419,11 +419,6 @@ bool CacheEntry::Load(bool aTruncate, bool aPriority) { mozilla::MutexAutoUnlock unlock(mLock); - if (reportMiss) { - CacheFileUtils::DetailedCacheHitTelemetry::AddRecord( - CacheFileUtils::DetailedCacheHitTelemetry::MISS, mLoadStart); - } - LOG((" performing load, file=%p", mFile.get())); if (NS_SUCCEEDED(rv)) { rv = mFile->Init(fileKey, @@ -458,16 +453,6 @@ NS_IMETHODIMP CacheEntry::OnFileReady(nsresult aResult, bool aIsNew) MOZ_ASSERT(!mLoadStart.IsNull()); - if (NS_SUCCEEDED(aResult)) { - if (aIsNew) { - CacheFileUtils::DetailedCacheHitTelemetry::AddRecord( - CacheFileUtils::DetailedCacheHitTelemetry::MISS, mLoadStart); - } else { - CacheFileUtils::DetailedCacheHitTelemetry::AddRecord( - CacheFileUtils::DetailedCacheHitTelemetry::HIT, mLoadStart); - } - } - // OnFileReady, that is the only code that can transit from LOADING // to any follow-on state and can only be invoked ones on an entry. // Until this moment there is no consumer that could manipulate diff --git a/netwerk/cache2/CacheFile.cpp b/netwerk/cache2/CacheFile.cpp index ce771c754..69fc3d33c 100644 --- a/netwerk/cache2/CacheFile.cpp +++ b/netwerk/cache2/CacheFile.cpp @@ -1865,33 +1865,6 @@ CacheFile::Truncate(int64_t aOffset) return NS_OK; } -static uint32_t -StatusToTelemetryEnum(nsresult aStatus) -{ - if (NS_SUCCEEDED(aStatus)) { - return 0; - } - - switch (aStatus) { - case NS_BASE_STREAM_CLOSED: - return 0; // Log this as a success - case NS_ERROR_OUT_OF_MEMORY: - return 2; - case NS_ERROR_FILE_DISK_FULL: - return 3; - case NS_ERROR_FILE_CORRUPTED: - return 4; - case NS_ERROR_FILE_NOT_FOUND: - return 5; - case NS_BINDING_ABORTED: - return 6; - default: - return 1; // other error - } - - NS_NOTREACHED("We should never get here"); -} - nsresult CacheFile::RemoveInput(CacheFileInputStream *aInput, nsresult aStatus) { diff --git a/netwerk/cache2/CacheFileIOManager.cpp b/netwerk/cache2/CacheFileIOManager.cpp index f6b499e47..25e621d12 100644 --- a/netwerk/cache2/CacheFileIOManager.cpp +++ b/netwerk/cache2/CacheFileIOManager.cpp @@ -3822,44 +3822,6 @@ CacheFileIOManager::CreateCacheTree() StartRemovingTrash(); - if (!CacheObserver::CacheFSReported()) { - uint32_t fsType = 4; // Other OS - -#ifdef XP_WIN - nsAutoString target; - nsresult rv = mCacheDirectory->GetTarget(target); - if (NS_FAILED(rv)) { - return NS_OK; - } - - wchar_t volume_path[MAX_PATH + 1] = { 0 }; - if (!::GetVolumePathNameW(target.get(), - volume_path, - mozilla::ArrayLength(volume_path))) { - return NS_OK; - } - - wchar_t fsName[6] = { 0 }; - if (!::GetVolumeInformationW(volume_path, nullptr, 0, nullptr, nullptr, - nullptr, fsName, - mozilla::ArrayLength(fsName))) { - return NS_OK; - } - - if (wcscmp(fsName, L"NTFS") == 0) { - fsType = 0; - } else if (wcscmp(fsName, L"FAT32") == 0) { - fsType = 1; - } else if (wcscmp(fsName, L"FAT") == 0) { - fsType = 2; - } else { - fsType = 3; - } -#endif - - CacheObserver::SetCacheFSReported(); - } - return NS_OK; } @@ -3905,16 +3867,6 @@ CacheFileIOManager::OpenNSPRHandle(CacheFileHandle *aHandle, bool aCreate) LOG(("CacheFileIOManager::OpenNSPRHandle() - Successfully evicted entry" " with hash %08x%08x%08x%08x%08x. %s to create the new file.", LOGSHA1(&hash), NS_SUCCEEDED(rv) ? "Succeeded" : "Failed")); - - // Report the full size only once per session - static bool sSizeReported = false; - if (!sSizeReported) { - uint32_t cacheUsage; - if (NS_SUCCEEDED(CacheIndex::GetCacheSize(&cacheUsage))) { - cacheUsage >>= 10; - sSizeReported = true; - } - } } else { LOG(("CacheFileIOManager::OpenNSPRHandle() - Couldn't evict an existing" " entry.")); diff --git a/netwerk/cache2/CacheFileUtils.cpp b/netwerk/cache2/CacheFileUtils.cpp index fe1a53b3d..a090a9cb1 100644 --- a/netwerk/cache2/CacheFileUtils.cpp +++ b/netwerk/cache2/CacheFileUtils.cpp @@ -401,101 +401,6 @@ ValidityMap::operator[](uint32_t aIdx) return mMap.ElementAt(aIdx); } -StaticMutex DetailedCacheHitTelemetry::sLock; -uint32_t DetailedCacheHitTelemetry::sRecordCnt = 0; -DetailedCacheHitTelemetry::HitRate DetailedCacheHitTelemetry::sHRStats[kNumOfRanges]; - -DetailedCacheHitTelemetry::HitRate::HitRate() -{ - Reset(); -} - -void -DetailedCacheHitTelemetry::HitRate::AddRecord(ERecType aType) -{ - if (aType == HIT) { - ++mHitCnt; - } else { - ++mMissCnt; - } -} - -uint32_t -DetailedCacheHitTelemetry::HitRate::GetHitRateBucket(uint32_t aNumOfBuckets) const -{ - uint32_t bucketIdx = (aNumOfBuckets * mHitCnt) / (mHitCnt + mMissCnt); - if (bucketIdx == aNumOfBuckets) { // make sure 100% falls into the last bucket - --bucketIdx; - } - - return bucketIdx; -} - -uint32_t -DetailedCacheHitTelemetry::HitRate::Count() -{ - return mHitCnt + mMissCnt; -} - -void -DetailedCacheHitTelemetry::HitRate::Reset() -{ - mHitCnt = 0; - mMissCnt = 0; -} - -// static -void -DetailedCacheHitTelemetry::AddRecord(ERecType aType, TimeStamp aLoadStart) -{ - bool isUpToDate = false; - CacheIndex::IsUpToDate(&isUpToDate); - if (!isUpToDate) { - // Ignore the record when the entry file count might be incorrect - return; - } - - uint32_t entryCount; - nsresult rv = CacheIndex::GetEntryFileCount(&entryCount); - if (NS_FAILED(rv)) { - return; - } - - uint32_t rangeIdx = entryCount / kRangeSize; - if (rangeIdx >= kNumOfRanges) { // The last range has no upper limit. - rangeIdx = kNumOfRanges - 1; - } - - uint32_t hitMissValue = 2 * rangeIdx; // 2 values per range - if (aType == MISS) { // The order is HIT, MISS - ++hitMissValue; - } - - StaticMutexAutoLock lock(sLock); - - sHRStats[rangeIdx].AddRecord(aType); - ++sRecordCnt; - - if (sRecordCnt < kTotalSamplesReportLimit) { - return; - } - - sRecordCnt = 0; - - for (uint32_t i = 0; i < kNumOfRanges; ++i) { - if (sHRStats[i].Count() >= kHitRateSamplesReportLimit) { - // The telemetry enums are grouped by buckets as follows: - // Telemetry value : 0,1,2,3, ... ,19,20,21,22, ... ,398,399 - // Hit rate bucket : 0,0,0,0, ... , 0, 1, 1, 1, ... , 19, 19 - // Cache size range: 0,1,2,3, ... ,19, 0, 1, 2, ... , 18, 19 - uint32_t bucketOffset = sHRStats[i].GetHitRateBucket(kHitRateBuckets) * - kNumOfRanges; - - sHRStats[i].Reset(); - } - } -} - void FreeBuffer(void *aBuf) { #ifndef NS_FREE_PERMANENT_DATA diff --git a/netwerk/cache2/CacheFileUtils.h b/netwerk/cache2/CacheFileUtils.h index 13acfd71d..b66f0adf1 100644 --- a/netwerk/cache2/CacheFileUtils.h +++ b/netwerk/cache2/CacheFileUtils.h @@ -10,7 +10,6 @@ #include "nsString.h" #include "nsTArray.h" #include "mozilla/StaticMutex.h" -#include "mozilla/TimeStamp.h" class nsILoadContextInfo; class nsACString; @@ -90,64 +89,6 @@ private: nsTArray<ValidityPair> mMap; }; - -class DetailedCacheHitTelemetry { -public: - enum ERecType { - HIT = 0, - MISS = 1 - }; - - static void AddRecord(ERecType aType, TimeStamp aLoadStart); - -private: - class HitRate { - public: - HitRate(); - - void AddRecord(ERecType aType); - // Returns the bucket index that the current hit rate falls into according - // to the given aNumOfBuckets. - uint32_t GetHitRateBucket(uint32_t aNumOfBuckets) const; - uint32_t Count(); - void Reset(); - - private: - uint32_t mHitCnt; - uint32_t mMissCnt; - }; - - // Group the hits and misses statistics by cache files count ranges (0-5000, - // 5001-10000, ... , 95001- ) - static const uint32_t kRangeSize = 5000; - static const uint32_t kNumOfRanges = 20; - - // Use the same ranges to report an average hit rate. Report the hit rates - // (and reset the counters) every kTotalSamplesReportLimit samples. - static const uint32_t kTotalSamplesReportLimit = 1000; - - // Report hit rate for a given cache size range only if it contains - // kHitRateSamplesReportLimit or more samples. This limit should avoid - // reporting a biased statistics. - static const uint32_t kHitRateSamplesReportLimit = 500; - - // All hit rates are accumulated in a single telemetry probe, so to use - // a sane number of enumerated values the hit rate is divided into buckets - // instead of using a percent value. This constant defines number of buckets - // that we divide the hit rates into. I.e. we'll report ranges 0%-5%, 5%-10%, - // 10-%15%, ... - static const uint32_t kHitRateBuckets = 20; - - // Protects sRecordCnt and sHitStats calls. - static StaticMutex sLock; - - // Counter of samples that is compared against kTotalSamplesReportLimit. - static uint32_t sRecordCnt; - - // Hit rate statistics for every cache size range. - static HitRate sHRStats[kNumOfRanges]; -}; - void FreeBuffer(void *aBuf); diff --git a/netwerk/cache2/CacheIOThread.cpp b/netwerk/cache2/CacheIOThread.cpp index d51f61b0f..2fbc0ccce 100644 --- a/netwerk/cache2/CacheIOThread.cpp +++ b/netwerk/cache2/CacheIOThread.cpp @@ -18,54 +18,6 @@ namespace mozilla { namespace net { -namespace { // anon - -class CacheIOTelemetry -{ -public: - typedef CacheIOThread::EventQueue::size_type size_type; - static size_type mMinLengthToReport[CacheIOThread::LAST_LEVEL]; - static void Report(uint32_t aLevel, size_type aLength); -}; - -static CacheIOTelemetry::size_type const kGranularity = 30; - -CacheIOTelemetry::size_type -CacheIOTelemetry::mMinLengthToReport[CacheIOThread::LAST_LEVEL] = { - kGranularity, kGranularity, kGranularity, kGranularity, - kGranularity, kGranularity, kGranularity, kGranularity -}; - -// static -void CacheIOTelemetry::Report(uint32_t aLevel, CacheIOTelemetry::size_type aLength) -{ - if (mMinLengthToReport[aLevel] > aLength) { - return; - } - - static Telemetry::ID telemetryID[] = { - Telemetry::HTTP_CACHE_IO_QUEUE_2_OPEN_PRIORITY, - Telemetry::HTTP_CACHE_IO_QUEUE_2_READ_PRIORITY, - Telemetry::HTTP_CACHE_IO_QUEUE_2_MANAGEMENT, - Telemetry::HTTP_CACHE_IO_QUEUE_2_OPEN, - Telemetry::HTTP_CACHE_IO_QUEUE_2_READ, - Telemetry::HTTP_CACHE_IO_QUEUE_2_WRITE_PRIORITY, - Telemetry::HTTP_CACHE_IO_QUEUE_2_WRITE, - Telemetry::HTTP_CACHE_IO_QUEUE_2_INDEX, - Telemetry::HTTP_CACHE_IO_QUEUE_2_EVICT - }; - - // Each bucket is a multiply of kGranularity (30, 60, 90..., 300+) - aLength = (aLength / kGranularity); - // Next time report only when over the current length + kGranularity - mMinLengthToReport[aLevel] = (aLength + 1) * kGranularity; - - // 10 is number of buckets we have in each probe - aLength = std::min<size_type>(aLength, 10); -} - -} // anon - namespace detail { /** @@ -525,7 +477,6 @@ void CacheIOThread::LoopOneLevel(uint32_t aLevel) mCurrentlyExecutingLevel = aLevel; bool returnEvents = false; - bool reportTelementry = true; EventQueue::size_type index; { @@ -539,11 +490,6 @@ void CacheIOThread::LoopOneLevel(uint32_t aLevel) break; } - if (reportTelementry) { - reportTelementry = false; - CacheIOTelemetry::Report(aLevel, length); - } - // Drop any previous flagging, only an event on the current level may set // this flag. mRerunCurrentEvent = false; diff --git a/netwerk/cache2/CacheIndex.cpp b/netwerk/cache2/CacheIndex.cpp index 1009aeaf8..2c6451d72 100644 --- a/netwerk/cache2/CacheIndex.cpp +++ b/netwerk/cache2/CacheIndex.cpp @@ -20,7 +20,6 @@ #include "nsITimer.h" #include "mozilla/AutoRestore.h" #include <algorithm> -#include "mozilla/Telemetry.h" #include "mozilla/Unused.h" @@ -1295,29 +1294,6 @@ CacheIndex::GetCacheSize(uint32_t *_retval) // static nsresult -CacheIndex::GetEntryFileCount(uint32_t *_retval) -{ - LOG(("CacheIndex::GetEntryFileCount()")); - - StaticMutexAutoLock lock(sLock); - - RefPtr<CacheIndex> index = gInstance; - - if (!index) { - return NS_ERROR_NOT_INITIALIZED; - } - - if (!index->IsIndexUsable()) { - return NS_ERROR_NOT_AVAILABLE; - } - - *_retval = index->mIndexStats.ActiveEntriesCount(); - LOG(("CacheIndex::GetEntryFileCount() - returning %u", *_retval)); - return NS_OK; -} - -// static -nsresult CacheIndex::GetCacheStats(nsILoadContextInfo *aInfo, uint32_t *aSize, uint32_t *aCount) { LOG(("CacheIndex::GetCacheStats() [info=%p]", aInfo)); @@ -3167,11 +3143,6 @@ CacheIndex::ChangeState(EState aNewState) return; } - if ((mState == READING || mState == BUILDING || mState == UPDATING) && - aNewState == READY) { - ReportHashStats(); - } - // Try to evict entries over limit everytime we're leaving state READING, // BUILDING or UPDATING, but not during shutdown or when removing all // entries. @@ -3720,75 +3691,6 @@ CacheIndex::SizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf) return mallocSizeOf(gInstance) + SizeOfExcludingThis(mallocSizeOf); } -namespace { - -class HashComparator -{ -public: - bool Equals(CacheIndexRecord* a, CacheIndexRecord* b) const { - return memcmp(&a->mHash, &b->mHash, sizeof(SHA1Sum::Hash)) == 0; - } - bool LessThan(CacheIndexRecord* a, CacheIndexRecord* b) const { - return memcmp(&a->mHash, &b->mHash, sizeof(SHA1Sum::Hash)) < 0; - } -}; - -void -ReportHashSizeMatch(const SHA1Sum::Hash *aHash1, const SHA1Sum::Hash *aHash2) -{ - const uint32_t *h1 = reinterpret_cast<const uint32_t *>(aHash1); - const uint32_t *h2 = reinterpret_cast<const uint32_t *>(aHash2); - - for (uint32_t i = 0; i < 5; ++i) { - if (h1[i] != h2[i]) { - uint32_t bitsDiff = h1[i] ^ h2[i]; - bitsDiff = NetworkEndian::readUint32(&bitsDiff); - - // count leading zeros in bitsDiff - static const uint8_t debruijn32[32] = - { 0, 31, 9, 30, 3, 8, 13, 29, 2, 5, 7, 21, 12, 24, 28, 19, - 1, 10, 4, 14, 6, 22, 25, 20, 11, 15, 23, 26, 16, 27, 17, 18}; - - bitsDiff |= bitsDiff>>1; - bitsDiff |= bitsDiff>>2; - bitsDiff |= bitsDiff>>4; - bitsDiff |= bitsDiff>>8; - bitsDiff |= bitsDiff>>16; - bitsDiff++; - - uint8_t hashSizeMatch = debruijn32[bitsDiff*0x076be629>>27] + (i<<5); - - return; - } - } - - MOZ_ASSERT(false, "Found a collision in the index!"); -} - -} // namespace - -void -CacheIndex::ReportHashStats() -{ - // We're gathering the hash stats only once, exclude too small caches. - if (CacheObserver::HashStatsReported() || mFrecencyArray.Length() < 15000) { - return; - } - - nsTArray<CacheIndexRecord *> records; - for (auto iter = mFrecencyArray.Iter(); !iter.Done(); iter.Next()) { - records.AppendElement(iter.Get()); - } - - records.Sort(HashComparator()); - - for (uint32_t i = 1; i < records.Length(); i++) { - ReportHashSizeMatch(&records[i-1]->mHash, &records[i]->mHash); - } - - CacheObserver::SetHashStatsReported(); -} - // static void CacheIndex::OnAsyncEviction(bool aEvicting) diff --git a/netwerk/cache2/CacheIndex.h b/netwerk/cache2/CacheIndex.h index dc72c346f..acb3bdd25 100644 --- a/netwerk/cache2/CacheIndex.h +++ b/netwerk/cache2/CacheIndex.h @@ -662,9 +662,6 @@ public: // Returns cache size in kB. static nsresult GetCacheSize(uint32_t *_retval); - // Returns number of entry files in the cache - static nsresult GetEntryFileCount(uint32_t *_retval); - // Synchronously returns the disk occupation and number of entries per-context. // Callable on any thread. static nsresult GetCacheStats(nsILoadContextInfo *aInfo, uint32_t *aSize, uint32_t *aCount); @@ -918,8 +915,6 @@ private: // Memory reporting (private part) size_t SizeOfExcludingThisInternal(mozilla::MallocSizeOf mallocSizeOf) const; - void ReportHashStats(); - static mozilla::StaticRefPtr<CacheIndex> gInstance; static StaticMutex sLock; diff --git a/netwerk/cache2/CacheObserver.cpp b/netwerk/cache2/CacheObserver.cpp index 6b6d89395..32e0dff95 100644 --- a/netwerk/cache2/CacheObserver.cpp +++ b/netwerk/cache2/CacheObserver.cpp @@ -86,12 +86,6 @@ bool CacheObserver::sSanitizeOnShutdown = kDefaultSanitizeOnShutdown; static bool kDefaultClearCacheOnShutdown = false; bool CacheObserver::sClearCacheOnShutdown = kDefaultClearCacheOnShutdown; -static bool kDefaultCacheFSReported = false; -bool CacheObserver::sCacheFSReported = kDefaultCacheFSReported; - -static bool kDefaultHashStatsReported = false; -bool CacheObserver::sHashStatsReported = kDefaultHashStatsReported; - static uint32_t const kDefaultMaxShutdownIOLag = 2; // seconds Atomic<uint32_t, Relaxed> CacheObserver::sMaxShutdownIOLag(kDefaultMaxShutdownIOLag); @@ -331,58 +325,6 @@ CacheObserver::StoreDiskCacheCapacity() } // static -void -CacheObserver::SetCacheFSReported() -{ - sCacheFSReported = true; - - if (!sSelf) { - return; - } - - if (NS_IsMainThread()) { - sSelf->StoreCacheFSReported(); - } else { - nsCOMPtr<nsIRunnable> event = - NewRunnableMethod(sSelf, &CacheObserver::StoreCacheFSReported); - NS_DispatchToMainThread(event); - } -} - -void -CacheObserver::StoreCacheFSReported() -{ - mozilla::Preferences::SetInt("browser.cache.disk.filesystem_reported", - sCacheFSReported); -} - -// static -void -CacheObserver::SetHashStatsReported() -{ - sHashStatsReported = true; - - if (!sSelf) { - return; - } - - if (NS_IsMainThread()) { - sSelf->StoreHashStatsReported(); - } else { - nsCOMPtr<nsIRunnable> event = - NewRunnableMethod(sSelf, &CacheObserver::StoreHashStatsReported); - NS_DispatchToMainThread(event); - } -} - -void -CacheObserver::StoreHashStatsReported() -{ - mozilla::Preferences::SetInt("browser.cache.disk.hashstats_reported", - sHashStatsReported); -} - -// static void CacheObserver::ParentDirOverride(nsIFile** aDir) { if (NS_WARN_IF(!aDir)) diff --git a/netwerk/cache2/CacheObserver.h b/netwerk/cache2/CacheObserver.h index 62e5bbc6e..ccdd89030 100644 --- a/netwerk/cache2/CacheObserver.h +++ b/netwerk/cache2/CacheObserver.h @@ -61,12 +61,6 @@ class CacheObserver : public nsIObserver { return sHalfLifeExperiment; } static bool ClearCacheOnShutdown() { return sSanitizeOnShutdown && sClearCacheOnShutdown; } - static bool CacheFSReported() - { return sCacheFSReported; } - static void SetCacheFSReported(); - static bool HashStatsReported() - { return sHashStatsReported; } - static void SetHashStatsReported(); static void ParentDirOverride(nsIFile ** aDir); static bool EntryIsTooBig(int64_t aSize, bool aUsingDisk); @@ -82,8 +76,6 @@ private: static CacheObserver* sSelf; void StoreDiskCacheCapacity(); - void StoreCacheFSReported(); - void StoreHashStatsReported(); void AttachToPreferences(); static uint32_t sUseNewCache; @@ -106,8 +98,6 @@ private: static int32_t sHalfLifeExperiment; static bool sSanitizeOnShutdown; static bool sClearCacheOnShutdown; - static bool sCacheFSReported; - static bool sHashStatsReported; static Atomic<uint32_t, Relaxed> sMaxShutdownIOLag; static Atomic<PRIntervalTime> sShutdownDemandedTime; diff --git a/netwerk/cookie/nsCookieService.cpp b/netwerk/cookie/nsCookieService.cpp index ea54dbd61..7bc5abcd1 100644 --- a/netwerk/cookie/nsCookieService.cpp +++ b/netwerk/cookie/nsCookieService.cpp @@ -3311,13 +3311,6 @@ nsCookieService::SetCookieInternal(nsIURI *aHostURI, // so we can handle them separately. bool newCookie = ParseAttributes(aCookieHeader, cookieAttributes); - // Collect telemetry on how often secure cookies are set from non-secure - // origins, and vice-versa. - // - // 0 = nonsecure and "http:" - // 1 = nonsecure and "https:" - // 2 = secure and "http:" - // 3 = secure and "https:" bool isHTTPS; nsresult rv = aHostURI->SchemeIs("https", &isHTTPS); diff --git a/netwerk/protocol/http/Http2Compression.cpp b/netwerk/protocol/http/Http2Compression.cpp index 64fd05a17..9206f8b4c 100644 --- a/netwerk/protocol/http/Http2Compression.cpp +++ b/netwerk/protocol/http/Http2Compression.cpp @@ -402,7 +402,7 @@ Http2Decompressor::DecodeHeaderBlock(const uint8_t *data, uint32_t datalen, nsresult rv = NS_OK; nsresult softfail_rv = NS_OK; - while (NS_SUCCEEDED(rv) && (mOffset < datalen)) { + while (NS_SUCCEEDED(rv) && (mOffset < mDataLen)) { bool modifiesTable = true; if (mData[mOffset] & 0x80) { rv = DoIndexed(); @@ -684,6 +684,11 @@ nsresult Http2Decompressor::DecodeFinalHuffmanCharacter(const HuffmanIncomingTable *table, uint8_t &c, uint8_t &bitsLeft) { + MOZ_ASSERT(mOffset <= mDataLen); + if (mOffset > mDataLen) { + NS_WARNING("DecodeFinalHuffmanCharacter trying to read beyond end of buffer"); + return NS_ERROR_FAILURE; + } uint8_t mask = (1 << bitsLeft) - 1; uint8_t idx = mData[mOffset - 1] & mask; idx <<= (8 - bitsLeft); @@ -721,6 +726,7 @@ Http2Decompressor::DecodeFinalHuffmanCharacter(const HuffmanIncomingTable *table uint8_t Http2Decompressor::ExtractByte(uint8_t bitsLeft, uint32_t &bytesConsumed) { + MOZ_DIAGNOSTIC_ASSERT(mOffset < mDataLen); uint8_t rv; if (bitsLeft) { @@ -750,8 +756,8 @@ Http2Decompressor::DecodeHuffmanCharacter(const HuffmanIncomingTable *table, uint8_t idx = ExtractByte(bitsLeft, bytesConsumed); if (table->IndexHasANextTable(idx)) { - if (bytesConsumed >= mDataLen) { - if (!bitsLeft || (bytesConsumed > mDataLen)) { + if (mOffset >= mDataLen) { + if (!bitsLeft || (mOffset > mDataLen)) { // TODO - does this get me into trouble in the new world? // No info left in input to try to consume, we're done LOG(("DecodeHuffmanCharacter all out of bits to consume, can't chain")); @@ -892,6 +898,13 @@ Http2Decompressor::DoLiteralInternal(nsACString &name, nsACString &value, return rv; } + // sanity check + if (mOffset >= mDataLen) { + NS_WARNING("Http2 Decompressor ran out of data"); + // This is session-fatal + return NS_ERROR_FAILURE; + } + bool isHuffmanEncoded; if (!index) { @@ -919,6 +932,13 @@ Http2Decompressor::DoLiteralInternal(nsACString &name, nsACString &value, return rv; } + // sanity check + if (mOffset >= mDataLen) { + NS_WARNING("Http2 Decompressor ran out of data"); + // This is session-fatal + return NS_ERROR_FAILURE; + } + // now the value uint32_t valueLen; isHuffmanEncoded = mData[mOffset] & (1 << 7); diff --git a/netwerk/protocol/http/HttpBaseChannel.cpp b/netwerk/protocol/http/HttpBaseChannel.cpp index c4e764d26..03123ceb0 100644 --- a/netwerk/protocol/http/HttpBaseChannel.cpp +++ b/netwerk/protocol/http/HttpBaseChannel.cpp @@ -1665,13 +1665,7 @@ HttpBaseChannel::SetRequestHeader(const nsACString& aHeader, return NS_ERROR_INVALID_ARG; } - nsHttpAtom atom = nsHttp::ResolveAtom(flatHeader.get()); - if (!atom) { - NS_WARNING("failed to resolve atom"); - return NS_ERROR_NOT_AVAILABLE; - } - - return mRequestHead.SetHeader(atom, flatValue, aMerge); + return mRequestHead.SetHeader(aHeader, flatValue, aMerge); } NS_IMETHODIMP @@ -1688,13 +1682,7 @@ HttpBaseChannel::SetEmptyRequestHeader(const nsACString& aHeader) return NS_ERROR_INVALID_ARG; } - nsHttpAtom atom = nsHttp::ResolveAtom(flatHeader.get()); - if (!atom) { - NS_WARNING("failed to resolve atom"); - return NS_ERROR_NOT_AVAILABLE; - } - - return mRequestHead.SetEmptyHeader(atom); + return mRequestHead.SetEmptyHeader(aHeader); } NS_IMETHODIMP @@ -1750,7 +1738,7 @@ HttpBaseChannel::SetResponseHeader(const nsACString& header, mResponseHeadersModified = true; - return mResponseHead->SetHeader(atom, value, merge); + return mResponseHead->SetHeader(header, value, merge); } NS_IMETHODIMP diff --git a/netwerk/protocol/http/PHttpChannelParams.h b/netwerk/protocol/http/PHttpChannelParams.h index 4df5c7832..b04f57306 100644 --- a/netwerk/protocol/http/PHttpChannelParams.h +++ b/netwerk/protocol/http/PHttpChannelParams.h @@ -98,7 +98,11 @@ struct ParamTraits<mozilla::net::nsHttpHeaderArray::nsEntry> static void Write(Message* aMsg, const paramType& aParam) { - WriteParam(aMsg, aParam.header); + if (aParam.headerNameOriginal.IsEmpty()) { + WriteParam(aMsg, aParam.header); + } else { + WriteParam(aMsg, aParam.headerNameOriginal); + } WriteParam(aMsg, aParam.value); switch (aParam.variety) { case mozilla::net::nsHttpHeaderArray::eVarietyUnknown: @@ -124,11 +128,18 @@ struct ParamTraits<mozilla::net::nsHttpHeaderArray::nsEntry> static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult) { uint8_t variety; - if (!ReadParam(aMsg, aIter, &aResult->header) || + nsAutoCString header; + if (!ReadParam(aMsg, aIter, &header) || !ReadParam(aMsg, aIter, &aResult->value) || !ReadParam(aMsg, aIter, &variety)) return false; + mozilla::net::nsHttpAtom atom = mozilla::net::nsHttp::ResolveAtom(header); + aResult->header = atom; + if (!header.Equals(atom.get())) { + aResult->headerNameOriginal = header; + } + switch (variety) { case 0: aResult->variety = mozilla::net::nsHttpHeaderArray::eVarietyUnknown; diff --git a/netwerk/protocol/http/nsHttpChannel.cpp b/netwerk/protocol/http/nsHttpChannel.cpp index bb0b3ca77..be5539a02 100644 --- a/netwerk/protocol/http/nsHttpChannel.cpp +++ b/netwerk/protocol/http/nsHttpChannel.cpp @@ -313,11 +313,15 @@ nsHttpChannel::nsHttpChannel() , mPushedStream(nullptr) , mLocalBlocklist(false) , mWarningReporter(nullptr) + , mSendUpgradeRequest(false) , mDidReval(false) { LOG(("Creating nsHttpChannel [this=%p]\n", this)); mChannelCreationTime = PR_Now(); mChannelCreationTimestamp = TimeStamp::Now(); + + mSendUpgradeRequest = + Preferences::GetBool("network.http.upgrade-insecure-requests", false); } nsHttpChannel::~nsHttpChannel() @@ -377,8 +381,9 @@ nsHttpChannel::Connect() mLoadInfo->GetExternalContentPolicyType() : nsIContentPolicy::TYPE_OTHER; - if (type == nsIContentPolicy::TYPE_DOCUMENT || - type == nsIContentPolicy::TYPE_SUBDOCUMENT) { + if (mSendUpgradeRequest && + (type == nsIContentPolicy::TYPE_DOCUMENT || + type == nsIContentPolicy::TYPE_SUBDOCUMENT)) { rv = SetRequestHeader(NS_LITERAL_CSTRING("Upgrade-Insecure-Requests"), NS_LITERAL_CSTRING("1"), false); NS_ENSURE_SUCCESS(rv, rv); diff --git a/netwerk/protocol/http/nsHttpChannel.h b/netwerk/protocol/http/nsHttpChannel.h index 2e24d6e81..152cf1503 100644 --- a/netwerk/protocol/http/nsHttpChannel.h +++ b/netwerk/protocol/http/nsHttpChannel.h @@ -597,6 +597,10 @@ private: HttpChannelSecurityWarningReporter* mWarningReporter; RefPtr<ADivertableParentChannel> mParentChannel; + + // Whether we send opportunistic encryption requests. + bool mSendUpgradeRequest; + protected: virtual void DoNotifyListenerCleanup() override; diff --git a/netwerk/protocol/http/nsHttpConnectionInfo.cpp b/netwerk/protocol/http/nsHttpConnectionInfo.cpp index e965fd1cc..93a40843c 100644 --- a/netwerk/protocol/http/nsHttpConnectionInfo.cpp +++ b/netwerk/protocol/http/nsHttpConnectionInfo.cpp @@ -15,32 +15,26 @@ #include "nsHttpConnectionInfo.h" #include "mozilla/net/DNS.h" -#include "prnetdb.h" -#include "nsICryptoHash.h" #include "nsComponentManagerUtils.h" +#include "nsICryptoHash.h" #include "nsIProtocolProxyService.h" +#include "nsNetCID.h" +#include "prnetdb.h" static nsresult SHA256(const char* aPlainText, nsAutoCString& aResult) { - static nsICryptoHash* hasher = nullptr; nsresult rv; - if (!hasher) { - rv = CallCreateInstance("@mozilla.org/security/hash;1", &hasher); - if (NS_FAILED(rv)) { - LOG(("nsHttpDigestAuth: no crypto hash!\n")); - return rv; - } + nsCOMPtr<nsICryptoHash> hasher = do_CreateInstance(NS_CRYPTO_HASH_CONTRACTID, &rv); + if (NS_FAILED(rv)) { + LOG(("nsHttpDigestAuth: no crypto hash!\n")); + return rv; } - rv = hasher->Init(nsICryptoHash::SHA256); NS_ENSURE_SUCCESS(rv, rv); - rv = hasher->Update((unsigned char*) aPlainText, strlen(aPlainText)); NS_ENSURE_SUCCESS(rv, rv); - - rv = hasher->Finish(false, aResult); - return rv; + return hasher->Finish(false, aResult); } namespace mozilla { diff --git a/netwerk/protocol/http/nsHttpHeaderArray.cpp b/netwerk/protocol/http/nsHttpHeaderArray.cpp index 670300dea..1030bc91e 100644 --- a/netwerk/protocol/http/nsHttpHeaderArray.cpp +++ b/netwerk/protocol/http/nsHttpHeaderArray.cpp @@ -18,12 +18,37 @@ namespace net { //----------------------------------------------------------------------------- // nsHttpHeaderArray <public> //----------------------------------------------------------------------------- + +nsresult +nsHttpHeaderArray::SetHeader(const nsACString &headerName, + const nsACString &value, + bool merge, + nsHttpHeaderArray::HeaderVariety variety) +{ + nsHttpAtom header = nsHttp::ResolveAtom(PromiseFlatCString(headerName).get()); + if (!header) { + NS_WARNING("failed to resolve atom"); + return NS_ERROR_NOT_AVAILABLE; + } + return SetHeader(header, headerName, value, merge, variety); +} + nsresult nsHttpHeaderArray::SetHeader(nsHttpAtom header, const nsACString &value, bool merge, nsHttpHeaderArray::HeaderVariety variety) { + return SetHeader(header, EmptyCString(), value, merge, variety); +} + +nsresult +nsHttpHeaderArray::SetHeader(nsHttpAtom header, + const nsACString &headerName, + const nsACString &value, + bool merge, + nsHttpHeaderArray::HeaderVariety variety) +{ MOZ_ASSERT((variety == eVarietyResponse) || (variety == eVarietyRequestDefault) || (variety == eVarietyRequestOverride), @@ -51,7 +76,7 @@ nsHttpHeaderArray::SetHeader(nsHttpAtom header, MOZ_ASSERT(!entry || variety != eVarietyRequestDefault, "Cannot set default entry which overrides existing entry!"); if (!entry) { - return SetHeader_internal(header, value, variety); + return SetHeader_internal(header, headerName, value, variety); } else if (merge && !IsSingletonHeader(header)) { return MergeHeader(header, entry, value, variety); } else { @@ -59,7 +84,7 @@ nsHttpHeaderArray::SetHeader(nsHttpAtom header, if (entry->variety == eVarietyResponseNetOriginalAndResponse) { MOZ_ASSERT(variety == eVarietyResponse); entry->variety = eVarietyResponseNetOriginal; - return SetHeader_internal(header, value, variety); + return SetHeader_internal(header, headerName, value, variety); } else { entry->value = value; entry->variety = variety; @@ -71,6 +96,7 @@ nsHttpHeaderArray::SetHeader(nsHttpAtom header, nsresult nsHttpHeaderArray::SetHeader_internal(nsHttpAtom header, + const nsACString &headerName, const nsACString &value, nsHttpHeaderArray::HeaderVariety variety) { @@ -79,14 +105,26 @@ nsHttpHeaderArray::SetHeader_internal(nsHttpAtom header, return NS_ERROR_OUT_OF_MEMORY; } entry->header = header; + // Only save original form of a header if it is different than the header + // atom string. + if (!headerName.Equals(header.get())) { + entry->headerNameOriginal = headerName; + } entry->value = value; entry->variety = variety; return NS_OK; } nsresult -nsHttpHeaderArray::SetEmptyHeader(nsHttpAtom header, HeaderVariety variety) +nsHttpHeaderArray::SetEmptyHeader(const nsACString &headerName, + HeaderVariety variety) { + nsHttpAtom header = nsHttp::ResolveAtom(PromiseFlatCString(headerName).get()); + if (!header) { + NS_WARNING("failed to resolve atom"); + return NS_ERROR_NOT_AVAILABLE; + } + MOZ_ASSERT((variety == eVarietyResponse) || (variety == eVarietyRequestDefault) || (variety == eVarietyRequestOverride), @@ -104,11 +142,12 @@ nsHttpHeaderArray::SetEmptyHeader(nsHttpAtom header, HeaderVariety variety) entry->variety = eVarietyResponseNetOriginal; } - return SetHeader_internal(header, EmptyCString(), variety); + return SetHeader_internal(header, headerName, EmptyCString(), variety); } nsresult nsHttpHeaderArray::SetHeaderFromNet(nsHttpAtom header, + const nsACString &headerNameOriginal, const nsACString &value, bool response) { @@ -125,7 +164,7 @@ nsHttpHeaderArray::SetHeaderFromNet(nsHttpAtom header, LOG(("Ignoring Empty Header: %s\n", header.get())); if (response) { // Set header as original but not as response header. - return SetHeader_internal(header, value, + return SetHeader_internal(header, headerNameOriginal, value, eVarietyResponseNetOriginal); } return NS_OK; // ignore empty headers by default @@ -135,7 +174,7 @@ nsHttpHeaderArray::SetHeaderFromNet(nsHttpAtom header, if (response) { variety = eVarietyResponseNetOriginalAndResponse; } - return SetHeader_internal(header, value, variety); + return SetHeader_internal(header, headerNameOriginal, value, variety); } else if (!IsSingletonHeader(header)) { HeaderVariety variety = eVarietyRequestOverride; @@ -147,7 +186,7 @@ nsHttpHeaderArray::SetHeaderFromNet(nsHttpAtom header, return rv; } if (response) { - rv = SetHeader_internal(header, value, + rv = SetHeader_internal(header, headerNameOriginal, value, eVarietyResponseNetOriginal); } return rv; @@ -164,7 +203,7 @@ nsHttpHeaderArray::SetHeaderFromNet(nsHttpAtom header, } if (response) { - return SetHeader_internal(header, value, + return SetHeader_internal(header, headerNameOriginal, value, eVarietyResponseNetOriginal); } } @@ -174,6 +213,7 @@ nsHttpHeaderArray::SetHeaderFromNet(nsHttpAtom header, nsresult nsHttpHeaderArray::SetResponseHeaderFromCache(nsHttpAtom header, + const nsACString &headerNameOriginal, const nsACString &value, nsHttpHeaderArray::HeaderVariety variety) { @@ -183,7 +223,7 @@ nsHttpHeaderArray::SetResponseHeaderFromCache(nsHttpAtom header, "eVarietyResponseNetOriginal"); if (variety == eVarietyResponseNetOriginal) { - return SetHeader_internal(header, value, + return SetHeader_internal(header, headerNameOriginal, value, eVarietyResponseNetOriginal); } else { nsTArray<nsEntry>::index_type index = 0; @@ -203,7 +243,8 @@ nsHttpHeaderArray::SetResponseHeaderFromCache(nsHttpAtom header, } } while (index != mHeaders.NoIndex); // If we are here, we have not found an entry so add a new one. - return SetHeader_internal(header, value, eVarietyResponse); + return SetHeader_internal(header, headerNameOriginal, value, + eVarietyResponse); } } @@ -260,8 +301,16 @@ nsHttpHeaderArray::GetOriginalHeader(nsHttpAtom aHeader, if (entry.variety == eVarietyResponse) { continue; } + + nsAutoCString hdr; + if (entry.headerNameOriginal.IsEmpty()) { + hdr = nsDependentCString(entry.header); + } else { + hdr = entry.headerNameOriginal; + } + rv = NS_OK; - if (NS_FAILED(aVisitor->VisitHeader(nsDependentCString(entry.header), + if (NS_FAILED(aVisitor->VisitHeader(hdr, entry.value))) { break; } @@ -298,8 +347,14 @@ nsHttpHeaderArray::VisitHeaders(nsIHttpHeaderVisitor *visitor, nsHttpHeaderArray } else if (filter == eFilterResponseOriginal && entry.variety == eVarietyResponse) { continue; } - rv = visitor->VisitHeader( - nsDependentCString(entry.header), entry.value); + + nsAutoCString hdr; + if (entry.headerNameOriginal.IsEmpty()) { + hdr = nsDependentCString(entry.header); + } else { + hdr = entry.headerNameOriginal; + } + rv = visitor->VisitHeader(hdr, entry.value); if NS_FAILED(rv) { return rv; } @@ -310,6 +365,7 @@ nsHttpHeaderArray::VisitHeaders(nsIHttpHeaderVisitor *visitor, nsHttpHeaderArray /*static*/ nsresult nsHttpHeaderArray::ParseHeaderLine(const nsACString& line, nsHttpAtom *hdr, + nsACString *headerName, nsACString *val) { // @@ -360,6 +416,7 @@ nsHttpHeaderArray::ParseHeaderLine(const nsACString& line, // assign return values if (hdr) *hdr = atom; if (val) val->Assign(p, p2 - p + 1); + if (headerName) headerName->Assign(sub); return NS_OK; } @@ -397,7 +454,11 @@ nsHttpHeaderArray::Flatten(nsACString &buf, bool pruneProxyHeaders, continue; } - buf.Append(entry.header); + if (entry.headerNameOriginal.IsEmpty()) { + buf.Append(entry.header); + } else { + buf.Append(entry.headerNameOriginal); + } buf.AppendLiteral(": "); buf.Append(entry.value); buf.AppendLiteral("\r\n"); @@ -415,7 +476,11 @@ nsHttpHeaderArray::FlattenOriginalHeader(nsACString &buf) continue; } - buf.Append(entry.header); + if (entry.headerNameOriginal.IsEmpty()) { + buf.Append(entry.header); + } else { + buf.Append(entry.headerNameOriginal); + } buf.AppendLiteral(": "); buf.Append(entry.value); buf.AppendLiteral("\r\n"); @@ -423,11 +488,13 @@ nsHttpHeaderArray::FlattenOriginalHeader(nsACString &buf) } const char * -nsHttpHeaderArray::PeekHeaderAt(uint32_t index, nsHttpAtom &header) const +nsHttpHeaderArray::PeekHeaderAt(uint32_t index, nsHttpAtom &header, + nsACString &headerNameOriginal) const { const nsEntry &entry = mHeaders[index]; header = entry.header; + headerNameOriginal = entry.headerNameOriginal; return entry.value.get(); } diff --git a/netwerk/protocol/http/nsHttpHeaderArray.h b/netwerk/protocol/http/nsHttpHeaderArray.h index 91b91f04a..3ffdfa814 100644 --- a/netwerk/protocol/http/nsHttpHeaderArray.h +++ b/netwerk/protocol/http/nsHttpHeaderArray.h @@ -49,19 +49,30 @@ public: }; // Used by internal setters: to set header from network use SetHeaderFromNet + nsresult SetHeader(const nsACString &headerName, + const nsACString &value, + bool merge, HeaderVariety variety); nsresult SetHeader(nsHttpAtom header, const nsACString &value, bool merge, HeaderVariety variety); + nsresult SetHeader(nsHttpAtom header, + const nsACString &headerName, + const nsACString &value, + bool merge, HeaderVariety variety); // Used by internal setters to set an empty header - nsresult SetEmptyHeader(nsHttpAtom header, HeaderVariety variety); + nsresult SetEmptyHeader(const nsACString &headerName, HeaderVariety variety); // Merges supported headers. For other duplicate values, determines if error // needs to be thrown or 1st value kept. // For the response header we keep the original headers as well. - nsresult SetHeaderFromNet(nsHttpAtom header, const nsACString &value, + nsresult SetHeaderFromNet(nsHttpAtom header, + const nsACString &headerNameOriginal, + const nsACString &value, bool response); - nsresult SetResponseHeaderFromCache(nsHttpAtom header, const nsACString &value, + nsresult SetResponseHeaderFromCache(nsHttpAtom header, + const nsACString &headerNameOriginal, + const nsACString &value, HeaderVariety variety); nsresult GetHeader(nsHttpAtom header, nsACString &value) const; @@ -97,15 +108,17 @@ public: // parse a header line, return the header atom and a pointer to the // header value (the substring of the header line -- do not free). static nsresult ParseHeaderLine(const nsACString& line, - nsHttpAtom *header=nullptr, - nsACString* value=nullptr); + nsHttpAtom *header = nullptr, + nsACString *headerNameOriginal = nullptr, + nsACString *value = nullptr); void Flatten(nsACString &, bool pruneProxyHeaders, bool pruneTransients); void FlattenOriginalHeader(nsACString &); uint32_t Count() const { return mHeaders.Length(); } - const char *PeekHeaderAt(uint32_t i, nsHttpAtom &header) const; + const char *PeekHeaderAt(uint32_t i, nsHttpAtom &header, + nsACString &headerNameOriginal) const; void Clear(); @@ -113,6 +126,7 @@ public: struct nsEntry { nsHttpAtom header; + nsCString headerNameOriginal; nsCString value; HeaderVariety variety = eVarietyUnknown; @@ -140,7 +154,9 @@ private: int32_t LookupEntry(nsHttpAtom header, nsEntry **); nsresult MergeHeader(nsHttpAtom header, nsEntry *entry, const nsACString &value, HeaderVariety variety); - nsresult SetHeader_internal(nsHttpAtom header, const nsACString &value, + nsresult SetHeader_internal(nsHttpAtom header, + const nsACString &headerName, + const nsACString &value, HeaderVariety variety); // Header cannot be merged: only one value possible @@ -257,7 +273,11 @@ nsHttpHeaderArray::MergeHeader(nsHttpAtom header, if (entry->variety == eVarietyResponseNetOriginalAndResponse) { MOZ_ASSERT(variety == eVarietyResponse); entry->variety = eVarietyResponseNetOriginal; - nsresult rv = SetHeader_internal(header, newValue, eVarietyResponse); + // Copy entry->headerNameOriginal because in SetHeader_internal we are going + // to a new one and a realocation can happen. + nsCString headerNameOriginal = entry->headerNameOriginal; + nsresult rv = SetHeader_internal(header, headerNameOriginal, + newValue, eVarietyResponse); if (NS_FAILED(rv)) { return rv; } diff --git a/netwerk/protocol/http/nsHttpRequestHead.cpp b/netwerk/protocol/http/nsHttpRequestHead.cpp index 094a79457..b366a8d54 100644 --- a/netwerk/protocol/http/nsHttpRequestHead.cpp +++ b/netwerk/protocol/http/nsHttpRequestHead.cpp @@ -131,6 +131,20 @@ nsHttpRequestHead::Origin(nsACString &aOrigin) } nsresult +nsHttpRequestHead::SetHeader(const nsACString &h, const nsACString &v, + bool m /*= false*/) +{ + ReentrantMonitorAutoEnter mon(mReentrantMonitor); + + if (mInVisitHeaders) { + return NS_ERROR_FAILURE; + } + + return mHeaders.SetHeader(h, v, m, + nsHttpHeaderArray::eVarietyRequestOverride); +} + +nsresult nsHttpRequestHead::SetHeader(nsHttpAtom h, const nsACString &v, bool m /*= false*/) { @@ -158,7 +172,7 @@ nsHttpRequestHead::SetHeader(nsHttpAtom h, const nsACString &v, bool m, } nsresult -nsHttpRequestHead::SetEmptyHeader(nsHttpAtom h) +nsHttpRequestHead::SetEmptyHeader(const nsACString &h) { ReentrantMonitorAutoEnter mon(mReentrantMonitor); @@ -253,6 +267,7 @@ nsHttpRequestHead::ParseHeaderSet(const char *buffer) { ReentrantMonitorAutoEnter mon(mReentrantMonitor); nsHttpAtom hdr; + nsAutoCString headerNameOriginal; nsAutoCString val; while (buffer) { const char *eof = strchr(buffer, '\r'); @@ -262,9 +277,13 @@ nsHttpRequestHead::ParseHeaderSet(const char *buffer) if (NS_SUCCEEDED(nsHttpHeaderArray::ParseHeaderLine( nsDependentCSubstring(buffer, eof - buffer), &hdr, + &headerNameOriginal, &val))) { - mHeaders.SetHeaderFromNet(hdr, val, false); + mHeaders.SetHeaderFromNet(hdr, + headerNameOriginal, + val, + false); } buffer = eof + 1; if (*buffer == '\n') { diff --git a/netwerk/protocol/http/nsHttpRequestHead.h b/netwerk/protocol/http/nsHttpRequestHead.h index 415968083..b7020d33a 100644 --- a/netwerk/protocol/http/nsHttpRequestHead.h +++ b/netwerk/protocol/http/nsHttpRequestHead.h @@ -57,10 +57,12 @@ public: int32_t port); void Origin(nsACString &aOrigin); + nsresult SetHeader(const nsACString &h, const nsACString &v, + bool m=false); nsresult SetHeader(nsHttpAtom h, const nsACString &v, bool m=false); nsresult SetHeader(nsHttpAtom h, const nsACString &v, bool m, nsHttpHeaderArray::HeaderVariety variety); - nsresult SetEmptyHeader(nsHttpAtom h); + nsresult SetEmptyHeader(const nsACString &h); nsresult GetHeader(nsHttpAtom h, nsACString &v); nsresult ClearHeader(nsHttpAtom h); diff --git a/netwerk/protocol/http/nsHttpResponseHead.cpp b/netwerk/protocol/http/nsHttpResponseHead.cpp index 6d384c488..fa6430b82 100644 --- a/netwerk/protocol/http/nsHttpResponseHead.cpp +++ b/netwerk/protocol/http/nsHttpResponseHead.cpp @@ -137,6 +137,26 @@ nsHttpResponseHead::Immutable() } nsresult +nsHttpResponseHead::SetHeader(const nsACString &hdr, + const nsACString &val, + bool merge) +{ + ReentrantMonitorAutoEnter monitor(mReentrantMonitor); + + if (mInVisitHeaders) { + return NS_ERROR_FAILURE; + } + + nsHttpAtom atom = nsHttp::ResolveAtom(PromiseFlatCString(hdr).get()); + if (!atom) { + NS_WARNING("failed to resolve atom"); + return NS_ERROR_NOT_AVAILABLE; + } + + return SetHeader_locked(atom, hdr, val, merge); +} + +nsresult nsHttpResponseHead::SetHeader(nsHttpAtom hdr, const nsACString &val, bool merge) @@ -147,24 +167,25 @@ nsHttpResponseHead::SetHeader(nsHttpAtom hdr, return NS_ERROR_FAILURE; } - return SetHeader_locked(hdr, val, merge); + return SetHeader_locked(hdr, EmptyCString(), val, merge); } nsresult -nsHttpResponseHead::SetHeader_locked(nsHttpAtom hdr, +nsHttpResponseHead::SetHeader_locked(nsHttpAtom atom, + const nsACString &hdr, const nsACString &val, bool merge) { - nsresult rv = mHeaders.SetHeader(hdr, val, merge, + nsresult rv = mHeaders.SetHeader(atom, hdr, val, merge, nsHttpHeaderArray::eVarietyResponse); if (NS_FAILED(rv)) return rv; // respond to changes in these headers. we need to reparse the entire // header since the change may have merged in additional values. - if (hdr == nsHttp::Cache_Control) - ParseCacheControl(mHeaders.PeekHeader(hdr)); - else if (hdr == nsHttp::Pragma) - ParsePragma(mHeaders.PeekHeader(hdr)); + if (atom == nsHttp::Cache_Control) + ParseCacheControl(mHeaders.PeekHeader(atom)); + else if (atom == nsHttp::Pragma) + ParsePragma(mHeaders.PeekHeader(atom)); return NS_OK; } @@ -316,6 +337,7 @@ nsHttpResponseHead::ParseCachedOriginalHeaders(char *block) char *p = block; nsHttpAtom hdr = {0}; + nsAutoCString headerNameOriginal; nsAutoCString val; nsresult rv; @@ -331,12 +353,13 @@ nsHttpResponseHead::ParseCachedOriginalHeaders(char *block) *p = 0; if (NS_FAILED(nsHttpHeaderArray::ParseHeaderLine( - nsDependentCString(block, p - block), &hdr, &val))) { + nsDependentCString(block, p - block), &hdr, &headerNameOriginal, &val))) { return NS_OK; } rv = mHeaders.SetResponseHeaderFromCache(hdr, + headerNameOriginal, val, nsHttpHeaderArray::eVarietyResponseNetOriginal); @@ -567,18 +590,21 @@ nsresult nsHttpResponseHead::ParseHeaderLine_locked(const nsACString &line, bool originalFromNetHeaders) { nsHttpAtom hdr = {0}; + nsAutoCString headerNameOriginal; nsAutoCString val; - if (NS_FAILED(nsHttpHeaderArray::ParseHeaderLine(line, &hdr, &val))) { + if (NS_FAILED(nsHttpHeaderArray::ParseHeaderLine(line, &hdr, &headerNameOriginal, &val))) { return NS_OK; } nsresult rv; if (originalFromNetHeaders) { rv = mHeaders.SetHeaderFromNet(hdr, + headerNameOriginal, val, true); } else { rv = mHeaders.SetResponseHeaderFromCache(hdr, + headerNameOriginal, val, nsHttpHeaderArray::eVarietyResponse); } @@ -856,7 +882,8 @@ nsHttpResponseHead::UpdateHeaders(nsHttpResponseHead *aOther) uint32_t i, count = aOther->mHeaders.Count(); for (i=0; i<count; ++i) { nsHttpAtom header; - const char *val = aOther->mHeaders.PeekHeaderAt(i, header); + nsAutoCString headerNameOriginal; + const char *val = aOther->mHeaders.PeekHeaderAt(i, header, headerNameOriginal); if (!val) { continue; @@ -890,7 +917,8 @@ nsHttpResponseHead::UpdateHeaders(nsHttpResponseHead *aOther) LOG(("new response header [%s: %s]\n", header.get(), val)); // overwrite the current header value with the new value... - SetHeader_locked(header, nsDependentCString(val)); + SetHeader_locked(header, headerNameOriginal, + nsDependentCString(val)); } } diff --git a/netwerk/protocol/http/nsHttpResponseHead.h b/netwerk/protocol/http/nsHttpResponseHead.h index 0a912f4b4..8b51386ea 100644 --- a/netwerk/protocol/http/nsHttpResponseHead.h +++ b/netwerk/protocol/http/nsHttpResponseHead.h @@ -65,6 +65,8 @@ public: */ int64_t TotalEntitySize(); + nsresult SetHeader(const nsACString &h, const nsACString &v, + bool m=false); nsresult SetHeader(nsHttpAtom h, const nsACString &v, bool m=false); nsresult GetHeader(nsHttpAtom h, nsACString &v); void ClearHeader(nsHttpAtom h); @@ -137,8 +139,8 @@ public: bool HasContentType(); bool HasContentCharset(); private: - nsresult SetHeader_locked(nsHttpAtom h, const nsACString &v, - bool m=false); + nsresult SetHeader_locked(nsHttpAtom atom, const nsACString &h, + const nsACString &v, bool m=false); void AssignDefaultStatusText(); void ParseVersion(const char *); void ParseCacheControl(const char *); diff --git a/netwerk/protocol/http/nsHttpTransaction.cpp b/netwerk/protocol/http/nsHttpTransaction.cpp index 8d837d172..76e0a4ad9 100644 --- a/netwerk/protocol/http/nsHttpTransaction.cpp +++ b/netwerk/protocol/http/nsHttpTransaction.cpp @@ -1164,7 +1164,9 @@ nsHttpTransaction::Close(nsresult reason) } // closing this pipe triggers the channel's OnStopRequest method. - mPipeOut->CloseWithStatus(reason); + if (mPipeOut) { + mPipeOut->CloseWithStatus(reason); + } #ifdef WIN32 // bug 1153929 MOZ_DIAGNOSTIC_ASSERT(mPipeOut); diff --git a/netwerk/sctp/datachannel/DataChannel.cpp b/netwerk/sctp/datachannel/DataChannel.cpp index f2a91c589..ebc430f8c 100644 --- a/netwerk/sctp/datachannel/DataChannel.cpp +++ b/netwerk/sctp/datachannel/DataChannel.cpp @@ -276,6 +276,7 @@ DataChannelConnection::Destroy() LOG(("Deregistered %p from the SCTP stack.", static_cast<void *>(this))); } + mListener = nullptr; // Finish Destroy on STS thread to avoid bug 876167 - once that's fixed, // the usrsctp_close() calls can move back here (and just proxy the // disconnect_all()) diff --git a/netwerk/socket/nsSOCKSIOLayer.cpp b/netwerk/socket/nsSOCKSIOLayer.cpp index 22f5751fb..5429637c1 100644 --- a/netwerk/socket/nsSOCKSIOLayer.cpp +++ b/netwerk/socket/nsSOCKSIOLayer.cpp @@ -229,6 +229,7 @@ nsSOCKSSocketInfo::nsSOCKSSocketInfo() , mDataLength(0) , mReadOffset(0) , mAmountToRead(0) + , mFD(nullptr) , mVersion(-1) , mDestinationFamily(AF_INET) , mFlags(0) diff --git a/netwerk/streamconv/converters/nsIndexedToHTML.cpp b/netwerk/streamconv/converters/nsIndexedToHTML.cpp index 0414c4841..29fea8bfb 100644 --- a/netwerk/streamconv/converters/nsIndexedToHTML.cpp +++ b/netwerk/streamconv/converters/nsIndexedToHTML.cpp @@ -146,7 +146,14 @@ nsIndexedToHTML::DoOnStartRequest(nsIRequest* request, nsISupports *aContext, nsAutoCString baseUri, titleUri; rv = uri->GetAsciiSpec(baseUri); if (NS_FAILED(rv)) return rv; - titleUri = baseUri; + + nsCOMPtr<nsIURI> titleURL; + rv = uri->Clone(getter_AddRefs(titleURL)); + if (NS_FAILED(rv)) titleURL = uri; + rv = titleURL->SetQuery(EmptyCString()); + if (NS_FAILED(rv)) titleURL = uri; + rv = titleURL->SetRef(EmptyCString()); + if (NS_FAILED(rv)) titleURL = uri; nsCString parentStr; @@ -170,16 +177,14 @@ nsIndexedToHTML::DoOnStartRequest(nsIRequest* request, nsISupports *aContext, // that - see above nsAutoCString pw; - rv = uri->GetPassword(pw); + rv = titleURL->GetPassword(pw); if (NS_FAILED(rv)) return rv; if (!pw.IsEmpty()) { nsCOMPtr<nsIURI> newUri; - rv = uri->Clone(getter_AddRefs(newUri)); + rv = titleURL->Clone(getter_AddRefs(newUri)); if (NS_FAILED(rv)) return rv; rv = newUri->SetPassword(EmptyCString()); if (NS_FAILED(rv)) return rv; - rv = newUri->GetAsciiSpec(titleUri); - if (NS_FAILED(rv)) return rv; } nsAutoCString path; @@ -247,6 +252,11 @@ nsIndexedToHTML::DoOnStartRequest(nsIRequest* request, nsISupports *aContext, } } + rv = titleURL->GetAsciiSpec(titleUri); + if (NS_FAILED(rv)) { + return rv; + } + buffer.AppendLiteral("<style type=\"text/css\">\n" ":root {\n" " font-family: sans-serif;\n" diff --git a/netwerk/test/unit/test_bug1064258.js b/netwerk/test/unit/test_bug1064258.js index 3f76837ae..da982c2d6 100644 --- a/netwerk/test/unit/test_bug1064258.js +++ b/netwerk/test/unit/test_bug1064258.js @@ -133,7 +133,7 @@ function cacheCheck2(status, entry) do_check_eq(entry.dataSize, 0); try { do_check_neq(entry.getMetaDataElement("response-head"), null); - do_check_true(entry.getMetaDataElement("response-head").match('Etag: testetag')); + do_check_true(entry.getMetaDataElement("response-head").match('etag: testetag')); } catch (ex) { do_throw("Missing response head"); diff --git a/netwerk/test/unit/test_original_sent_received_head.js b/netwerk/test/unit/test_original_sent_received_head.js index c4d02d5d2..d668abf59 100644 --- a/netwerk/test/unit/test_original_sent_received_head.js +++ b/netwerk/test/unit/test_original_sent_received_head.js @@ -114,11 +114,11 @@ function checkResponse(request, data, context) { var locationHeaderFound = 0; request.visitResponseHeaders({ visitHeader: function visit(aName, aValue) { - if (aName == "Link") { + if (aName == "link") { linkHeaderFound++; do_check_eq(aValue, "value1, value2"); } - if (aName == "Location") { + if (aName == "location") { locationHeaderFound++; do_check_eq(aValue, "loc"); } @@ -132,7 +132,7 @@ function checkResponse(request, data, context) { var locationOrgHeaderFound = 0; request.visitOriginalResponseHeaders({ visitHeader: function visitOrg(aName, aValue) { - if (aName == "Link") { + if (aName == "link") { if (linkOrgHeaderFound == 0) { do_check_eq(aValue, ""); } else if (linkOrgHeaderFound == 1 ) { @@ -142,7 +142,7 @@ function checkResponse(request, data, context) { } linkOrgHeaderFound++; } - if (aName == "Location") { + if (aName == "location") { locationOrgHeaderFound++; do_check_eq(aValue, "loc"); } @@ -160,10 +160,10 @@ function checkResponse(request, data, context) { var locationHeaderFound2 = 0; request.visitResponseHeaders({ visitHeader: function visit(aName, aValue) { - if (aName == "Link") { + if (aName == "link") { linkHeaderFound2 = true; } - if (aName == "Location") { + if (aName == "location") { locationHeaderFound2 = true; } } @@ -176,7 +176,7 @@ function checkResponse(request, data, context) { var locationOrgHeaderFound2 = 0; request.visitOriginalResponseHeaders({ visitHeader: function visitOrg(aName, aValue) { - if (aName == "Link") { + if (aName == "link") { if (linkOrgHeaderFound2 == 0) { do_check_eq(aValue, ""); } else if (linkOrgHeaderFound2 == 1 ) { @@ -186,7 +186,7 @@ function checkResponse(request, data, context) { } linkOrgHeaderFound2++; } - if (aName == "Location") { + if (aName == "location") { locationOrgHeaderFound2++; do_check_eq(aValue, "loc"); } @@ -199,7 +199,7 @@ function checkResponse(request, data, context) { if (dbg) { print("============== Test GetResponseHeader"); } var linkOrgHeaderFound3 = 0; - request.getOriginalResponseHeader("Link",{ + request.getOriginalResponseHeader("link",{ visitHeader: function visitOrg(aName, aValue) { if (linkOrgHeaderFound3 == 0) { do_check_eq(aValue, ""); |