зеркало из https://github.com/mozilla/pjs.git
Bug 226101 DRefTool analysis for MRJ files
r=roc sr=roc
This commit is contained in:
Родитель
70391bdab4
Коммит
511dfa3646
|
@ -898,7 +898,7 @@ public:
|
|||
nsIPluginStreamInfo* CreatePluginStreamInfo(const char* url, nsMIMEType type, PRBool seekable) {
|
||||
if (mStreamInfo == NULL) {
|
||||
mStreamInfo = new CPluginStreamInfo(url, this, type, seekable);
|
||||
mStreamInfo->AddRef();
|
||||
NS_IF_ADDREF(mStreamInfo);
|
||||
}
|
||||
return mStreamInfo;
|
||||
}
|
||||
|
@ -1954,18 +1954,20 @@ CPluginManager::AllocateMenuID(nsIEventHandler* handler, PRBool isSubmenu, PRInt
|
|||
NS_METHOD
|
||||
CPluginManager::GetService(const nsCID& aClass, const nsIID& aIID, void* *result)
|
||||
{
|
||||
// the only service we support currently is nsIMemory.
|
||||
if (aClass.Equals(kPluginManagerCID) || aClass.Equals(kMemoryCID)) {
|
||||
return QueryInterface(aIID, (void**) result);
|
||||
}
|
||||
if (aClass.Equals(nsILiveconnect::GetCID())) {
|
||||
if (mLiveconnect == NULL) {
|
||||
mLiveconnect = new nsLiveconnect;
|
||||
NS_IF_ADDREF(mLiveconnect);
|
||||
}
|
||||
return mLiveconnect->QueryInterface(aIID, (void**)result);
|
||||
}
|
||||
return NS_ERROR_SERVICE_NOT_FOUND;
|
||||
// the only service we support currently is nsIMemory.
|
||||
if (aClass.Equals(kPluginManagerCID) || aClass.Equals(kMemoryCID)) {
|
||||
return QueryInterface(aIID, result);
|
||||
}
|
||||
if (!aClass.Equals(nsILiveconnect::GetCID())) {
|
||||
return NS_ERROR_SERVICE_NOT_FOUND;
|
||||
}
|
||||
if (mLiveconnect == NULL) {
|
||||
mLiveconnect = new nsLiveconnect;
|
||||
if (!mLiveconnect)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
NS_ADDREF(mLiveconnect);
|
||||
}
|
||||
return mLiveconnect->QueryInterface(aIID, result);
|
||||
}
|
||||
|
||||
//////////////////////////////
|
||||
|
|
|
@ -135,19 +135,21 @@ EmbeddedFrame::EmbeddedFrame(MRJPluginInstance* pluginInstance, JMFrameRef frame
|
|||
int screenX = mBounds.left;
|
||||
int screenY = mBounds.top;
|
||||
|
||||
char* script = new char[::strlen(kEmbeddedFrameScript) + 100];
|
||||
::sprintf(script, kEmbeddedFrameScript, ++embeddedFrameCounter, width, height, screenX, screenY, width, height, this);
|
||||
char* script = new char[::strlen(kEmbeddedFrameScript) + 100];
|
||||
if (script)
|
||||
::sprintf(script, kEmbeddedFrameScript, ++embeddedFrameCounter, width, height, screenX, screenY, width, height, this);
|
||||
|
||||
JSEvaluator* evaluator = new JSEvaluator(pluginInstance);
|
||||
evaluator->AddRef();
|
||||
|
||||
// create the window. It will have been created after returning from eval.
|
||||
const char* result = evaluator->eval(script);
|
||||
|
||||
evaluator->Release();
|
||||
|
||||
delete[] script;
|
||||
JSEvaluator* evaluator = new JSEvaluator(pluginInstance);
|
||||
if (evaluator) {
|
||||
NS_ADDREF(evaluator);
|
||||
|
||||
// create the window. It will have been created after returning from eval.
|
||||
const char* result = evaluator->eval(script);
|
||||
|
||||
NS_RELEASE(evaluator);
|
||||
}
|
||||
delete[] script;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (mWindow != NULL) {
|
||||
|
|
|
@ -388,6 +388,8 @@ static void sendMessage(JNIEnv* env, JavaMessage* msg)
|
|||
static CSecureEnv* mainEnv = NULL;
|
||||
if (mainEnv == NULL) {
|
||||
mainEnv = new CSecureEnv(theJVMPlugin, NULL, env);
|
||||
if (!mainEnv)
|
||||
return;
|
||||
mainEnv->AddRef();
|
||||
}
|
||||
mainEnv->setJavaEnv(env);
|
||||
|
@ -410,22 +412,26 @@ static void sendMessage(JNIEnv* env, JavaMessage* msg)
|
|||
static CSecureEnv* sharedEnv = NULL;
|
||||
if (sharedEnv == NULL) {
|
||||
sharedEnv = new CSecureEnv(theJVMPlugin, NULL, env);
|
||||
sharedEnv->AddRef();
|
||||
NS_IF_ADDREF(sharedEnv);
|
||||
}
|
||||
sharedEnv->setJavaEnv(env);
|
||||
if (sharedEnv) {
|
||||
sharedEnv->setJavaEnv(env);
|
||||
|
||||
// In the current Seamonkey architecture, there's really only one thread that JavaScript
|
||||
// can execute in. We take advantage of that fact here. When we have a more multithreaded
|
||||
// system, this will have to be revisited.
|
||||
static PRUint32 theJavaScriptThread = getJavaScriptThread(env);
|
||||
|
||||
// if the JavaScript thread is known, wrap the message in a MessageRunnable to handle
|
||||
// the message in the JavaScript thread.
|
||||
if (theJavaScriptThread != 0) {
|
||||
MessageRunnable* runnableMsg = new MessageRunnable(theJavaScriptThread, msg);
|
||||
NS_ADDREF(runnableMsg);
|
||||
sharedEnv->sendMessageFromJava(env, runnableMsg);
|
||||
NS_IF_RELEASE(runnableMsg);
|
||||
// In the current Seamonkey architecture, there's really only one thread that JavaScript
|
||||
// can execute in. We take advantage of that fact here. When we have a more multithreaded
|
||||
// system, this will have to be revisited.
|
||||
static PRUint32 theJavaScriptThread = getJavaScriptThread(env);
|
||||
|
||||
// if the JavaScript thread is known, wrap the message in a MessageRunnable to handle
|
||||
// the message in the JavaScript thread.
|
||||
if (theJavaScriptThread != 0) {
|
||||
MessageRunnable* runnableMsg = new MessageRunnable(theJavaScriptThread, msg);
|
||||
if (runnableMsg) {
|
||||
NS_ADDREF(runnableMsg);
|
||||
sharedEnv->sendMessageFromJava(env, runnableMsg);
|
||||
NS_RELEASE(runnableMsg);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
sharedMonitor.exit();
|
||||
|
|
|
@ -333,13 +333,16 @@ static OSStatus openInputStream(
|
|||
{
|
||||
MRJURLConnection* connection = reinterpret_cast<MRJURLConnection*>(urlConnectionRef);
|
||||
MRJInputStream* inputStream = new MRJInputStream(connection->getInstance()->getSession());
|
||||
if (!inputStream)
|
||||
return memFullErr;
|
||||
|
||||
inputStream->AddRef();
|
||||
*urlInputStreamRef = inputStream;
|
||||
|
||||
nsIPluginInstance* pluginInstance = connection->getInstance();
|
||||
nsIPluginStreamListener* listener = inputStream;
|
||||
nsresult rv = thePluginManager->GetURL(pluginInstance, connection->getURL(), NULL, listener);
|
||||
|
||||
nsIPluginInstance* pluginInstance = connection->getInstance();
|
||||
nsIPluginStreamListener* listener = inputStream;
|
||||
nsresult rv = thePluginManager->GetURL(pluginInstance, connection->getURL(), NULL, listener);
|
||||
|
||||
return noErr;
|
||||
}
|
||||
|
||||
|
|
|
@ -113,31 +113,32 @@ nsresult MRJPlugin::GetService(const char* aContractID, const nsIID& aIID, void*
|
|||
|
||||
nsresult NSGetFactory(nsISupports* serviceManager, const nsCID &aClass, const char *aClassName, const char *aContractID, nsIFactory **aFactory)
|
||||
{
|
||||
nsresult result = NS_OK;
|
||||
|
||||
if (theServiceManager == NULL && theServiceManagerObsolete == NULL) {
|
||||
if (NS_FAILED(serviceManager->QueryInterface(NS_GET_IID(nsIServiceManager), (void**)&theServiceManager)))
|
||||
if (NS_FAILED(serviceManager->QueryInterface(NS_GET_IID(nsIServiceManagerObsolete), (void**)&theServiceManagerObsolete)))
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
// Our global operator new wants to use nsIMalloc to do all of its allocation.
|
||||
// This should be available from the Service Manager.
|
||||
#ifdef MRJPLUGIN_4X
|
||||
if (MRJPlugin::GetService(kMemoryCID, NS_GET_IID(nsIMemory), (void**)&theMemoryAllocator) != NS_OK)
|
||||
return NS_ERROR_FAILURE;
|
||||
// Our global operator new wants to use nsIMalloc to do all of its allocation.
|
||||
// This should be available from the Service Manager.
|
||||
#ifdef MRJPLUGIN_4X
|
||||
if (MRJPlugin::GetService(kMemoryCID, NS_GET_IID(nsIMemory), (void**)&theMemoryAllocator) != NS_OK)
|
||||
return NS_ERROR_FAILURE;
|
||||
#else
|
||||
if (NS_FAILED(MRJPlugin::GetService("@mozilla.org/xpcom/memory-service;1", NS_GET_IID(nsIMemory), (void **)&theMemoryAllocator)))
|
||||
return NS_ERROR_FAILURE;
|
||||
return NS_ERROR_FAILURE;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
if (aClass.Equals(kPluginCID)) {
|
||||
MRJPlugin* pluginFactory = new MRJPlugin();
|
||||
pluginFactory->AddRef();
|
||||
*aFactory = pluginFactory;
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_NOINTERFACE;
|
||||
if (!aClass.Equals(kPluginCID))
|
||||
return NS_NOINTERFACE;
|
||||
|
||||
MRJPlugin* pluginFactory = new MRJPlugin();
|
||||
if (!pluginFactory)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
pluginFactory->AddRef();
|
||||
*aFactory = pluginFactory;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
#pragma export off
|
||||
|
@ -213,31 +214,18 @@ MRJPlugin::MRJPlugin()
|
|||
|
||||
MRJPlugin::~MRJPlugin()
|
||||
{
|
||||
// make sure the plugin is no longer visible.
|
||||
::thePlugin = NULL;
|
||||
// make sure the plugin is no longer visible.
|
||||
::thePlugin = NULL;
|
||||
|
||||
// Release the console.
|
||||
if (mConsole != NULL) {
|
||||
mConsole->Release();
|
||||
mConsole = NULL;
|
||||
}
|
||||
// Release the console.
|
||||
NS_IF_RELEASE(mConsole);
|
||||
|
||||
// tear down the MRJ session, if it exists.
|
||||
if (mSession != NULL) {
|
||||
delete mSession;
|
||||
mSession = NULL;
|
||||
}
|
||||
// tear down the MRJ session, if it exists.
|
||||
delete mSession;
|
||||
|
||||
// Release the manager?
|
||||
if (mManager != NULL) {
|
||||
mManager->Release();
|
||||
mManager = NULL;
|
||||
}
|
||||
|
||||
if (mThreadManager != NULL) {
|
||||
mThreadManager->Release();
|
||||
mThreadManager = NULL;
|
||||
}
|
||||
// Release the manager?
|
||||
NS_IF_RELEASE(mManager);
|
||||
NS_IF_RELEASE(mThreadManager);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -249,11 +237,14 @@ MRJPlugin::~MRJPlugin()
|
|||
*/
|
||||
NS_METHOD MRJPlugin::QueryInterface(const nsIID& aIID, void** instancePtr)
|
||||
{
|
||||
nsresult result = queryInterface(aIID, instancePtr);
|
||||
if (result == NS_NOINTERFACE) {
|
||||
result = mConsole->queryInterface(aIID, instancePtr);
|
||||
}
|
||||
return result;
|
||||
nsresult result = queryInterface(aIID, instancePtr);
|
||||
if (result == NS_NOINTERFACE) {
|
||||
if (!mConsole)
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
|
||||
result = mConsole->queryInterface(aIID, instancePtr);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
NS_METHOD MRJPlugin::CreateInstance(nsISupports *aOuter, const nsIID& aIID, void **aResult)
|
||||
|
@ -274,58 +265,61 @@ NS_METHOD MRJPlugin::CreateInstance(nsISupports *aOuter, const nsIID& aIID, void
|
|||
|
||||
NS_METHOD MRJPlugin::CreatePluginInstance(nsISupports *aOuter, REFNSIID aIID, const char* aPluginMIMEType, void **aResult)
|
||||
{
|
||||
nsresult result = NS_NOINTERFACE;
|
||||
nsresult result = NS_NOINTERFACE;
|
||||
|
||||
if (::strcmp(aPluginMIMEType, "application/x-java-frame") == 0) {
|
||||
// create a special plugin instance that manages an embedded frame.
|
||||
EmbeddedFramePluginInstance* instance = new EmbeddedFramePluginInstance();
|
||||
nsresult result = instance->QueryInterface(aIID, aResult);
|
||||
if (result != NS_OK)
|
||||
delete instance;
|
||||
} else {
|
||||
// assume it's some kind of an applet.
|
||||
result = CreateInstance(aOuter, aIID, aResult);
|
||||
}
|
||||
return result;
|
||||
if (::strcmp(aPluginMIMEType, "application/x-java-frame") == 0) {
|
||||
// create a special plugin instance that manages an embedded frame.
|
||||
EmbeddedFramePluginInstance* instance = new EmbeddedFramePluginInstance();
|
||||
if (!instance)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
nsresult result = instance->QueryInterface(aIID, aResult);
|
||||
if (result != NS_OK)
|
||||
delete instance;
|
||||
} else {
|
||||
// assume it's some kind of an applet.
|
||||
result = CreateInstance(aOuter, aIID, aResult);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
NS_METHOD MRJPlugin::Initialize()
|
||||
{
|
||||
nsresult result = NS_OK;
|
||||
nsresult result = NS_OK;
|
||||
|
||||
// try to get a plugin manager.
|
||||
if (thePluginManager == NULL) {
|
||||
result = MRJPlugin::GetService(kPluginManagerCID, NS_GET_IID(nsIPluginManager), (void**)&thePluginManager);
|
||||
if (result != NS_OK || thePluginManager == NULL)
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
// try to get a plugin manager.
|
||||
if (thePluginManager == NULL) {
|
||||
result = MRJPlugin::GetService(kPluginManagerCID, NS_GET_IID(nsIPluginManager), (void**)&thePluginManager);
|
||||
if (result != NS_OK || thePluginManager == NULL)
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
// see if the enhanced plugin manager exists.
|
||||
if (thePluginManager2 == NULL) {
|
||||
if (thePluginManager->QueryInterface(NS_GET_IID(nsIPluginManager2), (void**)&thePluginManager2) != NS_OK)
|
||||
thePluginManager2 = NULL;
|
||||
}
|
||||
// see if the enhanced plugin manager exists.
|
||||
if (thePluginManager2 == NULL) {
|
||||
if (thePluginManager->QueryInterface(NS_GET_IID(nsIPluginManager2), (void**)&thePluginManager2) != NS_OK)
|
||||
thePluginManager2 = NULL;
|
||||
}
|
||||
|
||||
// try to get a JVM manager. we have to be able to run without one.
|
||||
if (MRJPlugin::GetService(kJVMManagerCID, NS_GET_IID(nsIJVMManager), (void**)&mManager) != NS_OK)
|
||||
mManager = NULL;
|
||||
|
||||
// try to get a Thread manager.
|
||||
if (mManager != NULL) {
|
||||
if (mManager->QueryInterface(NS_GET_IID(nsIThreadManager), (void**)&mThreadManager) != NS_OK)
|
||||
mThreadManager = NULL;
|
||||
// try to get a JVM manager. we have to be able to run without one.
|
||||
if (MRJPlugin::GetService(kJVMManagerCID, NS_GET_IID(nsIJVMManager), (void**)&mManager) != NS_OK)
|
||||
mManager = NULL;
|
||||
|
||||
// try to get a Thread manager.
|
||||
if (mManager != NULL) {
|
||||
if (mManager->QueryInterface(NS_GET_IID(nsIThreadManager), (void**)&mThreadManager) != NS_OK)
|
||||
mThreadManager = NULL;
|
||||
|
||||
if (mThreadManager != NULL)
|
||||
mThreadManager->GetCurrentThread(&mPluginThreadID);
|
||||
}
|
||||
if (mThreadManager != NULL)
|
||||
mThreadManager->GetCurrentThread(&mPluginThreadID);
|
||||
}
|
||||
|
||||
// create a console, only if there's user interface for it.
|
||||
if (thePluginManager2 != NULL) {
|
||||
mConsole = new MRJConsole(this);
|
||||
mConsole->AddRef();
|
||||
}
|
||||
// create a console, only if there's user interface for it.
|
||||
if (thePluginManager2 != NULL) {
|
||||
mConsole = new MRJConsole(this);
|
||||
NS_IF_ADDREF(mConsole);
|
||||
}
|
||||
|
||||
return result;
|
||||
return result;
|
||||
}
|
||||
|
||||
NS_METHOD MRJPlugin::Shutdown()
|
||||
|
@ -621,35 +615,28 @@ MRJPluginInstance::MRJPluginInstance(MRJPlugin* plugin)
|
|||
|
||||
MRJPluginInstance::~MRJPluginInstance()
|
||||
{
|
||||
// Remove this instance from the global list.
|
||||
popInstance();
|
||||
// Remove this instance from the global list.
|
||||
popInstance();
|
||||
|
||||
#if 0
|
||||
if (mContext != NULL) {
|
||||
delete mContext;
|
||||
mContext = NULL;
|
||||
}
|
||||
delete mContext;
|
||||
|
||||
if (mPlugin != NULL) {
|
||||
mPlugin->Release();
|
||||
mPlugin = NULL;
|
||||
}
|
||||
if (mPlugin != NULL) {
|
||||
mPlugin->Release();
|
||||
}
|
||||
|
||||
if (mWindowlessPeer != NULL) {
|
||||
mWindowlessPeer->Release();
|
||||
mWindowlessPeer = NULL;
|
||||
}
|
||||
if (mWindowlessPeer != NULL) {
|
||||
mWindowlessPeer->Release();
|
||||
}
|
||||
|
||||
if (mPeer != NULL) {
|
||||
mPeer->Release();
|
||||
mPeer = NULL;
|
||||
}
|
||||
if (mPeer != NULL) {
|
||||
mPeer->Release();
|
||||
}
|
||||
|
||||
if (mApplet != NULL) {
|
||||
JNIEnv* env = mSession->getCurrentEnv();
|
||||
env->DeleteGlobalRef(mApplet);
|
||||
mApplet = NULL;
|
||||
}
|
||||
if (mApplet != NULL) {
|
||||
JNIEnv* env = mSession->getCurrentEnv();
|
||||
env->DeleteGlobalRef(mApplet);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -668,29 +655,31 @@ static bool hasTagInfo(nsISupports* supports)
|
|||
|
||||
NS_METHOD MRJPluginInstance::Initialize(nsIPluginInstancePeer* peer)
|
||||
{
|
||||
// Tell the peer we are retaining a reference.
|
||||
mPeer = peer;
|
||||
mPeer->AddRef();
|
||||
// Tell the peer we are retaining a reference.
|
||||
mPeer = peer;
|
||||
mPeer->AddRef();
|
||||
|
||||
// See if we have a windowless peer.
|
||||
nsresult result = mPeer->QueryInterface(kIWindowlessPluginInstancePeerIID, (void **)&mWindowlessPeer);
|
||||
if (result != NS_OK) mWindowlessPeer = NULL;
|
||||
// See if we have a windowless peer.
|
||||
nsresult result = mPeer->QueryInterface(kIWindowlessPluginInstancePeerIID, (void **)&mWindowlessPeer);
|
||||
if (result != NS_OK) mWindowlessPeer = NULL;
|
||||
|
||||
// create a context for the applet we will run.
|
||||
mContext = new MRJContext(mSession, this);
|
||||
// create a context for the applet we will run.
|
||||
mContext = new MRJContext(mSession, this);
|
||||
if (!mContext)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
if (hasTagInfo(mPeer)) {
|
||||
mContext->processAppletTag();
|
||||
mContext->createContext();
|
||||
} else {
|
||||
// we'll be using JavaScript to create windows.
|
||||
// fire up a JavaScript URL to get the current document's location.
|
||||
nsIPluginInstance* pluginInstance = this;
|
||||
nsIPluginStreamListener* listener = this;
|
||||
result = thePluginManager->GetURL(pluginInstance, kGetDocumentBaseScriptURL, NULL, listener);
|
||||
}
|
||||
if (hasTagInfo(mPeer)) {
|
||||
mContext->processAppletTag();
|
||||
mContext->createContext();
|
||||
} else {
|
||||
// we'll be using JavaScript to create windows.
|
||||
// fire up a JavaScript URL to get the current document's location.
|
||||
nsIPluginInstance* pluginInstance = this;
|
||||
nsIPluginStreamListener* listener = this;
|
||||
result = thePluginManager->GetURL(pluginInstance, kGetDocumentBaseScriptURL, NULL, listener);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD MRJPluginInstance::OnDataAvailable(nsIPluginStreamInfo* pluginInfo, nsIInputStream* input, PRUint32 length)
|
||||
|
|
|
@ -61,8 +61,7 @@ nsLiveconnect::nsLiveconnect()
|
|||
|
||||
nsLiveconnect::~nsLiveconnect()
|
||||
{
|
||||
if (mJavaScriptMonitor != NULL)
|
||||
delete mJavaScriptMonitor;
|
||||
delete mJavaScriptMonitor;
|
||||
}
|
||||
|
||||
static char* u2c(const jchar *ustr, jsize length)
|
||||
|
@ -87,8 +86,11 @@ nsLiveconnect::Eval(JNIEnv *env, jsobject obj, const jchar *script, jsize length
|
|||
MRJPluginInstance* pluginInstance = (MRJPluginInstance*) obj;
|
||||
nsIPluginStreamListener* listener = this;
|
||||
|
||||
if (mJavaScriptMonitor == NULL)
|
||||
if (!mJavaScriptMonitor) {
|
||||
mJavaScriptMonitor = new MRJMonitor(pluginInstance->getSession());
|
||||
if (!mJavaScriptMonitor)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
mJavaScriptMonitor->enter();
|
||||
|
||||
|
@ -96,36 +98,45 @@ nsLiveconnect::Eval(JNIEnv *env, jsobject obj, const jchar *script, jsize length
|
|||
// some other thread is evaluating a script.
|
||||
mJavaScriptMonitor->wait();
|
||||
}
|
||||
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
// convert the script to ASCII, construct a "javascript:" URL.
|
||||
char* cscript = u2c(script, length);
|
||||
mScript = new char[strlen(kJavaScriptPrefix) + length + 1];
|
||||
strcpy(mScript, kJavaScriptPrefix);
|
||||
strcat(mScript, cscript);
|
||||
delete[] cscript;
|
||||
nsresult result = thePluginManager->GetURL((nsIPluginInstance*)pluginInstance, mScript, NULL, listener);
|
||||
|
||||
// need to block until the result is ready.
|
||||
mJavaScriptMonitor->wait();
|
||||
|
||||
// default result is NULL, in case JavaScript returns undefined value.
|
||||
*outResult = NULL;
|
||||
if (!cscript) {
|
||||
rv = NS_ERROR_OUT_OF_MEMORY;
|
||||
} else {
|
||||
mScript = new char[strlen(kJavaScriptPrefix) + length + 1];
|
||||
if (!mScript) {
|
||||
rv = NS_ERROR_OUT_OF_MEMORY;
|
||||
} else {
|
||||
strcpy(mScript, kJavaScriptPrefix);
|
||||
strcat(mScript, cscript);
|
||||
delete[] cscript;
|
||||
rv = thePluginManager->GetURL((nsIPluginInstance*)pluginInstance, mScript, NULL, listener);
|
||||
|
||||
// result should now be ready, convert it to a Java string and return.
|
||||
if (mResult != NULL) {
|
||||
*outResult = env->NewStringUTF(mResult);
|
||||
delete[] mResult;
|
||||
mResult = NULL;
|
||||
// need to block until the result is ready.
|
||||
mJavaScriptMonitor->wait();
|
||||
|
||||
// default result is NULL, in case JavaScript returns undefined value.
|
||||
*outResult = NULL;
|
||||
|
||||
// result should now be ready, convert it to a Java string and return.
|
||||
if (mResult != NULL) {
|
||||
*outResult = env->NewStringUTF(mResult);
|
||||
delete[] mResult;
|
||||
mResult = NULL;
|
||||
}
|
||||
|
||||
delete[] mScript;
|
||||
mScript = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
delete[] mScript;
|
||||
mScript = NULL;
|
||||
|
||||
|
||||
mJavaScriptMonitor->notifyAll();
|
||||
|
||||
|
||||
mJavaScriptMonitor->exit();
|
||||
|
||||
return NS_OK;
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_METHOD nsLiveconnect::OnDataAvailable(nsIPluginStreamInfo* pluginInfo, nsIInputStream* input, PRUint32 length)
|
||||
|
@ -135,7 +146,7 @@ NS_METHOD nsLiveconnect::OnDataAvailable(nsIPluginStreamInfo* pluginInfo, nsIInp
|
|||
if (mResult != NULL) {
|
||||
if (input->Read(mResult, length, &length) == NS_OK) {
|
||||
// We've delayed processing the applet tag, because we
|
||||
// don't know the location of the curren document yet.
|
||||
// don't know the location of the current document yet.
|
||||
mResult[length] = '\0';
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче