Commit 0ba5a52a authored by Jonathan Kew's avatar Jonathan Kew
Browse files

Bug 1704812 - Broadcast newly-added FontList shm blocks to Content Processes...

Bug 1704812 - Broadcast newly-added FontList shm blocks to Content Processes instead of waiting and doing sync IPC. r=emilio,jld

Differential Revision: https://phabricator.services.mozilla.com/D112666
parent c94f215c
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -2357,6 +2357,14 @@ mozilla::ipc::IPCResult ContentChild::RecvRebuildFontList(
  return IPC_OK();
}

mozilla::ipc::IPCResult ContentChild::RecvFontListShmBlockAdded(
    const uint32_t& aGeneration, const uint32_t& aIndex,
    const base::SharedMemoryHandle& aHandle) {
  gfxPlatformFontList::PlatformFontList()->ShmBlockAdded(aGeneration, aIndex,
                                                         aHandle);
  return IPC_OK();
}

mozilla::ipc::IPCResult ContentChild::RecvUpdateAppLocales(
    nsTArray<nsCString>&& aAppLocales) {
  LocaleService::GetInstance()->AssignAppLocales(aAppLocales);
+3 −0
Original line number Diff line number Diff line
@@ -352,6 +352,9 @@ class ContentChild final : public PContentChild,

  mozilla::ipc::IPCResult RecvUpdateFontList(SystemFontList&&);
  mozilla::ipc::IPCResult RecvRebuildFontList(const bool& aFullRebuild);
  mozilla::ipc::IPCResult RecvFontListShmBlockAdded(
      const uint32_t& aGeneration, const uint32_t& aIndex,
      const base::SharedMemoryHandle& aHandle);

  mozilla::ipc::IPCResult RecvUpdateAppLocales(
      nsTArray<nsCString>&& aAppLocales);
+15 −0
Original line number Diff line number Diff line
@@ -1632,6 +1632,21 @@ void ContentParent::BroadcastFontListChanged() {
  }
}

void ContentParent::BroadcastShmBlockAdded(uint32_t aGeneration,
                                           uint32_t aIndex) {
  auto* pfl = gfxPlatformFontList::PlatformFontList();
  for (auto* cp : AllProcesses(eLive)) {
    base::SharedMemoryHandle handle =
        pfl->ShareShmBlockToProcess(aIndex, cp->Pid());
    if (handle == base::SharedMemory::NULLHandle()) {
      // If something went wrong here, we just skip it; the child will need to
      // request the block as needed, at some performance cost.
      continue;
    }
    Unused << cp->SendFontListShmBlockAdded(aGeneration, aIndex, handle);
  }
}

void ContentParent::BroadcastThemeUpdate(widget::ThemeChangeKind aKind) {
  const FullLookAndFeel& lnf = *RemoteLookAndFeel::ExtractData();
  for (auto* cp : AllProcesses(eLive)) {
+1 −0
Original line number Diff line number Diff line
@@ -259,6 +259,7 @@ class ContentParent final
  static void BroadcastStringBundle(const StringBundleDescriptor&);

  static void BroadcastFontListChanged();
  static void BroadcastShmBlockAdded(uint32_t aGeneration, uint32_t aIndex);

  static void BroadcastThemeUpdate(widget::ThemeChangeKind);

+7 −0
Original line number Diff line number Diff line
@@ -635,6 +635,13 @@ child:
     */
    async FontListChanged();

    /**
     * A new shmem block has been added to the font list; the child process
     * should map the new block and add to its index.
     */
    async FontListShmBlockAdded(uint32_t aGeneration, uint32_t aIndex,
                                SharedMemoryHandle aHandle);

    async UpdateAppLocales(nsCString[] appLocales);
    async UpdateRequestedLocales(nsCString[] requestedLocales);

Loading