gecko-dev/dom/workers/Principal.h
Tom Ritter cdd2029b79 Bug 1576254 - Cut WorkerPrincipal over to a real object and implement isSystemOrAddonPrincipal r=baku
Unlike WorkletPrincipal, a WorkerPrincipal had been a simple static object shared by
all Workers. We never needed to consult it about an individual Worker before. Now we
do. So we cut it over from a static object to individual objects for each Worker.

We have an off main thread access problem for the Principal however, WorkerPrivate
has a method UsesSystemPrincipal that returns a bool that was initialized from the
Principal on the main thread. We copy that pattern and add a
UsesAddonOrExpandedAddonPrincipal method that will be called by the
isSystemOrAddonPrincipal method we must implement so we can inheirt from JSPrincipal.

Differential Revision: https://phabricator.services.mozilla.com/D47476

--HG--
extra : moz-landing-system : lando
2019-10-04 17:37:09 +00:00

37 lines
1.1 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/. */
#ifndef mozilla_dom_workers_principal_h__
#define mozilla_dom_workers_principal_h__
#include "WorkerCommon.h"
namespace mozilla {
namespace dom {
struct MOZ_HEAP_CLASS WorkerPrincipal final : public JSPrincipals {
explicit WorkerPrincipal(bool aIsSystemOrAddonPrincipal);
bool write(JSContext* aCx, JSStructuredCloneWriter* aWriter) override;
// We don't distinguish between System or Addon because the only use
// case for this right now doesn't need to. When you need to distinguish
// add a second bool.
bool isSystemOrAddonPrincipal() override;
// Callback for JS_InitDestroyPrincipalsCallback()
static void Destroy(JSPrincipals* aPrincipals);
private:
~WorkerPrincipal();
bool mIsSystemOrAddonPrincipal;
};
} // namespace dom
} // namespace mozilla
#endif /* mozilla_dom_workers_principal_h__ */