2013-01-04 14:59:05 -08:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=2 et sw=2 tw=80: */
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#include "PluginHangUI.h"
|
|
|
|
|
|
|
|
#include "PluginHangUIParent.h"
|
|
|
|
|
|
|
|
#include "mozilla/Telemetry.h"
|
|
|
|
#include "mozilla/plugins/PluginModuleParent.h"
|
|
|
|
|
|
|
|
#include "nsContentUtils.h"
|
|
|
|
#include "nsDirectoryServiceDefs.h"
|
|
|
|
#include "nsIFile.h"
|
|
|
|
#include "nsIProperties.h"
|
|
|
|
#include "nsIWindowMediator.h"
|
2013-02-14 15:03:05 -08:00
|
|
|
#include "nsIWinTaskbar.h"
|
2013-01-04 14:59:05 -08:00
|
|
|
#include "nsServiceManagerUtils.h"
|
2013-09-19 06:54:39 -07:00
|
|
|
#include "nsThreadUtils.h"
|
2013-01-04 14:59:05 -08:00
|
|
|
|
|
|
|
#include "WidgetUtils.h"
|
|
|
|
|
2013-02-14 15:03:05 -08:00
|
|
|
#define NS_TASKBAR_CONTRACTID "@mozilla.org/windows-taskbar;1"
|
|
|
|
|
2013-01-04 14:59:05 -08:00
|
|
|
using base::ProcessHandle;
|
|
|
|
|
|
|
|
using mozilla::widget::WidgetUtils;
|
|
|
|
|
|
|
|
using std::string;
|
|
|
|
using std::vector;
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
class nsPluginHangUITelemetry : public nsRunnable
|
|
|
|
{
|
|
|
|
public:
|
2013-02-12 12:05:39 -08:00
|
|
|
nsPluginHangUITelemetry(int aResponseCode, int aDontAskCode,
|
|
|
|
uint32_t aResponseTimeMs, uint32_t aTimeoutMs)
|
2013-01-04 14:59:05 -08:00
|
|
|
: mResponseCode(aResponseCode),
|
2013-02-12 12:05:39 -08:00
|
|
|
mDontAskCode(aDontAskCode),
|
|
|
|
mResponseTimeMs(aResponseTimeMs),
|
|
|
|
mTimeoutMs(aTimeoutMs)
|
2013-01-04 14:59:05 -08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHOD
|
|
|
|
Run()
|
|
|
|
{
|
|
|
|
mozilla::Telemetry::Accumulate(
|
|
|
|
mozilla::Telemetry::PLUGIN_HANG_UI_USER_RESPONSE, mResponseCode);
|
2013-02-12 12:05:39 -08:00
|
|
|
mozilla::Telemetry::Accumulate(
|
|
|
|
mozilla::Telemetry::PLUGIN_HANG_UI_DONT_ASK, mDontAskCode);
|
|
|
|
mozilla::Telemetry::Accumulate(
|
|
|
|
mozilla::Telemetry::PLUGIN_HANG_UI_RESPONSE_TIME, mResponseTimeMs);
|
|
|
|
mozilla::Telemetry::Accumulate(
|
|
|
|
mozilla::Telemetry::PLUGIN_HANG_TIME, mTimeoutMs + mResponseTimeMs);
|
2013-01-04 14:59:05 -08:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
int mResponseCode;
|
|
|
|
int mDontAskCode;
|
2013-02-12 12:05:39 -08:00
|
|
|
uint32_t mResponseTimeMs;
|
|
|
|
uint32_t mTimeoutMs;
|
2013-01-04 14:59:05 -08:00
|
|
|
};
|
|
|
|
} // anonymous namespace
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace plugins {
|
|
|
|
|
2013-02-12 12:05:39 -08:00
|
|
|
PluginHangUIParent::PluginHangUIParent(PluginModuleParent* aModule,
|
2013-04-11 14:08:55 -07:00
|
|
|
const int32_t aHangUITimeoutPref,
|
|
|
|
const int32_t aChildTimeoutPref)
|
2013-07-10 10:00:55 -07:00
|
|
|
: mMutex("mozilla::plugins::PluginHangUIParent::mMutex"),
|
|
|
|
mModule(aModule),
|
2013-02-12 12:05:39 -08:00
|
|
|
mTimeoutPrefMs(static_cast<uint32_t>(aHangUITimeoutPref) * 1000U),
|
2013-04-11 14:08:55 -07:00
|
|
|
mIPCTimeoutMs(static_cast<uint32_t>(aChildTimeoutPref) * 1000U),
|
2013-01-04 14:59:05 -08:00
|
|
|
mMainThreadMessageLoop(MessageLoop::current()),
|
|
|
|
mIsShowing(false),
|
|
|
|
mLastUserResponse(0),
|
2013-10-23 13:34:46 -07:00
|
|
|
mHangUIProcessHandle(nullptr),
|
|
|
|
mMainWindowHandle(nullptr),
|
|
|
|
mRegWait(nullptr),
|
|
|
|
mShowEvent(nullptr),
|
2013-01-04 14:59:05 -08:00
|
|
|
mShowTicks(0),
|
|
|
|
mResponseTicks(0)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
PluginHangUIParent::~PluginHangUIParent()
|
|
|
|
{
|
2013-07-10 10:00:55 -07:00
|
|
|
{ // Scope for lock
|
|
|
|
MutexAutoLock lock(mMutex);
|
|
|
|
UnwatchHangUIChildProcess(true);
|
2013-01-04 14:59:05 -08:00
|
|
|
}
|
|
|
|
if (mShowEvent) {
|
|
|
|
::CloseHandle(mShowEvent);
|
|
|
|
}
|
|
|
|
if (mHangUIProcessHandle) {
|
|
|
|
::CloseHandle(mHangUIProcessHandle);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
PluginHangUIParent::DontShowAgain() const
|
|
|
|
{
|
|
|
|
return (mLastUserResponse & HANGUI_USER_RESPONSE_DONT_SHOW_AGAIN);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
PluginHangUIParent::WasLastHangStopped() const
|
|
|
|
{
|
|
|
|
return (mLastUserResponse & HANGUI_USER_RESPONSE_STOP);
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned int
|
|
|
|
PluginHangUIParent::LastShowDurationMs() const
|
|
|
|
{
|
|
|
|
// We only return something if there was a user response
|
|
|
|
if (!mLastUserResponse) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return static_cast<unsigned int>(mResponseTicks - mShowTicks);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
PluginHangUIParent::Init(const nsString& aPluginName)
|
|
|
|
{
|
|
|
|
if (mHangUIProcessHandle) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult rv;
|
2013-04-11 14:08:55 -07:00
|
|
|
rv = mMiniShm.Init(this, ::IsDebuggerPresent() ? INFINITE : mIPCTimeoutMs);
|
2013-01-07 07:11:35 -08:00
|
|
|
NS_ENSURE_SUCCESS(rv, false);
|
2013-01-04 14:59:05 -08:00
|
|
|
nsCOMPtr<nsIProperties>
|
|
|
|
directoryService(do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID));
|
|
|
|
if (!directoryService) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
nsCOMPtr<nsIFile> greDir;
|
|
|
|
rv = directoryService->Get(NS_GRE_DIR,
|
|
|
|
NS_GET_IID(nsIFile),
|
|
|
|
getter_AddRefs(greDir));
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
nsAutoString path;
|
|
|
|
greDir->GetPath(path);
|
|
|
|
|
|
|
|
FilePath exePath(path.get());
|
|
|
|
exePath = exePath.AppendASCII(MOZ_HANGUI_PROCESS_NAME);
|
|
|
|
CommandLine commandLine(exePath.value());
|
|
|
|
|
|
|
|
nsXPIDLString localizedStr;
|
2014-01-04 07:02:17 -08:00
|
|
|
const char16_t* formatParams[] = { aPluginName.get() };
|
2013-01-04 14:59:05 -08:00
|
|
|
rv = nsContentUtils::FormatLocalizedString(nsContentUtils::eDOM_PROPERTIES,
|
|
|
|
"PluginHangUIMessage",
|
|
|
|
formatParams,
|
|
|
|
localizedStr);
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
commandLine.AppendLooseValue(localizedStr.get());
|
|
|
|
|
|
|
|
const char* keys[] = { "PluginHangUITitle",
|
|
|
|
"PluginHangUIWaitButton",
|
|
|
|
"PluginHangUIStopButton",
|
|
|
|
"DontAskAgain" };
|
|
|
|
for (unsigned int i = 0; i < ArrayLength(keys); ++i) {
|
|
|
|
rv = nsContentUtils::GetLocalizedString(nsContentUtils::eDOM_PROPERTIES,
|
|
|
|
keys[i],
|
|
|
|
localizedStr);
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
commandLine.AppendLooseValue(localizedStr.get());
|
|
|
|
}
|
|
|
|
|
|
|
|
rv = GetHangUIOwnerWindowHandle(mMainWindowHandle);
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
nsAutoString hwndStr;
|
|
|
|
hwndStr.AppendPrintf("%p", mMainWindowHandle);
|
|
|
|
commandLine.AppendLooseValue(hwndStr.get());
|
|
|
|
|
|
|
|
ScopedHandle procHandle(::OpenProcess(SYNCHRONIZE,
|
|
|
|
TRUE,
|
|
|
|
GetCurrentProcessId()));
|
|
|
|
if (!procHandle.IsValid()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
nsAutoString procHandleStr;
|
2013-01-09 14:34:14 -08:00
|
|
|
procHandleStr.AppendPrintf("%p", procHandle.Get());
|
2013-01-04 14:59:05 -08:00
|
|
|
commandLine.AppendLooseValue(procHandleStr.get());
|
|
|
|
|
2013-02-14 15:03:05 -08:00
|
|
|
// On Win7+, pass the application user model to the child, so it can
|
|
|
|
// register with it. This insures windows created by the Hang UI
|
|
|
|
// properly group with the parent app on the Win7 taskbar.
|
|
|
|
nsCOMPtr<nsIWinTaskbar> taskbarInfo = do_GetService(NS_TASKBAR_CONTRACTID);
|
|
|
|
if (taskbarInfo) {
|
|
|
|
bool isSupported = false;
|
|
|
|
taskbarInfo->GetAvailable(&isSupported);
|
|
|
|
nsAutoString appId;
|
|
|
|
if (isSupported && NS_SUCCEEDED(taskbarInfo->GetDefaultGroupId(appId))) {
|
|
|
|
commandLine.AppendLooseValue(appId.get());
|
|
|
|
} else {
|
|
|
|
commandLine.AppendLooseValue(L"-");
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
commandLine.AppendLooseValue(L"-");
|
|
|
|
}
|
|
|
|
|
2013-04-11 14:08:55 -07:00
|
|
|
nsAutoString ipcTimeoutStr;
|
|
|
|
ipcTimeoutStr.AppendInt(mIPCTimeoutMs);
|
|
|
|
commandLine.AppendLooseValue(ipcTimeoutStr.get());
|
|
|
|
|
2013-01-04 14:59:05 -08:00
|
|
|
std::wstring ipcCookie;
|
|
|
|
rv = mMiniShm.GetCookie(ipcCookie);
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
commandLine.AppendLooseValue(ipcCookie);
|
|
|
|
|
2014-03-03 18:35:51 -08:00
|
|
|
ScopedHandle showEvent(::CreateEventW(nullptr, FALSE, FALSE, nullptr));
|
2013-01-04 14:59:05 -08:00
|
|
|
if (!showEvent.IsValid()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
mShowEvent = showEvent.Get();
|
|
|
|
|
2013-07-10 10:00:55 -07:00
|
|
|
MutexAutoLock lock(mMutex);
|
2013-01-04 14:59:05 -08:00
|
|
|
STARTUPINFO startupInfo = { sizeof(STARTUPINFO) };
|
2013-10-23 13:34:46 -07:00
|
|
|
PROCESS_INFORMATION processInfo = { nullptr };
|
2013-01-04 14:59:05 -08:00
|
|
|
BOOL isProcessCreated = ::CreateProcess(exePath.value().c_str(),
|
|
|
|
const_cast<wchar_t*>(commandLine.command_line_string().c_str()),
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
TRUE,
|
|
|
|
DETACHED_PROCESS,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
&startupInfo,
|
|
|
|
&processInfo);
|
|
|
|
if (isProcessCreated) {
|
|
|
|
::CloseHandle(processInfo.hThread);
|
|
|
|
mHangUIProcessHandle = processInfo.hProcess;
|
|
|
|
::RegisterWaitForSingleObject(&mRegWait,
|
|
|
|
processInfo.hProcess,
|
|
|
|
&SOnHangUIProcessExit,
|
|
|
|
this,
|
|
|
|
INFINITE,
|
|
|
|
WT_EXECUTEDEFAULT | WT_EXECUTEONLYONCE);
|
2013-02-14 15:03:05 -08:00
|
|
|
::WaitForSingleObject(mShowEvent, ::IsDebuggerPresent() ? INFINITE
|
2013-04-11 14:08:55 -07:00
|
|
|
: mIPCTimeoutMs);
|
2013-02-14 15:03:05 -08:00
|
|
|
// Setting this to true even if we time out on mShowEvent. This timeout
|
|
|
|
// typically occurs when the machine is thrashing so badly that
|
|
|
|
// plugin-hang-ui.exe is taking a while to start. If we didn't set
|
|
|
|
// this to true, Firefox would keep spawning additional plugin-hang-ui
|
|
|
|
// processes, which is not what we want.
|
|
|
|
mIsShowing = true;
|
2013-01-04 14:59:05 -08:00
|
|
|
}
|
2013-10-23 13:34:46 -07:00
|
|
|
mShowEvent = nullptr;
|
2013-01-04 14:59:05 -08:00
|
|
|
return !(!isProcessCreated);
|
|
|
|
}
|
|
|
|
|
|
|
|
// static
|
|
|
|
VOID CALLBACK PluginHangUIParent::SOnHangUIProcessExit(PVOID aContext,
|
|
|
|
BOOLEAN aIsTimer)
|
|
|
|
{
|
|
|
|
PluginHangUIParent* object = static_cast<PluginHangUIParent*>(aContext);
|
2013-07-10 10:00:55 -07:00
|
|
|
MutexAutoLock lock(object->mMutex);
|
2013-01-04 14:59:05 -08:00
|
|
|
// If the Hang UI child process died unexpectedly, act as if the UI cancelled
|
|
|
|
if (object->IsShowing()) {
|
|
|
|
object->RecvUserResponse(HANGUI_USER_RESPONSE_CANCEL);
|
|
|
|
// Firefox window was disabled automatically when the Hang UI was shown.
|
|
|
|
// If plugin-hang-ui.exe was unexpectedly terminated, we need to re-enable.
|
|
|
|
::EnableWindow(object->mMainWindowHandle, TRUE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-07-10 10:00:55 -07:00
|
|
|
// A precondition for this function is that the caller has locked mMutex
|
|
|
|
bool
|
|
|
|
PluginHangUIParent::UnwatchHangUIChildProcess(bool aWait)
|
|
|
|
{
|
|
|
|
mMutex.AssertCurrentThreadOwns();
|
|
|
|
if (mRegWait) {
|
2013-10-23 13:34:46 -07:00
|
|
|
// If aWait is false then we want to pass a nullptr (i.e. default
|
|
|
|
// constructor) completionEvent
|
2013-07-10 10:00:55 -07:00
|
|
|
ScopedHandle completionEvent;
|
|
|
|
if (aWait) {
|
2014-03-03 18:35:51 -08:00
|
|
|
completionEvent.Set(::CreateEventW(nullptr, FALSE, FALSE, nullptr));
|
2013-07-10 10:00:55 -07:00
|
|
|
if (!completionEvent.IsValid()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// if aWait == false and UnregisterWaitEx fails with ERROR_IO_PENDING,
|
|
|
|
// it is okay to clear mRegWait; Windows is telling us that the wait's
|
|
|
|
// callback is running but will be cleaned up once the callback returns.
|
|
|
|
if (::UnregisterWaitEx(mRegWait, completionEvent) ||
|
|
|
|
!aWait && ::GetLastError() == ERROR_IO_PENDING) {
|
2013-10-23 13:34:46 -07:00
|
|
|
mRegWait = nullptr;
|
2013-07-10 10:00:55 -07:00
|
|
|
if (aWait) {
|
|
|
|
// We must temporarily unlock mMutex while waiting for the registered
|
|
|
|
// wait callback to complete, or else we could deadlock.
|
|
|
|
MutexAutoUnlock unlock(mMutex);
|
|
|
|
::WaitForSingleObject(completionEvent, INFINITE);
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-01-04 14:59:05 -08:00
|
|
|
bool
|
|
|
|
PluginHangUIParent::Cancel()
|
|
|
|
{
|
2013-07-10 10:00:55 -07:00
|
|
|
MutexAutoLock lock(mMutex);
|
2013-01-04 14:59:05 -08:00
|
|
|
bool result = mIsShowing && SendCancel();
|
|
|
|
if (result) {
|
|
|
|
mIsShowing = false;
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
PluginHangUIParent::SendCancel()
|
|
|
|
{
|
|
|
|
PluginHangUICommand* cmd = nullptr;
|
|
|
|
nsresult rv = mMiniShm.GetWritePtr(cmd);
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
cmd->mCode = PluginHangUICommand::HANGUI_CMD_CANCEL;
|
|
|
|
return NS_SUCCEEDED(mMiniShm.Send());
|
|
|
|
}
|
|
|
|
|
2013-07-10 10:00:55 -07:00
|
|
|
// A precondition for this function is that the caller has locked mMutex
|
2013-01-04 14:59:05 -08:00
|
|
|
bool
|
|
|
|
PluginHangUIParent::RecvUserResponse(const unsigned int& aResponse)
|
|
|
|
{
|
2013-07-10 10:00:55 -07:00
|
|
|
mMutex.AssertCurrentThreadOwns();
|
2013-03-19 08:23:37 -07:00
|
|
|
if (!mIsShowing && !(aResponse & HANGUI_USER_RESPONSE_CANCEL)) {
|
|
|
|
// Don't process a user response if a cancellation is already pending
|
|
|
|
return true;
|
|
|
|
}
|
2013-01-04 14:59:05 -08:00
|
|
|
mLastUserResponse = aResponse;
|
2013-07-10 10:00:55 -07:00
|
|
|
mResponseTicks = ::GetTickCount();
|
2013-01-04 14:59:05 -08:00
|
|
|
mIsShowing = false;
|
|
|
|
// responseCode: 1 = Stop, 2 = Continue, 3 = Cancel
|
|
|
|
int responseCode;
|
|
|
|
if (aResponse & HANGUI_USER_RESPONSE_STOP) {
|
|
|
|
// User clicked Stop
|
|
|
|
mModule->TerminateChildProcess(mMainThreadMessageLoop);
|
|
|
|
responseCode = 1;
|
|
|
|
} else if(aResponse & HANGUI_USER_RESPONSE_CONTINUE) {
|
|
|
|
// User clicked Continue
|
|
|
|
responseCode = 2;
|
|
|
|
} else {
|
|
|
|
// Dialog was cancelled
|
|
|
|
responseCode = 3;
|
|
|
|
}
|
|
|
|
int dontAskCode = (aResponse & HANGUI_USER_RESPONSE_DONT_SHOW_AGAIN) ? 1 : 0;
|
|
|
|
nsCOMPtr<nsIRunnable> workItem = new nsPluginHangUITelemetry(responseCode,
|
2013-02-12 12:05:39 -08:00
|
|
|
dontAskCode,
|
|
|
|
LastShowDurationMs(),
|
|
|
|
mTimeoutPrefMs);
|
2013-01-04 14:59:05 -08:00
|
|
|
NS_DispatchToMainThread(workItem, NS_DISPATCH_NORMAL);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
PluginHangUIParent::GetHangUIOwnerWindowHandle(NativeWindowHandle& windowHandle)
|
|
|
|
{
|
2013-10-23 13:34:46 -07:00
|
|
|
windowHandle = nullptr;
|
2013-01-04 14:59:05 -08:00
|
|
|
|
|
|
|
nsresult rv;
|
|
|
|
nsCOMPtr<nsIWindowMediator> winMediator(do_GetService(NS_WINDOWMEDIATOR_CONTRACTID,
|
|
|
|
&rv));
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDOMWindow> navWin;
|
2013-12-12 17:50:01 -08:00
|
|
|
rv = winMediator->GetMostRecentWindow(MOZ_UTF16("navigator:browser"),
|
2013-01-04 14:59:05 -08:00
|
|
|
getter_AddRefs(navWin));
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
if (!navWin) {
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsIWidget> widget = WidgetUtils::DOMWindowToWidget(navWin);
|
|
|
|
if (!widget) {
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
windowHandle = reinterpret_cast<NativeWindowHandle>(widget->GetNativeData(NS_NATIVE_WINDOW));
|
|
|
|
if (!windowHandle) {
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
PluginHangUIParent::OnMiniShmEvent(MiniShmBase *aMiniShmObj)
|
|
|
|
{
|
|
|
|
const PluginHangUIResponse* response = nullptr;
|
|
|
|
nsresult rv = aMiniShmObj->GetReadPtr(response);
|
|
|
|
NS_ASSERTION(NS_SUCCEEDED(rv),
|
|
|
|
"Couldn't obtain read pointer OnMiniShmEvent");
|
|
|
|
if (NS_SUCCEEDED(rv)) {
|
2013-01-17 18:22:21 -08:00
|
|
|
// The child process has returned a response so we shouldn't worry about
|
|
|
|
// its state anymore.
|
2013-07-10 10:00:55 -07:00
|
|
|
MutexAutoLock lock(mMutex);
|
|
|
|
UnwatchHangUIChildProcess(false);
|
2013-01-04 14:59:05 -08:00
|
|
|
RecvUserResponse(response->mResponseBits);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
PluginHangUIParent::OnMiniShmConnect(MiniShmBase* aMiniShmObj)
|
|
|
|
{
|
|
|
|
PluginHangUICommand* cmd = nullptr;
|
|
|
|
nsresult rv = aMiniShmObj->GetWritePtr(cmd);
|
|
|
|
NS_ASSERTION(NS_SUCCEEDED(rv),
|
|
|
|
"Couldn't obtain write pointer OnMiniShmConnect");
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
cmd->mCode = PluginHangUICommand::HANGUI_CMD_SHOW;
|
2013-02-14 15:03:05 -08:00
|
|
|
if (NS_SUCCEEDED(aMiniShmObj->Send())) {
|
2013-07-10 10:00:55 -07:00
|
|
|
mShowTicks = ::GetTickCount();
|
2013-01-04 14:59:05 -08:00
|
|
|
}
|
|
|
|
::SetEvent(mShowEvent);
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace plugins
|
|
|
|
} // namespace mozilla
|