Commit b8279164 authored by Nika Layzell's avatar Nika Layzell
Browse files

Bug 1732343 - Part 2: Migrate all uses of base::FileDescriptor to UniqueFileHandle, r=handyman

This is useful for the following parts, as UniqueFileHandle is a cross-platform
type which can also be used to support transferring HANDLEs between processes.

This change requires fairly sweeping changes to existing callsites, which
previously did not require owning access to the handle types when transferring.
For the most part these changes were straightforward, but manual.

Differential Revision: https://phabricator.services.mozilla.com/D126564
parent 9f232662
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -35,7 +35,7 @@ using class mozilla::dom::indexedDB::KeyPath
using mozilla::dom::quota::PersistenceType
  from "mozilla/dom/quota/PersistenceType.h";

[MoveOnly] using mozilla::SerializedStructuredCloneBuffer
[MoveOnly=data] using mozilla::SerializedStructuredCloneBuffer
  from "mozilla/ipc/SerializedStructuredCloneBuffer.h";

namespace mozilla {
+6 −6
Original line number Diff line number Diff line
@@ -677,7 +677,7 @@ NS_INTERFACE_MAP_END
mozilla::ipc::IPCResult ContentChild::RecvSetXPCOMProcessAttributes(
    XPCOMInitData&& aXPCOMInit, const StructuredCloneData& aInitialData,
    FullLookAndFeel&& aLookAndFeelData, dom::SystemFontList&& aFontList,
    const Maybe<SharedMemoryHandle>& aSharedUASheetHandle,
    Maybe<SharedMemoryHandle>&& aSharedUASheetHandle,
    const uintptr_t& aSharedUASheetAddress,
    nsTArray<SharedMemoryHandle>&& aSharedFontListBlocks) {
  if (!sShutdownCanary) {
@@ -693,7 +693,7 @@ mozilla::ipc::IPCResult ContentChild::RecvSetXPCOMProcessAttributes(
#endif

  gfx::gfxVars::SetValuesForInitialize(aXPCOMInit.gfxNonDefaultVarUpdates());
  InitSharedUASheets(aSharedUASheetHandle, aSharedUASheetAddress);
  InitSharedUASheets(std::move(aSharedUASheetHandle), aSharedUASheetAddress);
  InitXPCOM(std::move(aXPCOMInit), aInitialData);
  InitGraphicsDeviceData(aXPCOMInit.contentDeviceData());

@@ -1313,7 +1313,7 @@ void ContentChild::InitGraphicsDeviceData(const ContentDeviceData& aData) {
  gfxPlatform::InitChild(aData);
}

void ContentChild::InitSharedUASheets(const Maybe<SharedMemoryHandle>& aHandle,
void ContentChild::InitSharedUASheets(Maybe<SharedMemoryHandle>&& aHandle,
                                      uintptr_t aAddress) {
  MOZ_ASSERT_IF(!aHandle, !aAddress);

@@ -1324,7 +1324,7 @@ void ContentChild::InitSharedUASheets(const Maybe<SharedMemoryHandle>& aHandle,
  // Map the shared memory storing the user agent style sheets.  Do this as
  // early as possible to maximize the chance of being able to map at the
  // address we want.
  GlobalStyleSheetCache::SetSharedMemory(*aHandle, aAddress);
  GlobalStyleSheetCache::SetSharedMemory(std::move(*aHandle), aAddress);
}

void ContentChild::InitXPCOM(
@@ -2520,10 +2520,10 @@ mozilla::ipc::IPCResult ContentChild::RecvRebuildFontList(

mozilla::ipc::IPCResult ContentChild::RecvFontListShmBlockAdded(
    const uint32_t& aGeneration, const uint32_t& aIndex,
    const base::SharedMemoryHandle& aHandle) {
    base::SharedMemoryHandle&& aHandle) {
  if (gfxPlatform::Initialized()) {
    gfxPlatformFontList::PlatformFontList()->ShmBlockAdded(aGeneration, aIndex,
                                                           aHandle);
                                                           std::move(aHandle));
  }
  return IPC_OK();
}
+3 −3
Original line number Diff line number Diff line
@@ -126,7 +126,7 @@ class ContentChild final : public PContentChild,
  void InitXPCOM(XPCOMInitData&& aXPCOMInit,
                 const mozilla::dom::ipc::StructuredCloneData& aInitialData);

  void InitSharedUASheets(const Maybe<base::SharedMemoryHandle>& aHandle,
  void InitSharedUASheets(Maybe<base::SharedMemoryHandle>&& aHandle,
                          uintptr_t aAddress);

  void InitGraphicsDeviceData(const ContentDeviceData& aData);
@@ -358,7 +358,7 @@ class ContentChild final : public PContentChild,
  mozilla::ipc::IPCResult RecvRebuildFontList(const bool& aFullRebuild);
  mozilla::ipc::IPCResult RecvFontListShmBlockAdded(
      const uint32_t& aGeneration, const uint32_t& aIndex,
      const base::SharedMemoryHandle& aHandle);
      base::SharedMemoryHandle&& aHandle);

  mozilla::ipc::IPCResult RecvUpdateAppLocales(
      nsTArray<nsCString>&& aAppLocales);
@@ -542,7 +542,7 @@ class ContentChild final : public PContentChild,
  mozilla::ipc::IPCResult RecvSetXPCOMProcessAttributes(
      XPCOMInitData&& aXPCOMInit, const StructuredCloneData& aInitialData,
      FullLookAndFeel&& aLookAndFeelData, SystemFontList&& aFontList,
      const Maybe<base::SharedMemoryHandle>& aSharedUASheetHandle,
      Maybe<base::SharedMemoryHandle>&& aSharedUASheetHandle,
      const uintptr_t& aSharedUASheetAddress,
      nsTArray<base::SharedMemoryHandle>&& aSharedFontListBlocks);

+5 −4
Original line number Diff line number Diff line
@@ -1637,7 +1637,8 @@ void ContentParent::BroadcastShmBlockAdded(uint32_t aGeneration,
      // request the block as needed, at some performance cost.
      continue;
    }
    Unused << cp->SendFontListShmBlockAdded(aGeneration, aIndex, handle);
    Unused << cp->SendFontListShmBlockAdded(aGeneration, aIndex,
                                            std::move(handle));
  }
}

@@ -2976,14 +2977,14 @@ bool ContentParent::InitInternal(ProcessPriority aInitialPriority) {

  SharedMemoryHandle handle;
  if (sheetCache->ShareToProcess(OtherPid(), &handle)) {
    sharedUASheetHandle.emplace(handle);
    sharedUASheetHandle.emplace(std::move(handle));
  } else {
    sharedUASheetAddress = 0;
  }

  Unused << SendSetXPCOMProcessAttributes(
      xpcomInit, initialData, lnf, fontList, sharedUASheetHandle,
      sharedUASheetAddress, sharedFontListBlocks);
      xpcomInit, initialData, lnf, fontList, std::move(sharedUASheetHandle),
      sharedUASheetAddress, std::move(sharedFontListBlocks));

  ipc::WritableSharedMap* sharedData =
      nsFrameMessageManager::sParentProcessManager->SharedData();
+2 −2
Original line number Diff line number Diff line
@@ -117,14 +117,14 @@ using mozilla::Telemetry::ChildEventData from "mozilla/TelemetryComms.h";
#endif  // defined(XP_WIN)

using mozilla::Telemetry::DiscardedData from "mozilla/TelemetryComms.h";
using mozilla::CrossProcessMutexHandle from "mozilla/ipc/CrossProcessMutex.h";
[MoveOnly] using mozilla::CrossProcessMutexHandle from "mozilla/ipc/CrossProcessMutex.h";
using mozilla::dom::MaybeDiscardedBrowsingContext from "mozilla/dom/BrowsingContext.h";
using mozilla::dom::BrowsingContextTransaction from "mozilla/dom/BrowsingContext.h";
using mozilla::dom::BrowsingContextInitializer from "mozilla/dom/BrowsingContext.h";
using mozilla::dom::PermitUnloadResult from "nsIContentViewer.h";
using mozilla::dom::MaybeDiscardedWindowContext from "mozilla/dom/WindowContext.h";
using mozilla::dom::WindowContextTransaction from "mozilla/dom/WindowContext.h";
using base::SharedMemoryHandle from "base/shared_memory.h";
[MoveOnly] using base::SharedMemoryHandle from "base/shared_memory.h";
using mozilla::fontlist::Pointer from "SharedFontList.h";
using gfxSparseBitSet from "gfxFontUtils.h";
using FontVisibility from "gfxFontEntry.h";
Loading