Bug 1784098 - make nsICacheEntry.securityInfo explicit as nsITransportSecurityInfo r=kershaw,necko-reviewers

Differential Revision: https://phabricator.services.mozilla.com/D154472
This commit is contained in:
Dana Keeler 2022-08-22 16:32:02 +00:00
Родитель 5a1655a87d
Коммит 51aa6b77a8
6 изменённых файлов: 62 добавлений и 46 удалений

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

@ -1331,7 +1331,7 @@ nsresult CacheEntry::OpenOutputStreamInternal(int64_t offset,
return NS_OK;
}
nsresult CacheEntry::GetSecurityInfo(nsISupports** aSecurityInfo) {
nsresult CacheEntry::GetSecurityInfo(nsITransportSecurityInfo** aSecurityInfo) {
{
mozilla::MutexAutoLock lock(mLock);
if (mSecurityInfoLoaded) {
@ -1343,17 +1343,23 @@ nsresult CacheEntry::GetSecurityInfo(nsISupports** aSecurityInfo) {
NS_ENSURE_SUCCESS(mFileStatus, NS_ERROR_NOT_AVAILABLE);
nsCString info;
nsCOMPtr<nsISupports> secInfo;
nsCOMPtr<nsISupports> secInfoSupports;
nsresult rv;
rv = mFile->GetElement("security-info", getter_Copies(info));
NS_ENSURE_SUCCESS(rv, rv);
if (!info.IsVoid()) {
rv = NS_DeserializeObject(info, getter_AddRefs(secInfo));
rv = NS_DeserializeObject(info, getter_AddRefs(secInfoSupports));
NS_ENSURE_SUCCESS(rv, rv);
}
nsCOMPtr<nsITransportSecurityInfo> secInfo =
do_QueryInterface(secInfoSupports);
if (!secInfo) {
return NS_ERROR_NOT_AVAILABLE;
}
{
mozilla::MutexAutoLock lock(mLock);
@ -1365,7 +1371,8 @@ nsresult CacheEntry::GetSecurityInfo(nsISupports** aSecurityInfo) {
return NS_OK;
}
nsresult CacheEntry::SetSecurityInfo(nsISupports* aSecurityInfo) {
nsresult CacheEntry::SetSecurityInfo(nsITransportSecurityInfo* aSecurityInfo) {
nsresult rv;
NS_ENSURE_SUCCESS(mFileStatus, mFileStatus);

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

@ -12,6 +12,7 @@
#include "nsIOutputStream.h"
#include "nsICacheEntryOpenCallback.h"
#include "nsICacheEntryDoomCallback.h"
#include "nsITransportSecurityInfo.h"
#include "nsCOMPtr.h"
#include "nsRefPtrHashtable.h"
@ -78,8 +79,8 @@ class CacheEntry final : public nsIRunnable, public CacheFileListener {
nsresult OpenInputStream(int64_t offset, nsIInputStream** _retval);
nsresult OpenOutputStream(int64_t offset, int64_t predictedSize,
nsIOutputStream** _retval);
nsresult GetSecurityInfo(nsISupports** aSecurityInfo);
nsresult SetSecurityInfo(nsISupports* aSecurityInfo);
nsresult GetSecurityInfo(nsITransportSecurityInfo** aSecurityInfo);
nsresult SetSecurityInfo(nsITransportSecurityInfo* aSecurityInfo);
nsresult GetStorageDataSize(uint32_t* aStorageDataSize);
nsresult AsyncDoom(nsICacheEntryDoomCallback* aCallback);
nsresult GetMetaDataElement(const char* key, char** aRetval);
@ -420,7 +421,7 @@ class CacheEntry final : public nsIRunnable, public CacheFileListener {
uint32_t mFlags{0};
} mBackgroundOperations;
nsCOMPtr<nsISupports> mSecurityInfo;
nsCOMPtr<nsITransportSecurityInfo> mSecurityInfo;
mozilla::TimeStamp mLoadStart;
uint32_t mUseCount{0};
@ -487,10 +488,11 @@ class CacheEntryHandle final : public nsICacheEntry {
nsIOutputStream** _retval) override {
return mEntry->OpenOutputStream(offset, predictedSize, _retval);
}
NS_IMETHOD GetSecurityInfo(nsISupports** aSecurityInfo) override {
NS_IMETHOD GetSecurityInfo(
nsITransportSecurityInfo** aSecurityInfo) override {
return mEntry->GetSecurityInfo(aSecurityInfo);
}
NS_IMETHOD SetSecurityInfo(nsISupports* aSecurityInfo) override {
NS_IMETHOD SetSecurityInfo(nsITransportSecurityInfo* aSecurityInfo) override {
return mEntry->SetSecurityInfo(aSecurityInfo);
}
NS_IMETHOD GetStorageDataSize(uint32_t* aStorageDataSize) override {

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

@ -4,14 +4,13 @@
#include "nsISupports.idl"
interface nsIInputStream;
interface nsIOutputStream;
interface nsIAsyncOutputStream;
interface nsICacheEntryDoomCallback;
interface nsIFile;
interface nsICacheEntryMetaDataVisitor;
interface nsIInputStream;
interface nsILoadContextInfo;
interface nsIOutputStream;
interface nsITransportSecurityInfo;
[scriptable, uuid(607c2a2c-0a48-40b9-a956-8cf2bb9857cf)]
interface nsICacheEntry : nsISupports
@ -169,7 +168,7 @@ interface nsICacheEntry : nsISupports
/**
* Get/set security info on the cache entry for this descriptor.
*/
attribute nsISupports securityInfo;
attribute nsITransportSecurityInfo securityInfo;
/**
* Get the size of the cache entry data, as stored. This may differ

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

@ -3,23 +3,24 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include <algorithm>
#include "nsAboutCacheEntry.h"
#include "mozilla/Sprintf.h"
#include "nsAboutCache.h"
#include "nsICacheStorage.h"
#include "CacheFileUtils.h"
#include "CacheObserver.h"
#include "nsNetUtil.h"
#include "mozilla/Sprintf.h"
#include "nsAboutCache.h"
#include "nsAboutProtocolUtils.h"
#include "nsContentUtils.h"
#include "nsEscape.h"
#include "nsIAsyncInputStream.h"
#include "nsIAsyncOutputStream.h"
#include "nsICacheStorage.h"
#include "nsIPipe.h"
#include "nsAboutProtocolUtils.h"
#include "nsContentUtils.h"
#include "nsITransportSecurityInfo.h"
#include "nsInputStreamPump.h"
#include "CacheFileUtils.h"
#include <algorithm>
#include "nsNetUtil.h"
using namespace mozilla::net;
@ -419,7 +420,7 @@ nsresult nsAboutCacheEntry::Channel::WriteCacheEntryDescription(
// A new bug(s) should be filed here.
// Security Info
nsCOMPtr<nsISupports> securityInfo;
nsCOMPtr<nsITransportSecurityInfo> securityInfo;
entry->GetSecurityInfo(getter_AddRefs(securityInfo));
if (securityInfo) {
APPEND_ROW("Security", "This is a secure document.");

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

@ -4596,7 +4596,10 @@ void nsHttpChannel::CloseCacheEntry(bool doomOnFailure) {
} else {
// Store updated security info, makes cached EV status race less likely
// (see bug 1040086)
if (mSecurityInfo) mCacheEntry->SetSecurityInfo(mSecurityInfo);
nsCOMPtr<nsITransportSecurityInfo> tsi = do_QueryInterface(mSecurityInfo);
if (tsi) {
mCacheEntry->SetSecurityInfo(tsi);
}
}
mCachedResponseHead = nullptr;
@ -4742,7 +4745,10 @@ nsresult DoAddCacheEntryHeaders(nsHttpChannel* self, nsICacheEntry* entry,
LOG(("nsHttpChannel::AddCacheEntryHeaders [this=%p] begin", self));
// Store secure data in memory only
if (securityInfo) entry->SetSecurityInfo(securityInfo);
nsCOMPtr<nsITransportSecurityInfo> tsi = do_QueryInterface(securityInfo);
if (tsi) {
entry->SetSecurityInfo(tsi);
}
// Store the HTTP request method with the cache entry so we can distinguish
// for example GET and HEAD responses.

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

@ -7,30 +7,31 @@
#ifndef nsHttpChannel_h__
#define nsHttpChannel_h__
#include "HttpBaseChannel.h"
#include "nsTArray.h"
#include "nsICachingChannel.h"
#include "nsICacheEntry.h"
#include "nsICacheEntryOpenCallback.h"
#include "nsIDNSListener.h"
#include "nsIProtocolProxyCallback.h"
#include "nsIHttpAuthenticableChannel.h"
#include "nsIAsyncVerifyRedirectCallback.h"
#include "nsIEarlyHintObserver.h"
#include "nsIThreadRetargetableRequest.h"
#include "nsIThreadRetargetableStreamListener.h"
#include "nsWeakReference.h"
#include "TimingStruct.h"
#include "AutoClose.h"
#include "nsIStreamListener.h"
#include "nsICorsPreflightCallback.h"
#include "AlternateServices.h"
#include "nsIRaceCacheWithNetwork.h"
#include "AutoClose.h"
#include "HttpBaseChannel.h"
#include "TimingStruct.h"
#include "mozilla/AtomicBitfields.h"
#include "mozilla/Atomics.h"
#include "mozilla/Mutex.h"
#include "mozilla/extensions/PStreamFilterParent.h"
#include "mozilla/net/DocumentLoadListener.h"
#include "mozilla/Mutex.h"
#include "nsIAsyncVerifyRedirectCallback.h"
#include "nsICacheEntry.h"
#include "nsICacheEntryOpenCallback.h"
#include "nsICachingChannel.h"
#include "nsICorsPreflightCallback.h"
#include "nsIDNSListener.h"
#include "nsIEarlyHintObserver.h"
#include "nsIHttpAuthenticableChannel.h"
#include "nsIProtocolProxyCallback.h"
#include "nsIRaceCacheWithNetwork.h"
#include "nsIStreamListener.h"
#include "nsIThreadRetargetableRequest.h"
#include "nsIThreadRetargetableStreamListener.h"
#include "nsITransportSecurityInfo.h"
#include "nsTArray.h"
#include "nsWeakReference.h"
class nsDNSPrefetch;
class nsICancelable;
@ -577,7 +578,7 @@ class nsHttpChannel final : public HttpBaseChannel,
AutoClose<nsIInputStream> mCacheInputStream;
RefPtr<nsInputStreamPump> mCachePump;
UniquePtr<nsHttpResponseHead> mCachedResponseHead;
nsCOMPtr<nsISupports> mCachedSecurityInfo;
nsCOMPtr<nsITransportSecurityInfo> mCachedSecurityInfo;
uint32_t mPostID{0};
uint32_t mRequestTime{0};