Files
firefox/docshell/base/ChromeBrowsingContext.cpp
T
arthur.iakab 69725c7dd7 Backed out 13 changesets (bug 1500948, bug 1509362, bug 1509591, bug 1448426, bug 1500949, bug 1487249, bug 1509930, bug 1500950, bug 1500944) for causing crashes and assertion failures on PBackgroundParent.cpp:696 CLOSED TREE
Backed out changeset c3fe435e473a (bug 1509362)
Backed out changeset 6494840edc17 (bug 1509591)
Backed out changeset 123b5d5a3637 (bug 1509591)
Backed out changeset bce195f98895 (bug 1509930)
Backed out changeset 66db13126408 (bug 1500950)
Backed out changeset 3b5fffae2d2b (bug 1500949)
Backed out changeset 71c3b3677db8 (bug 1500948)
Backed out changeset 784b3b56e2ab (bug 1500944)
Backed out changeset 0bad27401ddb (bug 1500944)
Backed out changeset e0f95dd96d54 (bug 1448426)
Backed out changeset c60fa11538db (bug 1487249)
Backed out changeset 0190d4ffa54f (bug 1487249)
Backed out changeset 3cd10aba9130 (bug 1487249)
2018-11-28 02:57:32 +02:00

67 lines
2.3 KiB
C++

/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* 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 "ChromeBrowsingContext.h"
namespace mozilla {
namespace dom {
ChromeBrowsingContext::ChromeBrowsingContext(BrowsingContext* aParent,
BrowsingContext* aOpener,
const nsAString& aName,
uint64_t aBrowsingContextId,
uint64_t aProcessId,
BrowsingContext::Type aType)
: BrowsingContext(aParent, aOpener, aName, aBrowsingContextId, aType)
, mProcessId(aProcessId)
{
// You are only ever allowed to create ChromeBrowsingContexts in the
// parent process.
MOZ_RELEASE_ASSERT(XRE_IsParentProcess());
}
// TODO(farre): ChromeBrowsingContext::CleanupContexts starts from the
// list of root BrowsingContexts. This isn't enough when separate
// BrowsingContext nodes of a BrowsingContext tree, not in a crashing
// child process, are from that process and thus needs to be
// cleaned. [Bug 1472108]
/* static */ void
ChromeBrowsingContext::CleanupContexts(uint64_t aProcessId)
{
nsTArray<RefPtr<BrowsingContext>> roots;
BrowsingContext::GetRootBrowsingContexts(roots);
for (RefPtr<BrowsingContext> context : roots) {
if (Cast(context)->IsOwnedByProcess(aProcessId)) {
context->Detach();
}
}
}
/* static */ already_AddRefed<ChromeBrowsingContext>
ChromeBrowsingContext::Get(uint64_t aId)
{
MOZ_RELEASE_ASSERT(XRE_IsParentProcess());
return BrowsingContext::Get(aId).downcast<ChromeBrowsingContext>();
}
/* static */ ChromeBrowsingContext*
ChromeBrowsingContext::Cast(BrowsingContext* aContext)
{
MOZ_RELEASE_ASSERT(XRE_IsParentProcess());
return static_cast<ChromeBrowsingContext*>(aContext);
}
/* static */ const ChromeBrowsingContext*
ChromeBrowsingContext::Cast(const BrowsingContext* aContext)
{
MOZ_RELEASE_ASSERT(XRE_IsParentProcess());
return static_cast<const ChromeBrowsingContext*>(aContext);
}
} // namespace dom
} // namespace mozilla