2013-01-05 02:59:05 +04: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/. */
|
|
|
|
|
|
|
|
#ifndef mozilla_plugins_PluginHangUIParent_h
|
|
|
|
#define mozilla_plugins_PluginHangUIParent_h
|
|
|
|
|
|
|
|
#include "nsString.h"
|
|
|
|
|
|
|
|
#include "base/process.h"
|
|
|
|
#include "base/process_util.h"
|
|
|
|
|
2013-07-10 21:00:55 +04:00
|
|
|
#include "mozilla/Mutex.h"
|
2013-01-05 02:59:05 +04:00
|
|
|
#include "mozilla/plugins/PluginMessageUtils.h"
|
|
|
|
|
|
|
|
#include "MiniShmParent.h"
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace plugins {
|
|
|
|
|
2014-10-29 18:05:36 +03:00
|
|
|
class PluginModuleChromeParent;
|
2013-01-05 02:59:05 +04:00
|
|
|
|
|
|
|
/**
|
2017-07-06 15:00:35 +03:00
|
|
|
* This class is responsible for launching and communicating with the
|
2013-01-05 02:59:05 +04:00
|
|
|
* plugin-hang-ui process.
|
|
|
|
*
|
2017-07-06 15:00:35 +03:00
|
|
|
* NOTE: PluginHangUIParent is *not* an IPDL actor! In this case, "Parent"
|
|
|
|
* is describing the fact that firefox is the parent process to the
|
2013-01-05 02:59:05 +04:00
|
|
|
* plugin-hang-ui process, which is the PluginHangUIChild.
|
|
|
|
* PluginHangUIParent and PluginHangUIChild are a matched pair.
|
|
|
|
* @see PluginHangUIChild
|
|
|
|
*/
|
|
|
|
class PluginHangUIParent : public MiniShmObserver
|
|
|
|
{
|
|
|
|
public:
|
2014-10-29 18:05:36 +03:00
|
|
|
PluginHangUIParent(PluginModuleChromeParent* aModule,
|
2013-04-12 01:08:55 +04:00
|
|
|
const int32_t aHangUITimeoutPref,
|
|
|
|
const int32_t aChildTimeoutPref);
|
2013-01-05 02:59:05 +04:00
|
|
|
virtual ~PluginHangUIParent();
|
|
|
|
|
|
|
|
/**
|
2017-07-06 15:00:35 +03:00
|
|
|
* Spawn the plugin-hang-ui.exe child process and terminate the given
|
2013-01-05 02:59:05 +04:00
|
|
|
* plugin container process if the user elects to stop the hung plugin.
|
|
|
|
*
|
|
|
|
* @param aPluginName Human-readable name of the affected plugin.
|
|
|
|
* @return true if the plugin hang ui process was successfully launched,
|
|
|
|
* otherwise false.
|
|
|
|
*/
|
|
|
|
bool
|
|
|
|
Init(const nsString& aPluginName);
|
|
|
|
|
|
|
|
/**
|
2017-07-06 15:00:35 +03:00
|
|
|
* If the Plugin Hang UI is being shown, send a cancel notification to the
|
2013-01-05 02:59:05 +04:00
|
|
|
* Plugin Hang UI child process.
|
|
|
|
*
|
|
|
|
* @return true if the UI was shown and the cancel command was successfully
|
|
|
|
* sent to the child process, otherwise false.
|
|
|
|
*/
|
|
|
|
bool
|
|
|
|
Cancel();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns whether the Plugin Hang UI is currently being displayed.
|
|
|
|
*
|
|
|
|
* @return true if the Plugin Hang UI is showing, otherwise false.
|
|
|
|
*/
|
|
|
|
bool
|
|
|
|
IsShowing() const { return mIsShowing; }
|
|
|
|
|
|
|
|
/**
|
2017-07-06 15:00:35 +03:00
|
|
|
* Returns whether this Plugin Hang UI instance has been shown. Note
|
2013-01-05 02:59:05 +04:00
|
|
|
* that this does not necessarily mean that the UI is showing right now.
|
|
|
|
*
|
|
|
|
* @return true if the Plugin Hang UI has shown, otherwise false.
|
|
|
|
*/
|
|
|
|
bool
|
|
|
|
WasShown() const { return mIsShowing || mLastUserResponse != 0; }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns whether the user checked the "Don't ask me again" checkbox.
|
|
|
|
*
|
|
|
|
* @return true if the user does not want to see the Hang UI again.
|
|
|
|
*/
|
|
|
|
bool
|
|
|
|
DontShowAgain() const;
|
|
|
|
|
|
|
|
/**
|
2017-07-06 15:00:35 +03:00
|
|
|
* Returns whether the user clicked stop during the last time that the
|
2013-01-05 02:59:05 +04:00
|
|
|
* Plugin Hang UI was displayed, if applicable.
|
|
|
|
*
|
2017-07-06 15:00:35 +03:00
|
|
|
* @return true if the UI was shown and the user chose to stop the
|
2013-01-05 02:59:05 +04:00
|
|
|
* plugin, otherwise false
|
|
|
|
*/
|
|
|
|
bool
|
|
|
|
WasLastHangStopped() const;
|
|
|
|
|
|
|
|
/**
|
2017-07-06 15:00:35 +03:00
|
|
|
* @return unsigned int containing the response bits from the last
|
2013-01-05 02:59:05 +04:00
|
|
|
* time the Plugin Hang UI ran.
|
|
|
|
*/
|
|
|
|
unsigned int
|
|
|
|
LastUserResponse() const { return mLastUserResponse; }
|
|
|
|
|
|
|
|
/**
|
2017-07-06 15:00:35 +03:00
|
|
|
* @return unsigned int containing the number of milliseconds that
|
2013-01-05 02:59:05 +04:00
|
|
|
* the Plugin Hang UI was displayed before the user responded.
|
|
|
|
* Returns 0 if the Plugin Hang UI has not been shown or was cancelled.
|
|
|
|
*/
|
|
|
|
unsigned int
|
|
|
|
LastShowDurationMs() const;
|
|
|
|
|
|
|
|
virtual void
|
2015-03-21 19:28:04 +03:00
|
|
|
OnMiniShmEvent(MiniShmBase* aMiniShmObj) override;
|
2013-01-05 02:59:05 +04:00
|
|
|
|
|
|
|
virtual void
|
2015-03-21 19:28:04 +03:00
|
|
|
OnMiniShmConnect(MiniShmBase* aMiniShmObj) override;
|
2013-01-05 02:59:05 +04:00
|
|
|
|
|
|
|
private:
|
|
|
|
nsresult
|
|
|
|
GetHangUIOwnerWindowHandle(NativeWindowHandle& windowHandle);
|
|
|
|
|
|
|
|
bool
|
|
|
|
SendCancel();
|
|
|
|
|
|
|
|
bool
|
|
|
|
RecvUserResponse(const unsigned int& aResponse);
|
|
|
|
|
2013-07-10 21:00:55 +04:00
|
|
|
bool
|
|
|
|
UnwatchHangUIChildProcess(bool aWait);
|
|
|
|
|
2013-01-05 02:59:05 +04:00
|
|
|
static
|
|
|
|
VOID CALLBACK SOnHangUIProcessExit(PVOID aContext, BOOLEAN aIsTimer);
|
|
|
|
|
|
|
|
private:
|
2013-07-10 21:00:55 +04:00
|
|
|
Mutex mMutex;
|
2014-10-29 18:05:36 +03:00
|
|
|
PluginModuleChromeParent* mModule;
|
2013-02-13 00:05:39 +04:00
|
|
|
const uint32_t mTimeoutPrefMs;
|
2013-04-12 01:08:55 +04:00
|
|
|
const uint32_t mIPCTimeoutMs;
|
2013-01-05 02:59:05 +04:00
|
|
|
MessageLoop* mMainThreadMessageLoop;
|
2013-07-10 21:00:55 +04:00
|
|
|
bool mIsShowing;
|
2013-01-05 02:59:05 +04:00
|
|
|
unsigned int mLastUserResponse;
|
|
|
|
base::ProcessHandle mHangUIProcessHandle;
|
|
|
|
NativeWindowHandle mMainWindowHandle;
|
|
|
|
HANDLE mRegWait;
|
|
|
|
HANDLE mShowEvent;
|
|
|
|
DWORD mShowTicks;
|
|
|
|
DWORD mResponseTicks;
|
|
|
|
MiniShmParent mMiniShm;
|
|
|
|
|
|
|
|
DISALLOW_COPY_AND_ASSIGN(PluginHangUIParent);
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace plugins
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // mozilla_plugins_PluginHangUIParent_h
|
|
|
|
|