mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-11-08 12:19:05 +02:00
The inclusions were removed with the following very crude script and the
resulting breakage was fixed up by hand. The manual fixups did either
revert the changes done by the script, replace a generic header with a more
specific one or replace a header with a forward declaration.
find . -name "*.idl" | grep -v web-platform | grep -v third_party | while read path; do
interfaces=$(grep "^\(class\|interface\).*:.*" "$path" | cut -d' ' -f2)
if [ -n "$interfaces" ]; then
if [[ "$interfaces" == *$'\n'* ]]; then
regexp="\("
for i in $interfaces; do regexp="$regexp$i\|"; done
regexp="${regexp%%\\\|}\)"
else
regexp="$interfaces"
fi
interface=$(basename "$path")
rg -l "#include.*${interface%%.idl}.h" . | while read path2; do
hits=$(grep -v "#include.*${interface%%.idl}.h" "$path2" | grep -c "$regexp" )
if [ $hits -eq 0 ]; then
echo "Removing ${interface} from ${path2}"
grep -v "#include.*${interface%%.idl}.h" "$path2" > "$path2".tmp
mv -f "$path2".tmp "$path2"
fi
done
fi
done
Differential Revision: https://phabricator.services.mozilla.com/D55442
--HG--
extra : moz-landing-system : lando
135 lines
3.9 KiB
C++
135 lines
3.9 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 "ContentProcessManager.h"
|
|
#include "ContentParent.h"
|
|
#include "mozilla/dom/BrowserParent.h"
|
|
|
|
#include "mozilla/StaticPtr.h"
|
|
#include "mozilla/ClearOnShutdown.h"
|
|
|
|
#include "nsPrintfCString.h"
|
|
|
|
// XXX need another bug to move this to a common header.
|
|
#ifdef DISABLE_ASSERTS_FOR_FUZZING
|
|
# define ASSERT_UNLESS_FUZZING(...) \
|
|
do { \
|
|
} while (0)
|
|
#else
|
|
# define ASSERT_UNLESS_FUZZING(...) MOZ_ASSERT(false, __VA_ARGS__)
|
|
#endif
|
|
|
|
namespace mozilla {
|
|
namespace dom {
|
|
|
|
/* static */
|
|
StaticAutoPtr<ContentProcessManager> ContentProcessManager::sSingleton;
|
|
|
|
/* static */
|
|
ContentProcessManager* ContentProcessManager::GetSingleton() {
|
|
MOZ_ASSERT(XRE_IsParentProcess());
|
|
|
|
if (!sSingleton) {
|
|
sSingleton = new ContentProcessManager();
|
|
ClearOnShutdown(&sSingleton);
|
|
}
|
|
return sSingleton;
|
|
}
|
|
|
|
void ContentProcessManager::AddContentProcess(ContentParent* aChildCp) {
|
|
MOZ_ASSERT(NS_IsMainThread());
|
|
MOZ_ASSERT(aChildCp);
|
|
|
|
auto entry = mContentParentMap.LookupForAdd(aChildCp->ChildID());
|
|
MOZ_ASSERT_IF(entry, entry.Data() == aChildCp);
|
|
entry.OrInsert([&] { return aChildCp; });
|
|
}
|
|
|
|
void ContentProcessManager::RemoveContentProcess(
|
|
const ContentParentId& aChildCpId) {
|
|
MOZ_ASSERT(NS_IsMainThread());
|
|
|
|
MOZ_ALWAYS_TRUE(mContentParentMap.Remove(aChildCpId));
|
|
}
|
|
|
|
ContentParent* ContentProcessManager::GetContentProcessById(
|
|
const ContentParentId& aChildCpId) {
|
|
MOZ_ASSERT(NS_IsMainThread());
|
|
|
|
ContentParent* contentParent = mContentParentMap.Get(aChildCpId);
|
|
if (NS_WARN_IF(!contentParent)) {
|
|
ASSERT_UNLESS_FUZZING();
|
|
return nullptr;
|
|
}
|
|
return contentParent;
|
|
}
|
|
|
|
bool ContentProcessManager::RegisterRemoteFrame(BrowserParent* aChildBp) {
|
|
MOZ_ASSERT(NS_IsMainThread());
|
|
MOZ_ASSERT(aChildBp);
|
|
|
|
auto entry = mBrowserParentMap.LookupForAdd(aChildBp->GetTabId());
|
|
MOZ_ASSERT_IF(entry, entry.Data() == aChildBp);
|
|
entry.OrInsert([&] { return aChildBp; });
|
|
return !entry;
|
|
}
|
|
|
|
void ContentProcessManager::UnregisterRemoteFrame(const TabId& aChildTabId) {
|
|
MOZ_ASSERT(NS_IsMainThread());
|
|
|
|
MOZ_ALWAYS_TRUE(mBrowserParentMap.Remove(aChildTabId));
|
|
}
|
|
|
|
ContentParentId ContentProcessManager::GetTabProcessId(
|
|
const TabId& aChildTabId) {
|
|
MOZ_ASSERT(NS_IsMainThread());
|
|
|
|
if (BrowserParent* browserParent = mBrowserParentMap.Get(aChildTabId)) {
|
|
return browserParent->Manager()->ChildID();
|
|
}
|
|
return ContentParentId(0);
|
|
}
|
|
|
|
uint32_t ContentProcessManager::GetBrowserParentCountByProcessId(
|
|
const ContentParentId& aChildCpId) {
|
|
MOZ_ASSERT(NS_IsMainThread());
|
|
|
|
ContentParent* contentParent = mContentParentMap.Get(aChildCpId);
|
|
if (NS_WARN_IF(!contentParent)) {
|
|
return 0;
|
|
}
|
|
return contentParent->ManagedPBrowserParent().Count();
|
|
}
|
|
|
|
already_AddRefed<BrowserParent>
|
|
ContentProcessManager::GetBrowserParentByProcessAndTabId(
|
|
const ContentParentId& aChildCpId, const TabId& aChildTabId) {
|
|
RefPtr<BrowserParent> browserParent = mBrowserParentMap.Get(aChildTabId);
|
|
if (NS_WARN_IF(!browserParent)) {
|
|
return nullptr;
|
|
}
|
|
|
|
if (NS_WARN_IF(browserParent->Manager()->ChildID() != aChildCpId)) {
|
|
return nullptr;
|
|
}
|
|
|
|
return browserParent.forget();
|
|
}
|
|
|
|
already_AddRefed<BrowserParent>
|
|
ContentProcessManager::GetTopLevelBrowserParentByProcessAndTabId(
|
|
const ContentParentId& aChildCpId, const TabId& aChildTabId) {
|
|
RefPtr<BrowserParent> browserParent =
|
|
GetBrowserParentByProcessAndTabId(aChildCpId, aChildTabId);
|
|
while (browserParent && browserParent->GetBrowserBridgeParent()) {
|
|
browserParent = browserParent->GetBrowserBridgeParent()->Manager();
|
|
}
|
|
|
|
return browserParent.forget();
|
|
}
|
|
|
|
} // namespace dom
|
|
} // namespace mozilla
|