2009-06-30 18:51:05 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
|
|
|
* vim: sw=4 ts=4 et :
|
2012-05-21 11:12:37 +00:00
|
|
|
* 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/. */
|
2009-06-30 18:51:05 +00:00
|
|
|
|
2013-08-02 01:21:32 +00:00
|
|
|
#ifdef MOZ_WIDGET_QT
|
|
|
|
// Must be included first to avoid conflicts.
|
|
|
|
#include <QtCore/QCoreApplication>
|
|
|
|
#include <QtCore/QEventLoop>
|
|
|
|
#include "NestedLoopTimer.h"
|
|
|
|
#endif
|
|
|
|
|
2013-07-24 07:41:03 +00:00
|
|
|
#include "mozilla/plugins/PluginModuleParent.h"
|
2010-03-11 07:35:29 +00:00
|
|
|
|
2010-02-11 20:32:18 +00:00
|
|
|
#include "base/process_util.h"
|
2013-07-24 07:41:03 +00:00
|
|
|
#include "mozilla/Attributes.h"
|
|
|
|
#include "mozilla/dom/PCrashReporterParent.h"
|
2013-09-28 01:42:08 +00:00
|
|
|
#include "mozilla/ipc/MessageChannel.h"
|
2009-09-09 14:04:09 +00:00
|
|
|
#include "mozilla/plugins/BrowserStreamParent.h"
|
2013-08-14 07:00:47 +00:00
|
|
|
#include "mozilla/plugins/PluginInstanceParent.h"
|
2013-07-24 07:41:03 +00:00
|
|
|
#include "mozilla/Preferences.h"
|
|
|
|
#include "mozilla/Services.h"
|
|
|
|
#include "mozilla/unused.h"
|
2010-08-10 21:14:10 +00:00
|
|
|
#include "nsAutoPtr.h"
|
2010-01-14 01:20:00 +00:00
|
|
|
#include "nsCRT.h"
|
2012-06-06 02:08:30 +00:00
|
|
|
#include "nsIFile.h"
|
2013-07-24 07:41:03 +00:00
|
|
|
#include "nsIObserverService.h"
|
|
|
|
#include "nsNPAPIPlugin.h"
|
2012-07-25 12:38:43 +00:00
|
|
|
#include "nsPrintfCString.h"
|
2013-07-24 07:41:03 +00:00
|
|
|
#include "PluginIdentifierParent.h"
|
2012-07-25 12:38:43 +00:00
|
|
|
#include "prsystem.h"
|
2013-09-10 20:56:05 +00:00
|
|
|
#include "GeckoProfiler.h"
|
2009-09-14 20:01:31 +00:00
|
|
|
|
2011-06-24 14:20:03 +00:00
|
|
|
#ifdef XP_WIN
|
2013-01-04 22:59:05 +00:00
|
|
|
#include "PluginHangUIParent.h"
|
2011-06-24 14:20:03 +00:00
|
|
|
#include "mozilla/widget/AudioSession.h"
|
|
|
|
#endif
|
2013-07-24 07:41:03 +00:00
|
|
|
|
2013-04-27 14:20:23 +00:00
|
|
|
#ifdef MOZ_ENABLE_PROFILER_SPS
|
2013-03-21 09:17:23 +00:00
|
|
|
#include "nsIProfileSaveEvent.h"
|
2013-04-27 14:20:23 +00:00
|
|
|
#endif
|
2013-07-24 07:41:03 +00:00
|
|
|
|
|
|
|
#ifdef MOZ_WIDGET_GTK
|
|
|
|
#include <glib.h>
|
|
|
|
#elif XP_MACOSX
|
|
|
|
#include "PluginInterposeOSX.h"
|
|
|
|
#include "PluginUtilsOSX.h"
|
|
|
|
#endif
|
|
|
|
|
2010-02-11 20:32:18 +00:00
|
|
|
using base::KillProcess;
|
2009-06-30 18:51:05 +00:00
|
|
|
|
2010-02-11 20:32:18 +00:00
|
|
|
using mozilla::PluginLibrary;
|
2013-09-28 01:42:08 +00:00
|
|
|
using mozilla::ipc::MessageChannel;
|
2011-06-08 19:56:31 +00:00
|
|
|
using mozilla::dom::PCrashReporterParent;
|
|
|
|
using mozilla::dom::CrashReporterParent;
|
2009-09-14 20:01:31 +00:00
|
|
|
|
2011-05-25 06:32:00 +00:00
|
|
|
using namespace mozilla;
|
2009-09-14 20:01:31 +00:00
|
|
|
using namespace mozilla::plugins;
|
2011-06-14 19:49:48 +00:00
|
|
|
using namespace mozilla::plugins::parent;
|
2009-09-14 20:01:31 +00:00
|
|
|
|
2012-07-11 02:20:05 +00:00
|
|
|
#ifdef MOZ_CRASHREPORTER
|
|
|
|
#include "mozilla/dom/CrashReporterParent.h"
|
|
|
|
|
|
|
|
using namespace CrashReporter;
|
|
|
|
#endif
|
|
|
|
|
2011-08-16 10:25:34 +00:00
|
|
|
static const char kChildTimeoutPref[] = "dom.ipc.plugins.timeoutSecs";
|
|
|
|
static const char kParentTimeoutPref[] = "dom.ipc.plugins.parentTimeoutSecs";
|
2010-08-10 21:14:10 +00:00
|
|
|
static const char kLaunchTimeoutPref[] = "dom.ipc.plugins.processLaunchTimeoutSecs";
|
2013-01-04 22:59:05 +00:00
|
|
|
#ifdef XP_WIN
|
|
|
|
static const char kHangUITimeoutPref[] = "dom.ipc.plugins.hangUITimeoutSecs";
|
|
|
|
static const char kHangUIMinDisplayPref[] = "dom.ipc.plugins.hangUIMinDisplaySecs";
|
|
|
|
#define CHILD_TIMEOUT_PREF kHangUITimeoutPref
|
|
|
|
#else
|
|
|
|
#define CHILD_TIMEOUT_PREF kChildTimeoutPref
|
|
|
|
#endif
|
2010-02-11 20:32:18 +00:00
|
|
|
|
|
|
|
template<>
|
|
|
|
struct RunnableMethodTraits<mozilla::plugins::PluginModuleParent>
|
|
|
|
{
|
|
|
|
typedef mozilla::plugins::PluginModuleParent Class;
|
|
|
|
static void RetainCallee(Class* obj) { }
|
|
|
|
static void ReleaseCallee(Class* obj) { }
|
|
|
|
};
|
|
|
|
|
2009-11-09 22:56:55 +00:00
|
|
|
// static
|
2009-10-27 19:51:12 +00:00
|
|
|
PluginLibrary*
|
|
|
|
PluginModuleParent::LoadModule(const char* aFilePath)
|
2009-06-30 18:51:05 +00:00
|
|
|
{
|
2009-12-18 22:22:51 +00:00
|
|
|
PLUGIN_LOG_DEBUG_FUNCTION;
|
2009-06-30 18:51:05 +00:00
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t prefSecs = Preferences::GetInt(kLaunchTimeoutPref, 0);
|
2010-08-10 21:14:10 +00:00
|
|
|
|
2009-06-30 18:51:05 +00:00
|
|
|
// Block on the child process being launched and initialized.
|
2010-08-10 21:14:10 +00:00
|
|
|
nsAutoPtr<PluginModuleParent> parent(new PluginModuleParent(aFilePath));
|
|
|
|
bool launched = parent->mSubprocess->Launch(prefSecs * 1000);
|
|
|
|
if (!launched) {
|
2014-02-28 23:39:17 +00:00
|
|
|
// We never reached open
|
2010-08-10 21:14:10 +00:00
|
|
|
parent->mShutdown = true;
|
2012-07-30 14:20:58 +00:00
|
|
|
return nullptr;
|
2010-08-10 21:14:10 +00:00
|
|
|
}
|
2009-11-09 22:56:55 +00:00
|
|
|
parent->Open(parent->mSubprocess->GetChannel(),
|
|
|
|
parent->mSubprocess->GetChildProcessHandle());
|
2009-06-30 18:51:05 +00:00
|
|
|
|
2013-01-04 22:59:05 +00:00
|
|
|
TimeoutChanged(CHILD_TIMEOUT_PREF, parent);
|
2011-06-08 19:56:31 +00:00
|
|
|
|
|
|
|
#ifdef MOZ_CRASHREPORTER
|
2011-10-19 19:32:17 +00:00
|
|
|
// If this fails, we're having IPC troubles, and we're doomed anyways.
|
|
|
|
if (!CrashReporterParent::CreateCrashReporter(parent.get())) {
|
2014-02-28 23:39:17 +00:00
|
|
|
parent->Close();
|
2012-07-30 14:20:58 +00:00
|
|
|
return nullptr;
|
2011-10-19 19:32:17 +00:00
|
|
|
}
|
2013-12-03 22:19:58 +00:00
|
|
|
#ifdef XP_WIN
|
|
|
|
mozilla::MutexAutoLock lock(parent->mCrashReporterMutex);
|
|
|
|
parent->mCrashReporter = parent->CrashReporter();
|
|
|
|
#endif
|
2011-06-08 19:56:31 +00:00
|
|
|
#endif
|
|
|
|
|
2010-08-10 21:14:10 +00:00
|
|
|
return parent.forget();
|
2009-06-30 18:51:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-11-09 22:56:55 +00:00
|
|
|
PluginModuleParent::PluginModuleParent(const char* aFilePath)
|
2009-12-03 20:31:52 +00:00
|
|
|
: mSubprocess(new PluginProcessParent(aFilePath))
|
|
|
|
, mShutdown(false)
|
2011-02-08 22:16:07 +00:00
|
|
|
, mClearSiteDataSupported(false)
|
|
|
|
, mGetSitesWithDataSupported(false)
|
2013-10-23 20:34:46 +00:00
|
|
|
, mNPNIface(nullptr)
|
|
|
|
, mPlugin(nullptr)
|
2013-07-24 07:41:03 +00:00
|
|
|
, mTaskFactory(MOZ_THIS_IN_INITIALIZER_LIST())
|
2012-07-25 12:38:43 +00:00
|
|
|
#ifdef XP_WIN
|
2012-08-09 10:36:30 +00:00
|
|
|
, mPluginCpuUsageOnHang()
|
2013-01-04 22:59:05 +00:00
|
|
|
, mHangUIParent(nullptr)
|
|
|
|
, mHangUIEnabled(true)
|
|
|
|
, mIsTimerReset(true)
|
2013-12-03 22:19:58 +00:00
|
|
|
#ifdef MOZ_CRASHREPORTER
|
|
|
|
, mCrashReporterMutex("PluginModuleParent::mCrashReporterMutex")
|
|
|
|
, mCrashReporter(nullptr)
|
|
|
|
#endif
|
2012-07-25 12:38:43 +00:00
|
|
|
#endif
|
2012-07-03 11:49:23 +00:00
|
|
|
#ifdef MOZ_CRASHREPORTER_INJECTOR
|
|
|
|
, mFlashProcess1(0)
|
|
|
|
, mFlashProcess2(0)
|
|
|
|
#endif
|
2009-06-30 18:51:05 +00:00
|
|
|
{
|
2009-11-09 22:56:55 +00:00
|
|
|
NS_ASSERTION(mSubprocess, "Out of memory!");
|
|
|
|
|
2011-08-16 10:25:34 +00:00
|
|
|
Preferences::RegisterCallback(TimeoutChanged, kChildTimeoutPref, this);
|
|
|
|
Preferences::RegisterCallback(TimeoutChanged, kParentTimeoutPref, this);
|
2013-01-04 22:59:05 +00:00
|
|
|
#ifdef XP_WIN
|
|
|
|
Preferences::RegisterCallback(TimeoutChanged, kHangUITimeoutPref, this);
|
|
|
|
Preferences::RegisterCallback(TimeoutChanged, kHangUIMinDisplayPref, this);
|
|
|
|
#endif
|
2013-03-21 09:17:23 +00:00
|
|
|
|
2013-04-27 14:20:23 +00:00
|
|
|
#ifdef MOZ_ENABLE_PROFILER_SPS
|
2013-03-21 09:17:23 +00:00
|
|
|
InitPluginProfiling();
|
2013-04-27 14:20:23 +00:00
|
|
|
#endif
|
2009-06-30 18:51:05 +00:00
|
|
|
}
|
|
|
|
|
2009-09-09 06:31:35 +00:00
|
|
|
PluginModuleParent::~PluginModuleParent()
|
2009-06-30 18:51:05 +00:00
|
|
|
{
|
2014-02-28 23:39:17 +00:00
|
|
|
if (!OkToCleanup()) {
|
|
|
|
NS_RUNTIMEABORT("unsafe destruction");
|
|
|
|
}
|
2010-03-07 20:16:02 +00:00
|
|
|
|
2013-04-27 14:20:23 +00:00
|
|
|
#ifdef MOZ_ENABLE_PROFILER_SPS
|
2013-03-21 09:17:23 +00:00
|
|
|
ShutdownPluginProfiling();
|
2013-04-27 14:20:23 +00:00
|
|
|
#endif
|
2013-03-21 09:17:23 +00:00
|
|
|
|
2009-12-03 20:31:52 +00:00
|
|
|
if (!mShutdown) {
|
|
|
|
NS_WARNING("Plugin host deleted the module without shutting down.");
|
|
|
|
NPError err;
|
|
|
|
NP_Shutdown(&err);
|
|
|
|
}
|
2014-02-28 23:39:17 +00:00
|
|
|
|
2009-12-03 20:31:52 +00:00
|
|
|
NS_ASSERTION(mShutdown, "NP_Shutdown didn't");
|
|
|
|
|
2009-11-09 22:56:55 +00:00
|
|
|
if (mSubprocess) {
|
|
|
|
mSubprocess->Delete();
|
2012-07-30 14:20:58 +00:00
|
|
|
mSubprocess = nullptr;
|
2009-11-09 22:56:55 +00:00
|
|
|
}
|
2010-02-11 20:32:18 +00:00
|
|
|
|
2012-07-03 11:49:23 +00:00
|
|
|
#ifdef MOZ_CRASHREPORTER_INJECTOR
|
|
|
|
if (mFlashProcess1)
|
2012-07-11 02:20:05 +00:00
|
|
|
UnregisterInjectorCallback(mFlashProcess1);
|
2012-07-03 11:49:23 +00:00
|
|
|
if (mFlashProcess2)
|
2012-07-11 02:20:05 +00:00
|
|
|
UnregisterInjectorCallback(mFlashProcess2);
|
2012-07-03 11:49:23 +00:00
|
|
|
#endif
|
|
|
|
|
2011-08-16 10:25:34 +00:00
|
|
|
Preferences::UnregisterCallback(TimeoutChanged, kChildTimeoutPref, this);
|
|
|
|
Preferences::UnregisterCallback(TimeoutChanged, kParentTimeoutPref, this);
|
2013-01-04 22:59:05 +00:00
|
|
|
#ifdef XP_WIN
|
|
|
|
Preferences::UnregisterCallback(TimeoutChanged, kHangUITimeoutPref, this);
|
|
|
|
Preferences::UnregisterCallback(TimeoutChanged, kHangUIMinDisplayPref, this);
|
|
|
|
|
|
|
|
if (mHangUIParent) {
|
|
|
|
delete mHangUIParent;
|
|
|
|
mHangUIParent = nullptr;
|
|
|
|
}
|
|
|
|
#endif
|
2009-06-30 18:51:05 +00:00
|
|
|
}
|
|
|
|
|
2010-03-24 21:22:03 +00:00
|
|
|
#ifdef MOZ_CRASHREPORTER
|
2010-01-14 01:20:00 +00:00
|
|
|
void
|
2012-07-11 02:20:05 +00:00
|
|
|
PluginModuleParent::WriteExtraDataForMinidump(AnnotationTable& notes)
|
2010-01-14 01:20:00 +00:00
|
|
|
{
|
2013-12-03 22:19:58 +00:00
|
|
|
#ifdef XP_WIN
|
|
|
|
// mCrashReporterMutex is already held by the caller
|
|
|
|
mCrashReporterMutex.AssertCurrentThreadOwns();
|
|
|
|
#endif
|
2010-03-24 21:22:03 +00:00
|
|
|
typedef nsDependentCString CS;
|
2010-01-14 01:20:00 +00:00
|
|
|
|
|
|
|
// Get the plugin filename, try to get just the file leafname
|
|
|
|
const std::string& pluginFile = mSubprocess->GetPluginFilePath();
|
|
|
|
size_t filePos = pluginFile.rfind(FILE_PATH_SEPARATOR);
|
|
|
|
if (filePos == std::string::npos)
|
|
|
|
filePos = 0;
|
|
|
|
else
|
|
|
|
filePos++;
|
2012-12-13 17:06:52 +00:00
|
|
|
notes.Put(NS_LITERAL_CSTRING("PluginFilename"), CS(pluginFile.substr(filePos).c_str()));
|
|
|
|
|
|
|
|
nsCString pluginName;
|
|
|
|
nsCString pluginVersion;
|
|
|
|
|
2013-03-20 18:29:00 +00:00
|
|
|
nsRefPtr<nsPluginHost> ph = nsPluginHost::GetInst();
|
2012-12-13 17:06:52 +00:00
|
|
|
if (ph) {
|
|
|
|
nsPluginTag* tag = ph->TagForPlugin(mPlugin);
|
|
|
|
if (tag) {
|
|
|
|
pluginName = tag->mName;
|
|
|
|
pluginVersion = tag->mVersion;
|
|
|
|
}
|
|
|
|
}
|
2014-02-28 23:39:17 +00:00
|
|
|
|
2012-12-13 17:06:52 +00:00
|
|
|
notes.Put(NS_LITERAL_CSTRING("PluginName"), pluginName);
|
|
|
|
notes.Put(NS_LITERAL_CSTRING("PluginVersion"), pluginVersion);
|
2010-02-24 22:25:16 +00:00
|
|
|
|
2012-07-03 11:49:23 +00:00
|
|
|
CrashReporterParent* crashReporter = CrashReporter();
|
|
|
|
if (crashReporter) {
|
2012-07-25 12:38:43 +00:00
|
|
|
#ifdef XP_WIN
|
2012-09-08 17:20:59 +00:00
|
|
|
if (mPluginCpuUsageOnHang.Length() > 0) {
|
2012-12-13 17:06:52 +00:00
|
|
|
notes.Put(NS_LITERAL_CSTRING("NumberOfProcessors"),
|
2012-09-08 17:20:59 +00:00
|
|
|
nsPrintfCString("%d", PR_GetNumberOfProcessors()));
|
2012-08-09 10:36:30 +00:00
|
|
|
|
2012-09-08 17:20:59 +00:00
|
|
|
nsCString cpuUsageStr;
|
|
|
|
cpuUsageStr.AppendFloat(std::ceil(mPluginCpuUsageOnHang[0] * 100) / 100);
|
2012-12-13 17:06:52 +00:00
|
|
|
notes.Put(NS_LITERAL_CSTRING("PluginCpuUsage"), cpuUsageStr);
|
2012-08-09 09:04:27 +00:00
|
|
|
|
2012-08-09 10:36:30 +00:00
|
|
|
#ifdef MOZ_CRASHREPORTER_INJECTOR
|
2012-09-08 17:20:59 +00:00
|
|
|
for (uint32_t i=1; i<mPluginCpuUsageOnHang.Length(); ++i) {
|
2012-08-09 10:36:30 +00:00
|
|
|
nsCString tempStr;
|
|
|
|
tempStr.AppendFloat(std::ceil(mPluginCpuUsageOnHang[i] * 100) / 100);
|
|
|
|
notes.Put(nsPrintfCString("CpuUsageFlashProcess%d", i), tempStr);
|
2012-07-25 12:38:43 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
2012-09-08 17:20:59 +00:00
|
|
|
#endif
|
2012-07-03 11:49:23 +00:00
|
|
|
}
|
2010-03-24 21:22:03 +00:00
|
|
|
}
|
|
|
|
#endif // MOZ_CRASHREPORTER
|
2010-02-24 22:25:16 +00:00
|
|
|
|
2013-01-04 22:59:05 +00:00
|
|
|
void
|
|
|
|
PluginModuleParent::SetChildTimeout(const int32_t aChildTimeout)
|
|
|
|
{
|
|
|
|
int32_t timeoutMs = (aChildTimeout > 0) ? (1000 * aChildTimeout) :
|
2013-09-28 01:42:08 +00:00
|
|
|
MessageChannel::kNoTimeout;
|
2013-01-04 22:59:05 +00:00
|
|
|
SetReplyTimeoutMs(timeoutMs);
|
|
|
|
}
|
|
|
|
|
2013-12-10 23:10:01 +00:00
|
|
|
void
|
2010-02-11 20:32:18 +00:00
|
|
|
PluginModuleParent::TimeoutChanged(const char* aPref, void* aModule)
|
|
|
|
{
|
2013-01-04 22:59:05 +00:00
|
|
|
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
|
|
|
#ifndef XP_WIN
|
2011-08-16 10:25:34 +00:00
|
|
|
if (!strcmp(aPref, kChildTimeoutPref)) {
|
|
|
|
// The timeout value used by the parent for children
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t timeoutSecs = Preferences::GetInt(kChildTimeoutPref, 0);
|
2013-01-04 22:59:05 +00:00
|
|
|
static_cast<PluginModuleParent*>(aModule)->SetChildTimeout(timeoutSecs);
|
|
|
|
#else
|
|
|
|
if (!strcmp(aPref, kChildTimeoutPref) ||
|
|
|
|
!strcmp(aPref, kHangUIMinDisplayPref) ||
|
|
|
|
!strcmp(aPref, kHangUITimeoutPref)) {
|
|
|
|
static_cast<PluginModuleParent*>(aModule)->EvaluateHangUIState(true);
|
|
|
|
#endif // XP_WIN
|
2011-08-16 10:25:34 +00:00
|
|
|
} else if (!strcmp(aPref, kParentTimeoutPref)) {
|
|
|
|
// The timeout value used by the child for its parent
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t timeoutSecs = Preferences::GetInt(kParentTimeoutPref, 0);
|
2012-02-22 00:32:06 +00:00
|
|
|
unused << static_cast<PluginModuleParent*>(aModule)->SendSetParentHangTimeout(timeoutSecs);
|
2011-08-16 10:25:34 +00:00
|
|
|
}
|
2010-02-11 20:32:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2013-01-25 02:10:02 +00:00
|
|
|
PluginModuleParent::CleanupFromTimeout(const bool aFromHangUI)
|
2010-02-11 20:32:18 +00:00
|
|
|
{
|
2012-10-15 10:29:47 +00:00
|
|
|
if (mShutdown) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!OkToCleanup()) {
|
|
|
|
// there's still plugin code on the C++ stack, try again
|
|
|
|
MessageLoop::current()->PostDelayedTask(
|
|
|
|
FROM_HERE,
|
|
|
|
mTaskFactory.NewRunnableMethod(
|
2013-01-25 02:10:02 +00:00
|
|
|
&PluginModuleParent::CleanupFromTimeout, aFromHangUI), 10);
|
2012-10-15 10:29:47 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-01-25 02:10:02 +00:00
|
|
|
/* If the plugin container was terminated by the Plugin Hang UI,
|
|
|
|
then either the I/O thread detects a channel error, or the
|
|
|
|
main thread must set the error (whomever gets there first).
|
|
|
|
OTOH, if we terminate and return false from
|
|
|
|
ShouldContinueFromReplyTimeout, then the channel state has
|
|
|
|
already been set to ChannelTimeout and we should call the
|
|
|
|
regular Close function. */
|
|
|
|
if (aFromHangUI) {
|
|
|
|
GetIPCChannel()->CloseWithError();
|
|
|
|
} else {
|
|
|
|
Close();
|
|
|
|
}
|
2010-02-11 20:32:18 +00:00
|
|
|
}
|
|
|
|
|
2012-07-25 12:38:43 +00:00
|
|
|
#ifdef XP_WIN
|
|
|
|
namespace {
|
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
uint64_t
|
2012-07-25 12:38:43 +00:00
|
|
|
FileTimeToUTC(const FILETIME& ftime)
|
|
|
|
{
|
|
|
|
ULARGE_INTEGER li;
|
|
|
|
li.LowPart = ftime.dwLowDateTime;
|
|
|
|
li.HighPart = ftime.dwHighDateTime;
|
|
|
|
return li.QuadPart;
|
|
|
|
}
|
|
|
|
|
2012-08-09 10:36:30 +00:00
|
|
|
struct CpuUsageSamples
|
|
|
|
{
|
2012-08-22 15:56:38 +00:00
|
|
|
uint64_t sampleTimes[2];
|
|
|
|
uint64_t cpuTimes[2];
|
2012-08-09 10:36:30 +00:00
|
|
|
};
|
|
|
|
|
2012-07-25 12:38:43 +00:00
|
|
|
bool
|
2012-08-09 10:36:30 +00:00
|
|
|
GetProcessCpuUsage(const InfallibleTArray<base::ProcessHandle>& processHandles, InfallibleTArray<float>& cpuUsage)
|
2012-07-25 12:38:43 +00:00
|
|
|
{
|
2012-08-09 10:36:30 +00:00
|
|
|
InfallibleTArray<CpuUsageSamples> samples(processHandles.Length());
|
2012-07-25 12:38:43 +00:00
|
|
|
FILETIME creationTime, exitTime, kernelTime, userTime, currentTime;
|
|
|
|
BOOL res;
|
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
for (uint32_t i = 0; i < processHandles.Length(); ++i) {
|
2012-08-09 10:36:30 +00:00
|
|
|
::GetSystemTimeAsFileTime(¤tTime);
|
|
|
|
res = ::GetProcessTimes(processHandles[i], &creationTime, &exitTime, &kernelTime, &userTime);
|
|
|
|
if (!res) {
|
|
|
|
NS_WARNING("failed to get process times");
|
|
|
|
return false;
|
|
|
|
}
|
2012-08-08 22:30:26 +00:00
|
|
|
|
2012-08-09 10:36:30 +00:00
|
|
|
CpuUsageSamples s;
|
|
|
|
s.sampleTimes[0] = FileTimeToUTC(currentTime);
|
|
|
|
s.cpuTimes[0] = FileTimeToUTC(kernelTime) + FileTimeToUTC(userTime);
|
|
|
|
samples.AppendElement(s);
|
|
|
|
}
|
2012-08-08 22:30:26 +00:00
|
|
|
|
2012-07-25 12:38:43 +00:00
|
|
|
// we already hung for a while, a little bit longer won't matter
|
|
|
|
::Sleep(50);
|
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
const int32_t numberOfProcessors = PR_GetNumberOfProcessors();
|
2012-08-09 10:36:30 +00:00
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
for (uint32_t i = 0; i < processHandles.Length(); ++i) {
|
2012-08-09 10:36:30 +00:00
|
|
|
::GetSystemTimeAsFileTime(¤tTime);
|
|
|
|
res = ::GetProcessTimes(processHandles[i], &creationTime, &exitTime, &kernelTime, &userTime);
|
|
|
|
if (!res) {
|
|
|
|
NS_WARNING("failed to get process times");
|
|
|
|
return false;
|
|
|
|
}
|
2012-07-25 12:38:43 +00:00
|
|
|
|
2012-08-09 10:36:30 +00:00
|
|
|
samples[i].sampleTimes[1] = FileTimeToUTC(currentTime);
|
|
|
|
samples[i].cpuTimes[1] = FileTimeToUTC(kernelTime) + FileTimeToUTC(userTime);
|
2012-07-25 12:38:43 +00:00
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
const uint64_t deltaSampleTime = samples[i].sampleTimes[1] - samples[i].sampleTimes[0];
|
|
|
|
const uint64_t deltaCpuTime = samples[i].cpuTimes[1] - samples[i].cpuTimes[0];
|
2012-08-09 10:36:30 +00:00
|
|
|
const float usage = 100.f * (float(deltaCpuTime) / deltaSampleTime) / numberOfProcessors;
|
|
|
|
cpuUsage.AppendElement(usage);
|
|
|
|
}
|
2012-07-25 12:38:43 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
} // anonymous namespace
|
2013-01-04 22:59:05 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
PluginModuleParent::ExitedCxxStack()
|
|
|
|
{
|
|
|
|
FinishHangUI();
|
|
|
|
}
|
|
|
|
|
2012-07-25 12:38:43 +00:00
|
|
|
#endif // #ifdef XP_WIN
|
|
|
|
|
2012-09-26 20:49:20 +00:00
|
|
|
#ifdef MOZ_CRASHREPORTER_INJECTOR
|
|
|
|
static bool
|
|
|
|
CreateFlashMinidump(DWORD processId, ThreadId childThread,
|
|
|
|
nsIFile* parentMinidump, const nsACString& name)
|
|
|
|
{
|
|
|
|
if (processId == 0) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
base::ProcessHandle handle;
|
|
|
|
if (!base::OpenPrivilegedProcessHandle(processId, &handle)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool res = CreateAdditionalChildMinidump(handle, 0, parentMinidump, name);
|
|
|
|
base::CloseProcessHandle(handle);
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2010-02-11 20:32:18 +00:00
|
|
|
bool
|
|
|
|
PluginModuleParent::ShouldContinueFromReplyTimeout()
|
|
|
|
{
|
2013-01-04 22:59:05 +00:00
|
|
|
#ifdef XP_WIN
|
|
|
|
if (LaunchHangUI()) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
// If LaunchHangUI returned false then we should proceed with the
|
|
|
|
// original plugin hang behaviour and kill the plugin container.
|
|
|
|
FinishHangUI();
|
|
|
|
#endif // XP_WIN
|
|
|
|
TerminateChildProcess(MessageLoop::current());
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
PluginModuleParent::TerminateChildProcess(MessageLoop* aMsgLoop)
|
|
|
|
{
|
2010-03-24 21:22:03 +00:00
|
|
|
#ifdef MOZ_CRASHREPORTER
|
2013-12-03 22:19:58 +00:00
|
|
|
#ifdef XP_WIN
|
|
|
|
mozilla::MutexAutoLock lock(mCrashReporterMutex);
|
|
|
|
CrashReporterParent* crashReporter = mCrashReporter;
|
|
|
|
if (!crashReporter) {
|
|
|
|
// If mCrashReporter is null then the hang has ended, the plugin module
|
|
|
|
// is shutting down. There's nothing to do here.
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
#else
|
2012-07-11 02:20:05 +00:00
|
|
|
CrashReporterParent* crashReporter = CrashReporter();
|
2013-12-03 22:19:58 +00:00
|
|
|
#endif
|
2012-09-08 17:20:59 +00:00
|
|
|
crashReporter->AnnotateCrashReport(NS_LITERAL_CSTRING("PluginHang"),
|
|
|
|
NS_LITERAL_CSTRING("1"));
|
2013-01-04 22:59:05 +00:00
|
|
|
#ifdef XP_WIN
|
|
|
|
if (mHangUIParent) {
|
|
|
|
unsigned int hangUIDuration = mHangUIParent->LastShowDurationMs();
|
|
|
|
if (hangUIDuration) {
|
|
|
|
nsPrintfCString strHangUIDuration("%u", hangUIDuration);
|
|
|
|
crashReporter->AnnotateCrashReport(
|
|
|
|
NS_LITERAL_CSTRING("PluginHangUIDuration"),
|
|
|
|
strHangUIDuration);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif // XP_WIN
|
2012-07-11 02:20:05 +00:00
|
|
|
if (crashReporter->GeneratePairedMinidump(this)) {
|
|
|
|
mPluginDumpID = crashReporter->ChildDumpID();
|
|
|
|
PLUGIN_LOG_DEBUG(
|
2012-09-08 17:20:59 +00:00
|
|
|
("generated paired browser/plugin minidumps: %s)",
|
|
|
|
NS_ConvertUTF16toUTF8(mPluginDumpID).get()));
|
|
|
|
|
2012-09-11 15:21:26 +00:00
|
|
|
nsAutoCString additionalDumps("browser");
|
|
|
|
|
|
|
|
#ifdef MOZ_CRASHREPORTER_INJECTOR
|
|
|
|
nsCOMPtr<nsIFile> pluginDumpFile;
|
|
|
|
|
|
|
|
if (GetMinidumpForID(mPluginDumpID, getter_AddRefs(pluginDumpFile)) &&
|
|
|
|
pluginDumpFile) {
|
|
|
|
nsCOMPtr<nsIFile> childDumpFile;
|
|
|
|
|
2012-09-26 20:49:20 +00:00
|
|
|
if (CreateFlashMinidump(mFlashProcess1, 0, pluginDumpFile,
|
|
|
|
NS_LITERAL_CSTRING("flash1"))) {
|
2012-09-11 15:21:26 +00:00
|
|
|
additionalDumps.Append(",flash1");
|
|
|
|
}
|
2012-09-26 20:49:20 +00:00
|
|
|
if (CreateFlashMinidump(mFlashProcess2, 0, pluginDumpFile,
|
|
|
|
NS_LITERAL_CSTRING("flash2"))) {
|
2012-09-11 15:21:26 +00:00
|
|
|
additionalDumps.Append(",flash2");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2012-09-08 17:20:59 +00:00
|
|
|
crashReporter->AnnotateCrashReport(
|
|
|
|
NS_LITERAL_CSTRING("additional_minidumps"),
|
2012-09-11 15:21:26 +00:00
|
|
|
additionalDumps);
|
2012-07-11 02:20:05 +00:00
|
|
|
} else {
|
|
|
|
NS_WARNING("failed to capture paired minidumps from hang");
|
2010-03-24 21:22:03 +00:00
|
|
|
}
|
|
|
|
#endif
|
2010-02-11 20:32:18 +00:00
|
|
|
|
2012-07-25 12:38:43 +00:00
|
|
|
#ifdef XP_WIN
|
2012-08-09 10:36:30 +00:00
|
|
|
// collect cpu usage for plugin processes
|
|
|
|
|
|
|
|
InfallibleTArray<base::ProcessHandle> processHandles;
|
|
|
|
|
|
|
|
processHandles.AppendElement(OtherProcess());
|
2013-02-28 01:25:38 +00:00
|
|
|
|
2012-08-09 10:36:30 +00:00
|
|
|
#ifdef MOZ_CRASHREPORTER_INJECTOR
|
2013-02-28 01:25:38 +00:00
|
|
|
{
|
|
|
|
base::ProcessHandle handle;
|
|
|
|
if (mFlashProcess1 && base::OpenProcessHandle(mFlashProcess1, &handle)) {
|
|
|
|
processHandles.AppendElement(handle);
|
|
|
|
}
|
|
|
|
if (mFlashProcess2 && base::OpenProcessHandle(mFlashProcess2, &handle)) {
|
|
|
|
processHandles.AppendElement(handle);
|
|
|
|
}
|
2012-08-09 10:36:30 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (!GetProcessCpuUsage(processHandles, mPluginCpuUsageOnHang)) {
|
|
|
|
mPluginCpuUsageOnHang.Clear();
|
2012-07-25 12:38:43 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2010-03-24 21:22:03 +00:00
|
|
|
// this must run before the error notification from the channel,
|
|
|
|
// or not at all
|
2013-01-25 02:10:02 +00:00
|
|
|
bool isFromHangUI = aMsgLoop != MessageLoop::current();
|
2013-09-23 17:34:00 +00:00
|
|
|
aMsgLoop->PostTask(
|
|
|
|
FROM_HERE,
|
|
|
|
mTaskFactory.NewRunnableMethod(
|
|
|
|
&PluginModuleParent::CleanupFromTimeout, isFromHangUI));
|
2010-03-24 21:22:03 +00:00
|
|
|
|
|
|
|
if (!KillProcess(OtherProcess(), 1, false))
|
|
|
|
NS_WARNING("failed to kill subprocess!");
|
2013-01-04 22:59:05 +00:00
|
|
|
}
|
2010-03-24 21:22:03 +00:00
|
|
|
|
2013-01-04 22:59:05 +00:00
|
|
|
#ifdef XP_WIN
|
|
|
|
void
|
|
|
|
PluginModuleParent::EvaluateHangUIState(const bool aReset)
|
|
|
|
{
|
|
|
|
int32_t minDispSecs = Preferences::GetInt(kHangUIMinDisplayPref, 10);
|
|
|
|
int32_t autoStopSecs = Preferences::GetInt(kChildTimeoutPref, 0);
|
|
|
|
int32_t timeoutSecs = 0;
|
|
|
|
if (autoStopSecs > 0 && autoStopSecs < minDispSecs) {
|
|
|
|
/* If we're going to automatically terminate the plugin within a
|
|
|
|
time frame shorter than minDispSecs, there's no point in
|
|
|
|
showing the hang UI; it would just flash briefly on the screen. */
|
|
|
|
mHangUIEnabled = false;
|
|
|
|
} else {
|
|
|
|
timeoutSecs = Preferences::GetInt(kHangUITimeoutPref, 0);
|
|
|
|
mHangUIEnabled = timeoutSecs > 0;
|
|
|
|
}
|
|
|
|
if (mHangUIEnabled) {
|
|
|
|
if (aReset) {
|
|
|
|
mIsTimerReset = true;
|
|
|
|
SetChildTimeout(timeoutSecs);
|
|
|
|
return;
|
|
|
|
} else if (mIsTimerReset) {
|
|
|
|
/* The Hang UI is being shown, so now we're setting the
|
|
|
|
timeout to kChildTimeoutPref while we wait for a user
|
|
|
|
response. ShouldContinueFromReplyTimeout will fire
|
|
|
|
after (reply timeout / 2) seconds, which is not what
|
|
|
|
we want. Doubling the timeout value here so that we get
|
|
|
|
the right result. */
|
|
|
|
autoStopSecs *= 2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
mIsTimerReset = false;
|
|
|
|
SetChildTimeout(autoStopSecs);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
PluginModuleParent::GetPluginName(nsAString& aPluginName)
|
|
|
|
{
|
2013-03-20 18:29:00 +00:00
|
|
|
nsRefPtr<nsPluginHost> host = nsPluginHost::GetInst();
|
2013-01-04 22:59:05 +00:00
|
|
|
if (!host) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
nsPluginTag* pluginTag = host->TagForPlugin(mPlugin);
|
|
|
|
if (!pluginTag) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
CopyUTF8toUTF16(pluginTag->mName, aPluginName);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
PluginModuleParent::LaunchHangUI()
|
|
|
|
{
|
|
|
|
if (!mHangUIEnabled) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (mHangUIParent) {
|
|
|
|
if (mHangUIParent->IsShowing()) {
|
|
|
|
// We've already shown the UI but the timeout has expired again.
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (mHangUIParent->DontShowAgain()) {
|
|
|
|
return !mHangUIParent->WasLastHangStopped();
|
|
|
|
}
|
|
|
|
delete mHangUIParent;
|
|
|
|
mHangUIParent = nullptr;
|
|
|
|
}
|
2013-02-12 20:05:39 +00:00
|
|
|
mHangUIParent = new PluginHangUIParent(this,
|
2013-04-11 21:08:55 +00:00
|
|
|
Preferences::GetInt(kHangUITimeoutPref, 0),
|
|
|
|
Preferences::GetInt(kChildTimeoutPref, 0));
|
2013-01-04 22:59:05 +00:00
|
|
|
nsAutoString pluginName;
|
|
|
|
if (!GetPluginName(pluginName)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
bool retval = mHangUIParent->Init(pluginName);
|
|
|
|
if (retval) {
|
|
|
|
/* Once the UI is shown we switch the timeout over to use
|
|
|
|
kChildTimeoutPref, allowing us to terminate a hung plugin
|
|
|
|
after kChildTimeoutPref seconds if the user doesn't respond to
|
|
|
|
the hang UI. */
|
|
|
|
EvaluateHangUIState(false);
|
|
|
|
}
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
PluginModuleParent::FinishHangUI()
|
|
|
|
{
|
|
|
|
if (mHangUIEnabled && mHangUIParent) {
|
|
|
|
bool needsCancel = mHangUIParent->IsShowing();
|
|
|
|
// If we're still showing, send a Cancel notification
|
|
|
|
if (needsCancel) {
|
|
|
|
mHangUIParent->Cancel();
|
|
|
|
}
|
|
|
|
/* If we cancelled the UI or if the user issued a response,
|
|
|
|
we need to reset the child process timeout. */
|
|
|
|
if (needsCancel ||
|
|
|
|
!mIsTimerReset && mHangUIParent->WasShown()) {
|
|
|
|
/* We changed the timeout to kChildTimeoutPref when the plugin hang
|
|
|
|
UI was displayed. Now that we're finishing the UI, we need to
|
|
|
|
switch it back to kHangUITimeoutPref. */
|
|
|
|
EvaluateHangUIState(true);
|
|
|
|
}
|
|
|
|
}
|
2010-02-11 20:32:18 +00:00
|
|
|
}
|
2013-01-04 22:59:05 +00:00
|
|
|
#endif // XP_WIN
|
2010-02-11 20:32:18 +00:00
|
|
|
|
2011-06-08 19:56:31 +00:00
|
|
|
#ifdef MOZ_CRASHREPORTER
|
|
|
|
CrashReporterParent*
|
|
|
|
PluginModuleParent::CrashReporter()
|
|
|
|
{
|
|
|
|
return static_cast<CrashReporterParent*>(ManagedPCrashReporterParent()[0]);
|
|
|
|
}
|
|
|
|
|
2012-08-07 07:06:29 +00:00
|
|
|
#ifdef MOZ_CRASHREPORTER_INJECTOR
|
2012-07-11 02:20:05 +00:00
|
|
|
static void
|
|
|
|
RemoveMinidump(nsIFile* minidump)
|
|
|
|
{
|
|
|
|
if (!minidump)
|
|
|
|
return;
|
|
|
|
|
|
|
|
minidump->Remove(false);
|
|
|
|
nsCOMPtr<nsIFile> extraFile;
|
|
|
|
if (GetExtraFileForMinidump(minidump,
|
|
|
|
getter_AddRefs(extraFile))) {
|
|
|
|
extraFile->Remove(true);
|
|
|
|
}
|
|
|
|
}
|
2012-08-07 07:06:29 +00:00
|
|
|
#endif // MOZ_CRASHREPORTER_INJECTOR
|
2012-07-11 02:20:05 +00:00
|
|
|
|
2009-12-03 20:31:52 +00:00
|
|
|
void
|
2012-07-11 02:20:05 +00:00
|
|
|
PluginModuleParent::ProcessFirstMinidump()
|
2009-12-03 20:31:52 +00:00
|
|
|
{
|
2013-12-03 22:19:58 +00:00
|
|
|
#ifdef XP_WIN
|
|
|
|
mozilla::MutexAutoLock lock(mCrashReporterMutex);
|
|
|
|
#endif
|
2012-07-11 02:20:05 +00:00
|
|
|
CrashReporterParent* crashReporter = CrashReporter();
|
|
|
|
if (!crashReporter)
|
|
|
|
return;
|
2011-06-08 19:56:31 +00:00
|
|
|
|
2013-09-02 08:41:57 +00:00
|
|
|
AnnotationTable notes(4);
|
2012-07-11 02:20:05 +00:00
|
|
|
WriteExtraDataForMinidump(notes);
|
2012-09-08 17:20:59 +00:00
|
|
|
|
|
|
|
if (!mPluginDumpID.IsEmpty()) {
|
|
|
|
crashReporter->GenerateChildData(¬es);
|
2012-07-11 02:20:05 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-09-28 06:57:33 +00:00
|
|
|
uint32_t sequence = UINT32_MAX;
|
2012-07-11 02:20:05 +00:00
|
|
|
nsCOMPtr<nsIFile> dumpFile;
|
2012-09-02 02:35:17 +00:00
|
|
|
nsAutoCString flashProcessType;
|
2012-07-11 02:20:05 +00:00
|
|
|
TakeMinidump(getter_AddRefs(dumpFile), &sequence);
|
|
|
|
|
|
|
|
#ifdef MOZ_CRASHREPORTER_INJECTOR
|
|
|
|
nsCOMPtr<nsIFile> childDumpFile;
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t childSequence;
|
2012-07-11 02:20:05 +00:00
|
|
|
|
|
|
|
if (mFlashProcess1 &&
|
|
|
|
TakeMinidumpForChild(mFlashProcess1,
|
|
|
|
getter_AddRefs(childDumpFile),
|
|
|
|
&childSequence)) {
|
|
|
|
if (childSequence < sequence) {
|
|
|
|
RemoveMinidump(dumpFile);
|
|
|
|
dumpFile = childDumpFile;
|
|
|
|
sequence = childSequence;
|
|
|
|
flashProcessType.AssignLiteral("Broker");
|
2012-07-03 11:49:23 +00:00
|
|
|
}
|
2012-07-11 02:20:05 +00:00
|
|
|
else {
|
|
|
|
RemoveMinidump(childDumpFile);
|
2012-07-03 11:49:23 +00:00
|
|
|
}
|
2012-07-11 02:20:05 +00:00
|
|
|
}
|
|
|
|
if (mFlashProcess2 &&
|
|
|
|
TakeMinidumpForChild(mFlashProcess2,
|
|
|
|
getter_AddRefs(childDumpFile),
|
|
|
|
&childSequence)) {
|
|
|
|
if (childSequence < sequence) {
|
|
|
|
RemoveMinidump(dumpFile);
|
|
|
|
dumpFile = childDumpFile;
|
|
|
|
sequence = childSequence;
|
|
|
|
flashProcessType.AssignLiteral("Sandbox");
|
2010-03-24 21:22:03 +00:00
|
|
|
}
|
2010-01-14 01:20:00 +00:00
|
|
|
else {
|
2012-07-11 02:20:05 +00:00
|
|
|
RemoveMinidump(childDumpFile);
|
2010-01-14 01:20:00 +00:00
|
|
|
}
|
2012-07-11 02:20:05 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (!dumpFile) {
|
|
|
|
NS_WARNING("[PluginModuleParent::ActorDestroy] abnormal shutdown without minidump!");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
PLUGIN_LOG_DEBUG(("got child minidump: %s",
|
|
|
|
NS_ConvertUTF16toUTF8(mPluginDumpID).get()));
|
|
|
|
|
|
|
|
GetIDFromMinidump(dumpFile, mPluginDumpID);
|
|
|
|
if (!flashProcessType.IsEmpty()) {
|
|
|
|
notes.Put(NS_LITERAL_CSTRING("FlashProcessDump"), flashProcessType);
|
|
|
|
}
|
|
|
|
crashReporter->GenerateCrashReportForMinidump(dumpFile, ¬es);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
void
|
|
|
|
PluginModuleParent::ActorDestroy(ActorDestroyReason why)
|
|
|
|
{
|
|
|
|
switch (why) {
|
|
|
|
case AbnormalShutdown: {
|
|
|
|
#ifdef MOZ_CRASHREPORTER
|
|
|
|
ProcessFirstMinidump();
|
2010-03-24 21:22:03 +00:00
|
|
|
#endif
|
2010-01-14 01:20:00 +00:00
|
|
|
|
2009-12-16 20:08:45 +00:00
|
|
|
mShutdown = true;
|
|
|
|
// Defer the PluginCrashed method so that we don't re-enter
|
|
|
|
// and potentially modify the actor child list while enumerating it.
|
2010-03-24 21:22:03 +00:00
|
|
|
if (mPlugin)
|
|
|
|
MessageLoop::current()->PostTask(
|
|
|
|
FROM_HERE,
|
|
|
|
mTaskFactory.NewRunnableMethod(
|
|
|
|
&PluginModuleParent::NotifyPluginCrashed));
|
2009-12-16 20:08:45 +00:00
|
|
|
break;
|
2010-01-14 01:20:00 +00:00
|
|
|
}
|
2009-12-03 20:31:52 +00:00
|
|
|
case NormalShutdown:
|
|
|
|
mShutdown = true;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2014-02-28 23:39:17 +00:00
|
|
|
NS_RUNTIMEABORT("Unexpected shutdown reason for toplevel actor.");
|
2009-12-03 20:31:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-03-07 20:16:02 +00:00
|
|
|
void
|
|
|
|
PluginModuleParent::NotifyPluginCrashed()
|
|
|
|
{
|
2010-03-18 22:52:35 +00:00
|
|
|
if (!OkToCleanup()) {
|
|
|
|
// there's still plugin code on the C++ stack. try again
|
|
|
|
MessageLoop::current()->PostDelayedTask(
|
2010-03-24 21:22:03 +00:00
|
|
|
FROM_HERE,
|
|
|
|
mTaskFactory.NewRunnableMethod(
|
|
|
|
&PluginModuleParent::NotifyPluginCrashed), 10);
|
2010-03-18 22:52:35 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-03-07 20:16:02 +00:00
|
|
|
if (mPlugin)
|
2010-03-24 21:22:04 +00:00
|
|
|
mPlugin->PluginCrashed(mPluginDumpID, mBrowserDumpID);
|
2010-03-07 20:16:02 +00:00
|
|
|
}
|
|
|
|
|
2010-03-23 14:30:51 +00:00
|
|
|
PPluginIdentifierParent*
|
2013-07-08 15:48:39 +00:00
|
|
|
PluginModuleParent::AllocPPluginIdentifierParent(const nsCString& aString,
|
|
|
|
const int32_t& aInt,
|
|
|
|
const bool& aTemporary)
|
2010-03-23 14:30:51 +00:00
|
|
|
{
|
2011-06-14 19:49:48 +00:00
|
|
|
if (aTemporary) {
|
|
|
|
NS_ERROR("Plugins don't create temporary identifiers.");
|
2013-10-23 20:34:46 +00:00
|
|
|
return nullptr; // should abort the plugin
|
2011-06-14 19:49:48 +00:00
|
|
|
}
|
|
|
|
|
2010-03-23 14:30:51 +00:00
|
|
|
NPIdentifier npident = aString.IsVoid() ?
|
|
|
|
mozilla::plugins::parent::_getintidentifier(aInt) :
|
|
|
|
mozilla::plugins::parent::_getstringidentifier(aString.get());
|
|
|
|
|
|
|
|
if (!npident) {
|
|
|
|
NS_WARNING("Failed to get identifier!");
|
2012-07-30 14:20:58 +00:00
|
|
|
return nullptr;
|
2010-03-23 14:30:51 +00:00
|
|
|
}
|
|
|
|
|
2011-06-14 19:49:48 +00:00
|
|
|
PluginIdentifierParent* ident = new PluginIdentifierParent(npident, false);
|
2010-03-23 14:30:51 +00:00
|
|
|
mIdentifiers.Put(npident, ident);
|
|
|
|
return ident;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2013-07-08 15:48:39 +00:00
|
|
|
PluginModuleParent::DeallocPPluginIdentifierParent(PPluginIdentifierParent* aActor)
|
2010-03-23 14:30:51 +00:00
|
|
|
{
|
|
|
|
delete aActor;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2009-09-09 22:59:06 +00:00
|
|
|
PPluginInstanceParent*
|
2013-07-08 15:48:39 +00:00
|
|
|
PluginModuleParent::AllocPPluginInstanceParent(const nsCString& aMimeType,
|
|
|
|
const uint16_t& aMode,
|
|
|
|
const InfallibleTArray<nsCString>& aNames,
|
|
|
|
const InfallibleTArray<nsCString>& aValues,
|
|
|
|
NPError* rv)
|
2009-07-02 16:54:22 +00:00
|
|
|
{
|
2009-08-18 20:20:03 +00:00
|
|
|
NS_ERROR("Not reachable!");
|
2013-10-23 20:34:46 +00:00
|
|
|
return nullptr;
|
2009-07-02 16:54:22 +00:00
|
|
|
}
|
|
|
|
|
2009-09-17 23:09:20 +00:00
|
|
|
bool
|
2013-07-08 15:48:39 +00:00
|
|
|
PluginModuleParent::DeallocPPluginInstanceParent(PPluginInstanceParent* aActor)
|
2009-07-02 16:54:22 +00:00
|
|
|
{
|
2009-12-18 22:22:51 +00:00
|
|
|
PLUGIN_LOG_DEBUG_METHOD;
|
2009-09-09 06:31:35 +00:00
|
|
|
delete aActor;
|
2009-09-17 23:09:20 +00:00
|
|
|
return true;
|
2009-07-02 16:54:22 +00:00
|
|
|
}
|
|
|
|
|
2009-06-30 18:51:05 +00:00
|
|
|
void
|
2009-09-09 06:31:35 +00:00
|
|
|
PluginModuleParent::SetPluginFuncs(NPPluginFuncs* aFuncs)
|
2009-06-30 18:51:05 +00:00
|
|
|
{
|
2009-07-02 16:54:22 +00:00
|
|
|
aFuncs->version = (NP_VERSION_MAJOR << 8) | NP_VERSION_MINOR;
|
2012-07-30 14:20:58 +00:00
|
|
|
aFuncs->javaClass = nullptr;
|
2009-07-02 16:54:22 +00:00
|
|
|
|
2011-02-08 22:16:07 +00:00
|
|
|
// Gecko should always call these functions through a PluginLibrary object.
|
2013-10-23 20:34:46 +00:00
|
|
|
aFuncs->newp = nullptr;
|
|
|
|
aFuncs->clearsitedata = nullptr;
|
|
|
|
aFuncs->getsiteswithdata = nullptr;
|
2011-02-08 22:16:07 +00:00
|
|
|
|
2009-09-14 18:56:23 +00:00
|
|
|
aFuncs->destroy = NPP_Destroy;
|
|
|
|
aFuncs->setwindow = NPP_SetWindow;
|
|
|
|
aFuncs->newstream = NPP_NewStream;
|
|
|
|
aFuncs->destroystream = NPP_DestroyStream;
|
|
|
|
aFuncs->asfile = NPP_StreamAsFile;
|
|
|
|
aFuncs->writeready = NPP_WriteReady;
|
|
|
|
aFuncs->write = NPP_Write;
|
|
|
|
aFuncs->print = NPP_Print;
|
|
|
|
aFuncs->event = NPP_HandleEvent;
|
|
|
|
aFuncs->urlnotify = NPP_URLNotify;
|
|
|
|
aFuncs->getvalue = NPP_GetValue;
|
|
|
|
aFuncs->setvalue = NPP_SetValue;
|
2013-10-23 20:34:46 +00:00
|
|
|
aFuncs->gotfocus = nullptr;
|
|
|
|
aFuncs->lostfocus = nullptr;
|
|
|
|
aFuncs->urlredirectnotify = nullptr;
|
2011-01-05 19:44:21 +00:00
|
|
|
|
2011-02-08 22:16:07 +00:00
|
|
|
// Provide 'NPP_URLRedirectNotify', 'NPP_ClearSiteData', and
|
|
|
|
// 'NPP_GetSitesWithData' functionality if it is supported by the plugin.
|
2011-01-05 19:44:21 +00:00
|
|
|
bool urlRedirectSupported = false;
|
2011-02-08 22:16:07 +00:00
|
|
|
unused << CallOptionalFunctionsSupported(&urlRedirectSupported,
|
|
|
|
&mClearSiteDataSupported,
|
|
|
|
&mGetSitesWithDataSupported);
|
2011-01-05 19:44:21 +00:00
|
|
|
if (urlRedirectSupported) {
|
|
|
|
aFuncs->urlredirectnotify = NPP_URLRedirectNotify;
|
|
|
|
}
|
2009-06-30 18:51:05 +00:00
|
|
|
}
|
|
|
|
|
2009-07-01 21:19:32 +00:00
|
|
|
NPError
|
2009-09-09 06:31:35 +00:00
|
|
|
PluginModuleParent::NPP_Destroy(NPP instance,
|
2010-01-15 20:35:57 +00:00
|
|
|
NPSavedData** /*saved*/)
|
2009-07-01 21:19:32 +00:00
|
|
|
{
|
|
|
|
// FIXME/cjones:
|
|
|
|
// (1) send a "destroy" message to the child
|
|
|
|
// (2) the child shuts down its instance
|
|
|
|
// (3) remove both parent and child IDs from map
|
|
|
|
// (4) free parent
|
2009-12-18 22:22:51 +00:00
|
|
|
PLUGIN_LOG_DEBUG_FUNCTION;
|
2009-07-01 21:19:32 +00:00
|
|
|
|
2009-09-09 06:31:35 +00:00
|
|
|
PluginInstanceParent* parentInstance =
|
|
|
|
static_cast<PluginInstanceParent*>(instance->pdata);
|
2009-07-01 21:19:32 +00:00
|
|
|
|
2009-11-20 08:23:07 +00:00
|
|
|
if (!parentInstance)
|
|
|
|
return NPERR_NO_ERROR;
|
|
|
|
|
2010-01-15 20:35:57 +00:00
|
|
|
NPError retval = parentInstance->Destroy();
|
2012-07-30 14:20:58 +00:00
|
|
|
instance->pdata = nullptr;
|
2009-10-07 23:50:48 +00:00
|
|
|
|
2010-04-27 05:43:03 +00:00
|
|
|
unused << PluginInstanceParent::Call__delete__(parentInstance);
|
2010-01-15 20:35:57 +00:00
|
|
|
return retval;
|
2009-11-20 08:23:07 +00:00
|
|
|
}
|
2009-06-30 18:51:05 +00:00
|
|
|
|
2009-09-14 18:56:23 +00:00
|
|
|
NPError
|
|
|
|
PluginModuleParent::NPP_NewStream(NPP instance, NPMIMEType type,
|
|
|
|
NPStream* stream, NPBool seekable,
|
|
|
|
uint16_t* stype)
|
|
|
|
{
|
2013-03-16 04:47:02 +00:00
|
|
|
PROFILER_LABEL("PluginModuleParent", "NPP_NewStream");
|
2009-12-03 20:31:01 +00:00
|
|
|
PluginInstanceParent* i = InstCast(instance);
|
|
|
|
if (!i)
|
|
|
|
return NPERR_GENERIC_ERROR;
|
|
|
|
|
|
|
|
return i->NPP_NewStream(type, stream, seekable,
|
|
|
|
stype);
|
2009-09-14 18:56:23 +00:00
|
|
|
}
|
|
|
|
|
2009-09-14 20:01:31 +00:00
|
|
|
NPError
|
|
|
|
PluginModuleParent::NPP_SetWindow(NPP instance, NPWindow* window)
|
|
|
|
{
|
2009-12-03 20:31:01 +00:00
|
|
|
PluginInstanceParent* i = InstCast(instance);
|
|
|
|
if (!i)
|
|
|
|
return NPERR_GENERIC_ERROR;
|
|
|
|
|
|
|
|
return i->NPP_SetWindow(window);
|
2009-09-14 20:01:31 +00:00
|
|
|
}
|
|
|
|
|
2009-09-14 18:56:23 +00:00
|
|
|
NPError
|
|
|
|
PluginModuleParent::NPP_DestroyStream(NPP instance,
|
|
|
|
NPStream* stream,
|
|
|
|
NPReason reason)
|
|
|
|
{
|
2009-12-03 20:31:01 +00:00
|
|
|
PluginInstanceParent* i = InstCast(instance);
|
|
|
|
if (!i)
|
|
|
|
return NPERR_GENERIC_ERROR;
|
|
|
|
|
|
|
|
return i->NPP_DestroyStream(stream, reason);
|
2009-09-14 18:56:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int32_t
|
|
|
|
PluginModuleParent::NPP_WriteReady(NPP instance,
|
|
|
|
NPStream* stream)
|
|
|
|
{
|
2009-12-03 20:31:01 +00:00
|
|
|
BrowserStreamParent* s = StreamCast(instance, stream);
|
|
|
|
if (!s)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
return s->WriteReady();
|
2009-09-14 18:56:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int32_t
|
|
|
|
PluginModuleParent::NPP_Write(NPP instance,
|
|
|
|
NPStream* stream,
|
|
|
|
int32_t offset,
|
|
|
|
int32_t len,
|
|
|
|
void* buffer)
|
|
|
|
{
|
2009-12-03 20:31:01 +00:00
|
|
|
BrowserStreamParent* s = StreamCast(instance, stream);
|
|
|
|
if (!s)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
return s->Write(offset, len, buffer);
|
2009-09-14 18:56:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
PluginModuleParent::NPP_StreamAsFile(NPP instance,
|
|
|
|
NPStream* stream,
|
|
|
|
const char* fname)
|
|
|
|
{
|
2009-12-03 20:31:01 +00:00
|
|
|
BrowserStreamParent* s = StreamCast(instance, stream);
|
|
|
|
if (!s)
|
|
|
|
return;
|
|
|
|
|
|
|
|
s->StreamAsFile(fname);
|
2009-09-14 18:56:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
PluginModuleParent::NPP_Print(NPP instance, NPPrint* platformPrint)
|
|
|
|
{
|
2009-12-03 20:31:01 +00:00
|
|
|
PluginInstanceParent* i = InstCast(instance);
|
|
|
|
if (i)
|
|
|
|
i->NPP_Print(platformPrint);
|
2009-09-14 18:56:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int16_t
|
|
|
|
PluginModuleParent::NPP_HandleEvent(NPP instance, void* event)
|
|
|
|
{
|
2009-12-03 20:31:01 +00:00
|
|
|
PluginInstanceParent* i = InstCast(instance);
|
|
|
|
if (!i)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return i->NPP_HandleEvent(event);
|
2009-09-14 18:56:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
PluginModuleParent::NPP_URLNotify(NPP instance, const char* url,
|
|
|
|
NPReason reason, void* notifyData)
|
|
|
|
{
|
2009-12-03 20:31:01 +00:00
|
|
|
PluginInstanceParent* i = InstCast(instance);
|
|
|
|
if (!i)
|
|
|
|
return;
|
|
|
|
|
|
|
|
i->NPP_URLNotify(url, reason, notifyData);
|
2009-09-14 18:56:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NPError
|
|
|
|
PluginModuleParent::NPP_GetValue(NPP instance,
|
|
|
|
NPPVariable variable, void *ret_value)
|
|
|
|
{
|
2009-12-03 20:31:01 +00:00
|
|
|
PluginInstanceParent* i = InstCast(instance);
|
|
|
|
if (!i)
|
|
|
|
return NPERR_GENERIC_ERROR;
|
|
|
|
|
|
|
|
return i->NPP_GetValue(variable, ret_value);
|
2009-09-14 18:56:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NPError
|
|
|
|
PluginModuleParent::NPP_SetValue(NPP instance, NPNVariable variable,
|
|
|
|
void *value)
|
|
|
|
{
|
2009-12-03 20:31:01 +00:00
|
|
|
PluginInstanceParent* i = InstCast(instance);
|
|
|
|
if (!i)
|
|
|
|
return NPERR_GENERIC_ERROR;
|
|
|
|
|
|
|
|
return i->NPP_SetValue(variable, value);
|
2009-09-14 18:56:23 +00:00
|
|
|
}
|
|
|
|
|
2010-11-09 02:48:59 +00:00
|
|
|
bool
|
|
|
|
PluginModuleParent::RecvBackUpXResources(const FileDescriptor& aXSocketFd)
|
|
|
|
{
|
|
|
|
#ifndef MOZ_X11
|
|
|
|
NS_RUNTIMEABORT("This message only makes sense on X11 platforms");
|
|
|
|
#else
|
2012-04-12 10:21:24 +00:00
|
|
|
NS_ABORT_IF_FALSE(0 > mPluginXSocketFdDup.get(),
|
2010-11-09 02:48:59 +00:00
|
|
|
"Already backed up X resources??");
|
2012-04-12 10:21:24 +00:00
|
|
|
mPluginXSocketFdDup.forget();
|
2013-01-25 01:10:39 +00:00
|
|
|
if (aXSocketFd.IsValid()) {
|
|
|
|
mPluginXSocketFdDup.reset(aXSocketFd.PlatformHandle());
|
|
|
|
}
|
2010-11-09 02:48:59 +00:00
|
|
|
#endif
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2011-01-05 19:44:21 +00:00
|
|
|
void
|
|
|
|
PluginModuleParent::NPP_URLRedirectNotify(NPP instance, const char* url,
|
|
|
|
int32_t status, void* notifyData)
|
|
|
|
{
|
|
|
|
PluginInstanceParent* i = InstCast(instance);
|
|
|
|
if (!i)
|
|
|
|
return;
|
|
|
|
|
|
|
|
i->NPP_URLRedirectNotify(url, status, notifyData);
|
|
|
|
}
|
|
|
|
|
2009-10-08 07:54:16 +00:00
|
|
|
bool
|
|
|
|
PluginModuleParent::AnswerNPN_UserAgent(nsCString* userAgent)
|
|
|
|
{
|
2012-07-30 14:20:58 +00:00
|
|
|
*userAgent = NullableString(mNPNIface->uagent(nullptr));
|
2009-10-08 07:54:16 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2011-06-14 19:49:48 +00:00
|
|
|
PluginIdentifierParent*
|
|
|
|
PluginModuleParent::GetIdentifierForNPIdentifier(NPP npp, NPIdentifier aIdentifier)
|
2009-08-10 23:28:22 +00:00
|
|
|
{
|
2012-04-14 15:52:34 +00:00
|
|
|
PluginIdentifierParent* ident;
|
2011-06-14 19:49:48 +00:00
|
|
|
if (mIdentifiers.Get(aIdentifier, &ident)) {
|
|
|
|
if (ident->IsTemporary()) {
|
|
|
|
ident->AddTemporaryRef();
|
2010-03-23 14:30:51 +00:00
|
|
|
}
|
2011-06-14 19:49:48 +00:00
|
|
|
return ident;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCString string;
|
|
|
|
int32_t intval = -1;
|
|
|
|
bool temporary = false;
|
|
|
|
if (mozilla::plugins::parent::_identifierisstring(aIdentifier)) {
|
|
|
|
NPUTF8* chars =
|
|
|
|
mozilla::plugins::parent::_utf8fromidentifier(aIdentifier);
|
|
|
|
if (!chars) {
|
2012-07-30 14:20:58 +00:00
|
|
|
return nullptr;
|
2011-06-14 19:49:48 +00:00
|
|
|
}
|
|
|
|
string.Adopt(chars);
|
|
|
|
temporary = !NPStringIdentifierIsPermanent(npp, aIdentifier);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
intval = mozilla::plugins::parent::_intfromidentifier(aIdentifier);
|
2011-10-17 14:59:28 +00:00
|
|
|
string.SetIsVoid(true);
|
2011-06-14 19:49:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ident = new PluginIdentifierParent(aIdentifier, temporary);
|
|
|
|
if (!SendPPluginIdentifierConstructor(ident, string, intval, temporary))
|
2012-07-30 14:20:58 +00:00
|
|
|
return nullptr;
|
2010-04-20 13:15:31 +00:00
|
|
|
|
2011-06-14 19:49:48 +00:00
|
|
|
if (!temporary) {
|
2010-03-23 14:30:51 +00:00
|
|
|
mIdentifiers.Put(aIdentifier, ident);
|
2009-09-14 20:01:31 +00:00
|
|
|
}
|
2010-03-23 14:30:51 +00:00
|
|
|
return ident;
|
2009-08-10 23:28:22 +00:00
|
|
|
}
|
2009-08-18 20:20:03 +00:00
|
|
|
|
2009-09-09 06:31:35 +00:00
|
|
|
PluginInstanceParent*
|
|
|
|
PluginModuleParent::InstCast(NPP instance)
|
2009-08-18 20:20:03 +00:00
|
|
|
{
|
2009-09-09 06:31:35 +00:00
|
|
|
PluginInstanceParent* ip =
|
|
|
|
static_cast<PluginInstanceParent*>(instance->pdata);
|
2009-12-03 20:31:01 +00:00
|
|
|
|
|
|
|
// If the plugin crashed and the PluginInstanceParent was deleted,
|
2013-10-23 20:34:46 +00:00
|
|
|
// instance->pdata will be nullptr.
|
2009-12-03 20:31:01 +00:00
|
|
|
if (!ip)
|
2013-10-23 20:34:46 +00:00
|
|
|
return nullptr;
|
2009-12-03 20:31:01 +00:00
|
|
|
|
2009-09-09 06:31:35 +00:00
|
|
|
if (instance != ip->mNPP) {
|
2009-08-18 20:20:03 +00:00
|
|
|
NS_RUNTIMEABORT("Corrupted plugin data.");
|
2009-09-09 06:31:35 +00:00
|
|
|
}
|
2009-08-18 20:20:03 +00:00
|
|
|
return ip;
|
|
|
|
}
|
|
|
|
|
2009-09-09 14:04:09 +00:00
|
|
|
BrowserStreamParent*
|
2009-09-09 06:31:35 +00:00
|
|
|
PluginModuleParent::StreamCast(NPP instance,
|
|
|
|
NPStream* s)
|
2009-08-18 20:20:03 +00:00
|
|
|
{
|
2009-09-09 06:31:35 +00:00
|
|
|
PluginInstanceParent* ip = InstCast(instance);
|
2009-12-03 20:31:01 +00:00
|
|
|
if (!ip)
|
2013-10-23 20:34:46 +00:00
|
|
|
return nullptr;
|
2009-12-03 20:31:01 +00:00
|
|
|
|
2009-09-09 14:04:09 +00:00
|
|
|
BrowserStreamParent* sp =
|
2009-09-21 14:51:35 +00:00
|
|
|
static_cast<BrowserStreamParent*>(static_cast<AStream*>(s->pdata));
|
2009-09-09 06:31:35 +00:00
|
|
|
if (sp->mNPP != ip || s != sp->mStream) {
|
2009-08-18 20:20:03 +00:00
|
|
|
NS_RUNTIMEABORT("Corrupted plugin stream data.");
|
2009-09-09 06:31:35 +00:00
|
|
|
}
|
2009-08-18 20:20:03 +00:00
|
|
|
return sp;
|
|
|
|
}
|
|
|
|
|
2009-10-27 19:51:12 +00:00
|
|
|
bool
|
|
|
|
PluginModuleParent::HasRequiredFunctions()
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-09-10 18:28:52 +00:00
|
|
|
nsresult
|
|
|
|
PluginModuleParent::AsyncSetWindow(NPP instance, NPWindow* window)
|
|
|
|
{
|
|
|
|
PluginInstanceParent* i = InstCast(instance);
|
|
|
|
if (!i)
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
return i->AsyncSetWindow(window);
|
|
|
|
}
|
|
|
|
|
2011-02-12 16:07:10 +00:00
|
|
|
nsresult
|
2012-02-08 15:34:27 +00:00
|
|
|
PluginModuleParent::GetImageContainer(NPP instance,
|
|
|
|
mozilla::layers::ImageContainer** aContainer)
|
2011-02-12 16:07:10 +00:00
|
|
|
{
|
|
|
|
PluginInstanceParent* i = InstCast(instance);
|
2012-02-08 15:34:27 +00:00
|
|
|
return !i ? NS_ERROR_FAILURE : i->GetImageContainer(aContainer);
|
2011-02-12 16:07:10 +00:00
|
|
|
}
|
|
|
|
|
2011-02-23 05:38:09 +00:00
|
|
|
nsresult
|
|
|
|
PluginModuleParent::GetImageSize(NPP instance,
|
|
|
|
nsIntSize* aSize)
|
|
|
|
{
|
|
|
|
PluginInstanceParent* i = InstCast(instance);
|
|
|
|
return !i ? NS_ERROR_FAILURE : i->GetImageSize(aSize);
|
|
|
|
}
|
|
|
|
|
2011-02-16 22:43:31 +00:00
|
|
|
nsresult
|
|
|
|
PluginModuleParent::SetBackgroundUnknown(NPP instance)
|
|
|
|
{
|
|
|
|
PluginInstanceParent* i = InstCast(instance);
|
|
|
|
if (!i)
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
return i->SetBackgroundUnknown();
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
PluginModuleParent::BeginUpdateBackground(NPP instance,
|
|
|
|
const nsIntRect& aRect,
|
|
|
|
gfxContext** aCtx)
|
|
|
|
{
|
|
|
|
PluginInstanceParent* i = InstCast(instance);
|
|
|
|
if (!i)
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
return i->BeginUpdateBackground(aRect, aCtx);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
PluginModuleParent::EndUpdateBackground(NPP instance,
|
|
|
|
gfxContext* aCtx,
|
|
|
|
const nsIntRect& aRect)
|
|
|
|
{
|
|
|
|
PluginInstanceParent* i = InstCast(instance);
|
|
|
|
if (!i)
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
return i->EndUpdateBackground(aCtx, aRect);
|
|
|
|
}
|
|
|
|
|
2011-11-11 00:17:46 +00:00
|
|
|
#if defined(XP_UNIX) && !defined(XP_MACOSX) && !defined(MOZ_WIDGET_GONK)
|
2009-10-27 19:51:12 +00:00
|
|
|
nsresult
|
|
|
|
PluginModuleParent::NP_Initialize(NPNetscapeFuncs* bFuncs, NPPluginFuncs* pFuncs, NPError* error)
|
|
|
|
{
|
2009-12-18 22:22:51 +00:00
|
|
|
PLUGIN_LOG_DEBUG_METHOD;
|
2009-10-27 19:51:12 +00:00
|
|
|
|
|
|
|
mNPNIface = bFuncs;
|
|
|
|
|
2009-12-03 20:31:52 +00:00
|
|
|
if (mShutdown) {
|
|
|
|
*error = NPERR_GENERIC_ERROR;
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
2012-02-16 03:24:38 +00:00
|
|
|
uint32_t flags = 0;
|
|
|
|
|
|
|
|
if (!CallNP_Initialize(flags, error)) {
|
2014-02-28 23:39:17 +00:00
|
|
|
Close();
|
2009-11-20 15:34:20 +00:00
|
|
|
return NS_ERROR_FAILURE;
|
2009-10-27 19:51:12 +00:00
|
|
|
}
|
|
|
|
else if (*error != NPERR_NO_ERROR) {
|
2014-02-28 23:39:17 +00:00
|
|
|
Close();
|
2009-10-27 19:51:12 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
SetPluginFuncs(pFuncs);
|
2011-01-05 19:44:21 +00:00
|
|
|
|
2009-10-27 19:51:12 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
nsresult
|
|
|
|
PluginModuleParent::NP_Initialize(NPNetscapeFuncs* bFuncs, NPError* error)
|
|
|
|
{
|
2009-12-18 22:22:51 +00:00
|
|
|
PLUGIN_LOG_DEBUG_METHOD;
|
2009-10-27 19:51:12 +00:00
|
|
|
|
|
|
|
mNPNIface = bFuncs;
|
|
|
|
|
2009-12-03 20:31:52 +00:00
|
|
|
if (mShutdown) {
|
|
|
|
*error = NPERR_GENERIC_ERROR;
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
2012-02-16 03:24:38 +00:00
|
|
|
uint32_t flags = 0;
|
2012-05-01 21:46:53 +00:00
|
|
|
#ifdef XP_WIN
|
|
|
|
flags |= kAllowAsyncDrawing;
|
|
|
|
#endif
|
2012-02-16 03:24:38 +00:00
|
|
|
|
2013-07-19 14:02:47 +00:00
|
|
|
if (!CallNP_Initialize(flags, error)) {
|
2014-02-28 23:39:17 +00:00
|
|
|
Close();
|
2009-11-20 15:34:20 +00:00
|
|
|
return NS_ERROR_FAILURE;
|
2013-07-19 14:02:47 +00:00
|
|
|
}
|
|
|
|
if (*error != NPERR_NO_ERROR) {
|
2014-02-28 23:39:17 +00:00
|
|
|
Close();
|
2013-07-19 14:02:47 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
2009-10-27 19:51:12 +00:00
|
|
|
|
2012-02-23 00:33:19 +00:00
|
|
|
#if defined XP_WIN
|
2011-06-24 14:20:03 +00:00
|
|
|
// Send the info needed to join the chrome process's audio session to the
|
|
|
|
// plugin process
|
|
|
|
nsID id;
|
|
|
|
nsString sessionName;
|
|
|
|
nsString iconPath;
|
|
|
|
|
|
|
|
if (NS_SUCCEEDED(mozilla::widget::GetAudioSessionData(id, sessionName,
|
|
|
|
iconPath)))
|
2012-05-16 08:48:45 +00:00
|
|
|
unused << SendSetAudioSessionData(id, sessionName, iconPath);
|
2011-06-24 14:20:03 +00:00
|
|
|
#endif
|
|
|
|
|
2012-07-03 11:49:23 +00:00
|
|
|
#ifdef MOZ_CRASHREPORTER_INJECTOR
|
|
|
|
InitializeInjector();
|
|
|
|
#endif
|
|
|
|
|
2009-10-27 19:51:12 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
PluginModuleParent::NP_Shutdown(NPError* error)
|
|
|
|
{
|
2009-12-18 22:22:51 +00:00
|
|
|
PLUGIN_LOG_DEBUG_METHOD;
|
2009-10-27 19:51:12 +00:00
|
|
|
|
2009-12-03 20:31:52 +00:00
|
|
|
if (mShutdown) {
|
|
|
|
*error = NPERR_GENERIC_ERROR;
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
2009-11-03 21:37:07 +00:00
|
|
|
bool ok = CallNP_Shutdown(error);
|
2009-12-03 08:16:28 +00:00
|
|
|
|
2013-10-01 00:27:45 +00:00
|
|
|
// if NP_Shutdown() is nested within another interrupt call, this will
|
2009-12-03 08:16:28 +00:00
|
|
|
// break things. but lord help us if we're doing that anyway; the
|
|
|
|
// plugin dso will have been unloaded on the other side by the
|
|
|
|
// CallNP_Shutdown() message
|
2009-11-03 21:37:07 +00:00
|
|
|
Close();
|
|
|
|
|
|
|
|
return ok ? NS_OK : NS_ERROR_FAILURE;
|
2009-10-27 19:51:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
2010-01-29 20:18:50 +00:00
|
|
|
PluginModuleParent::NP_GetMIMEDescription(const char** mimeDesc)
|
2009-10-27 19:51:12 +00:00
|
|
|
{
|
2009-12-18 22:22:51 +00:00
|
|
|
PLUGIN_LOG_DEBUG_METHOD;
|
2009-10-27 19:51:12 +00:00
|
|
|
|
2010-01-29 20:18:50 +00:00
|
|
|
*mimeDesc = "application/x-foobar";
|
2009-10-27 19:51:12 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
PluginModuleParent::NP_GetValue(void *future, NPPVariable aVariable,
|
|
|
|
void *aValue, NPError* error)
|
|
|
|
{
|
2012-10-29 23:32:10 +00:00
|
|
|
PR_LOG(GetPluginLog(), PR_LOG_WARNING, ("%s Not implemented, requested variable %i", __FUNCTION__,
|
2009-12-18 22:22:51 +00:00
|
|
|
(int) aVariable));
|
2009-10-27 19:51:12 +00:00
|
|
|
|
|
|
|
//TODO: implement this correctly
|
|
|
|
*error = NPERR_GENERIC_ERROR;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2014-02-10 22:57:01 +00:00
|
|
|
#if defined(XP_WIN) || defined(XP_MACOSX)
|
2009-10-27 19:51:12 +00:00
|
|
|
nsresult
|
|
|
|
PluginModuleParent::NP_GetEntryPoints(NPPluginFuncs* pFuncs, NPError* error)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(pFuncs, "Null pointer!");
|
|
|
|
|
2011-01-05 19:44:21 +00:00
|
|
|
// We need to have the child process update its function table
|
|
|
|
// here by actually calling NP_GetEntryPoints since the parent's
|
2013-10-23 20:34:46 +00:00
|
|
|
// function table can reflect nullptr entries in the child's table.
|
2011-01-05 19:44:21 +00:00
|
|
|
if (!CallNP_GetEntryPoints(error)) {
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
else if (*error != NPERR_NO_ERROR) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2009-10-27 19:51:12 +00:00
|
|
|
SetPluginFuncs(pFuncs);
|
2011-01-05 19:44:21 +00:00
|
|
|
|
2009-10-27 19:51:12 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
PluginModuleParent::NPP_New(NPMIMEType pluginType, NPP instance,
|
|
|
|
uint16_t mode, int16_t argc, char* argn[],
|
|
|
|
char* argv[], NPSavedData* saved,
|
|
|
|
NPError* error)
|
|
|
|
{
|
2009-12-18 22:22:51 +00:00
|
|
|
PLUGIN_LOG_DEBUG_METHOD;
|
2009-10-27 19:51:12 +00:00
|
|
|
|
2009-12-03 20:31:52 +00:00
|
|
|
if (mShutdown) {
|
|
|
|
*error = NPERR_GENERIC_ERROR;
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
2009-10-27 19:51:12 +00:00
|
|
|
// create the instance on the other side
|
2010-11-09 02:49:00 +00:00
|
|
|
InfallibleTArray<nsCString> names;
|
|
|
|
InfallibleTArray<nsCString> values;
|
2009-10-27 19:51:12 +00:00
|
|
|
|
|
|
|
for (int i = 0; i < argc; ++i) {
|
|
|
|
names.AppendElement(NullableString(argn[i]));
|
|
|
|
values.AppendElement(NullableString(argv[i]));
|
|
|
|
}
|
|
|
|
|
2009-11-19 22:47:09 +00:00
|
|
|
PluginInstanceParent* parentInstance =
|
2010-04-20 14:52:19 +00:00
|
|
|
new PluginInstanceParent(this, instance,
|
|
|
|
nsDependentCString(pluginType), mNPNIface);
|
2009-10-27 19:51:12 +00:00
|
|
|
|
2010-01-15 20:35:57 +00:00
|
|
|
if (!parentInstance->Init()) {
|
|
|
|
delete parentInstance;
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
2009-11-19 22:47:09 +00:00
|
|
|
instance->pdata = parentInstance;
|
2009-10-27 19:51:12 +00:00
|
|
|
|
|
|
|
if (!CallPPluginInstanceConstructor(parentInstance,
|
|
|
|
nsDependentCString(pluginType), mode,
|
2009-11-19 22:47:09 +00:00
|
|
|
names, values, error)) {
|
|
|
|
// |parentInstance| is automatically deleted.
|
2012-07-30 14:20:58 +00:00
|
|
|
instance->pdata = nullptr;
|
2009-11-20 08:23:07 +00:00
|
|
|
// if IPC is down, we'll get an immediate "failed" return, but
|
|
|
|
// without *error being set. So make sure that the error
|
|
|
|
// condition is signaled to nsNPAPIPluginInstance
|
|
|
|
if (NPERR_NO_ERROR == *error)
|
|
|
|
*error = NPERR_GENERIC_ERROR;
|
2009-10-27 19:51:12 +00:00
|
|
|
return NS_ERROR_FAILURE;
|
2009-11-19 22:47:09 +00:00
|
|
|
}
|
2009-10-27 19:51:12 +00:00
|
|
|
|
2009-11-19 22:47:09 +00:00
|
|
|
if (*error != NPERR_NO_ERROR) {
|
2010-01-15 20:35:57 +00:00
|
|
|
NPP_Destroy(instance, 0);
|
2010-05-12 18:12:49 +00:00
|
|
|
return NS_ERROR_FAILURE;
|
2009-11-19 22:47:09 +00:00
|
|
|
}
|
2009-10-27 19:51:12 +00:00
|
|
|
|
2011-08-16 10:25:34 +00:00
|
|
|
TimeoutChanged(kParentTimeoutPref, this);
|
|
|
|
|
2009-10-27 19:51:12 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2011-02-08 22:16:07 +00:00
|
|
|
nsresult
|
|
|
|
PluginModuleParent::NPP_ClearSiteData(const char* site, uint64_t flags,
|
|
|
|
uint64_t maxAge)
|
|
|
|
{
|
|
|
|
if (!mClearSiteDataSupported)
|
|
|
|
return NS_ERROR_NOT_AVAILABLE;
|
|
|
|
|
|
|
|
NPError result;
|
|
|
|
if (!CallNPP_ClearSiteData(NullableString(site), flags, maxAge, &result))
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
switch (result) {
|
|
|
|
case NPERR_NO_ERROR:
|
|
|
|
return NS_OK;
|
|
|
|
case NPERR_TIME_RANGE_NOT_SUPPORTED:
|
|
|
|
return NS_ERROR_PLUGIN_TIME_RANGE_NOT_SUPPORTED;
|
|
|
|
case NPERR_MALFORMED_SITE:
|
|
|
|
return NS_ERROR_INVALID_ARG;
|
|
|
|
default:
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
PluginModuleParent::NPP_GetSitesWithData(InfallibleTArray<nsCString>& result)
|
|
|
|
{
|
|
|
|
if (!mGetSitesWithDataSupported)
|
|
|
|
return NS_ERROR_NOT_AVAILABLE;
|
|
|
|
|
|
|
|
if (!CallNPP_GetSitesWithData(&result))
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2011-06-30 16:46:26 +00:00
|
|
|
#if defined(XP_MACOSX)
|
|
|
|
nsresult
|
2011-09-29 06:19:26 +00:00
|
|
|
PluginModuleParent::IsRemoteDrawingCoreAnimation(NPP instance, bool *aDrawing)
|
2011-06-30 16:46:26 +00:00
|
|
|
{
|
|
|
|
PluginInstanceParent* i = InstCast(instance);
|
|
|
|
if (!i)
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
return i->IsRemoteDrawingCoreAnimation(aDrawing);
|
|
|
|
}
|
2012-10-16 19:41:21 +00:00
|
|
|
|
|
|
|
nsresult
|
|
|
|
PluginModuleParent::ContentsScaleFactorChanged(NPP instance, double aContentsScaleFactor)
|
|
|
|
{
|
|
|
|
PluginInstanceParent* i = InstCast(instance);
|
|
|
|
if (!i)
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
return i->ContentsScaleFactorChanged(aContentsScaleFactor);
|
|
|
|
}
|
|
|
|
#endif // #if defined(XP_MACOSX)
|
2011-06-30 16:46:26 +00:00
|
|
|
|
2009-12-01 21:27:13 +00:00
|
|
|
bool
|
|
|
|
PluginModuleParent::AnswerNPN_GetValue_WithBoolReturn(const NPNVariable& aVariable,
|
|
|
|
NPError* aError,
|
|
|
|
bool* aBoolVal)
|
|
|
|
{
|
|
|
|
NPBool boolVal = false;
|
2012-07-30 14:20:58 +00:00
|
|
|
*aError = mozilla::plugins::parent::_getvalue(nullptr, aVariable, &boolVal);
|
2009-12-01 21:27:13 +00:00
|
|
|
*aBoolVal = boolVal ? true : false;
|
|
|
|
return true;
|
|
|
|
}
|
2010-02-16 18:44:25 +00:00
|
|
|
|
2010-06-02 03:58:00 +00:00
|
|
|
#if defined(MOZ_WIDGET_QT)
|
|
|
|
static const int kMaxtimeToProcessEvents = 30;
|
|
|
|
bool
|
|
|
|
PluginModuleParent::AnswerProcessSomeEvents()
|
|
|
|
{
|
|
|
|
PLUGIN_LOG_DEBUG(("Spinning mini nested loop ..."));
|
|
|
|
QCoreApplication::processEvents(QEventLoop::AllEvents, kMaxtimeToProcessEvents);
|
|
|
|
|
|
|
|
PLUGIN_LOG_DEBUG(("... quitting mini nested loop"));
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-07-29 22:38:32 +00:00
|
|
|
#elif defined(XP_MACOSX)
|
|
|
|
bool
|
|
|
|
PluginModuleParent::AnswerProcessSomeEvents()
|
|
|
|
{
|
|
|
|
mozilla::plugins::PluginUtilsOSX::InvokeNativeEventLoop();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-06-28 00:15:32 +00:00
|
|
|
#elif !defined(MOZ_WIDGET_GTK)
|
2010-02-16 18:44:25 +00:00
|
|
|
bool
|
|
|
|
PluginModuleParent::AnswerProcessSomeEvents()
|
|
|
|
{
|
|
|
|
NS_RUNTIMEABORT("unreached");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
#else
|
|
|
|
static const int kMaxChancesToProcessEvents = 20;
|
|
|
|
|
|
|
|
bool
|
|
|
|
PluginModuleParent::AnswerProcessSomeEvents()
|
|
|
|
{
|
|
|
|
PLUGIN_LOG_DEBUG(("Spinning mini nested loop ..."));
|
|
|
|
|
2010-03-11 07:35:29 +00:00
|
|
|
int i = 0;
|
|
|
|
for (; i < kMaxChancesToProcessEvents; ++i)
|
2013-10-23 20:34:46 +00:00
|
|
|
if (!g_main_context_iteration(nullptr, FALSE))
|
2010-03-11 07:35:29 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
PLUGIN_LOG_DEBUG(("... quitting mini nested loop; processed %i tasks", i));
|
2010-02-16 18:44:25 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
#endif
|
2010-04-20 14:52:19 +00:00
|
|
|
|
2010-04-30 18:42:51 +00:00
|
|
|
bool
|
2013-10-01 00:27:45 +00:00
|
|
|
PluginModuleParent::RecvProcessNativeEventsInInterruptCall()
|
2010-04-30 18:42:51 +00:00
|
|
|
{
|
|
|
|
PLUGIN_LOG_DEBUG(("%s", FULLFUNCTION));
|
|
|
|
#if defined(OS_WIN)
|
2013-10-01 00:27:45 +00:00
|
|
|
ProcessNativeEventsInInterruptCall();
|
2010-04-30 18:42:51 +00:00
|
|
|
return true;
|
|
|
|
#else
|
|
|
|
NS_NOTREACHED(
|
2013-10-01 00:27:45 +00:00
|
|
|
"PluginModuleParent::RecvProcessNativeEventsInInterruptCall not implemented!");
|
2010-08-13 16:45:50 +00:00
|
|
|
return false;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2011-05-18 11:57:08 +00:00
|
|
|
void
|
2013-10-01 00:27:45 +00:00
|
|
|
PluginModuleParent::ProcessRemoteNativeEventsInInterruptCall()
|
2011-05-18 11:57:08 +00:00
|
|
|
{
|
|
|
|
#if defined(OS_WIN)
|
2013-10-01 00:27:45 +00:00
|
|
|
unused << SendProcessNativeEventsInInterruptCall();
|
2011-05-18 11:57:08 +00:00
|
|
|
return;
|
|
|
|
#endif
|
|
|
|
NS_NOTREACHED(
|
2013-10-01 00:27:45 +00:00
|
|
|
"PluginModuleParent::ProcessRemoteNativeEventsInInterruptCall not implemented!");
|
2011-05-18 11:57:08 +00:00
|
|
|
}
|
|
|
|
|
2010-08-13 16:45:50 +00:00
|
|
|
bool
|
|
|
|
PluginModuleParent::RecvPluginShowWindow(const uint32_t& aWindowId, const bool& aModal,
|
|
|
|
const int32_t& aX, const int32_t& aY,
|
|
|
|
const size_t& aWidth, const size_t& aHeight)
|
|
|
|
{
|
|
|
|
PLUGIN_LOG_DEBUG(("%s", FULLFUNCTION));
|
|
|
|
#if defined(XP_MACOSX)
|
|
|
|
CGRect windowBound = ::CGRectMake(aX, aY, aWidth, aHeight);
|
|
|
|
mac_plugin_interposing::parent::OnPluginShowWindow(aWindowId, windowBound, aModal);
|
|
|
|
return true;
|
|
|
|
#else
|
|
|
|
NS_NOTREACHED(
|
|
|
|
"PluginInstanceParent::RecvPluginShowWindow not implemented!");
|
|
|
|
return false;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
PluginModuleParent::RecvPluginHideWindow(const uint32_t& aWindowId)
|
|
|
|
{
|
|
|
|
PLUGIN_LOG_DEBUG(("%s", FULLFUNCTION));
|
|
|
|
#if defined(XP_MACOSX)
|
|
|
|
mac_plugin_interposing::parent::OnPluginHideWindow(aWindowId, OtherSidePID());
|
|
|
|
return true;
|
|
|
|
#else
|
|
|
|
NS_NOTREACHED(
|
|
|
|
"PluginInstanceParent::RecvPluginHideWindow not implemented!");
|
2010-04-30 18:42:51 +00:00
|
|
|
return false;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2011-06-08 19:56:31 +00:00
|
|
|
PCrashReporterParent*
|
2013-07-08 15:48:39 +00:00
|
|
|
PluginModuleParent::AllocPCrashReporterParent(mozilla::dom::NativeThreadId* id,
|
|
|
|
uint32_t* processType)
|
2011-06-08 19:56:31 +00:00
|
|
|
{
|
|
|
|
#ifdef MOZ_CRASHREPORTER
|
|
|
|
return new CrashReporterParent();
|
|
|
|
#else
|
2012-07-30 14:20:58 +00:00
|
|
|
return nullptr;
|
2011-06-08 19:56:31 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2013-07-08 15:48:39 +00:00
|
|
|
PluginModuleParent::DeallocPCrashReporterParent(PCrashReporterParent* actor)
|
2011-06-08 19:56:31 +00:00
|
|
|
{
|
2013-12-04 13:20:41 +00:00
|
|
|
#ifdef MOZ_CRASHREPORTER
|
2013-12-03 22:19:58 +00:00
|
|
|
#ifdef XP_WIN
|
|
|
|
mozilla::MutexAutoLock lock(mCrashReporterMutex);
|
|
|
|
if (actor == static_cast<PCrashReporterParent*>(mCrashReporter)) {
|
|
|
|
mCrashReporter = nullptr;
|
|
|
|
}
|
2013-12-04 13:20:41 +00:00
|
|
|
#endif
|
2013-12-03 22:19:58 +00:00
|
|
|
#endif
|
2011-06-08 19:56:31 +00:00
|
|
|
delete actor;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2011-05-24 06:58:28 +00:00
|
|
|
bool
|
|
|
|
PluginModuleParent::RecvSetCursor(const NSCursorInfo& aCursorInfo)
|
|
|
|
{
|
|
|
|
PLUGIN_LOG_DEBUG(("%s", FULLFUNCTION));
|
|
|
|
#if defined(XP_MACOSX)
|
|
|
|
mac_plugin_interposing::parent::OnSetCursor(aCursorInfo);
|
|
|
|
return true;
|
|
|
|
#else
|
|
|
|
NS_NOTREACHED(
|
|
|
|
"PluginInstanceParent::RecvSetCursor not implemented!");
|
|
|
|
return false;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
PluginModuleParent::RecvShowCursor(const bool& aShow)
|
|
|
|
{
|
|
|
|
PLUGIN_LOG_DEBUG(("%s", FULLFUNCTION));
|
|
|
|
#if defined(XP_MACOSX)
|
|
|
|
mac_plugin_interposing::parent::OnShowCursor(aShow);
|
|
|
|
return true;
|
|
|
|
#else
|
|
|
|
NS_NOTREACHED(
|
|
|
|
"PluginInstanceParent::RecvShowCursor not implemented!");
|
|
|
|
return false;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
PluginModuleParent::RecvPushCursor(const NSCursorInfo& aCursorInfo)
|
|
|
|
{
|
|
|
|
PLUGIN_LOG_DEBUG(("%s", FULLFUNCTION));
|
|
|
|
#if defined(XP_MACOSX)
|
|
|
|
mac_plugin_interposing::parent::OnPushCursor(aCursorInfo);
|
|
|
|
return true;
|
|
|
|
#else
|
|
|
|
NS_NOTREACHED(
|
|
|
|
"PluginInstanceParent::RecvPushCursor not implemented!");
|
|
|
|
return false;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
PluginModuleParent::RecvPopCursor()
|
|
|
|
{
|
|
|
|
PLUGIN_LOG_DEBUG(("%s", FULLFUNCTION));
|
|
|
|
#if defined(XP_MACOSX)
|
|
|
|
mac_plugin_interposing::parent::OnPopCursor();
|
|
|
|
return true;
|
|
|
|
#else
|
|
|
|
NS_NOTREACHED(
|
|
|
|
"PluginInstanceParent::RecvPopCursor not implemented!");
|
|
|
|
return false;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
PluginModuleParent::RecvGetNativeCursorsSupported(bool* supported)
|
|
|
|
{
|
|
|
|
PLUGIN_LOG_DEBUG(("%s", FULLFUNCTION));
|
|
|
|
#if defined(XP_MACOSX)
|
2012-04-04 04:09:20 +00:00
|
|
|
*supported =
|
|
|
|
Preferences::GetBool("dom.ipc.plugins.nativeCursorSupport", false);
|
2011-05-24 06:58:28 +00:00
|
|
|
return true;
|
|
|
|
#else
|
|
|
|
NS_NOTREACHED(
|
|
|
|
"PluginInstanceParent::RecvGetNativeCursorSupportLevel not implemented!");
|
|
|
|
return false;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2011-07-26 16:55:58 +00:00
|
|
|
bool
|
|
|
|
PluginModuleParent::RecvNPN_SetException(PPluginScriptableObjectParent* aActor,
|
|
|
|
const nsCString& aMessage)
|
|
|
|
{
|
|
|
|
PLUGIN_LOG_DEBUG(("%s", FULLFUNCTION));
|
|
|
|
|
2013-10-23 20:34:46 +00:00
|
|
|
NPObject* aNPObj = nullptr;
|
2011-07-26 16:55:58 +00:00
|
|
|
if (aActor) {
|
|
|
|
aNPObj = static_cast<PluginScriptableObjectParent*>(aActor)->GetObject(true);
|
|
|
|
if (!aNPObj) {
|
|
|
|
NS_ERROR("Failed to get object!");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
mozilla::plugins::parent::_setexception(aNPObj, NullableStringGet(aMessage));
|
|
|
|
return true;
|
|
|
|
}
|
2012-05-30 14:23:03 +00:00
|
|
|
|
|
|
|
bool
|
|
|
|
PluginModuleParent::RecvNPN_ReloadPlugins(const bool& aReloadPages)
|
|
|
|
{
|
|
|
|
PLUGIN_LOG_DEBUG(("%s", FULLFUNCTION));
|
|
|
|
|
|
|
|
mozilla::plugins::parent::_reloadplugins(aReloadPages);
|
|
|
|
return true;
|
|
|
|
}
|
2012-07-03 11:49:23 +00:00
|
|
|
|
|
|
|
#ifdef MOZ_CRASHREPORTER_INJECTOR
|
|
|
|
|
|
|
|
// We only add the crash reporter to subprocess which have the filename
|
|
|
|
// FlashPlayerPlugin*
|
|
|
|
#define FLASH_PROCESS_PREFIX "FLASHPLAYERPLUGIN"
|
|
|
|
|
|
|
|
static DWORD
|
|
|
|
GetFlashChildOfPID(DWORD pid, HANDLE snapshot)
|
|
|
|
{
|
|
|
|
PROCESSENTRY32 entry = {
|
|
|
|
sizeof(entry)
|
|
|
|
};
|
|
|
|
for (BOOL ok = Process32First(snapshot, &entry);
|
|
|
|
ok;
|
|
|
|
ok = Process32Next(snapshot, &entry)) {
|
|
|
|
if (entry.th32ParentProcessID == pid) {
|
|
|
|
nsString name(entry.szExeFile);
|
|
|
|
ToUpperCase(name);
|
|
|
|
if (StringBeginsWith(name, NS_LITERAL_STRING(FLASH_PROCESS_PREFIX))) {
|
|
|
|
return entry.th32ProcessID;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// We only look for child processes of the Flash plugin, NPSWF*
|
|
|
|
#define FLASH_PLUGIN_PREFIX "NPSWF"
|
|
|
|
|
|
|
|
void
|
|
|
|
PluginModuleParent::InitializeInjector()
|
|
|
|
{
|
|
|
|
if (!Preferences::GetBool("dom.ipc.plugins.flash.subprocess.crashreporter.enabled", false))
|
|
|
|
return;
|
|
|
|
|
|
|
|
nsCString path(Process()->GetPluginFilePath().c_str());
|
|
|
|
ToUpperCase(path);
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t lastSlash = path.RFindCharInSet("\\/");
|
2012-07-03 11:49:23 +00:00
|
|
|
if (kNotFound == lastSlash)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (!StringBeginsWith(Substring(path, lastSlash + 1),
|
|
|
|
NS_LITERAL_CSTRING(FLASH_PLUGIN_PREFIX)))
|
|
|
|
return;
|
|
|
|
|
|
|
|
HANDLE snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
|
|
|
|
if (INVALID_HANDLE_VALUE == snapshot)
|
|
|
|
return;
|
|
|
|
|
|
|
|
DWORD pluginProcessPID = GetProcessId(Process()->GetChildProcessHandle());
|
|
|
|
mFlashProcess1 = GetFlashChildOfPID(pluginProcessPID, snapshot);
|
|
|
|
if (mFlashProcess1) {
|
|
|
|
InjectCrashReporterIntoProcess(mFlashProcess1, this);
|
|
|
|
|
|
|
|
mFlashProcess2 = GetFlashChildOfPID(mFlashProcess1, snapshot);
|
|
|
|
if (mFlashProcess2) {
|
|
|
|
InjectCrashReporterIntoProcess(mFlashProcess2, this);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-07-11 02:20:05 +00:00
|
|
|
PluginModuleParent::OnCrash(DWORD processID)
|
2012-07-03 11:49:23 +00:00
|
|
|
{
|
2012-10-04 16:58:42 +00:00
|
|
|
if (!mShutdown) {
|
|
|
|
GetIPCChannel()->CloseWithError();
|
|
|
|
KillProcess(OtherProcess(), 1, false);
|
|
|
|
}
|
2012-07-03 11:49:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif // MOZ_CRASHREPORTER_INJECTOR
|
2013-03-21 09:17:23 +00:00
|
|
|
|
2013-04-27 14:20:23 +00:00
|
|
|
#ifdef MOZ_ENABLE_PROFILER_SPS
|
2013-03-21 09:17:23 +00:00
|
|
|
class PluginProfilerObserver MOZ_FINAL : public nsIObserver,
|
|
|
|
public nsSupportsWeakReference
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
NS_DECL_NSIOBSERVER
|
|
|
|
|
|
|
|
explicit PluginProfilerObserver(PluginModuleParent* pmp)
|
|
|
|
: mPmp(pmp)
|
|
|
|
{}
|
|
|
|
|
|
|
|
private:
|
|
|
|
PluginModuleParent* mPmp;
|
|
|
|
};
|
|
|
|
|
|
|
|
NS_IMPL_ISUPPORTS2(PluginProfilerObserver, nsIObserver, nsISupportsWeakReference)
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
PluginProfilerObserver::Observe(nsISupports *aSubject,
|
|
|
|
const char *aTopic,
|
2014-01-04 15:02:17 +00:00
|
|
|
const char16_t *aData)
|
2013-03-21 09:17:23 +00:00
|
|
|
{
|
|
|
|
nsCOMPtr<nsIProfileSaveEvent> pse = do_QueryInterface(aSubject);
|
|
|
|
if (pse) {
|
|
|
|
nsCString result;
|
|
|
|
bool success = mPmp->CallGeckoGetProfile(&result);
|
|
|
|
if (success && !result.IsEmpty()) {
|
|
|
|
pse->AddSubProfile(result.get());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
PluginModuleParent::InitPluginProfiling()
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIObserverService> observerService = mozilla::services::GetObserverService();
|
|
|
|
if (observerService) {
|
|
|
|
mProfilerObserver = new PluginProfilerObserver(this);
|
|
|
|
observerService->AddObserver(mProfilerObserver, "profiler-subprocess", false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
PluginModuleParent::ShutdownPluginProfiling()
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIObserverService> observerService = mozilla::services::GetObserverService();
|
|
|
|
if (observerService) {
|
|
|
|
observerService->RemoveObserver(mProfilerObserver, "profiler-subprocess");
|
|
|
|
}
|
|
|
|
}
|
2013-04-27 14:20:23 +00:00
|
|
|
#endif
|