gfx/thebes/gfxFontSrcPrincipal.cpp
author Alex Gaynor <agaynor@mozilla.com>
Mon, 27 Nov 2017 14:37:34 -0600
changeset 403385 bcc0a91dd43feae18d4bf04d7db3d146035aa416
parent 396002 b6b78f4aa40fc67b891fef7c6fb995e3e380379f
child 447151 edff28b27f207b3d6e592b131bd0f7bf94da9982
permissions -rw-r--r--
Bug 1407693 - Part 2 - when a child process crashes, write extra annotation data to a pre-opened file descriptor instead of creating a new file; r=gsvelto,rbarker This removes the need for the content process to have permissions to create new files on macOS, allowing more aggressive sandboxing. MozReview-Commit-ID: 8agL5jwxDSL

/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
 * 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 "gfxFontSrcPrincipal.h"

#include "nsProxyRelease.h"
#include "nsURIHashKey.h"
#include "mozilla/BasePrincipal.h"

using mozilla::BasePrincipal;

gfxFontSrcPrincipal::gfxFontSrcPrincipal(nsIPrincipal* aPrincipal)
{
  MOZ_ASSERT(NS_IsMainThread());
  MOZ_ASSERT(aPrincipal);

  mPrincipal = aPrincipal;

  uint32_t hash = 0;
  mPrincipal->GetHashValue(&hash);
  mHash = hash;
}

gfxFontSrcPrincipal::~gfxFontSrcPrincipal()
{
  NS_ReleaseOnMainThreadSystemGroup("gfxFontSrcPrincipal::mPrincipal",
                                    mPrincipal.forget());
}

bool
gfxFontSrcPrincipal::Equals(gfxFontSrcPrincipal* aOther)
{
  return BasePrincipal::Cast(mPrincipal)->
           FastEquals(BasePrincipal::Cast(aOther->mPrincipal));
}