2014-05-18 07:05:46 +04:00
|
|
|
/* -*- 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 "GMPChild.h"
|
2015-02-10 13:48:42 +03:00
|
|
|
#include "GMPContentChild.h"
|
2014-11-14 11:26:24 +03:00
|
|
|
#include "GMPProcessChild.h"
|
|
|
|
#include "GMPLoader.h"
|
2014-05-18 07:05:46 +04:00
|
|
|
#include "GMPVideoDecoderChild.h"
|
|
|
|
#include "GMPVideoEncoderChild.h"
|
|
|
|
#include "GMPVideoHost.h"
|
2014-09-11 01:52:36 +04:00
|
|
|
#include "nsDebugImpl.h"
|
2017-11-13 12:35:03 +03:00
|
|
|
#include "nsExceptionHandler.h"
|
2014-05-18 07:05:46 +04:00
|
|
|
#include "nsIFile.h"
|
|
|
|
#include "nsXULAppAPI.h"
|
|
|
|
#include "gmp-video-decode.h"
|
|
|
|
#include "gmp-video-encode.h"
|
|
|
|
#include "GMPPlatform.h"
|
2018-03-27 18:02:28 +03:00
|
|
|
#include "mozilla/Algorithm.h"
|
2017-02-12 22:39:44 +03:00
|
|
|
#include "mozilla/ipc/CrashReporterClient.h"
|
2016-04-11 11:12:33 +03:00
|
|
|
#include "mozilla/ipc/ProcessChild.h"
|
2019-02-25 23:22:24 +03:00
|
|
|
#include "mozilla/TextUtils.h"
|
2015-08-11 01:27:41 +03:00
|
|
|
#include "GMPUtils.h"
|
2015-08-04 07:06:50 +03:00
|
|
|
#include "prio.h"
|
2016-05-13 01:15:43 +03:00
|
|
|
#include "base/task.h"
|
2017-07-27 03:50:46 +03:00
|
|
|
#include "base/command_line.h"
|
2017-03-13 06:59:34 +03:00
|
|
|
#include "ChromiumCDMAdapter.h"
|
2017-07-27 03:50:46 +03:00
|
|
|
#include "GMPLog.h"
|
2014-07-18 21:35:44 +04:00
|
|
|
|
2016-04-11 11:12:33 +03:00
|
|
|
using namespace mozilla::ipc;
|
2014-05-18 07:05:46 +04:00
|
|
|
|
2014-05-18 18:29:00 +04:00
|
|
|
#ifdef XP_WIN
|
|
|
|
# include <stdlib.h> // for _exit()
|
2017-07-27 03:50:46 +03:00
|
|
|
# include "WinUtils.h"
|
2014-05-18 18:29:00 +04:00
|
|
|
#else
|
|
|
|
# include <unistd.h> // for _exit()
|
|
|
|
#endif
|
|
|
|
|
2014-11-25 02:22:13 +03:00
|
|
|
#if defined(MOZ_GMP_SANDBOX)
|
2015-04-01 11:40:35 +03:00
|
|
|
# if defined(XP_MACOSX)
|
2014-08-05 02:11:18 +04:00
|
|
|
# include "mozilla/Sandbox.h"
|
2014-07-17 03:01:34 +04:00
|
|
|
# endif
|
2014-08-08 20:55:22 +04:00
|
|
|
#endif
|
2014-07-17 03:01:34 +04:00
|
|
|
|
2014-05-18 07:05:46 +04:00
|
|
|
namespace mozilla {
|
2015-03-16 06:27:49 +03:00
|
|
|
|
|
|
|
#undef LOG
|
|
|
|
#undef LOGD
|
|
|
|
|
2015-11-15 16:49:01 +03:00
|
|
|
extern LogModule* GetGMPLog();
|
2015-05-21 23:22:04 +03:00
|
|
|
#define LOG(level, x, ...) MOZ_LOG(GetGMPLog(), (level), (x, ##__VA_ARGS__))
|
2015-06-04 01:25:57 +03:00
|
|
|
#define LOGD(x, ...) \
|
|
|
|
LOG(mozilla::LogLevel::Debug, "GMPChild[pid=%d] " x, \
|
|
|
|
(int)base::GetCurrentProcId(), ##__VA_ARGS__)
|
2015-03-16 06:27:49 +03:00
|
|
|
|
2014-05-18 07:05:46 +04:00
|
|
|
namespace gmp {
|
|
|
|
|
|
|
|
GMPChild::GMPChild()
|
2017-01-18 05:01:56 +03:00
|
|
|
: mGMPMessageLoop(MessageLoop::current()), mGMPLoader(nullptr) {
|
2015-03-16 06:27:49 +03:00
|
|
|
LOGD("GMPChild ctor");
|
2014-09-11 01:52:36 +04:00
|
|
|
nsDebugImpl::SetMultiprocessMode("GMP");
|
2014-05-18 07:05:46 +04:00
|
|
|
}
|
|
|
|
|
2015-03-16 06:27:49 +03:00
|
|
|
GMPChild::~GMPChild() { LOGD("GMPChild dtor"); }
|
2014-05-18 07:05:46 +04:00
|
|
|
|
2015-08-04 07:06:32 +03:00
|
|
|
static bool GetFileBase(const nsAString& aPluginPath,
|
2014-10-09 19:45:22 +04:00
|
|
|
nsCOMPtr<nsIFile>& aLibDirectory,
|
|
|
|
nsCOMPtr<nsIFile>& aFileBase, nsAutoString& aBaseName) {
|
2015-08-04 07:06:32 +03:00
|
|
|
nsresult rv = NS_NewLocalFile(aPluginPath, true, getter_AddRefs(aFileBase));
|
2017-09-19 11:14:49 +03:00
|
|
|
if (NS_WARN_IF(NS_FAILED(rv))) {
|
2014-08-08 20:55:22 +04:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2017-09-19 11:14:49 +03:00
|
|
|
if (NS_WARN_IF(NS_FAILED(aFileBase->Clone(getter_AddRefs(aLibDirectory))))) {
|
2014-08-21 22:23:02 +04:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2014-08-25 19:23:34 +04:00
|
|
|
nsCOMPtr<nsIFile> parent;
|
2014-10-09 19:45:22 +04:00
|
|
|
rv = aFileBase->GetParent(getter_AddRefs(parent));
|
2017-09-19 11:14:49 +03:00
|
|
|
if (NS_WARN_IF(NS_FAILED(rv))) {
|
2014-08-25 19:23:34 +04:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsAutoString parentLeafName;
|
|
|
|
rv = parent->GetLeafName(parentLeafName);
|
2017-09-19 11:14:49 +03:00
|
|
|
if (NS_WARN_IF(NS_FAILED(rv))) {
|
2014-08-08 20:55:22 +04:00
|
|
|
return false;
|
|
|
|
}
|
2014-08-25 19:23:34 +04:00
|
|
|
|
2014-10-09 19:45:22 +04:00
|
|
|
aBaseName = Substring(parentLeafName, 4, parentLeafName.Length() - 1);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-08-04 07:06:32 +03:00
|
|
|
static bool GetPluginFile(const nsAString& aPluginPath,
|
2014-10-09 19:45:22 +04:00
|
|
|
nsCOMPtr<nsIFile>& aLibDirectory,
|
|
|
|
nsCOMPtr<nsIFile>& aLibFile) {
|
|
|
|
nsAutoString baseName;
|
|
|
|
GetFileBase(aPluginPath, aLibDirectory, aLibFile, baseName);
|
2014-08-08 20:55:22 +04:00
|
|
|
|
|
|
|
#if defined(XP_MACOSX)
|
|
|
|
nsAutoString binaryName =
|
|
|
|
NS_LITERAL_STRING("lib") + baseName + NS_LITERAL_STRING(".dylib");
|
|
|
|
#elif defined(OS_POSIX)
|
|
|
|
nsAutoString binaryName =
|
|
|
|
NS_LITERAL_STRING("lib") + baseName + NS_LITERAL_STRING(".so");
|
|
|
|
#elif defined(XP_WIN)
|
|
|
|
nsAutoString binaryName = baseName + NS_LITERAL_STRING(".dll");
|
|
|
|
#else
|
|
|
|
# error not defined
|
|
|
|
#endif
|
2014-08-20 18:13:25 +04:00
|
|
|
aLibFile->AppendRelativePath(binaryName);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-02-10 05:48:45 +03:00
|
|
|
static bool GetPluginFile(const nsAString& aPluginPath,
|
|
|
|
nsCOMPtr<nsIFile>& aLibFile) {
|
|
|
|
nsCOMPtr<nsIFile> unusedlibDir;
|
|
|
|
return GetPluginFile(aPluginPath, unusedlibDir, aLibFile);
|
|
|
|
}
|
|
|
|
|
2017-10-18 17:27:34 +03:00
|
|
|
#if defined(XP_MACOSX)
|
2016-02-10 05:48:45 +03:00
|
|
|
static nsCString GetNativeTarget(nsIFile* aFile) {
|
|
|
|
bool isLink;
|
|
|
|
nsCString path;
|
|
|
|
aFile->IsSymlink(&isLink);
|
|
|
|
if (isLink) {
|
|
|
|
aFile->GetNativeTarget(path);
|
|
|
|
} else {
|
|
|
|
aFile->GetNativePath(path);
|
|
|
|
}
|
|
|
|
return path;
|
|
|
|
}
|
|
|
|
|
2017-10-18 17:27:34 +03:00
|
|
|
# if defined(MOZ_GMP_SANDBOX)
|
2015-08-04 07:06:32 +03:00
|
|
|
static bool GetPluginPaths(const nsAString& aPluginPath,
|
2014-08-21 22:23:02 +04:00
|
|
|
nsCString& aPluginDirectoryPath,
|
|
|
|
nsCString& aPluginFilePath) {
|
|
|
|
nsCOMPtr<nsIFile> libDirectory, libFile;
|
|
|
|
if (!GetPluginFile(aPluginPath, libDirectory, libFile)) {
|
2014-08-20 18:13:25 +04:00
|
|
|
return false;
|
|
|
|
}
|
2014-08-08 20:55:22 +04:00
|
|
|
|
2014-08-21 22:23:02 +04:00
|
|
|
// Mac sandbox rules expect paths to actual files and directories -- not
|
|
|
|
// soft links.
|
2016-12-20 05:16:31 +03:00
|
|
|
libDirectory->Normalize();
|
2016-02-10 05:48:45 +03:00
|
|
|
aPluginDirectoryPath = GetNativeTarget(libDirectory);
|
2016-12-20 05:16:31 +03:00
|
|
|
|
|
|
|
libFile->Normalize();
|
2016-02-10 05:48:45 +03:00
|
|
|
aPluginFilePath = GetNativeTarget(libFile);
|
2014-08-21 22:23:02 +04:00
|
|
|
|
2014-08-08 20:55:22 +04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-08-26 00:01:04 +04:00
|
|
|
static bool GetAppPaths(nsCString& aAppPath, nsCString& aAppBinaryPath) {
|
|
|
|
nsAutoCString appPath;
|
|
|
|
nsAutoCString appBinaryPath(
|
|
|
|
(CommandLine::ForCurrentProcess()->argv()[0]).c_str());
|
|
|
|
|
|
|
|
nsAutoCString::const_iterator start, end;
|
|
|
|
appBinaryPath.BeginReading(start);
|
|
|
|
appBinaryPath.EndReading(end);
|
|
|
|
if (RFindInReadable(NS_LITERAL_CSTRING(".app/Contents/MacOS/"), start, end)) {
|
|
|
|
end = start;
|
|
|
|
++end;
|
|
|
|
++end;
|
|
|
|
++end;
|
|
|
|
++end;
|
|
|
|
appBinaryPath.BeginReading(start);
|
|
|
|
appPath.Assign(Substring(start, end));
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsIFile> app, appBinary;
|
|
|
|
nsresult rv = NS_NewLocalFile(NS_ConvertUTF8toUTF16(appPath), true,
|
|
|
|
getter_AddRefs(app));
|
2017-09-19 11:14:49 +03:00
|
|
|
if (NS_WARN_IF(NS_FAILED(rv))) {
|
2014-08-26 00:01:04 +04:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
rv = NS_NewLocalFile(NS_ConvertUTF8toUTF16(appBinaryPath), true,
|
|
|
|
getter_AddRefs(appBinary));
|
2017-09-19 11:14:49 +03:00
|
|
|
if (NS_WARN_IF(NS_FAILED(rv))) {
|
2014-08-26 00:01:04 +04:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2016-02-10 05:48:45 +03:00
|
|
|
// Mac sandbox rules expect paths to actual files and directories -- not
|
|
|
|
// soft links.
|
|
|
|
aAppPath = GetNativeTarget(app);
|
|
|
|
appBinaryPath = GetNativeTarget(appBinary);
|
2014-08-26 00:01:04 +04:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-05-02 20:33:08 +03:00
|
|
|
bool GMPChild::SetMacSandboxInfo(MacSandboxPluginType aPluginType) {
|
2015-04-03 19:51:41 +03:00
|
|
|
if (!mGMPLoader) {
|
|
|
|
return false;
|
|
|
|
}
|
2014-08-21 22:23:02 +04:00
|
|
|
nsAutoCString pluginDirectoryPath, pluginFilePath;
|
|
|
|
if (!GetPluginPaths(mPluginPath, pluginDirectoryPath, pluginFilePath)) {
|
2015-04-03 19:51:41 +03:00
|
|
|
return false;
|
2014-08-21 22:23:02 +04:00
|
|
|
}
|
2014-08-26 00:01:04 +04:00
|
|
|
nsAutoCString appPath, appBinaryPath;
|
|
|
|
if (!GetAppPaths(appPath, appBinaryPath)) {
|
2015-04-03 19:51:41 +03:00
|
|
|
return false;
|
2014-08-26 00:01:04 +04:00
|
|
|
}
|
2014-08-21 22:23:02 +04:00
|
|
|
|
2014-08-08 20:55:22 +04:00
|
|
|
MacSandboxInfo info;
|
|
|
|
info.type = MacSandboxType_Plugin;
|
2017-01-23 23:46:49 +03:00
|
|
|
info.shouldLog = Preferences::GetBool("security.sandbox.logging.enabled") ||
|
|
|
|
PR_GetEnv("MOZ_SANDBOX_LOGGING");
|
2016-05-02 20:33:08 +03:00
|
|
|
info.pluginInfo.type = aPluginType;
|
2015-04-03 19:51:41 +03:00
|
|
|
info.pluginInfo.pluginPath.assign(pluginDirectoryPath.get());
|
|
|
|
info.pluginInfo.pluginBinaryPath.assign(pluginFilePath.get());
|
|
|
|
info.appPath.assign(appPath.get());
|
|
|
|
info.appBinaryPath.assign(appBinaryPath.get());
|
|
|
|
|
|
|
|
mGMPLoader->SetSandboxInfo(&info);
|
|
|
|
return true;
|
2014-08-08 20:55:22 +04:00
|
|
|
}
|
2017-10-18 17:27:34 +03:00
|
|
|
# endif // MOZ_GMP_SANDBOX
|
|
|
|
#endif // XP_MACOSX
|
2014-08-08 20:55:22 +04:00
|
|
|
|
2015-08-04 07:06:32 +03:00
|
|
|
bool GMPChild::Init(const nsAString& aPluginPath, base::ProcessId aParentPid,
|
2014-05-18 07:05:46 +04:00
|
|
|
MessageLoop* aIOLoop, IPC::Channel* aChannel) {
|
2015-08-04 07:06:32 +03:00
|
|
|
LOGD("%s pluginPath=%s", __FUNCTION__,
|
|
|
|
NS_ConvertUTF16toUTF8(aPluginPath).get());
|
2015-03-16 06:27:49 +03:00
|
|
|
|
2015-04-01 11:40:35 +03:00
|
|
|
if (NS_WARN_IF(!Open(aChannel, aParentPid, aIOLoop))) {
|
2014-07-22 18:00:00 +04:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2017-02-12 22:39:44 +03:00
|
|
|
CrashReporterClient::InitSingleton(this);
|
2014-08-19 23:22:16 +04:00
|
|
|
|
2014-08-08 20:55:22 +04:00
|
|
|
mPluginPath = aPluginPath;
|
2016-02-09 04:37:22 +03:00
|
|
|
|
2014-08-08 20:55:22 +04:00
|
|
|
return true;
|
2014-10-13 02:53:44 +04:00
|
|
|
}
|
|
|
|
|
2018-01-03 10:37:07 +03:00
|
|
|
mozilla::ipc::IPCResult GMPChild::RecvProvideStorageId(
|
|
|
|
const nsCString& aStorageId) {
|
|
|
|
LOGD("%s", __FUNCTION__);
|
|
|
|
mStorageId = aStorageId;
|
|
|
|
return IPC_OK();
|
|
|
|
}
|
|
|
|
|
2016-11-11 04:55:56 +03:00
|
|
|
GMPErr GMPChild::GetAPI(const char* aAPIName, void* aHostAPI, void** aPluginAPI,
|
|
|
|
uint32_t aDecryptorId) {
|
2014-11-14 11:26:24 +03:00
|
|
|
if (!mGMPLoader) {
|
|
|
|
return GMPGenericErr;
|
|
|
|
}
|
2016-11-11 04:55:56 +03:00
|
|
|
return mGMPLoader->GetAPI(aAPIName, aHostAPI, aPluginAPI, aDecryptorId);
|
2014-05-18 07:05:46 +04:00
|
|
|
}
|
|
|
|
|
2016-02-23 21:21:47 +03:00
|
|
|
mozilla::ipc::IPCResult GMPChild::RecvPreloadLibs(const nsCString& aLibs) {
|
|
|
|
#ifdef XP_WIN
|
|
|
|
// Pre-load DLLs that need to be used by the EME plugin but that can't be
|
|
|
|
// loaded after the sandbox has started
|
2016-02-09 04:37:22 +03:00
|
|
|
// Items in this must be lowercase!
|
2018-03-27 18:02:28 +03:00
|
|
|
constexpr static const char16_t* whitelist[] = {
|
|
|
|
u"dxva2.dll", // Get monitor information
|
|
|
|
u"evr.dll", // MFGetStrideForBitmapInfoHeader
|
|
|
|
u"mfplat.dll", // MFCreateSample, MFCreateAlignedMemoryBuffer,
|
|
|
|
// MFCreateMediaType
|
|
|
|
u"msmpeg2vdec.dll", // H.264 decoder
|
|
|
|
u"psapi.dll", // For GetMappedFileNameW, see bug 1383611
|
2015-08-04 07:06:50 +03:00
|
|
|
};
|
2019-02-25 23:22:24 +03:00
|
|
|
constexpr static bool (*IsASCII)(const char16_t*) =
|
|
|
|
IsAsciiNullTerminated<char16_t>;
|
2018-03-27 18:02:28 +03:00
|
|
|
static_assert(AllOf(std::begin(whitelist), std::end(whitelist), IsASCII),
|
|
|
|
"Items in the whitelist must not contain non-ASCII "
|
|
|
|
"characters!");
|
2014-10-09 19:45:22 +04:00
|
|
|
|
2016-02-09 04:37:22 +03:00
|
|
|
nsTArray<nsCString> libs;
|
2016-02-23 21:21:47 +03:00
|
|
|
SplitAt(", ", aLibs, libs);
|
2016-02-09 04:37:22 +03:00
|
|
|
for (nsCString lib : libs) {
|
|
|
|
ToLowerCase(lib);
|
2018-03-27 18:02:28 +03:00
|
|
|
for (const char16_t* whiteListedLib : whitelist) {
|
|
|
|
if (nsDependentString(whiteListedLib)
|
|
|
|
.EqualsASCII(lib.Data(), lib.Length())) {
|
|
|
|
LoadLibraryW(char16ptr_t(whiteListedLib));
|
2016-02-09 04:37:22 +03:00
|
|
|
break;
|
2014-10-09 19:45:22 +04:00
|
|
|
}
|
|
|
|
}
|
2015-08-04 07:06:50 +03:00
|
|
|
}
|
2016-02-23 21:21:47 +03:00
|
|
|
#endif
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2014-10-09 19:45:22 +04:00
|
|
|
}
|
|
|
|
|
2019-02-18 08:13:58 +03:00
|
|
|
static bool ResolveLinks(nsCOMPtr<nsIFile>& aPath) {
|
2017-07-27 03:50:46 +03:00
|
|
|
#if defined(XP_WIN)
|
|
|
|
return widget::WinUtils::ResolveJunctionPointsAndSymLinks(aPath);
|
|
|
|
#elif defined(XP_MACOSX)
|
|
|
|
nsCString targetPath = GetNativeTarget(aPath);
|
|
|
|
nsCOMPtr<nsIFile> newFile;
|
2017-09-19 11:14:49 +03:00
|
|
|
if (NS_WARN_IF(NS_FAILED(
|
|
|
|
NS_NewNativeLocalFile(targetPath, true, getter_AddRefs(newFile))))) {
|
2017-07-27 03:50:46 +03:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
aPath = newFile;
|
|
|
|
return true;
|
|
|
|
#else
|
|
|
|
return true;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2015-07-17 02:09:49 +03:00
|
|
|
bool GMPChild::GetUTF8LibPath(nsACString& aOutLibPath) {
|
2014-08-08 20:55:22 +04:00
|
|
|
#if defined(XP_MACOSX) && defined(MOZ_GMP_SANDBOX)
|
2014-11-14 11:26:24 +03:00
|
|
|
nsAutoCString pluginDirectoryPath, pluginFilePath;
|
|
|
|
if (!GetPluginPaths(mPluginPath, pluginDirectoryPath, pluginFilePath)) {
|
|
|
|
MOZ_CRASH("Error scanning plugin path");
|
|
|
|
}
|
|
|
|
aOutLibPath.Assign(pluginFilePath);
|
|
|
|
return true;
|
2014-08-08 20:55:22 +04:00
|
|
|
#else
|
2014-08-20 18:13:25 +04:00
|
|
|
nsCOMPtr<nsIFile> libFile;
|
2014-11-14 11:26:24 +03:00
|
|
|
if (!GetPluginFile(mPluginPath, libFile)) {
|
2014-05-18 07:05:46 +04:00
|
|
|
return false;
|
|
|
|
}
|
2015-07-17 02:09:49 +03:00
|
|
|
|
|
|
|
if (!FileExists(libFile)) {
|
|
|
|
NS_WARNING("Can't find GMP library file!");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsAutoString path;
|
|
|
|
libFile->GetPath(path);
|
|
|
|
aOutLibPath = NS_ConvertUTF16toUTF8(path);
|
|
|
|
|
|
|
|
return true;
|
2014-11-14 11:26:24 +03:00
|
|
|
#endif
|
|
|
|
}
|
2014-08-05 02:11:18 +04:00
|
|
|
|
2019-02-15 11:27:01 +03:00
|
|
|
static nsCOMPtr<nsIFile> AppendFile(nsCOMPtr<nsIFile>&& aFile,
|
|
|
|
const nsString& aStr) {
|
|
|
|
return (aFile && NS_SUCCEEDED(aFile->Append(aStr))) ? aFile : nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsCOMPtr<nsIFile> CloneFile(const nsCOMPtr<nsIFile>& aFile) {
|
|
|
|
nsCOMPtr<nsIFile> clone;
|
|
|
|
return (aFile && NS_SUCCEEDED(aFile->Clone(getter_AddRefs(clone)))) ? clone
|
|
|
|
: nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsCOMPtr<nsIFile> GetParentFile(const nsCOMPtr<nsIFile>& aFile) {
|
|
|
|
nsCOMPtr<nsIFile> parent;
|
|
|
|
return (aFile && NS_SUCCEEDED(aFile->GetParent(getter_AddRefs(parent))))
|
|
|
|
? parent
|
|
|
|
: nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
#if defined(XP_WIN)
|
|
|
|
static bool IsFileLeafEqualToASCII(const nsCOMPtr<nsIFile>& aFile,
|
|
|
|
const char* aStr) {
|
|
|
|
nsAutoString leafName;
|
|
|
|
return aFile && NS_SUCCEEDED(aFile->GetLeafName(leafName)) &&
|
|
|
|
leafName.EqualsASCII(aStr);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2017-07-28 14:48:56 +03:00
|
|
|
#if defined(XP_WIN)
|
|
|
|
# define FIREFOX_FILE NS_LITERAL_STRING("firefox.exe")
|
|
|
|
# define XUL_LIB_FILE NS_LITERAL_STRING("xul.dll")
|
|
|
|
#elif defined(XP_MACOSX)
|
2017-07-27 03:50:46 +03:00
|
|
|
# define FIREFOX_FILE NS_LITERAL_STRING("firefox")
|
|
|
|
# define XUL_LIB_FILE NS_LITERAL_STRING("XUL")
|
2017-07-28 14:48:56 +03:00
|
|
|
#else
|
2017-07-27 03:50:46 +03:00
|
|
|
# define FIREFOX_FILE NS_LITERAL_STRING("firefox")
|
|
|
|
# define XUL_LIB_FILE NS_LITERAL_STRING("libxul.so")
|
|
|
|
#endif
|
|
|
|
|
2019-02-15 11:27:01 +03:00
|
|
|
static nsCOMPtr<nsIFile> GetFirefoxAppPath(
|
|
|
|
nsCOMPtr<nsIFile> aPluginContainerPath) {
|
|
|
|
MOZ_ASSERT(aPluginContainerPath);
|
2017-07-27 03:50:46 +03:00
|
|
|
#if defined(XP_MACOSX)
|
2019-02-15 11:27:01 +03:00
|
|
|
// On MacOS the firefox binary is a few parent directories up from
|
|
|
|
// plugin-container.
|
2017-07-27 03:50:46 +03:00
|
|
|
// aPluginContainerPath will end with something like:
|
|
|
|
// xxxx/NightlyDebug.app/Contents/MacOS/plugin-container.app/Contents/MacOS/plugin-container
|
|
|
|
nsCOMPtr<nsIFile> path = aPluginContainerPath;
|
|
|
|
for (int i = 0; i < 4; i++) {
|
2019-02-18 08:13:58 +03:00
|
|
|
path = GetParentFile(path);
|
2017-07-27 03:50:46 +03:00
|
|
|
}
|
2019-02-18 08:13:58 +03:00
|
|
|
return path;
|
2019-02-15 11:27:01 +03:00
|
|
|
#else
|
|
|
|
nsCOMPtr<nsIFile> parent = GetParentFile(aPluginContainerPath);
|
|
|
|
# if XP_WIN
|
|
|
|
if (IsFileLeafEqualToASCII(parent, "i686")) {
|
|
|
|
// We must be on Windows on ARM64, where the plugin-container path will
|
|
|
|
// be in the 'i686' subdir. The firefox.exe is in the parent directory.
|
|
|
|
parent = GetParentFile(parent);
|
|
|
|
}
|
|
|
|
# endif
|
|
|
|
return parent;
|
|
|
|
#endif
|
2017-07-27 03:50:46 +03:00
|
|
|
}
|
2017-08-16 19:13:05 +03:00
|
|
|
|
2019-02-15 11:27:01 +03:00
|
|
|
#if defined(XP_MACOSX)
|
2017-08-21 10:17:19 +03:00
|
|
|
static bool GetSigPath(const int aRelativeLayers,
|
|
|
|
const nsString& aTargetSigFileName,
|
|
|
|
nsCOMPtr<nsIFile> aExecutablePath,
|
|
|
|
nsCOMPtr<nsIFile>& aOutSigPath) {
|
2017-08-16 19:13:05 +03:00
|
|
|
// The sig file will be located in
|
2017-08-21 10:17:19 +03:00
|
|
|
// xxxx/NightlyDebug.app/Contents/Resources/XUL.sig
|
|
|
|
// xxxx/NightlyDebug.app/Contents/Resources/firefox.sig
|
2017-08-16 19:13:05 +03:00
|
|
|
// xxxx/NightlyDebug.app/Contents/MacOS/plugin-container.app/Contents/Resources/plugin-container.sig
|
2017-08-21 10:17:19 +03:00
|
|
|
// On MacOS the sig file is a few parent directories up from
|
|
|
|
// its executable file.
|
|
|
|
// Start to search the path from the path of the executable file we provided.
|
|
|
|
MOZ_ASSERT(aExecutablePath);
|
|
|
|
nsCOMPtr<nsIFile> path = aExecutablePath;
|
|
|
|
for (int i = 0; i < aRelativeLayers; i++) {
|
2017-08-16 19:13:05 +03:00
|
|
|
nsCOMPtr<nsIFile> parent;
|
2017-09-19 11:14:49 +03:00
|
|
|
if (NS_WARN_IF(NS_FAILED(path->GetParent(getter_AddRefs(parent))))) {
|
2017-08-16 19:13:05 +03:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
path = parent;
|
|
|
|
}
|
|
|
|
MOZ_ASSERT(path);
|
2017-08-21 10:17:19 +03:00
|
|
|
aOutSigPath = path;
|
2017-08-16 19:13:05 +03:00
|
|
|
return NS_SUCCEEDED(path->Append(NS_LITERAL_STRING("Resources"))) &&
|
2017-08-21 10:17:19 +03:00
|
|
|
NS_SUCCEEDED(path->Append(aTargetSigFileName));
|
2017-08-16 19:13:05 +03:00
|
|
|
}
|
2017-07-27 03:50:46 +03:00
|
|
|
#endif
|
|
|
|
|
2019-02-18 08:13:58 +03:00
|
|
|
static bool AppendHostPath(nsCOMPtr<nsIFile>& aFile,
|
|
|
|
nsTArray<Pair<nsCString, nsCString>>& aPaths) {
|
|
|
|
nsString str;
|
|
|
|
if (!FileExists(aFile) || !ResolveLinks(aFile) ||
|
|
|
|
NS_FAILED(aFile->GetPath(str))) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCString filePath = NS_ConvertUTF16toUTF8(str);
|
|
|
|
nsCString sigFilePath;
|
|
|
|
#if defined(XP_MACOSX)
|
|
|
|
nsAutoString binary;
|
|
|
|
if (NS_FAILED(aFile->GetLeafName(binary))) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
binary.Append(NS_LITERAL_STRING(".sig"));
|
|
|
|
nsCOMPtr<nsIFile> sigFile;
|
|
|
|
if (GetSigPath(2, binary, aFile, sigFile) &&
|
|
|
|
NS_SUCCEEDED(sigFile->GetPath(str))) {
|
|
|
|
sigFilePath = NS_ConvertUTF16toUTF8(str);
|
|
|
|
} else {
|
|
|
|
// Cannot successfully get the sig file path.
|
|
|
|
// Assume it is located at the same place as plugin-container
|
|
|
|
// alternatively.
|
|
|
|
sigFilePath =
|
|
|
|
nsCString(NS_ConvertUTF16toUTF8(str) + NS_LITERAL_CSTRING(".sig"));
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
sigFilePath =
|
|
|
|
nsCString(NS_ConvertUTF16toUTF8(str) + NS_LITERAL_CSTRING(".sig"));
|
|
|
|
#endif
|
|
|
|
aPaths.AppendElement(MakePair(std::move(filePath), std::move(sigFilePath)));
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2017-07-27 03:50:46 +03:00
|
|
|
nsTArray<Pair<nsCString, nsCString>> GMPChild::MakeCDMHostVerificationPaths() {
|
2017-08-16 19:13:05 +03:00
|
|
|
// Record the file path and its sig file path.
|
|
|
|
nsTArray<Pair<nsCString, nsCString>> paths;
|
2017-07-27 03:50:46 +03:00
|
|
|
// Plugin binary path.
|
|
|
|
nsCOMPtr<nsIFile> path;
|
|
|
|
nsString str;
|
|
|
|
if (GetPluginFile(mPluginPath, path) && FileExists(path) &&
|
|
|
|
ResolveLinks(path) && NS_SUCCEEDED(path->GetPath(str))) {
|
2017-08-16 19:13:05 +03:00
|
|
|
paths.AppendElement(MakePair(
|
|
|
|
nsCString(NS_ConvertUTF16toUTF8(str)),
|
|
|
|
nsCString(NS_ConvertUTF16toUTF8(str) + NS_LITERAL_CSTRING(".sig"))));
|
2017-07-27 03:50:46 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// Plugin-container binary path.
|
|
|
|
// Note: clang won't let us initialize an nsString from a wstring, so we
|
|
|
|
// need to go through UTF8 to get to an nsString.
|
|
|
|
const std::string pluginContainer =
|
|
|
|
WideToUTF8(CommandLine::ForCurrentProcess()->program());
|
|
|
|
path = nullptr;
|
|
|
|
str = NS_ConvertUTF8toUTF16(nsDependentCString(pluginContainer.c_str()));
|
2019-02-18 08:13:58 +03:00
|
|
|
if (NS_FAILED(NS_NewLocalFile(str, true, /* aFollowLinks */
|
|
|
|
getter_AddRefs(path))) ||
|
|
|
|
!AppendHostPath(path, paths)) {
|
2017-07-27 03:50:46 +03:00
|
|
|
// Without successfully determining plugin-container's path, we can't
|
|
|
|
// determine libxul's or Firefox's. So give up.
|
|
|
|
return paths;
|
|
|
|
}
|
|
|
|
|
2019-02-15 11:27:01 +03:00
|
|
|
#if defined(XP_WIN)
|
|
|
|
// On Windows on ARM64, we should also append the x86 plugin-container's
|
|
|
|
// xul.dll.
|
|
|
|
const bool isWindowsOnARM64 =
|
|
|
|
IsFileLeafEqualToASCII(GetParentFile(path), "i686");
|
|
|
|
if (isWindowsOnARM64) {
|
|
|
|
nsCOMPtr<nsIFile> x86XulPath =
|
|
|
|
AppendFile(GetParentFile(path), XUL_LIB_FILE);
|
2019-02-18 08:13:58 +03:00
|
|
|
if (!AppendHostPath(x86XulPath, paths)) {
|
|
|
|
return paths;
|
2019-02-15 11:27:01 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2017-07-27 03:50:46 +03:00
|
|
|
// Firefox application binary path.
|
2019-02-15 11:27:01 +03:00
|
|
|
nsCOMPtr<nsIFile> appDir = GetFirefoxAppPath(path);
|
|
|
|
path = AppendFile(CloneFile(appDir), FIREFOX_FILE);
|
2019-02-18 08:13:58 +03:00
|
|
|
if (!AppendHostPath(path, paths)) {
|
|
|
|
return paths;
|
2019-02-15 11:27:01 +03:00
|
|
|
}
|
|
|
|
|
2019-02-18 08:13:58 +03:00
|
|
|
// Libxul path. Note: re-using 'appDir' var here, as we assume libxul is in
|
2017-07-27 03:50:46 +03:00
|
|
|
// the same directory as Firefox executable.
|
|
|
|
appDir->GetPath(str);
|
2019-02-15 11:27:01 +03:00
|
|
|
path = AppendFile(CloneFile(appDir), XUL_LIB_FILE);
|
2019-02-18 08:13:58 +03:00
|
|
|
if (!AppendHostPath(path, paths)) {
|
|
|
|
return paths;
|
2017-07-27 03:50:46 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
return paths;
|
|
|
|
}
|
|
|
|
|
2017-08-16 19:13:05 +03:00
|
|
|
static nsCString ToCString(const nsTArray<Pair<nsCString, nsCString>>& aPairs) {
|
2017-07-27 03:50:46 +03:00
|
|
|
nsCString result;
|
2017-08-16 19:13:05 +03:00
|
|
|
for (const auto& p : aPairs) {
|
2017-07-27 03:50:46 +03:00
|
|
|
if (!result.IsEmpty()) {
|
|
|
|
result.AppendLiteral(",");
|
|
|
|
}
|
2017-08-16 19:13:05 +03:00
|
|
|
result.Append(
|
|
|
|
nsPrintfCString("(%s,%s)", p.first().get(), p.second().get()));
|
2017-07-27 03:50:46 +03:00
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2016-04-12 07:12:21 +03:00
|
|
|
mozilla::ipc::IPCResult GMPChild::AnswerStartPlugin(const nsString& aAdapter) {
|
2015-03-16 06:27:49 +03:00
|
|
|
LOGD("%s", __FUNCTION__);
|
|
|
|
|
2014-11-14 11:26:24 +03:00
|
|
|
nsCString libPath;
|
2015-07-17 02:09:49 +03:00
|
|
|
if (!GetUTF8LibPath(libPath)) {
|
Bug 1348273 - Convert crash annotations into a machine-readable list of constants; r=ted.mielczarek,njn,dholbert,mak,cpearce,mcmanus,froydnj,Dexter,jrmuizel,jchen,jimm,bz,surkov
This introduces the machinery needed to generate crash annotations from a YAML
file. The relevant C++ functions are updated to take a typed enum. JavaScript
calls are unaffected but they will throw if the string argument does not
correspond to one of the known entries in the C++ enum. The existing whitelists
and blacklists of annotations are also generated from the YAML file and all
duplicate code related to them has been consolidated. Once written out to the
.extra file the annotations are converted in string form and are no different
than the existing ones.
All existing annotations have been included in the list (and some obsolete ones
have been removed) and all call sites have been updated including tests where
appropriate.
--HG--
extra : source : 4f6c43f2830701ec5552e08e3f1b06fe6d045860
2018-07-05 16:42:11 +03:00
|
|
|
CrashReporter::AnnotateCrashReport(
|
|
|
|
CrashReporter::Annotation::GMPLibraryPath,
|
|
|
|
NS_ConvertUTF16toUTF8(mPluginPath));
|
2017-11-13 12:35:03 +03:00
|
|
|
|
|
|
|
#ifdef XP_WIN
|
|
|
|
return IPC_FAIL(this,
|
|
|
|
nsPrintfCString("Failed to get lib path with error(%d).",
|
|
|
|
GetLastError())
|
|
|
|
.get());
|
|
|
|
#else
|
|
|
|
return IPC_FAIL(this, "Failed to get lib path.");
|
|
|
|
#endif
|
2014-05-18 07:05:46 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
auto platformAPI = new GMPPlatformAPI();
|
2014-08-05 11:56:05 +04:00
|
|
|
InitPlatformAPI(*platformAPI, this);
|
2014-05-18 07:05:46 +04:00
|
|
|
|
2017-01-19 05:44:54 +03:00
|
|
|
mGMPLoader = MakeUnique<GMPLoader>();
|
2017-01-25 00:30:37 +03:00
|
|
|
#if defined(MOZ_GMP_SANDBOX)
|
2017-01-19 05:44:54 +03:00
|
|
|
if (!mGMPLoader->CanSandbox()) {
|
|
|
|
LOGD("%s Can't sandbox GMP, failing", __FUNCTION__);
|
2015-05-28 10:32:00 +03:00
|
|
|
delete platformAPI;
|
2017-11-13 12:35:03 +03:00
|
|
|
return IPC_FAIL(this, "Can't sandbox GMP.");
|
2014-05-18 07:05:46 +04:00
|
|
|
}
|
2017-01-25 00:30:37 +03:00
|
|
|
#endif
|
2017-03-13 06:59:34 +03:00
|
|
|
bool isChromium = aAdapter.EqualsLiteral("chromium");
|
2014-11-25 02:22:14 +03:00
|
|
|
#if defined(MOZ_GMP_SANDBOX) && defined(XP_MACOSX)
|
2016-05-02 20:33:08 +03:00
|
|
|
MacSandboxPluginType pluginType = MacSandboxPluginType_GMPlugin_Default;
|
2017-08-29 12:42:25 +03:00
|
|
|
if (isChromium) {
|
2016-05-31 02:00:55 +03:00
|
|
|
pluginType = MacSandboxPluginType_GMPlugin_EME_Widevine;
|
2016-05-02 20:33:08 +03:00
|
|
|
}
|
|
|
|
if (!SetMacSandboxInfo(pluginType)) {
|
2015-04-03 19:51:41 +03:00
|
|
|
NS_WARNING("Failed to set Mac GMP sandbox info");
|
2015-05-28 10:32:00 +03:00
|
|
|
delete platformAPI;
|
2017-11-13 12:35:03 +03:00
|
|
|
return IPC_FAIL(
|
|
|
|
this, nsPrintfCString(
|
|
|
|
"Failed to set Mac GMP sandbox info with plugin type %d.",
|
|
|
|
pluginType)
|
|
|
|
.get());
|
2015-04-03 19:51:41 +03:00
|
|
|
}
|
2014-11-14 11:26:24 +03:00
|
|
|
#endif
|
|
|
|
|
2017-03-13 06:59:34 +03:00
|
|
|
GMPAdapter* adapter = nullptr;
|
2017-08-29 12:42:25 +03:00
|
|
|
if (isChromium) {
|
2017-08-16 19:13:05 +03:00
|
|
|
auto&& paths = MakeCDMHostVerificationPaths();
|
2017-07-27 03:50:46 +03:00
|
|
|
GMP_LOG("%s CDM host paths=%s", __func__, ToCString(paths).get());
|
2018-05-30 22:15:35 +03:00
|
|
|
adapter = new ChromiumCDMAdapter(std::move(paths));
|
2017-03-13 06:59:34 +03:00
|
|
|
}
|
|
|
|
|
2014-11-14 11:26:24 +03:00
|
|
|
if (!mGMPLoader->Load(libPath.get(), libPath.Length(), platformAPI,
|
2016-04-12 07:12:21 +03:00
|
|
|
adapter)) {
|
2014-11-14 11:26:24 +03:00
|
|
|
NS_WARNING("Failed to load GMP");
|
2015-05-28 10:32:00 +03:00
|
|
|
delete platformAPI;
|
Bug 1348273 - Convert crash annotations into a machine-readable list of constants; r=ted.mielczarek,njn,dholbert,mak,cpearce,mcmanus,froydnj,Dexter,jrmuizel,jchen,jimm,bz,surkov
This introduces the machinery needed to generate crash annotations from a YAML
file. The relevant C++ functions are updated to take a typed enum. JavaScript
calls are unaffected but they will throw if the string argument does not
correspond to one of the known entries in the C++ enum. The existing whitelists
and blacklists of annotations are also generated from the YAML file and all
duplicate code related to them has been consolidated. Once written out to the
.extra file the annotations are converted in string form and are no different
than the existing ones.
All existing annotations have been included in the list (and some obsolete ones
have been removed) and all call sites have been updated including tests where
appropriate.
--HG--
extra : source : 4f6c43f2830701ec5552e08e3f1b06fe6d045860
2018-07-05 16:42:11 +03:00
|
|
|
CrashReporter::AnnotateCrashReport(
|
|
|
|
CrashReporter::Annotation::GMPLibraryPath,
|
|
|
|
NS_ConvertUTF16toUTF8(mPluginPath));
|
2017-11-13 12:35:03 +03:00
|
|
|
|
|
|
|
#ifdef XP_WIN
|
|
|
|
return IPC_FAIL(this, nsPrintfCString("Failed to load GMP with error(%d).",
|
|
|
|
GetLastError())
|
|
|
|
.get());
|
|
|
|
#else
|
|
|
|
return IPC_FAIL(this, "Failed to load GMP.");
|
|
|
|
#endif
|
2014-05-18 07:05:46 +04:00
|
|
|
}
|
|
|
|
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2014-05-18 07:05:46 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
MessageLoop* GMPChild::GMPMessageLoop() { return mGMPMessageLoop; }
|
|
|
|
|
|
|
|
void GMPChild::ActorDestroy(ActorDestroyReason aWhy) {
|
2015-03-16 06:27:49 +03:00
|
|
|
LOGD("%s reason=%d", __FUNCTION__, aWhy);
|
|
|
|
|
2015-02-10 13:48:42 +03:00
|
|
|
for (uint32_t i = mGMPContentChildren.Length(); i > 0; i--) {
|
|
|
|
MOZ_ASSERT_IF(aWhy == NormalShutdown,
|
|
|
|
!mGMPContentChildren[i - 1]->IsUsed());
|
|
|
|
mGMPContentChildren[i - 1]->Close();
|
|
|
|
}
|
|
|
|
|
2014-11-14 11:26:24 +03:00
|
|
|
if (mGMPLoader) {
|
|
|
|
mGMPLoader->Shutdown();
|
2014-05-18 07:05:46 +04:00
|
|
|
}
|
|
|
|
if (AbnormalShutdown == aWhy) {
|
|
|
|
NS_WARNING("Abnormal shutdown of GMP process!");
|
2016-04-11 11:12:33 +03:00
|
|
|
ProcessChild::QuickExit();
|
2014-05-18 07:05:46 +04:00
|
|
|
}
|
|
|
|
|
2017-02-12 22:39:44 +03:00
|
|
|
CrashReporterClient::DestroySingleton();
|
2017-10-10 13:43:09 +03:00
|
|
|
|
2014-05-18 07:05:46 +04:00
|
|
|
XRE_ShutdownChildProcess();
|
|
|
|
}
|
|
|
|
|
2015-02-03 20:09:27 +03:00
|
|
|
void GMPChild::ProcessingError(Result aCode, const char* aReason) {
|
|
|
|
switch (aCode) {
|
2014-05-18 07:05:46 +04:00
|
|
|
case MsgDropped:
|
|
|
|
_exit(0); // Don't trigger a crash report.
|
|
|
|
case MsgNotKnown:
|
2018-01-30 05:02:01 +03:00
|
|
|
MOZ_CRASH("aborting because of MsgNotKnown");
|
2014-05-18 07:05:46 +04:00
|
|
|
case MsgNotAllowed:
|
2018-01-30 05:02:01 +03:00
|
|
|
MOZ_CRASH("aborting because of MsgNotAllowed");
|
2014-05-18 07:05:46 +04:00
|
|
|
case MsgPayloadError:
|
2018-01-30 05:02:01 +03:00
|
|
|
MOZ_CRASH("aborting because of MsgPayloadError");
|
2014-05-18 07:05:46 +04:00
|
|
|
case MsgProcessingError:
|
2018-01-30 05:02:01 +03:00
|
|
|
MOZ_CRASH("aborting because of MsgProcessingError");
|
2014-05-18 07:05:46 +04:00
|
|
|
case MsgRouteError:
|
2018-01-30 05:02:01 +03:00
|
|
|
MOZ_CRASH("aborting because of MsgRouteError");
|
2014-05-18 07:05:46 +04:00
|
|
|
case MsgValueError:
|
2018-01-30 05:02:01 +03:00
|
|
|
MOZ_CRASH("aborting because of MsgValueError");
|
2014-05-18 07:05:46 +04:00
|
|
|
default:
|
|
|
|
MOZ_CRASH("not reached");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-08-05 11:56:05 +04:00
|
|
|
PGMPTimerChild* GMPChild::AllocPGMPTimerChild() {
|
|
|
|
return new GMPTimerChild(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool GMPChild::DeallocPGMPTimerChild(PGMPTimerChild* aActor) {
|
|
|
|
MOZ_ASSERT(mTimerChild == static_cast<GMPTimerChild*>(aActor));
|
|
|
|
mTimerChild = nullptr;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
GMPTimerChild* GMPChild::GetGMPTimers() {
|
|
|
|
if (!mTimerChild) {
|
|
|
|
PGMPTimerChild* sc = SendPGMPTimerConstructor();
|
|
|
|
if (!sc) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
mTimerChild = static_cast<GMPTimerChild*>(sc);
|
|
|
|
}
|
|
|
|
return mTimerChild;
|
|
|
|
}
|
|
|
|
|
2014-08-19 12:56:33 +04:00
|
|
|
PGMPStorageChild* GMPChild::AllocPGMPStorageChild() {
|
|
|
|
return new GMPStorageChild(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool GMPChild::DeallocPGMPStorageChild(PGMPStorageChild* aActor) {
|
|
|
|
mStorage = nullptr;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
GMPStorageChild* GMPChild::GetGMPStorage() {
|
|
|
|
if (!mStorage) {
|
|
|
|
PGMPStorageChild* sc = SendPGMPStorageConstructor();
|
|
|
|
if (!sc) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
mStorage = static_cast<GMPStorageChild*>(sc);
|
|
|
|
}
|
|
|
|
return mStorage;
|
|
|
|
}
|
|
|
|
|
2015-10-14 09:42:25 +03:00
|
|
|
mozilla::ipc::IPCResult GMPChild::RecvCrashPluginNow() {
|
|
|
|
MOZ_CRASH();
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2014-07-31 01:40:43 +04:00
|
|
|
}
|
|
|
|
|
2015-02-10 13:48:42 +03:00
|
|
|
mozilla::ipc::IPCResult GMPChild::RecvCloseActive() {
|
|
|
|
for (uint32_t i = mGMPContentChildren.Length(); i > 0; i--) {
|
|
|
|
mGMPContentChildren[i - 1]->CloseActive();
|
|
|
|
}
|
2016-11-15 06:26:00 +03:00
|
|
|
return IPC_OK();
|
2015-02-10 13:48:42 +03:00
|
|
|
}
|
|
|
|
|
2017-01-05 23:55:27 +03:00
|
|
|
mozilla::ipc::IPCResult GMPChild::RecvInitGMPContentChild(
|
|
|
|
Endpoint<PGMPContentChild>&& aEndpoint) {
|
2015-02-10 13:48:42 +03:00
|
|
|
GMPContentChild* child =
|
|
|
|
mGMPContentChildren.AppendElement(new GMPContentChild(this))->get();
|
2017-01-05 23:55:27 +03:00
|
|
|
aEndpoint.Bind(child);
|
|
|
|
return IPC_OK();
|
2015-02-10 13:48:42 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void GMPChild::GMPContentChildActorDestroy(GMPContentChild* aGMPContentChild) {
|
|
|
|
for (uint32_t i = mGMPContentChildren.Length(); i > 0; i--) {
|
|
|
|
UniquePtr<GMPContentChild>& toDestroy = mGMPContentChildren[i - 1];
|
|
|
|
if (toDestroy.get() == aGMPContentChild) {
|
|
|
|
SendPGMPContentChildDestroyed();
|
2016-04-28 03:06:05 +03:00
|
|
|
RefPtr<DeleteTask<GMPContentChild>> task =
|
|
|
|
new DeleteTask<GMPContentChild>(toDestroy.release());
|
|
|
|
MessageLoop::current()->PostTask(task.forget());
|
2015-02-10 13:48:42 +03:00
|
|
|
mGMPContentChildren.RemoveElementAt(i - 1);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-18 07:05:46 +04:00
|
|
|
} // namespace gmp
|
|
|
|
} // namespace mozilla
|
2015-03-16 06:27:49 +03:00
|
|
|
|
|
|
|
#undef LOG
|
|
|
|
#undef LOGD
|