зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1306327 - Use UniquePtr for CreateGMPLoader. r=cpearce
--HG-- extra : rebase_source : 9f363a194d63c531f37946d76103cb0ad830c1a3
This commit is contained in:
Родитель
4bca295e61
Коммит
35a7101bda
|
@ -24,8 +24,8 @@ namespace gmp {
|
|||
|
||||
class GMPLoaderImpl : public GMPLoader {
|
||||
public:
|
||||
explicit GMPLoaderImpl(SandboxStarter* aStarter)
|
||||
: mSandboxStarter(aStarter)
|
||||
explicit GMPLoaderImpl(UniquePtr<SandboxStarter> aStarter)
|
||||
: mSandboxStarter(Move(aStarter))
|
||||
, mAdapter(nullptr)
|
||||
{}
|
||||
~GMPLoaderImpl() override = default;
|
||||
|
@ -49,12 +49,12 @@ public:
|
|||
#endif
|
||||
|
||||
private:
|
||||
SandboxStarter* mSandboxStarter;
|
||||
UniquePtr<SandboxStarter> mSandboxStarter;
|
||||
UniquePtr<GMPAdapter> mAdapter;
|
||||
};
|
||||
|
||||
UniquePtr<GMPLoader> CreateGMPLoader(SandboxStarter* aStarter) {
|
||||
return MakeUnique<GMPLoaderImpl>(aStarter);
|
||||
UniquePtr<GMPLoader> CreateGMPLoader(UniquePtr<SandboxStarter> aStarter) {
|
||||
return MakeUnique<GMPLoaderImpl>(Move(aStarter));
|
||||
}
|
||||
|
||||
class PassThroughGMPAdapter : public GMPAdapter {
|
||||
|
|
|
@ -105,7 +105,7 @@ public:
|
|||
|
||||
// On Desktop, this function resides in plugin-container.
|
||||
// On Mobile, this function resides in XUL.
|
||||
UniquePtr<GMPLoader> CreateGMPLoader(SandboxStarter* aStarter);
|
||||
UniquePtr<GMPLoader> CreateGMPLoader(UniquePtr<SandboxStarter> aStarter);
|
||||
|
||||
} // namespace gmp
|
||||
} // namespace mozilla
|
||||
|
|
|
@ -58,13 +58,13 @@ private:
|
|||
};
|
||||
#endif
|
||||
|
||||
mozilla::gmp::SandboxStarter*
|
||||
mozilla::UniquePtr<mozilla::gmp::SandboxStarter>
|
||||
MakeSandboxStarter()
|
||||
{
|
||||
#if defined(XP_WIN) && defined(MOZ_SANDBOX)
|
||||
return new WinSandboxStarter();
|
||||
return mozilla::MakeUnique<WinSandboxStarter>();
|
||||
#elif defined(XP_MACOSX) && defined(MOZ_GMP_SANDBOX)
|
||||
return new MacSandboxStarter();
|
||||
return mozilla::MakeUnique<MacSandboxStarter>();
|
||||
#else
|
||||
return nullptr;
|
||||
#endif
|
||||
|
@ -107,9 +107,8 @@ content_process_main(int argc, char* argv[])
|
|||
#if !defined(XP_LINUX) && defined(MOZ_PLUGIN_CONTAINER)
|
||||
// On Windows and MacOS, the GMPLoader lives in plugin-container, so that its
|
||||
// code can be covered by an EME/GMP vendor's voucher.
|
||||
nsAutoPtr<mozilla::gmp::SandboxStarter> starter(MakeSandboxStarter());
|
||||
if (XRE_GetProcessType() == GeckoProcessType_GMPlugin) {
|
||||
childData.gmpLoader = mozilla::gmp::CreateGMPLoader(starter);
|
||||
childData.gmpLoader = mozilla::gmp::CreateGMPLoader(MakeSandboxStarter());
|
||||
}
|
||||
#endif
|
||||
nsresult rv = XRE_InitChildProcess(argc, argv, &childData);
|
||||
|
|
|
@ -331,11 +331,14 @@ AddContentSandboxLevelAnnotation()
|
|||
#if defined (XP_LINUX) && defined(MOZ_GMP_SANDBOX)
|
||||
namespace {
|
||||
class LinuxSandboxStarter : public mozilla::gmp::SandboxStarter {
|
||||
private:
|
||||
LinuxSandboxStarter() { }
|
||||
friend mozilla::detail::UniqueSelector<LinuxSandboxStarter>::SingleObject mozilla::MakeUnique<LinuxSandboxStarter>();
|
||||
|
||||
public:
|
||||
static SandboxStarter* Make() {
|
||||
static UniquePtr<SandboxStarter> Make() {
|
||||
if (mozilla::SandboxInfo::Get().CanSandboxMedia()) {
|
||||
return new LinuxSandboxStarter();
|
||||
return MakeUnique<LinuxSandboxStarter>();
|
||||
} else {
|
||||
// Sandboxing isn't possible, but the parent has already
|
||||
// checked that this plugin doesn't require it. (Bug 1074561)
|
||||
|
@ -379,11 +382,11 @@ XRE_InitChildProcess(int aArgc,
|
|||
// On desktop Linux, the sandbox code lives in a shared library, and
|
||||
// the GMPLoader is in libxul instead of executables to avoid unwanted
|
||||
// library dependencies.
|
||||
mozilla::gmp::SandboxStarter* starter = nullptr;
|
||||
UniquePtr<mozilla::gmp::SandboxStarter> starter;
|
||||
#ifdef MOZ_GMP_SANDBOX
|
||||
starter = LinuxSandboxStarter::Make();
|
||||
#endif
|
||||
UniquePtr<GMPLoader> loader = CreateGMPLoader(starter);
|
||||
UniquePtr<GMPLoader> loader = CreateGMPLoader(Move(starter));
|
||||
GMPProcessChild::SetGMPLoader(loader.get());
|
||||
#else
|
||||
// On non-Linux platforms, the GMPLoader code resides in plugin-container,
|
||||
|
|
Загрузка…
Ссылка в новой задаче