Backing out changesets ed8d3323a50d, 3930bbdffdd5, 36e32abd2cc8, f4bcfc703ff9, 21051d997076, and 49f489315dd9 at the request of bsmedberg.

This commit is contained in:
Ben Turner 2009-12-11 12:48:37 -08:00
parent aadcbce897
commit 6e20a64631
10 changed files with 52 additions and 115 deletions

View File

@ -1,4 +1,4 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
* vim: sw=4 ts=4 et :
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
@ -43,8 +43,6 @@
#include "npapi.h"
#include "nscore.h"
class nsNPAPIPlugin;
namespace mozilla {
class PluginLibrary
@ -52,12 +50,6 @@ class PluginLibrary
public:
virtual ~PluginLibrary() { }
/**
* Inform this library about the nsNPAPIPlugin which owns it. This
* object will hold a weak pointer to the plugin.
*/
virtual void SetPlugin(nsNPAPIPlugin* plugin) = 0;
virtual bool HasRequiredFunctions() = 0;
#if defined(XP_UNIX) && !defined(XP_MACOSX)

View File

@ -69,7 +69,6 @@ PluginModuleParent::PluginModuleParent(const char* aFilePath)
: mSubprocess(new PluginProcessParent(aFilePath))
, mShutdown(false)
, mNPNIface(NULL)
, mPlugin(NULL)
{
NS_ASSERTION(mSubprocess, "Out of memory!");
@ -98,14 +97,9 @@ PluginModuleParent::ActorDestroy(ActorDestroyReason why)
{
switch (why) {
case AbnormalShutdown:
mShutdown = true;
if (mPlugin) {
nsCOMPtr<nsIRunnable> r =
new nsRunnableMethod<nsNPAPIPlugin>(
mPlugin, &nsNPAPIPlugin::PluginCrashed);
NS_DispatchToMainThread(r);
}
break;
// TODObsmedberg: notify the plugin host to forget this plugin module
// and instantiate us again.
// FALL THROUGH
case NormalShutdown:
mShutdown = true;

View File

@ -97,12 +97,8 @@ protected:
public:
PluginModuleParent(const char* aFilePath);
virtual ~PluginModuleParent();
NS_OVERRIDE virtual void SetPlugin(nsNPAPIPlugin* plugin)
{
mPlugin = plugin;
}
virtual ~PluginModuleParent();
NS_OVERRIDE virtual void ActorDestroy(ActorDestroyReason why);
@ -217,7 +213,6 @@ private:
bool mShutdown;
const NPNetscapeFuncs* mNPNIface;
nsTHashtable<nsVoidPtrHashKey> mValidIdentifiers;
nsNPAPIPlugin* mPlugin;
};
} // namespace plugins

View File

@ -83,8 +83,6 @@ public:
// unref here??
}
virtual void SetPlugin(nsNPAPIPlugin*) { }
virtual bool HasRequiredFunctions() {
mNP_Initialize = (NP_InitializeFunc)
PR_FindFunctionSymbol(mLibrary, "NP_Initialize");

View File

@ -281,7 +281,6 @@ nsNPAPIPlugin::nsNPAPIPlugin(NPPluginFuncs* callbacks,
#endif
fLibrary = aLibrary;
fLibrary->SetPlugin(this);
}
nsNPAPIPlugin::~nsNPAPIPlugin()
@ -301,17 +300,6 @@ nsNPAPIPlugin::SetPluginRefNum(short aRefNum)
}
#endif
#ifdef MOZ_IPC
void
nsNPAPIPlugin::PluginCrashed()
{
nsPluginTag* tag = nsPluginHost::GetInst()->FindPluginTag(this);
if (tag) {
tag->mEntryPoint = NULL;
}
}
#endif
namespace {
#ifdef MOZ_IPC
@ -597,7 +585,7 @@ nsNPAPIPlugin::CreatePluginInstance(nsIPluginInstance **aResult)
*aResult = NULL;
nsRefPtr<nsNPAPIPluginInstance> inst =
new nsNPAPIPluginInstance(this);
new nsNPAPIPluginInstance(&fCallbacks, fLibrary);
if (!inst)
return NS_ERROR_OUT_OF_MEMORY;

View File

@ -94,15 +94,7 @@ public:
void SetPluginRefNum(short aRefNum);
#endif
#ifdef MOZ_IPC
// The IPC mechanism will notify us if a plugin crashed and is no longer usable.
void PluginCrashed();
#endif
protected:
friend class nsNPAPIPluginInstance;
friend class nsNPAPIPluginStreamListener;
// Ensures that the static CALLBACKS is properly initialized
static void CheckClassInitialized(void);

View File

@ -272,7 +272,7 @@ nsresult nsNPAPIPluginStreamListener::CleanUpStream(NPReason reason)
NPPAutoPusher nppPusher(npp);
PluginLibrary* lib = nsnull;
lib = mInst->mPlugin->fLibrary;
lib = mInst->mLibrary;
NPError error;
NS_TRY_SAFE_CALL_RETURN(error, (*callbacks->destroystream)(npp, &mNPStream, reason), lib, mInst);
@ -314,7 +314,7 @@ void nsNPAPIPluginStreamListener::CallURLNotify(NPReason reason)
NPP npp;
mInst->GetNPP(&npp);
NS_TRY_SAFE_CALL_VOID((*callbacks->urlnotify)(npp, mNotifyURL, reason, mNotifyData), mInst->mPlugin->fLibrary, mInst);
NS_TRY_SAFE_CALL_VOID((*callbacks->urlnotify)(npp, mNotifyURL, reason, mNotifyData), mInst->mLibrary, mInst);
NPP_PLUGIN_LOG(PLUGIN_LOG_NORMAL,
("NPP URLNotify called: this=%p, npp=%p, notify=%p, reason=%d, url=%s\n",
@ -362,7 +362,7 @@ nsNPAPIPluginStreamListener::OnStartBinding(nsIPluginStreamInfo* pluginInfo)
NPPAutoPusher nppPusher(npp);
NS_TRY_SAFE_CALL_RETURN(error, (*callbacks->newstream)(npp, (char*)contentType, &mNPStream, seekable, &streamType), mInst->mPlugin->fLibrary, mInst);
NS_TRY_SAFE_CALL_RETURN(error, (*callbacks->newstream)(npp, (char*)contentType, &mNPStream, seekable, &streamType), mInst->mLibrary, mInst);
NPP_PLUGIN_LOG(PLUGIN_LOG_NORMAL,
("NPP NewStream called: this=%p, npp=%p, mime=%s, seek=%d, type=%d, return=%d, url=%s\n",
@ -603,7 +603,7 @@ nsNPAPIPluginStreamListener::OnDataAvailable(nsIPluginStreamInfo* pluginInfo,
if (callbacks->writeready) {
NPPAutoPusher nppPusher(npp);
NS_TRY_SAFE_CALL_RETURN(numtowrite, (*callbacks->writeready)(npp, &mNPStream), mInst->mPlugin->fLibrary, mInst);
NS_TRY_SAFE_CALL_RETURN(numtowrite, (*callbacks->writeready)(npp, &mNPStream), mInst->mLibrary, mInst);
NPP_PLUGIN_LOG(PLUGIN_LOG_NOISY,
("NPP WriteReady called: this=%p, npp=%p, "
"return(towrite)=%d, url=%s\n",
@ -652,7 +652,7 @@ nsNPAPIPluginStreamListener::OnDataAvailable(nsIPluginStreamInfo* pluginInfo,
NPPAutoPusher nppPusher(npp);
PRInt32 writeCount = 0; // bytes consumed by plugin instance
NS_TRY_SAFE_CALL_RETURN(writeCount, (*callbacks->write)(npp, &mNPStream, streamPosition, numtowrite, ptrStreamBuffer), mInst->mPlugin->fLibrary, mInst);
NS_TRY_SAFE_CALL_RETURN(writeCount, (*callbacks->write)(npp, &mNPStream, streamPosition, numtowrite, ptrStreamBuffer), mInst->mLibrary, mInst);
NPP_PLUGIN_LOG(PLUGIN_LOG_NOISY,
("NPP Write called: this=%p, npp=%p, pos=%d, len=%d, "
@ -757,7 +757,7 @@ nsNPAPIPluginStreamListener::OnFileAvailable(nsIPluginStreamInfo* pluginInfo,
mInst->GetNPP(&npp);
PluginLibrary* lib = nsnull;
lib = mInst->mPlugin->fLibrary;
lib = mInst->mLibrary;
NS_TRY_SAFE_CALL_VOID((*callbacks->asfile)(npp, &mNPStream, fileName), lib, mInst);
@ -875,8 +875,9 @@ nsInstanceStream::~nsInstanceStream()
NS_IMPL_ISUPPORTS1(nsNPAPIPluginInstance, nsIPluginInstance)
nsNPAPIPluginInstance::nsNPAPIPluginInstance(nsNPAPIPlugin* plugin)
: mPlugin(plugin),
nsNPAPIPluginInstance::nsNPAPIPluginInstance(NPPluginFuncs* callbacks,
PluginLibrary* aLibrary)
: mCallbacks(callbacks),
#ifdef XP_MACOSX
#ifdef NP_NO_QUICKDRAW
mDrawingModel(NPDrawingModelCoreGraphics),
@ -891,11 +892,14 @@ nsNPAPIPluginInstance::nsNPAPIPluginInstance(nsNPAPIPlugin* plugin)
mCached(PR_FALSE),
mWantsAllNetworkStreams(PR_FALSE),
mInPluginInitCall(PR_FALSE),
mLibrary(aLibrary),
mStreams(nsnull),
mMIMEType(nsnull),
mOwner(nsnull),
mCurrentPluginEvent(nsnull)
{
NS_ASSERTION(mCallbacks != NULL, "null callbacks");
// Initialize the NPP structure.
mNPP.pdata = NULL;
@ -990,7 +994,7 @@ NS_IMETHODIMP nsNPAPIPluginInstance::Stop(void)
OnPluginDestroy(&mNPP);
if (mPlugin->fCallbacks.destroy == NULL) {
if (mCallbacks->destroy == NULL) {
return NS_ERROR_FAILURE;
}
@ -1011,8 +1015,7 @@ NS_IMETHODIMP nsNPAPIPluginInstance::Stop(void)
listener->CleanUpStream(NPRES_USER_BREAK);
}
NS_TRY_SAFE_CALL_RETURN(error, (mPlugin->fCallbacks.destroy)(&mNPP, &sdata),
mPlugin->fLibrary, this);
NS_TRY_SAFE_CALL_RETURN(error, (*mCallbacks->destroy)(&mNPP, &sdata), mLibrary, this);
NPP_PLUGIN_LOG(PLUGIN_LOG_NORMAL,
("NPP Destroy called: this=%p, npp=%p, return=%d\n", this, &mNPP, error));
@ -1195,9 +1198,7 @@ nsNPAPIPluginInstance::InitializePlugin()
// Need this on the stack before calling NPP_New otherwise some callbacks that
// the plugin may make could fail (NPN_HasProperty, for example).
NPPAutoPusher autopush(&mNPP);
nsresult newResult = mPlugin->fLibrary->NPP_New(
(char*)mimetype, &mNPP, (PRUint16)mode, count,
(char**)names, (char**)values, NULL, &error);
nsresult newResult = mLibrary->NPP_New((char*)mimetype, &mNPP, (PRUint16)mode, count, (char**)names, (char**)values, NULL, &error);
if (NS_FAILED(newResult))
return newResult;
@ -1230,7 +1231,7 @@ NS_IMETHODIMP nsNPAPIPluginInstance::SetWindow(NPWindow* window)
}
#endif
if (mPlugin->fCallbacks.setwindow) {
if (mCallbacks->setwindow) {
PluginDestructionGuard guard(this);
// XXX Turns out that NPPluginWindow and NPWindow are structurally
@ -1244,7 +1245,7 @@ NS_IMETHODIMP nsNPAPIPluginInstance::SetWindow(NPWindow* window)
NPPAutoPusher nppPusher(&mNPP);
NPError error;
NS_TRY_SAFE_CALL_RETURN(error, (mPlugin->fCallbacks.setwindow)(&mNPP, (NPWindow*)window), mPlugin->fLibrary, this);
NS_TRY_SAFE_CALL_RETURN(error, (*mCallbacks->setwindow)(&mNPP, (NPWindow*)window), mLibrary, this);
mInPluginInitCall = oldVal;
@ -1314,8 +1315,8 @@ NS_IMETHODIMP nsNPAPIPluginInstance::Print(NPPrint* platformPrint)
// to be compatible with the older SDK versions and to match what
// NPAPI and other browsers do, overwrite |window.type| field with one
// more copy of |platformPrint|. See bug 113264
PRUint16 sdkmajorversion = (mPlugin->fCallbacks.version & 0xff00)>>8;
PRUint16 sdkminorversion = mPlugin->fCallbacks.version & 0x00ff;
PRUint16 sdkmajorversion = (mCallbacks->version & 0xff00)>>8;
PRUint16 sdkminorversion = mCallbacks->version & 0x00ff;
if ((sdkmajorversion == 0) && (sdkminorversion < 11)) {
// Let's copy platformPrint bytes over to where it was supposed to be
// in older versions -- four bytes towards the beginning of the struct
@ -1329,9 +1330,8 @@ NS_IMETHODIMP nsNPAPIPluginInstance::Print(NPPrint* platformPrint)
}
}
if (mPlugin->fCallbacks.print)
NS_TRY_SAFE_CALL_VOID((*mPlugin->fCallbacks.print)(&mNPP, thePrint),
mPlugin->fLibrary, this);
if (mCallbacks->print)
NS_TRY_SAFE_CALL_VOID((*mCallbacks->print)(&mNPP, thePrint), mLibrary, this);
NPP_PLUGIN_LOG(PLUGIN_LOG_NORMAL,
("NPP PrintProc called: this=%p, pDC=%p, [x=%d,y=%d,w=%d,h=%d], clip[t=%d,b=%d,l=%d,r=%d]\n",
@ -1361,13 +1361,12 @@ NS_IMETHODIMP nsNPAPIPluginInstance::HandleEvent(void* event, PRBool* handled)
PRInt16 result = 0;
if (mPlugin->fCallbacks.event) {
if (mCallbacks->event) {
mCurrentPluginEvent = event;
#if defined(XP_WIN) || defined(XP_OS2)
NS_TRY_SAFE_CALL_RETURN(result, (*mPlugin->fCallbacks.event)(&mNPP, event),
mPlugin->fLibrary, this);
NS_TRY_SAFE_CALL_RETURN(result, (*mCallbacks->event)(&mNPP, event), mLibrary, this);
#else
result = (*mPlugin->fCallbacks.event)(&mNPP, event);
result = (*mCallbacks->event)(&mNPP, event);
#endif
NPP_PLUGIN_LOG(PLUGIN_LOG_NOISY,
("NPP HandleEvent called: this=%p, npp=%p, event=%p, return=%d\n",
@ -1391,12 +1390,10 @@ NS_IMETHODIMP nsNPAPIPluginInstance::GetValueFromPlugin(NPPVariable variable, vo
}
#endif
nsresult res = NS_OK;
if (mPlugin->fCallbacks.getvalue && mStarted) {
if (mCallbacks->getvalue && mStarted) {
PluginDestructionGuard guard(this);
NS_TRY_SAFE_CALL_RETURN(res,
(*mPlugin->fCallbacks.getvalue)(&mNPP, variable, value),
mPlugin->fLibrary, this);
NS_TRY_SAFE_CALL_RETURN(res, (*mCallbacks->getvalue)(&mNPP, variable, value), mLibrary, this);
NPP_PLUGIN_LOG(PLUGIN_LOG_NORMAL,
("NPP GetValue called: this=%p, npp=%p, var=%d, value=%d, return=%d\n",
this, &mNPP, variable, value, res));
@ -1418,7 +1415,7 @@ nsresult nsNPAPIPluginInstance::GetNPP(NPP* aNPP)
nsresult nsNPAPIPluginInstance::GetCallbacks(const NPPluginFuncs ** aCallbacks)
{
if (aCallbacks)
*aCallbacks = &mPlugin->fCallbacks;
*aCallbacks = mCallbacks;
else
return NS_ERROR_NULL_POINTER;
@ -1646,7 +1643,7 @@ NS_IMETHODIMP
nsNPAPIPluginInstance::GetPluginAPIVersion(PRUint16* version)
{
NS_ENSURE_ARG_POINTER(version);
*version = mPlugin->fCallbacks.version;
*version = mCallbacks->version;
return NS_OK;
}
@ -1658,7 +1655,7 @@ nsNPAPIPluginInstance::PrivateModeStateChanged()
PLUGIN_LOG(PLUGIN_LOG_NORMAL, ("nsNPAPIPluginInstance informing plugin of private mode state change this=%p\n",this));
if (mPlugin->fCallbacks.setvalue) {
if (mCallbacks->setvalue) {
PluginDestructionGuard guard(this);
nsCOMPtr<nsIPrivateBrowsingService> pbs = do_GetService(NS_PRIVATE_BROWSING_SERVICE_CONTRACTID);
@ -1669,9 +1666,7 @@ nsNPAPIPluginInstance::PrivateModeStateChanged()
return rv;
NPError error;
NS_TRY_SAFE_CALL_RETURN(error,
(*mPlugin->fCallbacks.setvalue)(&mNPP, NPNVprivateModeBool, &pme),
mPlugin->fLibrary, this);
NS_TRY_SAFE_CALL_RETURN(error, (*mCallbacks->setvalue)(&mNPP, NPNVprivateModeBool, &pme), mLibrary, this);
return (error == NPERR_NO_ERROR) ? NS_OK : NS_ERROR_FAILURE;
}
}

View File

@ -49,7 +49,6 @@
#include "nsIPluginInstanceOwner.h"
#include "nsITimer.h"
#include "nsNPAPIPlugin.h"
#include "npfunctions.h"
#include "mozilla/PluginLibrary.h"
@ -106,7 +105,7 @@ public:
PRBool aCallNotify,
const char * aURL);
nsNPAPIPluginInstance(nsNPAPIPlugin* plugin);
nsNPAPIPluginInstance(NPPluginFuncs* callbacks, PluginLibrary* aLibrary);
// Use Release() to destroy this
virtual ~nsNPAPIPluginInstance();
@ -128,10 +127,7 @@ public:
void UnscheduleTimer(uint32_t timerID);
NPError PopUpContextMenu(NPMenu* menu);
NPBool ConvertPoint(double sourceX, double sourceY, NPCoordinateSpace sourceSpace, double *destX, double *destY, NPCoordinateSpace destSpace);
private:
friend class nsNPAPIPluginStreamListener;
protected:
nsresult InitializePlugin();
nsresult GetTagType(nsPluginTagType *result);
@ -141,7 +137,10 @@ private:
const char*const*& values);
nsresult GetMode(PRInt32 *result);
nsRefPtr<nsNPAPIPlugin> mPlugin;
// A pointer to the plugin's callback functions. This information
// is actually stored in the plugin class (<b>nsPluginClass</b>),
// and is common for all plugins of the class.
NPPluginFuncs* mCallbacks;
// The structure used to communicate between the plugin instance and
// the browser.
@ -160,10 +159,13 @@ private:
PRPackedBool mCached;
PRPackedBool mWantsAllNetworkStreams;
public:
// True while creating the plugin, or calling NPP_SetWindow() on it.
PRPackedBool mInPluginInitCall;
PluginLibrary* mLibrary;
nsInstanceStream *mStreams;
private:
nsTArray<PopupControlState> mPopupStates;
char* mMIMEType;

View File

@ -3917,19 +3917,6 @@ nsPluginHost::FindPluginEnabledForExtension(const char* aExtension,
return nsnull;
}
nsPluginTag*
nsPluginHost::FindPluginTag(nsIPlugin* plugin)
{
nsPluginTag* plugins = mPlugins;
while (plugins) {
if (plugins->mEntryPoint == plugin)
return plugins;
plugins = plugins->mNext;
}
return nsnull;
}
static nsresult ConvertToNative(nsIUnicodeEncoder *aEncoder,
const nsACString& aUTF8String,
nsACString& aNativeString)
@ -6160,13 +6147,6 @@ PRCList nsPluginDestroyRunnable::sRunnableListHead =
PRCList PluginDestructionGuard::sListHead =
PR_INIT_STATIC_CLIST(&PluginDestructionGuard::sListHead);
PluginDestructionGuard::PluginDestructionGuard(NPP npp)
: mInstance(npp ? static_cast<nsNPAPIPluginInstance*>(npp->ndata) : nsnull)
{
Init();
}
PluginDestructionGuard::~PluginDestructionGuard()
{
NS_ASSERTION(NS_IsMainThread(), "Should be on the main thread");

View File

@ -45,6 +45,7 @@
#include "prlink.h"
#include "prclist.h"
#include "npapi.h"
#include "nsNPAPIPluginInstance.h"
#include "nsIPlugin.h"
#include "nsIPluginTag.h"
#include "nsPluginsDir.h"
@ -266,8 +267,6 @@ public:
static nsresult GetPrompt(nsIPluginInstanceOwner *aOwner, nsIPrompt **aPrompt);
private:
friend class nsNPAPIPlugin;
nsresult
TrySetUpPluginInstance(const char *aMimeType, nsIURI *aURL, nsIPluginInstanceOwner *aOwner);
@ -290,9 +289,6 @@ private:
nsPluginTag*
FindPluginEnabledForExtension(const char* aExtension, const char* &aMimeType);
nsPluginTag*
FindPluginTag(nsIPlugin* plugin);
nsresult
FindStoppedPluginForURL(nsIURI* aURL, nsIPluginInstanceOwner *aOwner);
@ -388,7 +384,12 @@ public:
Init();
}
PluginDestructionGuard(NPP npp);
PluginDestructionGuard(NPP npp)
: mInstance(npp ? static_cast<nsNPAPIPluginInstance*>(npp->ndata) : nsnull)
{
Init();
}
~PluginDestructionGuard();
static PRBool DelayDestroy(nsIPluginInstance *aInstance);