Backed out 3 changesets (bug 1593246) for build bustages on BrowsingContext.h. CLOSED TREE

Backed out changeset fd389138a684 (bug 1593246)
Backed out changeset 2663311a1b62 (bug 1593246)
Backed out changeset d9f0d827e28d (bug 1593246)
This commit is contained in:
Razvan Maries 2019-12-09 20:32:18 +02:00
Родитель edc814040b
Коммит ae7f240305
10 изменённых файлов: 74 добавлений и 72 удалений

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

@ -19,7 +19,6 @@
#include "mozilla/dom/LocationBinding.h"
#include "mozilla/dom/PopupBlocker.h"
#include "mozilla/dom/ScriptSettings.h"
#include "mozilla/dom/SessionStorageManager.h"
#include "mozilla/dom/StructuredCloneTags.h"
#include "mozilla/dom/UserActivationIPCUtils.h"
#include "mozilla/dom/WindowBinding.h"
@ -676,14 +675,6 @@ bool BrowsingContext::CanAccess(BrowsingContext* aTarget,
return false;
}
RefPtr<SessionStorageManager> BrowsingContext::SessionStorageManager() {
RefPtr<dom::SessionStorageManager>& manager = Top()->mSessionStorageManager;
if (!manager) {
manager = new dom::SessionStorageManager(this);
}
return manager;
}
BrowsingContext::~BrowsingContext() {
MOZ_DIAGNOSTIC_ASSERT(!mParent || !mParent->mChildren.Contains(this));
MOZ_DIAGNOSTIC_ASSERT(!mGroup || !mGroup->Toplevels().Contains(this));
@ -821,7 +812,7 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(BrowsingContext)
}
NS_IMPL_CYCLE_COLLECTION_UNLINK(mDocShell, mChildren, mParent, mGroup,
mEmbedderElement, mSessionStorageManager)
mEmbedderElement)
if (XRE_IsParentProcess()) {
CanonicalBrowsingContext::Cast(tmp)->Unlink();
}
@ -830,7 +821,7 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_END
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(BrowsingContext)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mDocShell, mChildren, mParent, mGroup,
mEmbedderElement, mSessionStorageManager)
mEmbedderElement)
if (XRE_IsParentProcess()) {
CanonicalBrowsingContext::Cast(tmp)->Traverse(cb);
}

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

@ -17,7 +17,6 @@
#include "mozilla/dom/LoadURIOptionsBinding.h"
#include "mozilla/dom/LocationBase.h"
#include "mozilla/dom/FeaturePolicyUtils.h"
#include "mozilla/dom/SessionStorageManager.h"
#include "mozilla/dom/UserActivation.h"
#include "nsCOMPtr.h"
#include "nsCycleCollectionParticipant.h"
@ -504,8 +503,6 @@ class BrowsingContext : public nsISupports,
// Must be called only on the top level BrowsingContext.
void AddDeprioritizedLoadRunner(nsIRunnable* aRunner);
RefPtr<SessionStorageManager> SessionStorageManager();
protected:
virtual ~BrowsingContext();
BrowsingContext(BrowsingContext* aParent, BrowsingContextGroup* aGroup,
@ -656,8 +653,6 @@ class BrowsingContext : public nsISupports,
};
mozilla::LinkedList<DeprioritizedLoadRunner> mDeprioritizedLoadRunner;
RefPtr<dom::SessionStorageManager> mSessionStorageManager;
};
/**

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

@ -529,7 +529,8 @@ void nsDocShell::DestroyChildren() {
nsDocLoader::DestroyChildren();
}
NS_IMPL_CYCLE_COLLECTION_INHERITED(nsDocShell, nsDocLoader, mScriptGlobal,
NS_IMPL_CYCLE_COLLECTION_INHERITED(nsDocShell, nsDocLoader,
mSessionStorageManager, mScriptGlobal,
mInitialClientSource, mSessionHistory,
mBrowsingContext, mChromeEventHandler)
@ -548,6 +549,7 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsDocShell)
NS_INTERFACE_MAP_ENTRY(nsIWebPageDescriptor)
NS_INTERFACE_MAP_ENTRY(nsIAuthPromptProvider)
NS_INTERFACE_MAP_ENTRY(nsILoadContext)
NS_INTERFACE_MAP_ENTRY(nsIDOMStorageManager)
NS_INTERFACE_MAP_ENTRY_CONDITIONAL(nsINetworkInterceptController,
mInterceptController)
NS_INTERFACE_MAP_ENTRY(nsIDeprecationWarner)
@ -2246,6 +2248,31 @@ nsDocShell::GetWindowDraggingAllowed(bool* aValue) {
return NS_OK;
}
nsIDOMStorageManager* nsDocShell::TopSessionStorageManager() {
nsresult rv;
nsCOMPtr<nsIDocShellTreeItem> topItem;
rv = GetInProcessSameTypeRootTreeItem(getter_AddRefs(topItem));
if (NS_FAILED(rv)) {
return nullptr;
}
if (!topItem) {
return nullptr;
}
nsDocShell* topDocShell = static_cast<nsDocShell*>(topItem.get());
if (topDocShell != this) {
return topDocShell->TopSessionStorageManager();
}
if (!mSessionStorageManager) {
mSessionStorageManager = new SessionStorageManager();
}
return mSessionStorageManager;
}
NS_IMETHODIMP
nsDocShell::GetCurrentDocumentChannel(nsIChannel** aResult) {
NS_IF_ADDREF(*aResult = GetCurrentDocChannel());

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

@ -28,6 +28,7 @@
#include "nsIDeprecationWarner.h"
#include "nsIDocShell.h"
#include "nsIDocShellTreeItem.h"
#include "nsIDOMStorageManager.h"
#include "nsIInterfaceRequestor.h"
#include "nsILoadContext.h"
#include "nsILoadURIDelegate.h"
@ -122,6 +123,7 @@ class nsDocShell final : public nsDocLoader,
public nsIWebPageDescriptor,
public nsIAuthPromptProvider,
public nsILoadContext,
public nsIDOMStorageManager,
public nsINetworkInterceptController,
public nsIDeprecationWarner,
public mozilla::SupportsWeakPtr<nsDocShell> {
@ -199,6 +201,8 @@ class nsDocShell final : public nsDocLoader,
NS_DECL_NSINETWORKINTERCEPTCONTROLLER
NS_DECL_NSIDEPRECATIONWARNER
NS_FORWARD_SAFE_NSIDOMSTORAGEMANAGER(TopSessionStorageManager())
// Create a new nsDocShell object, initializing it.
static already_AddRefed<nsDocShell> Create(
mozilla::dom::BrowsingContext* aBrowsingContext,
@ -989,6 +993,7 @@ class nsDocShell final : public nsDocLoader,
bool aCheckIfUnloadFired = true);
uint32_t GetInheritedFrameType();
nsIScrollableFrame* GetRootScrollFrame();
nsIDOMStorageManager* TopSessionStorageManager();
nsIChannel* GetCurrentDocChannel();
nsresult EnsureScriptEnvironment();
nsresult EnsureEditorData();
@ -1090,6 +1095,7 @@ class nsDocShell final : public nsDocLoader,
nsCOMPtr<nsIPrincipal> mParentCharsetPrincipal;
nsCOMPtr<nsIMutableArray> mRefreshURIList;
nsCOMPtr<nsIMutableArray> mSavedRefreshURIList;
nsCOMPtr<nsIDOMStorageManager> mSessionStorageManager;
uint64_t mContentWindowID;
nsCOMPtr<nsIContentViewer> mContentViewer;
nsCOMPtr<nsIWidget> mParentWidget;

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

@ -4314,9 +4314,9 @@ already_AddRefed<nsICSSDeclaration> nsGlobalWindowInner::GetComputedStyleHelper(
Storage* nsGlobalWindowInner::GetSessionStorage(ErrorResult& aError) {
nsIPrincipal* principal = GetPrincipal();
BrowsingContext* browsingContext = GetBrowsingContext();
nsIDocShell* docShell = GetDocShell();
if (!principal || !browsingContext || !Storage::StoragePrefIsEnabled()) {
if (!principal || !docShell || !Storage::StoragePrefIsEnabled()) {
return nullptr;
}
@ -4396,10 +4396,12 @@ Storage* nsGlobalWindowInner::GetSessionStorage(ErrorResult& aError) {
return nullptr;
}
const RefPtr<SessionStorageManager> storageManager =
browsingContext->SessionStorageManager();
if (!storageManager) {
aError.Throw(NS_ERROR_DOM_NOT_SUPPORTED_ERR);
nsresult rv;
nsCOMPtr<nsIDOMStorageManager> storageManager =
do_QueryInterface(docShell, &rv);
if (NS_FAILED(rv)) {
aError.Throw(rv);
return nullptr;
}
@ -4987,8 +4989,9 @@ void nsGlobalWindowInner::ObserveStorageNotification(
bool check = false;
if (const RefPtr<SessionStorageManager> storageManager =
GetBrowsingContext()->SessionStorageManager()) {
nsCOMPtr<nsIDOMStorageManager> storageManager =
do_QueryInterface(GetDocShell());
if (storageManager) {
nsresult rv =
storageManager->CheckStorage(principal, changingStorage, &check);
if (NS_FAILED(rv)) {

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

@ -17,19 +17,10 @@ namespace dom {
using namespace StorageUtils;
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(SessionStorageManager)
NS_INTERFACE_MAP_ENTRY(nsISupports)
NS_INTERFACE_MAP_ENTRY(nsIDOMStorageManager)
NS_INTERFACE_MAP_ENTRY(nsIDOMSessionStorageManager)
NS_INTERFACE_MAP_END
NS_IMPL_ISUPPORTS(SessionStorageManager, nsIDOMStorageManager,
nsIDOMSessionStorageManager)
NS_IMPL_CYCLE_COLLECTION(SessionStorageManager, mBrowsingContext)
NS_IMPL_CYCLE_COLLECTING_ADDREF(SessionStorageManager)
NS_IMPL_CYCLE_COLLECTING_RELEASE(SessionStorageManager)
SessionStorageManager::SessionStorageManager(
RefPtr<BrowsingContext> aBrowsingContext)
: mBrowsingContext(aBrowsingContext.forget()) {
SessionStorageManager::SessionStorageManager() {
StorageObserver* observer = StorageObserver::Self();
NS_ASSERTION(
observer,
@ -83,12 +74,14 @@ NS_IMETHODIMP
SessionStorageManager::GetSessionStorageCache(
nsIPrincipal* aPrincipal, nsIPrincipal* aStoragePrincipal,
RefPtr<SessionStorageCache>* aRetVal) {
return GetSessionStorageCacheHelper(aPrincipal, true, nullptr, aRetVal);
return GetSessionStorageCacheHelper(aPrincipal, aStoragePrincipal, true,
nullptr, aRetVal);
}
nsresult SessionStorageManager::GetSessionStorageCacheHelper(
nsIPrincipal* aPrincipal, bool aMakeIfNeeded,
SessionStorageCache* aCloneFrom, RefPtr<SessionStorageCache>* aRetVal) {
nsIPrincipal* aPrincipal, nsIPrincipal* aStoragePrincipal,
bool aMakeIfNeeded, SessionStorageCache* aCloneFrom,
RefPtr<SessionStorageCache>* aRetVal) {
*aRetVal = nullptr;
nsAutoCString originKey;
@ -157,8 +150,8 @@ SessionStorageManager::GetStorage(mozIDOMWindow* aWindow,
*aRetval = nullptr;
RefPtr<SessionStorageCache> cache;
nsresult rv =
GetSessionStorageCacheHelper(aPrincipal, false, nullptr, &cache);
nsresult rv = GetSessionStorageCacheHelper(aPrincipal, aStoragePrincipal,
false, nullptr, &cache);
if (NS_FAILED(rv) || !cache) {
return rv;
}
@ -184,7 +177,7 @@ SessionStorageManager::CloneStorage(Storage* aStorage) {
RefPtr<SessionStorageCache> cache;
return GetSessionStorageCacheHelper(
aStorage->Principal(), true,
aStorage->Principal(), aStorage->StoragePrincipal(), true,
static_cast<SessionStorage*>(aStorage)->Cache(), &cache);
}
@ -202,8 +195,8 @@ SessionStorageManager::CheckStorage(nsIPrincipal* aPrincipal, Storage* aStorage,
*aRetval = false;
RefPtr<SessionStorageCache> cache;
nsresult rv =
GetSessionStorageCacheHelper(aPrincipal, false, nullptr, &cache);
nsresult rv = GetSessionStorageCacheHelper(
aPrincipal, aStorage->StoragePrincipal(), false, nullptr, &cache);
if (NS_FAILED(rv) || !cache) {
return rv;
}

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

@ -21,18 +21,12 @@ class SessionStorageObserver;
class SessionStorageManager final : public nsIDOMSessionStorageManager,
public StorageObserverSink {
public:
explicit SessionStorageManager(RefPtr<BrowsingContext> aBrowsingContext);
SessionStorageManager();
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_ISUPPORTS
NS_DECL_NSIDOMSTORAGEMANAGER
NS_DECL_NSIDOMSESSIONSTORAGEMANAGER
NS_DECL_CYCLE_COLLECTION_CLASS(SessionStorageManager)
RefPtr<BrowsingContext> GetBrowsingContext() const {
return mBrowsingContext;
}
private:
~SessionStorageManager();
@ -51,6 +45,7 @@ class SessionStorageManager final : public nsIDOMSessionStorageManager,
const nsACString& aOriginScope);
nsresult GetSessionStorageCacheHelper(nsIPrincipal* aPrincipal,
nsIPrincipal* aStoragePrincipal,
bool aMakeIfNeeded,
SessionStorageCache* aCloneFrom,
RefPtr<SessionStorageCache>* aRetVal);
@ -60,8 +55,6 @@ class SessionStorageManager final : public nsIDOMSessionStorageManager,
nsClassHashtable<nsCStringHashKey, OriginKeyHashTable> mOATable;
RefPtr<SessionStorageObserver> mObserver;
RefPtr<BrowsingContext> mBrowsingContext;
};
} // namespace dom

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

@ -241,7 +241,7 @@ nsresult LocalStorageManagerConstructor(nsISupports* aOuter, REFNSIID aIID,
nsresult SessionStorageManagerConstructor(nsISupports* aOuter, REFNSIID aIID,
void** aResult) {
RefPtr<SessionStorageManager> manager = new SessionStorageManager(nullptr);
RefPtr<SessionStorageManager> manager = new SessionStorageManager();
return manager->QueryInterface(aIID, aResult);
}

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

@ -1080,8 +1080,8 @@ static void ReadAllEntriesFromStorage(nsPIDOMWindowOuter* aWindow,
nsTArray<nsCString>& aOrigins,
nsTArray<nsString>& aKeys,
nsTArray<nsString>& aValues) {
BrowsingContext* const browsingContext = aWindow->GetBrowsingContext();
if (!browsingContext) {
nsCOMPtr<nsIDocShell> docShell = aWindow->GetDocShell();
if (!docShell) {
return;
}
@ -1108,8 +1108,7 @@ static void ReadAllEntriesFromStorage(nsPIDOMWindowOuter* aWindow,
}
/* Completed checking for recursion and is about to read storage*/
const RefPtr<SessionStorageManager> storageManager =
browsingContext->SessionStorageManager();
nsCOMPtr<nsIDOMStorageManager> storageManager = do_QueryInterface(docShell);
if (!storageManager) {
return;
}
@ -1210,14 +1209,10 @@ void SessionStoreUtils::RestoreSessionStorage(
int32_t pos = entry.mKey.RFindChar('^');
nsCOMPtr<nsIPrincipal> principal = BasePrincipal::CreateContentPrincipal(
NS_ConvertUTF16toUTF8(Substring(entry.mKey, 0, pos)));
BrowsingContext* const browsingContext =
nsDocShell::Cast(aDocShell)->GetBrowsingContext();
if (!browsingContext) {
return;
}
const RefPtr<SessionStorageManager> storageManager =
browsingContext->SessionStorageManager();
if (!storageManager) {
nsresult rv;
nsCOMPtr<nsIDOMStorageManager> storageManager =
do_QueryInterface(aDocShell, &rv);
if (NS_FAILED(rv)) {
return;
}
RefPtr<Storage> storage;

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

@ -1236,10 +1236,9 @@ nsresult nsWindowWatcher::OpenWindowInternal(
// Copy the current session storage for the current domain. Don't perform the
// copy if we're forcing noopener, however.
if (!aForceNoOpener && subjectPrincipal && parentDocShell) {
const RefPtr<SessionStorageManager> parentStorageManager =
parentDocShell->GetBrowsingContext()->SessionStorageManager();
const RefPtr<SessionStorageManager> newStorageManager =
newDocShell->GetBrowsingContext()->SessionStorageManager();
nsCOMPtr<nsIDOMStorageManager> parentStorageManager =
do_QueryInterface(parentDocShell);
nsCOMPtr<nsIDOMStorageManager> newStorageManager(newDocShell);
if (parentStorageManager && newStorageManager) {
RefPtr<Storage> storage;