mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 547359 - '[OOPP] Silverlight plugin takes 6X longer to load with IPC plugins than without - make NPIdentifier handler smarter/faster'. r=bsmedberg.
This commit is contained in:
parent
2ddaaa1db3
commit
95882b79e1
@ -63,6 +63,8 @@ EXPORTS_mozilla/plugins = \
|
||||
NPEventOSX.h \
|
||||
NPEventWindows.h \
|
||||
NPEventX11.h \
|
||||
PluginIdentifierChild.h \
|
||||
PluginIdentifierParent.h \
|
||||
PluginInstanceChild.h \
|
||||
PluginInstanceParent.h \
|
||||
PluginMessageUtils.h \
|
||||
|
56
dom/plugins/PPluginIdentifier.ipdl
Normal file
56
dom/plugins/PPluginIdentifier.ipdl
Normal file
@ -0,0 +1,56 @@
|
||||
/* -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 8 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Plugins.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Mozilla Foundation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2010
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Ben Turner <bent.mozilla@gmail.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
include protocol "PPluginModule.ipdl";
|
||||
|
||||
namespace mozilla {
|
||||
namespace plugins {
|
||||
|
||||
/**
|
||||
* Represents an NPIdentifier that wraps either a string or an integer.
|
||||
*/
|
||||
async protocol PPluginIdentifier
|
||||
{
|
||||
manager PPluginModule;
|
||||
|
||||
child:
|
||||
async __delete__();
|
||||
};
|
||||
|
||||
} // namespace plugins
|
||||
} // namespace mozilla
|
@ -37,6 +37,7 @@
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
include protocol "PPluginIdentifier.ipdl";
|
||||
include protocol "PPluginInstance.ipdl";
|
||||
|
||||
include "npapi.h";
|
||||
@ -44,7 +45,6 @@ include "mozilla/plugins/PluginMessageUtils.h";
|
||||
|
||||
using NPError;
|
||||
using NPNVariable;
|
||||
using mozilla::ipc::NPRemoteIdentifier;
|
||||
|
||||
namespace mozilla {
|
||||
namespace plugins {
|
||||
@ -52,6 +52,19 @@ namespace plugins {
|
||||
rpc protocol PPluginModule
|
||||
{
|
||||
manages PPluginInstance;
|
||||
manages PPluginIdentifier;
|
||||
|
||||
both:
|
||||
/**
|
||||
* Sending a void string to this constructor creates an int identifier whereas
|
||||
* sending a non-void string will create a string identifier. This constructor
|
||||
* may be called by either child or parent. If a race occurs by calling the
|
||||
* constructor with the same string or int argument then we create two actors
|
||||
* and detect the second instance in the child. We prevent the parent's actor
|
||||
* from leaking out to plugin code and only allow the child's to be used.
|
||||
*/
|
||||
async PPluginIdentifier(nsCString aString,
|
||||
int32_t aInt);
|
||||
|
||||
child:
|
||||
rpc NP_Initialize()
|
||||
@ -70,26 +83,6 @@ parent:
|
||||
rpc NPN_UserAgent()
|
||||
returns (nsCString userAgent);
|
||||
|
||||
sync NPN_GetStringIdentifier(nsCString aString)
|
||||
returns (NPRemoteIdentifier aId);
|
||||
sync NPN_GetIntIdentifier(int32_t aInt)
|
||||
returns (NPRemoteIdentifier aId);
|
||||
|
||||
// for the following two methods, the returned value is valid iff
|
||||
// |err == NPERR_NO_ERROR|
|
||||
sync NPN_UTF8FromIdentifier(NPRemoteIdentifier aId)
|
||||
returns (NPError err, nsCString aString);
|
||||
// technically |aInt| is undefined when |aId| is invalid. but it's
|
||||
// nice to let the other side know that |aId| was invalid
|
||||
sync NPN_IntFromIdentifier(NPRemoteIdentifier aId)
|
||||
returns (NPError err, int32_t aInt);
|
||||
|
||||
sync NPN_IdentifierIsString(NPRemoteIdentifier aId)
|
||||
returns (bool aIsString);
|
||||
|
||||
sync NPN_GetStringIdentifiers(nsCString[] aNames)
|
||||
returns (NPRemoteIdentifier[] aIds);
|
||||
|
||||
rpc NPN_GetValue_WithBoolReturn(NPNVariable aVariable)
|
||||
returns (NPError aError,
|
||||
bool aBoolVal);
|
||||
|
@ -38,12 +38,12 @@
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
include protocol "PPluginInstance.ipdl";
|
||||
include protocol "PPluginIdentifier.ipdl";
|
||||
|
||||
include "npapi.h";
|
||||
include "npruntime.h";
|
||||
include "mozilla/plugins/PluginMessageUtils.h";
|
||||
|
||||
using mozilla::ipc::NPRemoteIdentifier;
|
||||
using mozilla::void_t;
|
||||
using mozilla::null_t;
|
||||
|
||||
@ -77,10 +77,10 @@ child:
|
||||
|
||||
both:
|
||||
// NPClass methods
|
||||
rpc HasMethod(NPRemoteIdentifier aId)
|
||||
rpc HasMethod(PPluginIdentifier aId)
|
||||
returns (bool aHasMethod);
|
||||
|
||||
rpc Invoke(NPRemoteIdentifier aId,
|
||||
rpc Invoke(PPluginIdentifier aId,
|
||||
Variant[] aArgs)
|
||||
returns (Variant aResult,
|
||||
bool aSuccess);
|
||||
@ -89,22 +89,22 @@ both:
|
||||
returns (Variant aResult,
|
||||
bool aSuccess);
|
||||
|
||||
rpc HasProperty(NPRemoteIdentifier aId)
|
||||
rpc HasProperty(PPluginIdentifier aId)
|
||||
returns (bool aHasProperty);
|
||||
|
||||
rpc GetProperty(NPRemoteIdentifier aId)
|
||||
rpc GetProperty(PPluginIdentifier aId)
|
||||
returns (Variant aResult,
|
||||
bool aSuccess);
|
||||
|
||||
rpc SetProperty(NPRemoteIdentifier aId,
|
||||
rpc SetProperty(PPluginIdentifier aId,
|
||||
Variant aValue)
|
||||
returns (bool aSuccess);
|
||||
|
||||
rpc RemoveProperty(NPRemoteIdentifier aId)
|
||||
rpc RemoveProperty(PPluginIdentifier aId)
|
||||
returns (bool aSuccess);
|
||||
|
||||
rpc Enumerate()
|
||||
returns (NPRemoteIdentifier[] aProperties,
|
||||
returns (PPluginIdentifier[] aProperties,
|
||||
bool aSuccess);
|
||||
|
||||
rpc Construct(Variant[] aArgs)
|
||||
|
140
dom/plugins/PluginIdentifierChild.h
Normal file
140
dom/plugins/PluginIdentifierChild.h
Normal file
@ -0,0 +1,140 @@
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
* vim: sw=2 ts=2 et :
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Plugins.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Mozilla Foundation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2010
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Ben Turner <bent.mozilla@gmail.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef dom_plugins_PluginIdentifierChild_h
|
||||
#define dom_plugins_PluginIdentifierChild_h
|
||||
|
||||
#include "mozilla/plugins/PPluginIdentifierChild.h"
|
||||
#include "mozilla/plugins/PluginModuleChild.h"
|
||||
|
||||
#include "nsStringGlue.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace plugins {
|
||||
|
||||
class PluginIdentifierChild : public PPluginIdentifierChild
|
||||
{
|
||||
friend class PluginModuleChild;
|
||||
public:
|
||||
bool IsString()
|
||||
{
|
||||
return reinterpret_cast<intptr_t>(mCanonicalIdentifier) & 1;
|
||||
}
|
||||
|
||||
NPIdentifier ToNPIdentifier()
|
||||
{
|
||||
return reinterpret_cast<PluginIdentifierChild*>(
|
||||
reinterpret_cast<intptr_t>(mCanonicalIdentifier) & ~1);
|
||||
}
|
||||
|
||||
protected:
|
||||
PluginIdentifierChild(bool aIsString)
|
||||
: ALLOW_THIS_IN_INITIALIZER_LIST(mCanonicalIdentifier(this))
|
||||
{
|
||||
MOZ_COUNT_CTOR(PluginIdentifierChild);
|
||||
if (aIsString) {
|
||||
SetIsString();
|
||||
}
|
||||
}
|
||||
|
||||
virtual ~PluginIdentifierChild()
|
||||
{
|
||||
MOZ_COUNT_DTOR(PluginIdentifierChild);
|
||||
}
|
||||
|
||||
void SetCanonicalIdentifier(PluginIdentifierChild* aIdentifier)
|
||||
{
|
||||
NS_ASSERTION(ToNPIdentifier() == this, "Already got one!");
|
||||
bool isString = IsString();
|
||||
mCanonicalIdentifier = aIdentifier;
|
||||
if (isString) {
|
||||
SetIsString();
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
void SetIsString()
|
||||
{
|
||||
mCanonicalIdentifier = reinterpret_cast<PluginIdentifierChild*>(
|
||||
reinterpret_cast<intptr_t>(mCanonicalIdentifier) | 1);
|
||||
}
|
||||
|
||||
PluginIdentifierChild* mCanonicalIdentifier;
|
||||
};
|
||||
|
||||
class PluginIdentifierChildString : public PluginIdentifierChild
|
||||
{
|
||||
friend class PluginModuleChild;
|
||||
public:
|
||||
NPUTF8* ToString()
|
||||
{
|
||||
return ToNewCString(mString);
|
||||
}
|
||||
|
||||
protected:
|
||||
PluginIdentifierChildString(const nsCString& aString)
|
||||
: PluginIdentifierChild(true),
|
||||
mString(aString)
|
||||
{ }
|
||||
|
||||
nsCString mString;
|
||||
};
|
||||
|
||||
class PluginIdentifierChildInt : public PluginIdentifierChild
|
||||
{
|
||||
friend class PluginModuleChild;
|
||||
public:
|
||||
int32_t ToInt()
|
||||
{
|
||||
return mInt;
|
||||
}
|
||||
|
||||
protected:
|
||||
PluginIdentifierChildInt(int32_t aInt)
|
||||
: PluginIdentifierChild(false),
|
||||
mInt(aInt)
|
||||
{ }
|
||||
|
||||
int32_t mInt;
|
||||
};
|
||||
|
||||
} // namespace plugins
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // dom_plugins_PluginIdentifierChild_h
|
80
dom/plugins/PluginIdentifierParent.h
Normal file
80
dom/plugins/PluginIdentifierParent.h
Normal file
@ -0,0 +1,80 @@
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
* vim: sw=2 ts=2 et :
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Plugins.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Mozilla Foundation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2010
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Ben Turner <bent.mozilla@gmail.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef dom_plugins_PluginIdentifierParent_h
|
||||
#define dom_plugins_PluginIdentifierParent_h
|
||||
|
||||
#include "mozilla/plugins/PPluginIdentifierParent.h"
|
||||
|
||||
#include "npapi.h"
|
||||
#include "npruntime.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace plugins {
|
||||
|
||||
class PluginIdentifierParent : public PPluginIdentifierParent
|
||||
{
|
||||
friend class PluginModuleParent;
|
||||
|
||||
public:
|
||||
NPIdentifier ToNPIdentifier()
|
||||
{
|
||||
return mIdentifier;
|
||||
}
|
||||
|
||||
protected:
|
||||
PluginIdentifierParent(NPIdentifier aIdentifier)
|
||||
: mIdentifier(aIdentifier)
|
||||
{
|
||||
MOZ_COUNT_CTOR(PluginIdentifierParent);
|
||||
}
|
||||
|
||||
virtual ~PluginIdentifierParent()
|
||||
{
|
||||
MOZ_COUNT_DTOR(PluginIdentifierParent);
|
||||
}
|
||||
|
||||
private:
|
||||
NPIdentifier mIdentifier;
|
||||
};
|
||||
|
||||
} // namespace plugins
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // dom_plugins_PluginIdentifierParent_h
|
@ -61,12 +61,6 @@ namespace mozilla {
|
||||
struct void_t { };
|
||||
struct null_t { };
|
||||
|
||||
namespace ipc {
|
||||
|
||||
typedef intptr_t NPRemoteIdentifier;
|
||||
|
||||
} /* namespace ipc */
|
||||
|
||||
namespace plugins {
|
||||
|
||||
enum ScriptableObjectType
|
||||
|
@ -60,11 +60,10 @@
|
||||
#include "mozilla/plugins/BrowserStreamChild.h"
|
||||
#include "mozilla/plugins/PluginStreamChild.h"
|
||||
#include "mozilla/plugins/PluginThreadChild.h"
|
||||
#include "PluginIdentifierChild.h"
|
||||
|
||||
#include "nsNPAPIPlugin.h"
|
||||
|
||||
using mozilla::ipc::NPRemoteIdentifier;
|
||||
|
||||
using namespace mozilla::plugins;
|
||||
|
||||
namespace {
|
||||
@ -128,6 +127,16 @@ PluginModuleChild::Init(const std::string& aPluginFilename,
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!mStringIdentifiers.Init()) {
|
||||
NS_ERROR("Failed to initialize string identifier hashtable!");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!mIntIdentifiers.Init()) {
|
||||
NS_ERROR("Failed to initialize int identifier hashtable!");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!InitGraphics())
|
||||
return false;
|
||||
|
||||
@ -523,25 +532,6 @@ _getjavaenv(void);
|
||||
static void* NP_CALLBACK /* OJI type: jref */
|
||||
_getjavapeer(NPP aNPP);
|
||||
|
||||
static NPIdentifier NP_CALLBACK
|
||||
_getstringidentifier(const NPUTF8* name);
|
||||
|
||||
static void NP_CALLBACK
|
||||
_getstringidentifiers(const NPUTF8** names, int32_t nameCount,
|
||||
NPIdentifier *identifiers);
|
||||
|
||||
static bool NP_CALLBACK
|
||||
_identifierisstring(NPIdentifier identifiers);
|
||||
|
||||
static NPIdentifier NP_CALLBACK
|
||||
_getintidentifier(int32_t intid);
|
||||
|
||||
static NPUTF8* NP_CALLBACK
|
||||
_utf8fromidentifier(NPIdentifier identifier);
|
||||
|
||||
static int32_t NP_CALLBACK
|
||||
_intfromidentifier(NPIdentifier identifier);
|
||||
|
||||
static bool NP_CALLBACK
|
||||
_invoke(NPP aNPP, NPObject* npobj, NPIdentifier method, const NPVariant *args,
|
||||
uint32_t argCount, NPVariant *result);
|
||||
@ -652,12 +642,12 @@ const NPNetscapeFuncs PluginModuleChild::sBrowserFuncs = {
|
||||
mozilla::plugins::child::_invalidaterect,
|
||||
mozilla::plugins::child::_invalidateregion,
|
||||
mozilla::plugins::child::_forceredraw,
|
||||
mozilla::plugins::child::_getstringidentifier,
|
||||
mozilla::plugins::child::_getstringidentifiers,
|
||||
mozilla::plugins::child::_getintidentifier,
|
||||
mozilla::plugins::child::_identifierisstring,
|
||||
mozilla::plugins::child::_utf8fromidentifier,
|
||||
mozilla::plugins::child::_intfromidentifier,
|
||||
PluginModuleChild::NPN_GetStringIdentifier,
|
||||
PluginModuleChild::NPN_GetStringIdentifiers,
|
||||
PluginModuleChild::NPN_GetIntIdentifier,
|
||||
PluginModuleChild::NPN_IdentifierIsString,
|
||||
PluginModuleChild::NPN_UTF8FromIdentifier,
|
||||
PluginModuleChild::NPN_IntFromIdentifier,
|
||||
PluginModuleChild::NPN_CreateObject,
|
||||
PluginModuleChild::NPN_RetainObject,
|
||||
PluginModuleChild::NPN_ReleaseObject,
|
||||
@ -998,125 +988,6 @@ _getjavapeer(NPP aNPP)
|
||||
return 0;
|
||||
}
|
||||
|
||||
NPIdentifier NP_CALLBACK
|
||||
_getstringidentifier(const NPUTF8* aName)
|
||||
{
|
||||
PLUGIN_LOG_DEBUG_FUNCTION;
|
||||
AssertPluginThread();
|
||||
|
||||
NPRemoteIdentifier ident = 0;
|
||||
if (aName)
|
||||
PluginModuleChild::current()->
|
||||
SendNPN_GetStringIdentifier(nsDependentCString(aName), &ident);
|
||||
return (NPIdentifier)ident;
|
||||
}
|
||||
|
||||
void NP_CALLBACK
|
||||
_getstringidentifiers(const NPUTF8** aNames,
|
||||
int32_t aNameCount,
|
||||
NPIdentifier* aIdentifiers)
|
||||
{
|
||||
PLUGIN_LOG_DEBUG_FUNCTION;
|
||||
AssertPluginThread();
|
||||
|
||||
if (!(aNames && aNameCount > 0 && aIdentifiers)) {
|
||||
NS_RUNTIMEABORT("Bad input! Headed for a crash!");
|
||||
}
|
||||
|
||||
// Initialize to zero in case of errors later
|
||||
for (int32_t index = 0; index < aNameCount; ++index)
|
||||
aIdentifiers[index] = 0;
|
||||
|
||||
nsTArray<nsCString> names;
|
||||
nsTArray<NPRemoteIdentifier> ids;
|
||||
|
||||
names.SetLength(aNameCount);
|
||||
for (int32_t index = 0; index < aNameCount; ++index) {
|
||||
if (aNames[index]) {
|
||||
names[index] = nsDependentCString(aNames[index]);
|
||||
}
|
||||
else {
|
||||
names[index].SetIsVoid(true);
|
||||
}
|
||||
}
|
||||
|
||||
PluginModuleChild::current()->
|
||||
SendNPN_GetStringIdentifiers(names, &ids);
|
||||
|
||||
for (int32_t index = 0; index < ids.Length(); ++index)
|
||||
aIdentifiers[index] = (NPIdentifier)ids[index];
|
||||
}
|
||||
|
||||
bool NP_CALLBACK
|
||||
_identifierisstring(NPIdentifier aIdentifier)
|
||||
{
|
||||
PLUGIN_LOG_DEBUG_FUNCTION;
|
||||
AssertPluginThread();
|
||||
|
||||
bool isString;
|
||||
if (!PluginModuleChild::current()->
|
||||
SendNPN_IdentifierIsString((NPRemoteIdentifier)aIdentifier,
|
||||
&isString)) {
|
||||
NS_WARNING("Failed to send message!");
|
||||
isString = false;
|
||||
}
|
||||
|
||||
return isString;
|
||||
}
|
||||
|
||||
NPIdentifier NP_CALLBACK
|
||||
_getintidentifier(int32_t aIntId)
|
||||
{
|
||||
PLUGIN_LOG_DEBUG_FUNCTION;
|
||||
AssertPluginThread();
|
||||
|
||||
NPRemoteIdentifier ident;
|
||||
if (!PluginModuleChild::current()->
|
||||
SendNPN_GetIntIdentifier(aIntId, &ident)) {
|
||||
NS_WARNING("Failed to send message!");
|
||||
ident = 0;
|
||||
}
|
||||
|
||||
return (NPIdentifier)ident;
|
||||
}
|
||||
|
||||
NPUTF8* NP_CALLBACK
|
||||
_utf8fromidentifier(NPIdentifier aIdentifier)
|
||||
{
|
||||
PLUGIN_LOG_DEBUG_FUNCTION;
|
||||
AssertPluginThread();
|
||||
|
||||
NPError err;
|
||||
nsCAutoString val;
|
||||
if (!PluginModuleChild::current()->
|
||||
SendNPN_UTF8FromIdentifier((NPRemoteIdentifier)aIdentifier,
|
||||
&err, &val)) {
|
||||
NS_WARNING("Failed to send message!");
|
||||
return 0;
|
||||
}
|
||||
|
||||
return (NPERR_NO_ERROR == err) ? strdup(val.get()) : 0;
|
||||
}
|
||||
|
||||
int32_t NP_CALLBACK
|
||||
_intfromidentifier(NPIdentifier aIdentifier)
|
||||
{
|
||||
PLUGIN_LOG_DEBUG_FUNCTION;
|
||||
AssertPluginThread();
|
||||
|
||||
NPError err;
|
||||
int32_t val;
|
||||
if (!PluginModuleChild::current()->
|
||||
SendNPN_IntFromIdentifier((NPRemoteIdentifier)aIdentifier,
|
||||
&err, &val)) {
|
||||
NS_WARNING("Failed to send message!");
|
||||
return -1;
|
||||
}
|
||||
|
||||
// -1 for consistency
|
||||
return (NPERR_NO_ERROR == err) ? val : -1;
|
||||
}
|
||||
|
||||
bool NP_CALLBACK
|
||||
_invoke(NPP aNPP,
|
||||
NPObject* aNPObj,
|
||||
@ -1516,6 +1387,39 @@ PluginModuleChild::AnswerNP_Initialize(NPError* _retval)
|
||||
#endif
|
||||
}
|
||||
|
||||
PPluginIdentifierChild*
|
||||
PluginModuleChild::AllocPPluginIdentifier(const nsCString& aString,
|
||||
const int32_t& aInt)
|
||||
{
|
||||
// There's a possibility that we already have an actor that wraps the same
|
||||
// string or int because we do all this identifier construction
|
||||
// asynchronously. Check to see if we've already wrapped here, and then set
|
||||
// canonical actor of the new one to the actor already in our hash.
|
||||
PluginIdentifierChild* newActor;
|
||||
PluginIdentifierChild* existingActor;
|
||||
|
||||
if (aString.IsVoid()) {
|
||||
newActor = new PluginIdentifierChildInt(aInt);
|
||||
if (mIntIdentifiers.Get(aInt, &existingActor)) {
|
||||
newActor->SetCanonicalIdentifier(existingActor);
|
||||
}
|
||||
}
|
||||
else {
|
||||
newActor = new PluginIdentifierChildString(aString);
|
||||
if (mStringIdentifiers.Get(aString, &existingActor)) {
|
||||
newActor->SetCanonicalIdentifier(existingActor);
|
||||
}
|
||||
}
|
||||
return newActor;
|
||||
}
|
||||
|
||||
bool
|
||||
PluginModuleChild::DeallocPPluginIdentifier(PPluginIdentifierChild* aActor)
|
||||
{
|
||||
delete aActor;
|
||||
return true;
|
||||
}
|
||||
|
||||
PPluginInstanceChild*
|
||||
PluginModuleChild::AllocPPluginInstance(const nsCString& aMimeType,
|
||||
const uint16_t& aMode,
|
||||
@ -1704,3 +1608,117 @@ PluginModuleChild::CollectForInstance(NPObjectData* d, void* userArg)
|
||||
}
|
||||
return PL_DHASH_NEXT;
|
||||
}
|
||||
|
||||
NPIdentifier NP_CALLBACK
|
||||
PluginModuleChild::NPN_GetStringIdentifier(const NPUTF8* aName)
|
||||
{
|
||||
PLUGIN_LOG_DEBUG_FUNCTION;
|
||||
AssertPluginThread();
|
||||
|
||||
if (!aName)
|
||||
return 0;
|
||||
|
||||
PluginModuleChild* self = PluginModuleChild::current();
|
||||
nsDependentCString name(aName);
|
||||
|
||||
PluginIdentifierChild* ident;
|
||||
if (!self->mStringIdentifiers.Get(name, &ident)) {
|
||||
nsCString nameCopy(name);
|
||||
|
||||
ident = new PluginIdentifierChildString(nameCopy);
|
||||
self->SendPPluginIdentifierConstructor(ident, nameCopy, -1);
|
||||
self->mStringIdentifiers.Put(nameCopy, ident);
|
||||
}
|
||||
|
||||
return ident;
|
||||
}
|
||||
|
||||
void NP_CALLBACK
|
||||
PluginModuleChild::NPN_GetStringIdentifiers(const NPUTF8** aNames,
|
||||
int32_t aNameCount,
|
||||
NPIdentifier* aIdentifiers)
|
||||
{
|
||||
PLUGIN_LOG_DEBUG_FUNCTION;
|
||||
AssertPluginThread();
|
||||
|
||||
if (!(aNames && aNameCount > 0 && aIdentifiers)) {
|
||||
NS_RUNTIMEABORT("Bad input! Headed for a crash!");
|
||||
}
|
||||
|
||||
PluginModuleChild* self = PluginModuleChild::current();
|
||||
|
||||
for (int32_t index = 0; index < aNameCount; ++index) {
|
||||
if (!aNames[index]) {
|
||||
aIdentifiers[index] = 0;
|
||||
continue;
|
||||
}
|
||||
nsDependentCString name(aNames[index]);
|
||||
PluginIdentifierChild* ident;
|
||||
if (!self->mStringIdentifiers.Get(name, &ident)) {
|
||||
nsCString nameCopy(name);
|
||||
|
||||
ident = new PluginIdentifierChildString(nameCopy);
|
||||
self->SendPPluginIdentifierConstructor(ident, nameCopy, -1);
|
||||
self->mStringIdentifiers.Put(nameCopy, ident);
|
||||
}
|
||||
aIdentifiers[index] = ident;
|
||||
}
|
||||
}
|
||||
|
||||
bool NP_CALLBACK
|
||||
PluginModuleChild::NPN_IdentifierIsString(NPIdentifier aIdentifier)
|
||||
{
|
||||
PLUGIN_LOG_DEBUG_FUNCTION;
|
||||
AssertPluginThread();
|
||||
|
||||
PluginIdentifierChild* ident =
|
||||
static_cast<PluginIdentifierChild*>(aIdentifier);
|
||||
return ident->IsString();
|
||||
}
|
||||
|
||||
NPIdentifier NP_CALLBACK
|
||||
PluginModuleChild::NPN_GetIntIdentifier(int32_t aIntId)
|
||||
{
|
||||
PLUGIN_LOG_DEBUG_FUNCTION;
|
||||
AssertPluginThread();
|
||||
|
||||
PluginModuleChild* self = PluginModuleChild::current();
|
||||
|
||||
PluginIdentifierChild* ident;
|
||||
if (!self->mIntIdentifiers.Get(aIntId, &ident)) {
|
||||
nsCString voidString;
|
||||
voidString.SetIsVoid(PR_TRUE);
|
||||
|
||||
ident = new PluginIdentifierChildInt(aIntId);
|
||||
self->SendPPluginIdentifierConstructor(ident, voidString, aIntId);
|
||||
self->mIntIdentifiers.Put(aIntId, ident);
|
||||
}
|
||||
return ident;
|
||||
}
|
||||
|
||||
NPUTF8* NP_CALLBACK
|
||||
PluginModuleChild::NPN_UTF8FromIdentifier(NPIdentifier aIdentifier)
|
||||
{
|
||||
PLUGIN_LOG_DEBUG_FUNCTION;
|
||||
AssertPluginThread();
|
||||
|
||||
if (static_cast<PluginIdentifierChild*>(aIdentifier)->IsString()) {
|
||||
return static_cast<PluginIdentifierChildString*>(aIdentifier)->ToString();
|
||||
}
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
int32_t NP_CALLBACK
|
||||
PluginModuleChild::NPN_IntFromIdentifier(NPIdentifier aIdentifier)
|
||||
{
|
||||
PLUGIN_LOG_DEBUG_FUNCTION;
|
||||
AssertPluginThread();
|
||||
|
||||
PluginIdentifierChild* ident =
|
||||
static_cast<PluginIdentifierChild*>(aIdentifier);
|
||||
|
||||
if (static_cast<PluginIdentifierChild*>(aIdentifier)->IsString()) {
|
||||
return static_cast<PluginIdentifierChildInt*>(aIdentifier)->ToInt();
|
||||
}
|
||||
return PR_INT32_MIN;
|
||||
}
|
||||
|
@ -51,11 +51,13 @@
|
||||
#include "npfunctions.h"
|
||||
|
||||
#include "nsAutoPtr.h"
|
||||
#include "nsDataHashtable.h"
|
||||
#include "nsTHashtable.h"
|
||||
#include "nsHashKeys.h"
|
||||
|
||||
#include "mozilla/plugins/PPluginModuleChild.h"
|
||||
#include "mozilla/plugins/PluginInstanceChild.h"
|
||||
#include "mozilla/plugins/PluginIdentifierChild.h"
|
||||
|
||||
// NOTE: stolen from nsNPAPIPlugin.h
|
||||
|
||||
@ -103,6 +105,13 @@ protected:
|
||||
// Implement the PPluginModuleChild interface
|
||||
virtual bool AnswerNP_Initialize(NPError* rv);
|
||||
|
||||
virtual PPluginIdentifierChild*
|
||||
AllocPPluginIdentifier(const nsCString& aString,
|
||||
const int32_t& aInt);
|
||||
|
||||
virtual bool
|
||||
DeallocPPluginIdentifier(PPluginIdentifierChild* aActor);
|
||||
|
||||
virtual PPluginInstanceChild*
|
||||
AllocPPluginInstance(const nsCString& aMimeType,
|
||||
const uint16_t& aMode,
|
||||
@ -167,6 +176,18 @@ public:
|
||||
*/
|
||||
static void NP_CALLBACK NPN_ReleaseObject(NPObject* aNPObj);
|
||||
|
||||
/**
|
||||
* The child implementations of NPIdentifier-related functions.
|
||||
*/
|
||||
static NPIdentifier NP_CALLBACK NPN_GetStringIdentifier(const NPUTF8* aName);
|
||||
static void NP_CALLBACK NPN_GetStringIdentifiers(const NPUTF8** aNames,
|
||||
int32_t aNameCount,
|
||||
NPIdentifier* aIdentifiers);
|
||||
static NPIdentifier NP_CALLBACK NPN_GetIntIdentifier(int32_t aIntId);
|
||||
static bool NP_CALLBACK NPN_IdentifierIsString(NPIdentifier aIdentifier);
|
||||
static NPUTF8* NP_CALLBACK NPN_UTF8FromIdentifier(NPIdentifier aIdentifier);
|
||||
static int32_t NP_CALLBACK NPN_IntFromIdentifier(NPIdentifier aIdentifier);
|
||||
|
||||
private:
|
||||
bool InitGraphics();
|
||||
#if defined(MOZ_WIDGET_GTK2)
|
||||
@ -248,6 +269,9 @@ private:
|
||||
*/
|
||||
nsTHashtable<NPObjectData> mObjectMap;
|
||||
|
||||
nsDataHashtable<nsCStringHashKey, PluginIdentifierChild*> mStringIdentifiers;
|
||||
nsDataHashtable<nsUint32HashKey, PluginIdentifierChild*> mIntIdentifiers;
|
||||
|
||||
public: // called by PluginInstanceChild
|
||||
/**
|
||||
* Dealloc an NPObject after last-release or when the associated instance
|
||||
|
@ -45,6 +45,7 @@
|
||||
#include "mozilla/ipc/SyncChannel.h"
|
||||
#include "mozilla/plugins/PluginModuleParent.h"
|
||||
#include "mozilla/plugins/BrowserStreamParent.h"
|
||||
#include "PluginIdentifierParent.h"
|
||||
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsCRT.h"
|
||||
@ -53,15 +54,12 @@
|
||||
using base::KillProcess;
|
||||
|
||||
using mozilla::PluginLibrary;
|
||||
using mozilla::ipc::NPRemoteIdentifier;
|
||||
using mozilla::ipc::SyncChannel;
|
||||
|
||||
using namespace mozilla::plugins;
|
||||
|
||||
static const char kTimeoutPref[] = "dom.ipc.plugins.timeoutSecs";
|
||||
|
||||
PR_STATIC_ASSERT(sizeof(NPIdentifier) == sizeof(void*));
|
||||
|
||||
template<>
|
||||
struct RunnableMethodTraits<mozilla::plugins::PluginModuleParent>
|
||||
{
|
||||
@ -98,7 +96,7 @@ PluginModuleParent::PluginModuleParent(const char* aFilePath)
|
||||
{
|
||||
NS_ASSERTION(mSubprocess, "Out of memory!");
|
||||
|
||||
if (!mValidIdentifiers.Init()) {
|
||||
if (!mIdentifiers.Init()) {
|
||||
NS_ERROR("Out of memory");
|
||||
}
|
||||
|
||||
@ -308,6 +306,31 @@ PluginModuleParent::NotifyPluginCrashed()
|
||||
mPlugin->PluginCrashed(mDumpID);
|
||||
}
|
||||
|
||||
PPluginIdentifierParent*
|
||||
PluginModuleParent::AllocPPluginIdentifier(const nsCString& aString,
|
||||
const int32_t& aInt)
|
||||
{
|
||||
NPIdentifier npident = aString.IsVoid() ?
|
||||
mozilla::plugins::parent::_getintidentifier(aInt) :
|
||||
mozilla::plugins::parent::_getstringidentifier(aString.get());
|
||||
|
||||
if (!npident) {
|
||||
NS_WARNING("Failed to get identifier!");
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
PluginIdentifierParent* ident = new PluginIdentifierParent(npident);
|
||||
mIdentifiers.Put(npident, ident);
|
||||
return ident;
|
||||
}
|
||||
|
||||
bool
|
||||
PluginModuleParent::DeallocPPluginIdentifier(PPluginIdentifierParent* aActor)
|
||||
{
|
||||
delete aActor;
|
||||
return true;
|
||||
}
|
||||
|
||||
PPluginInstanceParent*
|
||||
PluginModuleParent::AllocPPluginInstance(const nsCString& aMimeType,
|
||||
const uint16_t& aMode,
|
||||
@ -372,30 +395,6 @@ PluginModuleParent::NPP_Destroy(NPP instance,
|
||||
return retval;
|
||||
}
|
||||
|
||||
bool
|
||||
PluginModuleParent::EnsureValidNPIdentifier(NPIdentifier aIdentifier)
|
||||
{
|
||||
if (!mValidIdentifiers.GetEntry(aIdentifier)) {
|
||||
nsVoidPtrHashKey* newEntry = mValidIdentifiers.PutEntry(aIdentifier);
|
||||
if (!newEntry) {
|
||||
NS_ERROR("Out of memory?");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
NPIdentifier
|
||||
PluginModuleParent::GetValidNPIdentifier(NPRemoteIdentifier aRemoteIdentifier)
|
||||
{
|
||||
NS_ASSERTION(mValidIdentifiers.IsInitialized(), "Not initialized!");
|
||||
if (aRemoteIdentifier &&
|
||||
mValidIdentifiers.GetEntry((NPIdentifier)aRemoteIdentifier)) {
|
||||
return (NPIdentifier)aRemoteIdentifier;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
NPError
|
||||
PluginModuleParent::NPP_NewStream(NPP instance, NPMIMEType type,
|
||||
NPStream* stream, NPBool seekable,
|
||||
@ -526,141 +525,36 @@ PluginModuleParent::AnswerNPN_UserAgent(nsCString* userAgent)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
PluginModuleParent::RecvNPN_GetStringIdentifier(const nsCString& aString,
|
||||
NPRemoteIdentifier* aId)
|
||||
PPluginIdentifierParent*
|
||||
PluginModuleParent::GetIdentifierForNPIdentifier(NPIdentifier aIdentifier)
|
||||
{
|
||||
if (aString.IsVoid()) {
|
||||
NS_ERROR("Someone sent over a void string?!");
|
||||
return false;
|
||||
}
|
||||
|
||||
NPIdentifier ident =
|
||||
mozilla::plugins::parent::_getstringidentifier(aString.BeginReading());
|
||||
if (!ident) {
|
||||
*aId = 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!EnsureValidNPIdentifier(ident)) {
|
||||
NS_ERROR("Out of memory?");
|
||||
return false;
|
||||
}
|
||||
|
||||
*aId = (NPRemoteIdentifier)ident;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
PluginModuleParent::RecvNPN_GetIntIdentifier(const int32_t& aInt,
|
||||
NPRemoteIdentifier* aId)
|
||||
{
|
||||
NPIdentifier ident = mozilla::plugins::parent::_getintidentifier(aInt);
|
||||
if (!ident) {
|
||||
*aId = 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!EnsureValidNPIdentifier(ident)) {
|
||||
NS_ERROR("Out of memory?");
|
||||
return false;
|
||||
}
|
||||
|
||||
*aId = (NPRemoteIdentifier)ident;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
PluginModuleParent::RecvNPN_UTF8FromIdentifier(const NPRemoteIdentifier& aId,
|
||||
NPError *err,
|
||||
nsCString* aString)
|
||||
{
|
||||
NPIdentifier ident = GetValidNPIdentifier(aId);
|
||||
if (!ident) {
|
||||
*err = NPERR_INVALID_PARAM;
|
||||
return true;
|
||||
}
|
||||
|
||||
NPUTF8* val = mozilla::plugins::parent::_utf8fromidentifier(ident);
|
||||
if (!val) {
|
||||
*err = NPERR_INVALID_PARAM;
|
||||
return true;
|
||||
}
|
||||
|
||||
aString->Assign(val);
|
||||
*err = NPERR_NO_ERROR;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
PluginModuleParent::RecvNPN_IntFromIdentifier(const NPRemoteIdentifier& aId,
|
||||
NPError* err,
|
||||
int32_t* aInt)
|
||||
{
|
||||
NPIdentifier ident = GetValidNPIdentifier(aId);
|
||||
if (!ident) {
|
||||
*err = NPERR_INVALID_PARAM;
|
||||
return true;
|
||||
}
|
||||
|
||||
*aInt = mozilla::plugins::parent::_intfromidentifier(ident);
|
||||
*err = NPERR_NO_ERROR;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
PluginModuleParent::RecvNPN_IdentifierIsString(const NPRemoteIdentifier& aId,
|
||||
bool* aIsString)
|
||||
{
|
||||
NPIdentifier ident = GetValidNPIdentifier(aId);
|
||||
if (!ident) {
|
||||
*aIsString = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
*aIsString = mozilla::plugins::parent::_identifierisstring(ident);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
PluginModuleParent::RecvNPN_GetStringIdentifiers(const nsTArray<nsCString>& aNames,
|
||||
nsTArray<NPRemoteIdentifier>* aIds)
|
||||
{
|
||||
NS_ASSERTION(aIds->IsEmpty(), "Non-empty array!");
|
||||
|
||||
PRUint32 count = aNames.Length();
|
||||
if (!count) {
|
||||
NS_ERROR("No names to get!");
|
||||
return false;
|
||||
}
|
||||
|
||||
nsTArray<NPUTF8*> buffers;
|
||||
nsTArray<NPIdentifier> ids;
|
||||
|
||||
if (!(buffers.SetLength(count) &&
|
||||
ids.SetLength(count))) {
|
||||
NS_ERROR("Out of memory?");
|
||||
return false;
|
||||
}
|
||||
|
||||
for (PRUint32 index = 0; index < count; ++index)
|
||||
buffers[index] = const_cast<NPUTF8*>(NullableStringGet(aNames[index]));
|
||||
|
||||
mozilla::plugins::parent::_getstringidentifiers(
|
||||
const_cast<const NPUTF8**>(buffers.Elements()), count, ids.Elements());
|
||||
|
||||
for (PRUint32 index = 0; index < count; index++) {
|
||||
NPIdentifier& id = ids[index];
|
||||
if (id) {
|
||||
if (!EnsureValidNPIdentifier(id)) {
|
||||
NS_ERROR("Out of memory?");
|
||||
return false;
|
||||
PluginIdentifierParent* ident;
|
||||
if (!mIdentifiers.Get(aIdentifier, &ident)) {
|
||||
nsCString string;
|
||||
int32_t intval = -1;
|
||||
if (mozilla::plugins::parent::_identifierisstring(aIdentifier)) {
|
||||
NPUTF8* chars =
|
||||
mozilla::plugins::parent::_utf8fromidentifier(aIdentifier);
|
||||
if (!chars) {
|
||||
return nsnull;
|
||||
}
|
||||
string.Adopt(chars);
|
||||
}
|
||||
aIds->AppendElement((NPRemoteIdentifier)id);
|
||||
else {
|
||||
intval = mozilla::plugins::parent::_intfromidentifier(aIdentifier);
|
||||
if (intval == -1) {
|
||||
return nsnull;
|
||||
}
|
||||
string.SetIsVoid(PR_TRUE);
|
||||
}
|
||||
ident = new PluginIdentifierParent(aIdentifier);
|
||||
if (!SendPPluginIdentifierConstructor(ident, string, intval)) {
|
||||
delete ident;
|
||||
return nsnull;
|
||||
}
|
||||
mIdentifiers.Put(aIdentifier, ident);
|
||||
}
|
||||
|
||||
return true;
|
||||
return ident;
|
||||
}
|
||||
|
||||
PluginInstanceParent*
|
||||
|
@ -54,9 +54,10 @@
|
||||
#include "mozilla/plugins/PPluginModuleParent.h"
|
||||
#include "mozilla/plugins/PluginInstanceParent.h"
|
||||
#include "mozilla/plugins/PluginProcessParent.h"
|
||||
#include "mozilla/plugins/PluginIdentifierParent.h"
|
||||
|
||||
#include "nsAutoPtr.h"
|
||||
#include "nsTHashtable.h"
|
||||
#include "nsDataHashtable.h"
|
||||
#include "nsHashKeys.h"
|
||||
#include "nsIFileStreams.h"
|
||||
|
||||
@ -83,6 +84,14 @@ private:
|
||||
typedef mozilla::PluginLibrary PluginLibrary;
|
||||
|
||||
protected:
|
||||
|
||||
virtual PPluginIdentifierParent*
|
||||
AllocPPluginIdentifier(const nsCString& aString,
|
||||
const int32_t& aInt);
|
||||
|
||||
virtual bool
|
||||
DeallocPPluginIdentifier(PPluginIdentifierParent* aActor);
|
||||
|
||||
PPluginInstanceParent*
|
||||
AllocPPluginInstance(const nsCString& aMimeType,
|
||||
const uint16_t& aMode,
|
||||
@ -118,12 +127,13 @@ public:
|
||||
|
||||
base::ProcessHandle ChildProcessHandle() { return mSubprocess->GetChildProcessHandle(); }
|
||||
|
||||
bool EnsureValidNPIdentifier(NPIdentifier aIdentifier);
|
||||
|
||||
bool OkToCleanup() const {
|
||||
return !IsOnCxxStack();
|
||||
}
|
||||
|
||||
PPluginIdentifierParent*
|
||||
GetIdentifierForNPIdentifier(NPIdentifier aIdentifier);
|
||||
|
||||
protected:
|
||||
NS_OVERRIDE
|
||||
virtual mozilla::ipc::RPCChannel::RacyRPCPolicy
|
||||
@ -138,28 +148,6 @@ protected:
|
||||
virtual bool
|
||||
AnswerNPN_UserAgent(nsCString* userAgent);
|
||||
|
||||
// NPRemoteIdentifier funcs
|
||||
virtual bool
|
||||
RecvNPN_GetStringIdentifier(const nsCString& aString,
|
||||
NPRemoteIdentifier* aId);
|
||||
virtual bool
|
||||
RecvNPN_GetIntIdentifier(const int32_t& aInt,
|
||||
NPRemoteIdentifier* aId);
|
||||
virtual bool
|
||||
RecvNPN_UTF8FromIdentifier(const NPRemoteIdentifier& aId,
|
||||
NPError* err,
|
||||
nsCString* aString);
|
||||
virtual bool
|
||||
RecvNPN_IntFromIdentifier(const NPRemoteIdentifier& aId,
|
||||
NPError* err,
|
||||
int32_t* aInt);
|
||||
virtual bool
|
||||
RecvNPN_IdentifierIsString(const NPRemoteIdentifier& aId,
|
||||
bool* aIsString);
|
||||
virtual bool
|
||||
RecvNPN_GetStringIdentifiers(const nsTArray<nsCString>& aNames,
|
||||
nsTArray<NPRemoteIdentifier>* aIds);
|
||||
|
||||
virtual bool
|
||||
AnswerNPN_GetValue_WithBoolReturn(const NPNVariable& aVariable,
|
||||
NPError* aError,
|
||||
@ -212,8 +200,6 @@ private:
|
||||
static NPError NPP_SetValue(NPP instance, NPNVariable variable,
|
||||
void *value);
|
||||
|
||||
NPIdentifier GetValidNPIdentifier(NPRemoteIdentifier aRemoteIdentifier);
|
||||
|
||||
virtual bool HasRequiredFunctions();
|
||||
|
||||
#if defined(XP_UNIX) && !defined(XP_MACOSX)
|
||||
@ -245,7 +231,7 @@ private:
|
||||
PluginProcessParent* mSubprocess;
|
||||
bool mShutdown;
|
||||
const NPNetscapeFuncs* mNPNIface;
|
||||
nsTHashtable<nsVoidPtrHashKey> mValidIdentifiers;
|
||||
nsDataHashtable<nsVoidPtrHashKey, PluginIdentifierParent*> mIdentifiers;
|
||||
nsNPAPIPlugin* mPlugin;
|
||||
time_t mProcessStartTime;
|
||||
CancelableTask* mPluginCrashedTask;
|
||||
|
@ -38,9 +38,9 @@
|
||||
|
||||
#include "PluginScriptableObjectChild.h"
|
||||
#include "PluginScriptableObjectUtils.h"
|
||||
#include "PluginIdentifierChild.h"
|
||||
|
||||
using namespace mozilla::plugins;
|
||||
using mozilla::ipc::NPRemoteIdentifier;
|
||||
|
||||
// static
|
||||
NPObject*
|
||||
@ -117,7 +117,7 @@ PluginScriptableObjectChild::ScriptableHasMethod(NPObject* aObject,
|
||||
NS_ASSERTION(actor->Type() == Proxy, "Bad type!");
|
||||
|
||||
bool result;
|
||||
actor->CallHasMethod((NPRemoteIdentifier)aName, &result);
|
||||
actor->CallHasMethod(static_cast<PPluginIdentifierChild*>(aName), &result);
|
||||
|
||||
return result;
|
||||
}
|
||||
@ -154,7 +154,8 @@ PluginScriptableObjectChild::ScriptableInvoke(NPObject* aObject,
|
||||
|
||||
Variant remoteResult;
|
||||
bool success;
|
||||
actor->CallInvoke((NPRemoteIdentifier)aName, args, &remoteResult, &success);
|
||||
actor->CallInvoke(static_cast<PPluginIdentifierChild*>(aName), args,
|
||||
&remoteResult, &success);
|
||||
|
||||
if (!success) {
|
||||
return false;
|
||||
@ -227,7 +228,7 @@ PluginScriptableObjectChild::ScriptableHasProperty(NPObject* aObject,
|
||||
NS_ASSERTION(actor->Type() == Proxy, "Bad type!");
|
||||
|
||||
bool result;
|
||||
actor->CallHasProperty((NPRemoteIdentifier)aName, &result);
|
||||
actor->CallHasProperty(static_cast<PPluginIdentifierChild*>(aName), &result);
|
||||
|
||||
return result;
|
||||
}
|
||||
@ -256,7 +257,8 @@ PluginScriptableObjectChild::ScriptableGetProperty(NPObject* aObject,
|
||||
|
||||
Variant result;
|
||||
bool success;
|
||||
actor->CallGetProperty((NPRemoteIdentifier)aName, &result, &success);
|
||||
actor->CallGetProperty(static_cast<PPluginIdentifierChild*>(aName), &result,
|
||||
&success);
|
||||
|
||||
if (!success) {
|
||||
return false;
|
||||
@ -295,7 +297,8 @@ PluginScriptableObjectChild::ScriptableSetProperty(NPObject* aObject,
|
||||
}
|
||||
|
||||
bool success;
|
||||
actor->CallSetProperty((NPRemoteIdentifier)aName, value, &success);
|
||||
actor->CallSetProperty(static_cast<PPluginIdentifierChild*>(aName), value,
|
||||
&success);
|
||||
|
||||
return success;
|
||||
}
|
||||
@ -322,7 +325,8 @@ PluginScriptableObjectChild::ScriptableRemoveProperty(NPObject* aObject,
|
||||
NS_ASSERTION(actor->Type() == Proxy, "Bad type!");
|
||||
|
||||
bool success;
|
||||
actor->CallRemoveProperty((NPRemoteIdentifier)aName, &success);
|
||||
actor->CallRemoveProperty(static_cast<PPluginIdentifierChild*>(aName),
|
||||
&success);
|
||||
|
||||
return success;
|
||||
}
|
||||
@ -349,7 +353,7 @@ PluginScriptableObjectChild::ScriptableEnumerate(NPObject* aObject,
|
||||
NS_ASSERTION(actor, "This shouldn't ever be null!");
|
||||
NS_ASSERTION(actor->Type() == Proxy, "Bad type!");
|
||||
|
||||
nsAutoTArray<NPRemoteIdentifier, 10> identifiers;
|
||||
nsAutoTArray<PPluginIdentifierChild*, 10> identifiers;
|
||||
bool success;
|
||||
actor->CallEnumerate(&identifiers, &success);
|
||||
|
||||
@ -371,7 +375,8 @@ PluginScriptableObjectChild::ScriptableEnumerate(NPObject* aObject,
|
||||
}
|
||||
|
||||
for (PRUint32 index = 0; index < *aCount; index++) {
|
||||
(*aIdentifiers)[index] = (NPIdentifier)identifiers[index];
|
||||
(*aIdentifiers)[index] =
|
||||
static_cast<PPluginIdentifierChild*>(identifiers[index]);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -636,7 +641,7 @@ PluginScriptableObjectChild::AnswerInvalidate()
|
||||
}
|
||||
|
||||
bool
|
||||
PluginScriptableObjectChild::AnswerHasMethod(const NPRemoteIdentifier& aId,
|
||||
PluginScriptableObjectChild::AnswerHasMethod(PPluginIdentifierChild* aId,
|
||||
bool* aHasMethod)
|
||||
{
|
||||
AssertPluginThread();
|
||||
@ -655,12 +660,13 @@ PluginScriptableObjectChild::AnswerHasMethod(const NPRemoteIdentifier& aId,
|
||||
return true;
|
||||
}
|
||||
|
||||
*aHasMethod = mObject->_class->hasMethod(mObject, (NPIdentifier)aId);
|
||||
PluginIdentifierChild* id = static_cast<PluginIdentifierChild*>(aId);
|
||||
*aHasMethod = mObject->_class->hasMethod(mObject, id->ToNPIdentifier());
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
PluginScriptableObjectChild::AnswerInvoke(const NPRemoteIdentifier& aId,
|
||||
PluginScriptableObjectChild::AnswerInvoke(PPluginIdentifierChild* aId,
|
||||
const nsTArray<Variant>& aArgs,
|
||||
Variant* aResult,
|
||||
bool* aSuccess)
|
||||
@ -698,7 +704,8 @@ PluginScriptableObjectChild::AnswerInvoke(const NPRemoteIdentifier& aId,
|
||||
|
||||
NPVariant result;
|
||||
VOID_TO_NPVARIANT(result);
|
||||
bool success = mObject->_class->invoke(mObject, (NPIdentifier)aId,
|
||||
PluginIdentifierChild* id = static_cast<PluginIdentifierChild*>(aId);
|
||||
bool success = mObject->_class->invoke(mObject, id->ToNPIdentifier(),
|
||||
convertedArgs.Elements(), argCount,
|
||||
&result);
|
||||
|
||||
@ -799,7 +806,7 @@ PluginScriptableObjectChild::AnswerInvokeDefault(const nsTArray<Variant>& aArgs,
|
||||
}
|
||||
|
||||
bool
|
||||
PluginScriptableObjectChild::AnswerHasProperty(const NPRemoteIdentifier& aId,
|
||||
PluginScriptableObjectChild::AnswerHasProperty(PPluginIdentifierChild* aId,
|
||||
bool* aHasProperty)
|
||||
{
|
||||
AssertPluginThread();
|
||||
@ -818,12 +825,13 @@ PluginScriptableObjectChild::AnswerHasProperty(const NPRemoteIdentifier& aId,
|
||||
return true;
|
||||
}
|
||||
|
||||
*aHasProperty = mObject->_class->hasProperty(mObject, (NPIdentifier)aId);
|
||||
PluginIdentifierChild* id = static_cast<PluginIdentifierChild*>(aId);
|
||||
*aHasProperty = mObject->_class->hasProperty(mObject, id->ToNPIdentifier());
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
PluginScriptableObjectChild::AnswerGetProperty(const NPRemoteIdentifier& aId,
|
||||
PluginScriptableObjectChild::AnswerGetProperty(PPluginIdentifierChild* aId,
|
||||
Variant* aResult,
|
||||
bool* aSuccess)
|
||||
{
|
||||
@ -847,7 +855,8 @@ PluginScriptableObjectChild::AnswerGetProperty(const NPRemoteIdentifier& aId,
|
||||
|
||||
NPVariant result;
|
||||
VOID_TO_NPVARIANT(result);
|
||||
if (!mObject->_class->getProperty(mObject, (NPIdentifier)aId, &result)) {
|
||||
PluginIdentifierChild* id = static_cast<PluginIdentifierChild*>(aId);
|
||||
if (!mObject->_class->getProperty(mObject, id->ToNPIdentifier(), &result)) {
|
||||
*aResult = void_t();
|
||||
*aSuccess = false;
|
||||
return true;
|
||||
@ -867,7 +876,7 @@ PluginScriptableObjectChild::AnswerGetProperty(const NPRemoteIdentifier& aId,
|
||||
}
|
||||
|
||||
bool
|
||||
PluginScriptableObjectChild::AnswerSetProperty(const NPRemoteIdentifier& aId,
|
||||
PluginScriptableObjectChild::AnswerSetProperty(PPluginIdentifierChild* aId,
|
||||
const Variant& aValue,
|
||||
bool* aSuccess)
|
||||
{
|
||||
@ -890,7 +899,8 @@ PluginScriptableObjectChild::AnswerSetProperty(const NPRemoteIdentifier& aId,
|
||||
NPVariant converted;
|
||||
ConvertToVariant(aValue, converted);
|
||||
|
||||
if ((*aSuccess = mObject->_class->setProperty(mObject, (NPIdentifier)aId,
|
||||
PluginIdentifierChild* id = static_cast<PluginIdentifierChild*>(aId);
|
||||
if ((*aSuccess = mObject->_class->setProperty(mObject, id->ToNPIdentifier(),
|
||||
&converted))) {
|
||||
PluginModuleChild::sBrowserFuncs.releasevariantvalue(&converted);
|
||||
}
|
||||
@ -898,7 +908,7 @@ PluginScriptableObjectChild::AnswerSetProperty(const NPRemoteIdentifier& aId,
|
||||
}
|
||||
|
||||
bool
|
||||
PluginScriptableObjectChild::AnswerRemoveProperty(const NPRemoteIdentifier& aId,
|
||||
PluginScriptableObjectChild::AnswerRemoveProperty(PPluginIdentifierChild* aId,
|
||||
bool* aSuccess)
|
||||
{
|
||||
AssertPluginThread();
|
||||
@ -917,12 +927,13 @@ PluginScriptableObjectChild::AnswerRemoveProperty(const NPRemoteIdentifier& aId,
|
||||
return true;
|
||||
}
|
||||
|
||||
*aSuccess = mObject->_class->removeProperty(mObject, (NPIdentifier)aId);
|
||||
PluginIdentifierChild* id = static_cast<PluginIdentifierChild*>(aId);
|
||||
*aSuccess = mObject->_class->removeProperty(mObject, id->ToNPIdentifier());
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
PluginScriptableObjectChild::AnswerEnumerate(nsTArray<NPRemoteIdentifier>* aProperties,
|
||||
PluginScriptableObjectChild::AnswerEnumerate(nsTArray<PPluginIdentifierChild*>* aProperties,
|
||||
bool* aSuccess)
|
||||
{
|
||||
AssertPluginThread();
|
||||
@ -955,11 +966,8 @@ PluginScriptableObjectChild::AnswerEnumerate(nsTArray<NPRemoteIdentifier>* aProp
|
||||
}
|
||||
|
||||
for (uint32_t index = 0; index < idCount; index++) {
|
||||
#ifdef DEBUG
|
||||
NPRemoteIdentifier* remoteId =
|
||||
#endif
|
||||
aProperties->AppendElement((NPRemoteIdentifier)ids[index]);
|
||||
NS_ASSERTION(remoteId, "Shouldn't fail if SetCapacity above succeeded!");
|
||||
PluginIdentifierChild* id = static_cast<PluginIdentifierChild*>(ids[index]);
|
||||
aProperties->AppendElement(id);
|
||||
}
|
||||
|
||||
PluginModuleChild::sBrowserFuncs.memfree(ids);
|
||||
|
@ -48,6 +48,7 @@ namespace plugins {
|
||||
|
||||
class PluginInstanceChild;
|
||||
class PluginScriptableObjectChild;
|
||||
class PPluginIdentifierChild;
|
||||
|
||||
struct ChildNPObject : NPObject
|
||||
{
|
||||
@ -87,11 +88,11 @@ public:
|
||||
AnswerInvalidate();
|
||||
|
||||
virtual bool
|
||||
AnswerHasMethod(const NPRemoteIdentifier& aId,
|
||||
AnswerHasMethod(PPluginIdentifierChild* aId,
|
||||
bool* aHasMethod);
|
||||
|
||||
virtual bool
|
||||
AnswerInvoke(const NPRemoteIdentifier& aId,
|
||||
AnswerInvoke(PPluginIdentifierChild* aId,
|
||||
const nsTArray<Variant>& aArgs,
|
||||
Variant* aResult,
|
||||
bool* aSuccess);
|
||||
@ -102,25 +103,25 @@ public:
|
||||
bool* aSuccess);
|
||||
|
||||
virtual bool
|
||||
AnswerHasProperty(const NPRemoteIdentifier& aId,
|
||||
AnswerHasProperty(PPluginIdentifierChild* aId,
|
||||
bool* aHasProperty);
|
||||
|
||||
virtual bool
|
||||
AnswerGetProperty(const NPRemoteIdentifier& aId,
|
||||
AnswerGetProperty(PPluginIdentifierChild* aId,
|
||||
Variant* aResult,
|
||||
bool* aSuccess);
|
||||
|
||||
virtual bool
|
||||
AnswerSetProperty(const NPRemoteIdentifier& aId,
|
||||
AnswerSetProperty(PPluginIdentifierChild* aId,
|
||||
const Variant& aValue,
|
||||
bool* aSuccess);
|
||||
|
||||
virtual bool
|
||||
AnswerRemoveProperty(const NPRemoteIdentifier& aId,
|
||||
AnswerRemoveProperty(PPluginIdentifierChild* aId,
|
||||
bool* aSuccess);
|
||||
|
||||
virtual bool
|
||||
AnswerEnumerate(nsTArray<NPRemoteIdentifier>* aProperties,
|
||||
AnswerEnumerate(nsTArray<PPluginIdentifierChild*>* aProperties,
|
||||
bool* aSuccess);
|
||||
|
||||
virtual bool
|
||||
|
@ -40,7 +40,6 @@
|
||||
#include "PluginScriptableObjectUtils.h"
|
||||
|
||||
using namespace mozilla::plugins;
|
||||
using mozilla::ipc::NPRemoteIdentifier;
|
||||
|
||||
namespace {
|
||||
|
||||
@ -54,9 +53,9 @@ ReleaseVariant(NPVariant& aVariant,
|
||||
}
|
||||
}
|
||||
|
||||
inline bool
|
||||
EnsureValidIdentifier(PluginInstanceParent* aInstance,
|
||||
NPIdentifier aIdentifier)
|
||||
inline PPluginIdentifierParent*
|
||||
GetIdentifier(PluginInstanceParent* aInstance,
|
||||
NPIdentifier aIdentifier)
|
||||
{
|
||||
PluginModuleParent* module = aInstance->Module();
|
||||
if (!module) {
|
||||
@ -64,12 +63,12 @@ EnsureValidIdentifier(PluginInstanceParent* aInstance,
|
||||
return false;
|
||||
}
|
||||
|
||||
return module->EnsureValidNPIdentifier(aIdentifier);
|
||||
return module->GetIdentifierForNPIdentifier(aIdentifier);
|
||||
}
|
||||
|
||||
inline bool
|
||||
EnsureValidIdentifier(NPObject* aObject,
|
||||
NPIdentifier aIdentifier)
|
||||
inline PPluginIdentifierParent*
|
||||
GetIdentifier(NPObject* aObject,
|
||||
NPIdentifier aIdentifier)
|
||||
{
|
||||
PluginInstanceParent* instance = GetInstance(aObject);
|
||||
if (!instance) {
|
||||
@ -77,7 +76,7 @@ EnsureValidIdentifier(NPObject* aObject,
|
||||
return false;
|
||||
}
|
||||
|
||||
return EnsureValidIdentifier(instance, aIdentifier);
|
||||
return GetIdentifier(instance, aIdentifier);
|
||||
}
|
||||
|
||||
} // anonymous namespace
|
||||
@ -153,7 +152,8 @@ PluginScriptableObjectParent::ScriptableHasMethod(NPObject* aObject,
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!EnsureValidIdentifier(aObject, aName)) {
|
||||
PPluginIdentifierParent* identifier = GetIdentifier(aObject, aName);
|
||||
if (!identifier) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -165,7 +165,7 @@ PluginScriptableObjectParent::ScriptableHasMethod(NPObject* aObject,
|
||||
NS_ASSERTION(actor->Type() == Proxy, "Bad type!");
|
||||
|
||||
bool result;
|
||||
if (!actor->CallHasMethod((NPRemoteIdentifier)aName, &result)) {
|
||||
if (!actor->CallHasMethod(identifier, &result)) {
|
||||
NS_WARNING("Failed to send message!");
|
||||
return false;
|
||||
}
|
||||
@ -192,7 +192,8 @@ PluginScriptableObjectParent::ScriptableInvoke(NPObject* aObject,
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!EnsureValidIdentifier(aObject, aName)) {
|
||||
PPluginIdentifierParent* identifier = GetIdentifier(aObject, aName);
|
||||
if (!identifier) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -211,7 +212,7 @@ PluginScriptableObjectParent::ScriptableInvoke(NPObject* aObject,
|
||||
|
||||
Variant remoteResult;
|
||||
bool success;
|
||||
if (!actor->CallInvoke((NPRemoteIdentifier)aName, args, &remoteResult,
|
||||
if (!actor->CallInvoke(identifier, args, &remoteResult,
|
||||
&success)) {
|
||||
NS_WARNING("Failed to send message!");
|
||||
return false;
|
||||
@ -293,7 +294,8 @@ PluginScriptableObjectParent::ScriptableHasProperty(NPObject* aObject,
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!EnsureValidIdentifier(aObject, aName)) {
|
||||
PPluginIdentifierParent* identifier = GetIdentifier(aObject, aName);
|
||||
if (!identifier) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -305,7 +307,7 @@ PluginScriptableObjectParent::ScriptableHasProperty(NPObject* aObject,
|
||||
NS_ASSERTION(actor->Type() == Proxy, "Bad type!");
|
||||
|
||||
bool result;
|
||||
if (!actor->CallHasProperty((NPRemoteIdentifier)aName, &result)) {
|
||||
if (!actor->CallHasProperty(identifier, &result)) {
|
||||
NS_WARNING("Failed to send message!");
|
||||
return false;
|
||||
}
|
||||
@ -330,7 +332,8 @@ PluginScriptableObjectParent::ScriptableGetProperty(NPObject* aObject,
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!EnsureValidIdentifier(aObject, aName)) {
|
||||
PPluginIdentifierParent* identifier = GetIdentifier(aObject, aName);
|
||||
if (!identifier) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -343,7 +346,7 @@ PluginScriptableObjectParent::ScriptableGetProperty(NPObject* aObject,
|
||||
|
||||
Variant result;
|
||||
bool success;
|
||||
if (!actor->CallGetProperty((NPRemoteIdentifier)aName, &result, &success)) {
|
||||
if (!actor->CallGetProperty(identifier, &result, &success)) {
|
||||
NS_WARNING("Failed to send message!");
|
||||
return false;
|
||||
}
|
||||
@ -377,7 +380,8 @@ PluginScriptableObjectParent::ScriptableSetProperty(NPObject* aObject,
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!EnsureValidIdentifier(aObject, aName)) {
|
||||
PPluginIdentifierParent* identifier = GetIdentifier(aObject, aName);
|
||||
if (!identifier) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -395,7 +399,7 @@ PluginScriptableObjectParent::ScriptableSetProperty(NPObject* aObject,
|
||||
}
|
||||
|
||||
bool success;
|
||||
if (!actor->CallSetProperty((NPRemoteIdentifier)aName, value, &success)) {
|
||||
if (!actor->CallSetProperty(identifier, value, &success)) {
|
||||
NS_WARNING("Failed to send message!");
|
||||
return false;
|
||||
}
|
||||
@ -419,7 +423,8 @@ PluginScriptableObjectParent::ScriptableRemoveProperty(NPObject* aObject,
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!EnsureValidIdentifier(aObject, aName)) {
|
||||
PPluginIdentifierParent* identifier = GetIdentifier(aObject, aName);
|
||||
if (!identifier) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -431,7 +436,7 @@ PluginScriptableObjectParent::ScriptableRemoveProperty(NPObject* aObject,
|
||||
NS_ASSERTION(actor->Type() == Proxy, "Bad type!");
|
||||
|
||||
bool success;
|
||||
if (!actor->CallRemoveProperty((NPRemoteIdentifier)aName, &success)) {
|
||||
if (!actor->CallRemoveProperty(identifier, &success)) {
|
||||
NS_WARNING("Failed to send message!");
|
||||
return false;
|
||||
}
|
||||
@ -469,7 +474,7 @@ PluginScriptableObjectParent::ScriptableEnumerate(NPObject* aObject,
|
||||
return false;
|
||||
}
|
||||
|
||||
nsAutoTArray<NPRemoteIdentifier, 10> identifiers;
|
||||
nsAutoTArray<PPluginIdentifierParent*, 10> identifiers;
|
||||
bool success;
|
||||
if (!actor->CallEnumerate(&identifiers, &success)) {
|
||||
NS_WARNING("Failed to send message!");
|
||||
@ -493,11 +498,9 @@ PluginScriptableObjectParent::ScriptableEnumerate(NPObject* aObject,
|
||||
}
|
||||
|
||||
for (PRUint32 index = 0; index < *aCount; index++) {
|
||||
NPIdentifier& id = *aIdentifiers[index];
|
||||
id = (NPIdentifier)identifiers[index];
|
||||
if (!EnsureValidIdentifier(aObject, id)) {
|
||||
return false;
|
||||
}
|
||||
PluginIdentifierParent* id =
|
||||
static_cast<PluginIdentifierParent*>(identifiers[index]);
|
||||
*aIdentifiers[index] = id->ToNPIdentifier();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -729,7 +732,7 @@ PluginScriptableObjectParent::DropNPObject()
|
||||
}
|
||||
|
||||
bool
|
||||
PluginScriptableObjectParent::AnswerHasMethod(const NPRemoteIdentifier& aId,
|
||||
PluginScriptableObjectParent::AnswerHasMethod(PPluginIdentifierParent* aId,
|
||||
bool* aHasMethod)
|
||||
{
|
||||
if (!mObject) {
|
||||
@ -755,18 +758,13 @@ PluginScriptableObjectParent::AnswerHasMethod(const NPRemoteIdentifier& aId,
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!EnsureValidIdentifier(instance, (NPIdentifier)aId)) {
|
||||
NS_WARNING("Invalid NPIdentifier!");
|
||||
*aHasMethod = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
*aHasMethod = npn->hasmethod(instance->GetNPP(), mObject, (NPIdentifier)aId);
|
||||
PluginIdentifierParent* id = static_cast<PluginIdentifierParent*>(aId);
|
||||
*aHasMethod = npn->hasmethod(instance->GetNPP(), mObject, id->ToNPIdentifier());
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
PluginScriptableObjectParent::AnswerInvoke(const NPRemoteIdentifier& aId,
|
||||
PluginScriptableObjectParent::AnswerInvoke(PPluginIdentifierParent* aId,
|
||||
const nsTArray<Variant>& aArgs,
|
||||
Variant* aResult,
|
||||
bool* aSuccess)
|
||||
@ -797,13 +795,6 @@ PluginScriptableObjectParent::AnswerInvoke(const NPRemoteIdentifier& aId,
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!EnsureValidIdentifier(instance, (NPIdentifier)aId)) {
|
||||
NS_WARNING("Invalid NPIdentifier!");
|
||||
*aResult = void_t();
|
||||
*aSuccess = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
nsAutoTArray<NPVariant, 10> convertedArgs;
|
||||
PRUint32 argCount = aArgs.Length();
|
||||
|
||||
@ -825,8 +816,9 @@ PluginScriptableObjectParent::AnswerInvoke(const NPRemoteIdentifier& aId,
|
||||
}
|
||||
}
|
||||
|
||||
PluginIdentifierParent* id = static_cast<PluginIdentifierParent*>(aId);
|
||||
NPVariant result;
|
||||
bool success = npn->invoke(instance->GetNPP(), mObject, (NPIdentifier)aId,
|
||||
bool success = npn->invoke(instance->GetNPP(), mObject, id->ToNPIdentifier(),
|
||||
convertedArgs.Elements(), argCount, &result);
|
||||
|
||||
for (PRUint32 index = 0; index < argCount; index++) {
|
||||
@ -939,7 +931,7 @@ PluginScriptableObjectParent::AnswerInvokeDefault(const nsTArray<Variant>& aArgs
|
||||
}
|
||||
|
||||
bool
|
||||
PluginScriptableObjectParent::AnswerHasProperty(const NPRemoteIdentifier& aId,
|
||||
PluginScriptableObjectParent::AnswerHasProperty(PPluginIdentifierParent* aId,
|
||||
bool* aHasProperty)
|
||||
{
|
||||
if (!mObject) {
|
||||
@ -965,19 +957,14 @@ PluginScriptableObjectParent::AnswerHasProperty(const NPRemoteIdentifier& aId,
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!EnsureValidIdentifier(instance, (NPIdentifier)aId)) {
|
||||
NS_WARNING("Invalid NPIdentifier!");
|
||||
*aHasProperty = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
PluginIdentifierParent* id = static_cast<PluginIdentifierParent*>(aId);
|
||||
*aHasProperty = npn->hasproperty(instance->GetNPP(), mObject,
|
||||
(NPIdentifier)aId);
|
||||
id->ToNPIdentifier());
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
PluginScriptableObjectParent::AnswerGetProperty(const NPRemoteIdentifier& aId,
|
||||
PluginScriptableObjectParent::AnswerGetProperty(PPluginIdentifierParent* aId,
|
||||
Variant* aResult,
|
||||
bool* aSuccess)
|
||||
{
|
||||
@ -1007,15 +994,9 @@ PluginScriptableObjectParent::AnswerGetProperty(const NPRemoteIdentifier& aId,
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!EnsureValidIdentifier(instance, (NPIdentifier)aId)) {
|
||||
NS_WARNING("Invalid NPIdentifier!");
|
||||
*aResult = void_t();
|
||||
*aSuccess = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
PluginIdentifierParent* id = static_cast<PluginIdentifierParent*>(aId);
|
||||
NPVariant result;
|
||||
if (!npn->getproperty(instance->GetNPP(), mObject, (NPIdentifier)aId,
|
||||
if (!npn->getproperty(instance->GetNPP(), mObject, id->ToNPIdentifier(),
|
||||
&result)) {
|
||||
*aResult = void_t();
|
||||
*aSuccess = false;
|
||||
@ -1035,7 +1016,7 @@ PluginScriptableObjectParent::AnswerGetProperty(const NPRemoteIdentifier& aId,
|
||||
}
|
||||
|
||||
bool
|
||||
PluginScriptableObjectParent::AnswerSetProperty(const NPRemoteIdentifier& aId,
|
||||
PluginScriptableObjectParent::AnswerSetProperty(PPluginIdentifierParent* aId,
|
||||
const Variant& aValue,
|
||||
bool* aSuccess)
|
||||
{
|
||||
@ -1062,27 +1043,22 @@ PluginScriptableObjectParent::AnswerSetProperty(const NPRemoteIdentifier& aId,
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!EnsureValidIdentifier(instance, (NPIdentifier)aId)) {
|
||||
NS_WARNING("Invalid NPIdentifier!");
|
||||
*aSuccess = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
NPVariant converted;
|
||||
if (!ConvertToVariant(aValue, converted, instance)) {
|
||||
*aSuccess = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
PluginIdentifierParent* id = static_cast<PluginIdentifierParent*>(aId);
|
||||
if ((*aSuccess = npn->setproperty(instance->GetNPP(), mObject,
|
||||
(NPIdentifier)aId, &converted))) {
|
||||
id->ToNPIdentifier(), &converted))) {
|
||||
ReleaseVariant(converted, instance);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
PluginScriptableObjectParent::AnswerRemoveProperty(const NPRemoteIdentifier& aId,
|
||||
PluginScriptableObjectParent::AnswerRemoveProperty(PPluginIdentifierParent* aId,
|
||||
bool* aSuccess)
|
||||
{
|
||||
if (!mObject) {
|
||||
@ -1108,19 +1084,14 @@ PluginScriptableObjectParent::AnswerRemoveProperty(const NPRemoteIdentifier& aId
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!EnsureValidIdentifier(instance, (NPIdentifier)aId)) {
|
||||
NS_WARNING("Invalid NPIdentifier!");
|
||||
*aSuccess = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
PluginIdentifierParent* id = static_cast<PluginIdentifierParent*>(aId);
|
||||
*aSuccess = npn->removeproperty(instance->GetNPP(), mObject,
|
||||
(NPIdentifier)aId);
|
||||
id->ToNPIdentifier());
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
PluginScriptableObjectParent::AnswerEnumerate(nsTArray<NPRemoteIdentifier>* aProperties,
|
||||
PluginScriptableObjectParent::AnswerEnumerate(nsTArray<PPluginIdentifierParent*>* aProperties,
|
||||
bool* aSuccess)
|
||||
{
|
||||
if (!mObject) {
|
||||
@ -1160,13 +1131,7 @@ PluginScriptableObjectParent::AnswerEnumerate(nsTArray<NPRemoteIdentifier>* aPro
|
||||
}
|
||||
|
||||
for (uint32_t index = 0; index < idCount; index++) {
|
||||
NS_ASSERTION(EnsureValidIdentifier(instance, ids[index]),
|
||||
"Identifier not yet in hashset!");
|
||||
#ifdef DEBUG
|
||||
NPRemoteIdentifier* remoteId =
|
||||
#endif
|
||||
aProperties->AppendElement((NPRemoteIdentifier)ids[index]);
|
||||
NS_ASSERTION(remoteId, "Shouldn't fail if SetCapacity above succeeded!");
|
||||
aProperties->AppendElement(GetIdentifier(instance, ids[index]));
|
||||
}
|
||||
|
||||
npn->memfree(ids);
|
||||
|
@ -49,6 +49,7 @@ namespace plugins {
|
||||
|
||||
class PluginInstanceParent;
|
||||
class PluginScriptableObjectParent;
|
||||
class PPluginIdentifierParent;
|
||||
|
||||
struct ParentNPObject : NPObject
|
||||
{
|
||||
@ -76,11 +77,11 @@ public:
|
||||
InitializeLocal(NPObject* aObject);
|
||||
|
||||
virtual bool
|
||||
AnswerHasMethod(const NPRemoteIdentifier& aId,
|
||||
AnswerHasMethod(PPluginIdentifierParent* aId,
|
||||
bool* aHasMethod);
|
||||
|
||||
virtual bool
|
||||
AnswerInvoke(const NPRemoteIdentifier& aId,
|
||||
AnswerInvoke(PPluginIdentifierParent* aId,
|
||||
const nsTArray<Variant>& aArgs,
|
||||
Variant* aResult,
|
||||
bool* aSuccess);
|
||||
@ -91,25 +92,25 @@ public:
|
||||
bool* aSuccess);
|
||||
|
||||
virtual bool
|
||||
AnswerHasProperty(const NPRemoteIdentifier& aId,
|
||||
AnswerHasProperty(PPluginIdentifierParent* aId,
|
||||
bool* aHasProperty);
|
||||
|
||||
virtual bool
|
||||
AnswerGetProperty(const NPRemoteIdentifier& aId,
|
||||
AnswerGetProperty(PPluginIdentifierParent* aId,
|
||||
Variant* aResult,
|
||||
bool* aSuccess);
|
||||
|
||||
virtual bool
|
||||
AnswerSetProperty(const NPRemoteIdentifier& aId,
|
||||
AnswerSetProperty(PPluginIdentifierParent* aId,
|
||||
const Variant& aValue,
|
||||
bool* aSuccess);
|
||||
|
||||
virtual bool
|
||||
AnswerRemoveProperty(const NPRemoteIdentifier& aId,
|
||||
AnswerRemoveProperty(PPluginIdentifierParent* aId,
|
||||
bool* aSuccess);
|
||||
|
||||
virtual bool
|
||||
AnswerEnumerate(nsTArray<NPRemoteIdentifier>* aProperties,
|
||||
AnswerEnumerate(nsTArray<PPluginIdentifierParent*>* aProperties,
|
||||
bool* aSuccess);
|
||||
|
||||
virtual bool
|
||||
|
@ -36,6 +36,7 @@
|
||||
|
||||
IPDLSRCS = \
|
||||
PPluginModule.ipdl \
|
||||
PPluginIdentifier.ipdl \
|
||||
PPluginInstance.ipdl \
|
||||
PPluginScriptableObject.ipdl \
|
||||
PBrowserStream.ipdl \
|
||||
|
Loading…
Reference in New Issue
Block a user