mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Improve memory mgmt and reduce COM pointer type usage in plugin stream code. b=578913 r=benwa (re-landing, did not cause Ts Shutdown regression)
This commit is contained in:
parent
4dc9f7dff4
commit
106040179d
@ -594,11 +594,12 @@ NS_IMETHODIMP nsPluginHost::GetURL(nsISupports* pluginInst,
|
||||
const char* referrer,
|
||||
PRBool forceJSEnabled)
|
||||
{
|
||||
return GetURLWithHeaders(pluginInst, url, target, streamListener,
|
||||
altHost, referrer, forceJSEnabled, nsnull, nsnull);
|
||||
return GetURLWithHeaders(static_cast<nsNPAPIPluginInstance*>(pluginInst),
|
||||
url, target, streamListener, altHost, referrer,
|
||||
forceJSEnabled, nsnull, nsnull);
|
||||
}
|
||||
|
||||
nsresult nsPluginHost::GetURLWithHeaders(nsISupports* pluginInst,
|
||||
nsresult nsPluginHost::GetURLWithHeaders(nsNPAPIPluginInstance* pluginInst,
|
||||
const char* url,
|
||||
const char* target,
|
||||
nsIPluginStreamListener* streamListener,
|
||||
@ -616,18 +617,13 @@ nsresult nsPluginHost::GetURLWithHeaders(nsISupports* pluginInst,
|
||||
if (!target && !streamListener)
|
||||
return NS_ERROR_ILLEGAL_VALUE;
|
||||
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIPluginInstance> instance = do_QueryInterface(pluginInst, &rv);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
rv = DoURLLoadSecurityCheck(instance, url);
|
||||
nsresult rv = DoURLLoadSecurityCheck(pluginInst, url);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
if (target) {
|
||||
nsCOMPtr<nsIPluginInstanceOwner> owner;
|
||||
rv = instance->GetOwner(getter_AddRefs(owner));
|
||||
rv = pluginInst->GetOwner(getter_AddRefs(owner));
|
||||
if (owner) {
|
||||
if ((0 == PL_strcmp(target, "newwindow")) ||
|
||||
(0 == PL_strcmp(target, "_new")))
|
||||
@ -640,7 +636,7 @@ nsresult nsPluginHost::GetURLWithHeaders(nsISupports* pluginInst,
|
||||
}
|
||||
|
||||
if (streamListener)
|
||||
rv = NewPluginURLStream(string, instance, streamListener, nsnull,
|
||||
rv = NewPluginURLStream(string, pluginInst, streamListener, nsnull,
|
||||
getHeaders, getHeadersLength);
|
||||
|
||||
return rv;
|
||||
@ -670,9 +666,7 @@ NS_IMETHODIMP nsPluginHost::PostURL(nsISupports* pluginInst,
|
||||
if (!target && !streamListener)
|
||||
return NS_ERROR_ILLEGAL_VALUE;
|
||||
|
||||
nsCOMPtr<nsIPluginInstance> instance = do_QueryInterface(pluginInst, &rv);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
nsNPAPIPluginInstance* instance = static_cast<nsNPAPIPluginInstance*>(pluginInst);
|
||||
|
||||
rv = DoURLLoadSecurityCheck(instance, url);
|
||||
if (NS_FAILED(rv))
|
||||
@ -950,8 +944,8 @@ NS_IMETHODIMP nsPluginHost::InstantiatePluginForChannel(nsIChannel* aChannel,
|
||||
|
||||
// Called by nsPluginInstanceOwner
|
||||
NS_IMETHODIMP nsPluginHost::InstantiateEmbeddedPlugin(const char *aMimeType,
|
||||
nsIURI* aURL,
|
||||
nsIPluginInstanceOwner *aOwner)
|
||||
nsIURI* aURL,
|
||||
nsIPluginInstanceOwner *aOwner)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aOwner);
|
||||
|
||||
@ -967,8 +961,7 @@ NS_IMETHODIMP nsPluginHost::InstantiateEmbeddedPlugin(const char *aMimeType,
|
||||
PR_LogFlush();
|
||||
#endif
|
||||
|
||||
nsresult rv;
|
||||
nsIPluginInstance *instance = nsnull;
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIPluginTagInfo> pti;
|
||||
nsPluginTagType tagType;
|
||||
|
||||
@ -1046,18 +1039,18 @@ NS_IMETHODIMP nsPluginHost::InstantiateEmbeddedPlugin(const char *aMimeType,
|
||||
PLUGIN_LOG(PLUGIN_LOG_NOISY,
|
||||
("nsPluginHost::InstantiateEmbeddedPlugin FoundStopped mime=%s\n", aMimeType));
|
||||
|
||||
aOwner->GetInstance(instance);
|
||||
nsCOMPtr<nsIPluginInstance> instanceCOMPtr;
|
||||
aOwner->GetInstance(getter_AddRefs(instanceCOMPtr));
|
||||
nsNPAPIPluginInstance *instance = static_cast<nsNPAPIPluginInstance*>(instanceCOMPtr.get());
|
||||
if (!isJava && bCanHandleInternally)
|
||||
rv = NewEmbeddedPluginStream(aURL, aOwner, instance);
|
||||
|
||||
// notify Java DOM component
|
||||
nsresult res;
|
||||
nsCOMPtr<nsIPluginInstanceOwner> javaDOM =
|
||||
do_GetService("@mozilla.org/blackwood/java-dom;1", &res);
|
||||
nsCOMPtr<nsIPluginInstanceOwner> javaDOM = do_GetService("@mozilla.org/blackwood/java-dom;1", &res);
|
||||
if (NS_SUCCEEDED(res) && javaDOM)
|
||||
javaDOM->SetInstance(instance);
|
||||
|
||||
NS_IF_RELEASE(instance);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -1071,15 +1064,15 @@ NS_IMETHODIMP nsPluginHost::InstantiateEmbeddedPlugin(const char *aMimeType,
|
||||
if (NS_FAILED(rv))
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
rv = aOwner->GetInstance(instance);
|
||||
|
||||
nsCOMPtr<nsIPluginInstance> instanceCOMPtr;
|
||||
rv = aOwner->GetInstance(getter_AddRefs(instanceCOMPtr));
|
||||
// if we have a failure error, it means we found a plugin for the mimetype,
|
||||
// but we had a problem with the entry point
|
||||
if (rv == NS_ERROR_FAILURE)
|
||||
return rv;
|
||||
|
||||
// if we are here then we have loaded a plugin for this mimetype
|
||||
|
||||
nsNPAPIPluginInstance *instance = static_cast<nsNPAPIPluginInstance*>(instanceCOMPtr.get());
|
||||
NPWindow *window = nsnull;
|
||||
|
||||
//we got a plugin built, now stream
|
||||
@ -1091,8 +1084,7 @@ NS_IMETHODIMP nsPluginHost::InstantiateEmbeddedPlugin(const char *aMimeType,
|
||||
|
||||
// If we've got a native window, the let the plugin know about it.
|
||||
if (window->window) {
|
||||
nsCOMPtr<nsIPluginInstance> inst = instance;
|
||||
((nsPluginNativeWindow*)window)->CallSetWindow(inst);
|
||||
((nsPluginNativeWindow*)window)->CallSetWindow(instanceCOMPtr);
|
||||
}
|
||||
|
||||
// create an initial stream with data
|
||||
@ -1116,8 +1108,6 @@ NS_IMETHODIMP nsPluginHost::InstantiateEmbeddedPlugin(const char *aMimeType,
|
||||
do_GetService("@mozilla.org/blackwood/java-dom;1", &res);
|
||||
if (NS_SUCCEEDED(res) && javaDOM)
|
||||
javaDOM->SetInstance(instance);
|
||||
|
||||
NS_RELEASE(instance);
|
||||
}
|
||||
|
||||
#ifdef PLUGIN_LOGGING
|
||||
@ -1136,9 +1126,9 @@ NS_IMETHODIMP nsPluginHost::InstantiateEmbeddedPlugin(const char *aMimeType,
|
||||
|
||||
// Called by full-page case
|
||||
NS_IMETHODIMP nsPluginHost::InstantiateFullPagePlugin(const char *aMimeType,
|
||||
nsIURI* aURI,
|
||||
nsIStreamListener *&aStreamListener,
|
||||
nsIPluginInstanceOwner *aOwner)
|
||||
nsIURI* aURI,
|
||||
nsIStreamListener *&aStreamListener,
|
||||
nsIPluginInstanceOwner *aOwner)
|
||||
{
|
||||
#ifdef PLUGIN_LOGGING
|
||||
nsCAutoString urlSpec;
|
||||
@ -1152,22 +1142,24 @@ NS_IMETHODIMP nsPluginHost::InstantiateFullPagePlugin(const char *aMimeType,
|
||||
PLUGIN_LOG(PLUGIN_LOG_NOISY,
|
||||
("nsPluginHost::InstantiateFullPagePlugin FoundStopped mime=%s\n",aMimeType));
|
||||
|
||||
nsIPluginInstance* instance;
|
||||
aOwner->GetInstance(instance);
|
||||
|
||||
nsPluginTag* pluginTag = FindPluginForType(aMimeType, PR_TRUE);
|
||||
if (!pluginTag || !pluginTag->mIsJavaPlugin)
|
||||
NewFullPagePluginStream(aStreamListener, aURI, instance);
|
||||
NS_IF_RELEASE(instance);
|
||||
if (!pluginTag || !pluginTag->mIsJavaPlugin) {
|
||||
nsCOMPtr<nsIPluginInstance> instanceCOMPtr;
|
||||
aOwner->GetInstance(getter_AddRefs(instanceCOMPtr));
|
||||
NewFullPagePluginStream(aStreamListener, aURI, static_cast<nsNPAPIPluginInstance*>(instanceCOMPtr.get()));
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult rv = SetUpPluginInstance(aMimeType, aURI, aOwner);
|
||||
|
||||
if (NS_OK == rv) {
|
||||
nsCOMPtr<nsIPluginInstance> instance;
|
||||
NPWindow* win = nsnull;
|
||||
nsCOMPtr<nsIPluginInstance> instanceCOMPtr;
|
||||
aOwner->GetInstance(getter_AddRefs(instanceCOMPtr));
|
||||
nsNPAPIPluginInstance *instance = static_cast<nsNPAPIPluginInstance*>(instanceCOMPtr.get());
|
||||
|
||||
aOwner->GetInstance(*getter_AddRefs(instance));
|
||||
NPWindow* win = nsnull;
|
||||
aOwner->GetWindow(win);
|
||||
|
||||
if (win && instance) {
|
||||
@ -1177,13 +1169,13 @@ NS_IMETHODIMP nsPluginHost::InstantiateFullPagePlugin(const char *aMimeType,
|
||||
// If we've got a native window, the let the plugin know about it.
|
||||
nsPluginNativeWindow * window = (nsPluginNativeWindow *)win;
|
||||
if (window->window)
|
||||
window->CallSetWindow(instance);
|
||||
window->CallSetWindow(instanceCOMPtr);
|
||||
|
||||
rv = NewFullPagePluginStream(aStreamListener, aURI, instance);
|
||||
|
||||
// If we've got a native window, the let the plugin know about it.
|
||||
if (window->window)
|
||||
window->CallSetWindow(instance);
|
||||
window->CallSetWindow(instanceCOMPtr);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2869,7 +2861,7 @@ nsPluginHost::EnsurePrivateDirServiceProvider()
|
||||
#endif /* XP_WIN */
|
||||
|
||||
nsresult nsPluginHost::NewPluginURLStream(const nsString& aURL,
|
||||
nsIPluginInstance *aInstance,
|
||||
nsNPAPIPluginInstance *aInstance,
|
||||
nsIPluginStreamListener* aListener,
|
||||
nsIInputStream *aPostStream,
|
||||
const char *aHeadersData,
|
||||
@ -2923,7 +2915,7 @@ nsresult nsPluginHost::NewPluginURLStream(const nsString& aURL,
|
||||
}
|
||||
|
||||
nsRefPtr<nsPluginStreamListenerPeer> listenerPeer = new nsPluginStreamListenerPeer();
|
||||
if (listenerPeer == NULL)
|
||||
if (!listenerPeer)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
rv = listenerPeer->Initialize(url, aInstance, aListener);
|
||||
@ -2992,8 +2984,8 @@ nsresult nsPluginHost::NewPluginURLStream(const nsString& aURL,
|
||||
|
||||
// Called by GetURL and PostURL
|
||||
nsresult
|
||||
nsPluginHost::DoURLLoadSecurityCheck(nsIPluginInstance *aInstance,
|
||||
const char* aURL)
|
||||
nsPluginHost::DoURLLoadSecurityCheck(nsNPAPIPluginInstance *aInstance,
|
||||
const char* aURL)
|
||||
{
|
||||
if (!aURL || *aURL == '\0')
|
||||
return NS_OK;
|
||||
@ -3158,15 +3150,14 @@ nsPluginHost::StoppedInstanceTagCount()
|
||||
|
||||
nsresult nsPluginHost::NewEmbeddedPluginStreamListener(nsIURI* aURL,
|
||||
nsIPluginInstanceOwner *aOwner,
|
||||
nsIPluginInstance* aInstance,
|
||||
nsNPAPIPluginInstance* aInstance,
|
||||
nsIStreamListener** aListener)
|
||||
{
|
||||
if (!aURL)
|
||||
return NS_OK;
|
||||
|
||||
nsRefPtr<nsPluginStreamListenerPeer> listener =
|
||||
new nsPluginStreamListenerPeer();
|
||||
if (listener == nsnull)
|
||||
nsRefPtr<nsPluginStreamListenerPeer> listener = new nsPluginStreamListenerPeer();
|
||||
if (!listener)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
nsresult rv;
|
||||
@ -3175,7 +3166,7 @@ nsresult nsPluginHost::NewEmbeddedPluginStreamListener(nsIURI* aURL,
|
||||
// if we only have an owner, then we need to pass it in
|
||||
// so the listener can set up the instance later after
|
||||
// we've determined the mimetype of the stream
|
||||
if (aInstance != nsnull)
|
||||
if (aInstance)
|
||||
rv = listener->InitializeEmbedded(aURL, aInstance);
|
||||
else if (aOwner != nsnull)
|
||||
rv = listener->InitializeEmbedded(aURL, nsnull, aOwner);
|
||||
@ -3190,7 +3181,7 @@ nsresult nsPluginHost::NewEmbeddedPluginStreamListener(nsIURI* aURL,
|
||||
// Called by InstantiateEmbeddedPlugin()
|
||||
nsresult nsPluginHost::NewEmbeddedPluginStream(nsIURI* aURL,
|
||||
nsIPluginInstanceOwner *aOwner,
|
||||
nsIPluginInstance* aInstance)
|
||||
nsNPAPIPluginInstance* aInstance)
|
||||
{
|
||||
nsCOMPtr<nsIStreamListener> listener;
|
||||
nsresult rv = NewEmbeddedPluginStreamListener(aURL, aOwner, aInstance,
|
||||
@ -3225,7 +3216,7 @@ nsresult nsPluginHost::NewEmbeddedPluginStream(nsIURI* aURL,
|
||||
// Called by InstantiateFullPagePlugin()
|
||||
nsresult nsPluginHost::NewFullPagePluginStream(nsIStreamListener *&aStreamListener,
|
||||
nsIURI* aURI,
|
||||
nsIPluginInstance *aInstance)
|
||||
nsNPAPIPluginInstance *aInstance)
|
||||
{
|
||||
nsPluginStreamListenerPeer *listener = new nsPluginStreamListenerPeer();
|
||||
if (!listener)
|
||||
|
@ -114,14 +114,14 @@ public:
|
||||
|
||||
nsresult
|
||||
NewPluginURLStream(const nsString& aURL,
|
||||
nsIPluginInstance *aInstance,
|
||||
nsNPAPIPluginInstance *aInstance,
|
||||
nsIPluginStreamListener *aListener,
|
||||
nsIInputStream *aPostStream = nsnull,
|
||||
const char *aHeadersData = nsnull,
|
||||
PRUint32 aHeadersDataLen = 0);
|
||||
|
||||
nsresult
|
||||
GetURLWithHeaders(nsISupports* pluginInst,
|
||||
GetURLWithHeaders(nsNPAPIPluginInstance *pluginInst,
|
||||
const char* url,
|
||||
const char* target = NULL,
|
||||
nsIPluginStreamListener* streamListener = NULL,
|
||||
@ -132,7 +132,7 @@ public:
|
||||
const char* getHeaders = NULL);
|
||||
|
||||
nsresult
|
||||
DoURLLoadSecurityCheck(nsIPluginInstance *aInstance,
|
||||
DoURLLoadSecurityCheck(nsNPAPIPluginInstance *aInstance,
|
||||
const char* aURL);
|
||||
|
||||
nsresult
|
||||
@ -185,14 +185,14 @@ private:
|
||||
|
||||
nsresult
|
||||
NewEmbeddedPluginStreamListener(nsIURI* aURL, nsIPluginInstanceOwner *aOwner,
|
||||
nsIPluginInstance* aInstance,
|
||||
nsNPAPIPluginInstance* aInstance,
|
||||
nsIStreamListener** aListener);
|
||||
|
||||
nsresult
|
||||
NewEmbeddedPluginStream(nsIURI* aURL, nsIPluginInstanceOwner *aOwner, nsIPluginInstance* aInstance);
|
||||
NewEmbeddedPluginStream(nsIURI* aURL, nsIPluginInstanceOwner *aOwner, nsNPAPIPluginInstance* aInstance);
|
||||
|
||||
nsresult
|
||||
NewFullPagePluginStream(nsIStreamListener *&aStreamListener, nsIURI* aURI, nsIPluginInstance *aInstance);
|
||||
NewFullPagePluginStream(nsIStreamListener *&aStreamListener, nsIURI* aURI, nsNPAPIPluginInstance *aInstance);
|
||||
|
||||
// Return an nsPluginTag for this type, if any. If aCheckEnabled is
|
||||
// true, only enabled plugins will be returned.
|
||||
|
@ -283,7 +283,7 @@ nsPluginStreamListenerPeer::~nsPluginStreamListenerPeer()
|
||||
|
||||
// Called as a result of GetURL and PostURL
|
||||
nsresult nsPluginStreamListenerPeer::Initialize(nsIURI *aURL,
|
||||
nsIPluginInstance *aInstance,
|
||||
nsNPAPIPluginInstance *aInstance,
|
||||
nsIPluginStreamListener* aListener,
|
||||
PRInt32 requestCount)
|
||||
{
|
||||
@ -299,7 +299,7 @@ nsresult nsPluginStreamListenerPeer::Initialize(nsIURI *aURL,
|
||||
|
||||
mURL = aURL;
|
||||
|
||||
mInstance = aInstance;
|
||||
mPluginInstance = aInstance;
|
||||
mPStreamListener = aListener;
|
||||
|
||||
mPendingRequests = requestCount;
|
||||
@ -317,7 +317,7 @@ nsresult nsPluginStreamListenerPeer::Initialize(nsIURI *aURL,
|
||||
* instance owner.
|
||||
*/
|
||||
nsresult nsPluginStreamListenerPeer::InitializeEmbedded(nsIURI *aURL,
|
||||
nsIPluginInstance* aInstance,
|
||||
nsNPAPIPluginInstance* aInstance,
|
||||
nsIPluginInstanceOwner *aOwner)
|
||||
{
|
||||
#ifdef PLUGIN_LOGGING
|
||||
@ -333,8 +333,8 @@ nsresult nsPluginStreamListenerPeer::InitializeEmbedded(nsIURI *aURL,
|
||||
mURL = aURL;
|
||||
|
||||
if (aInstance) {
|
||||
NS_ASSERTION(mInstance == nsnull, "nsPluginStreamListenerPeer::InitializeEmbedded mInstance != nsnull");
|
||||
mInstance = aInstance;
|
||||
NS_ASSERTION(mPluginInstance == nsnull, "nsPluginStreamListenerPeer::InitializeEmbedded mPluginInstance != nsnull");
|
||||
mPluginInstance = aInstance;
|
||||
} else {
|
||||
mOwner = aOwner;
|
||||
}
|
||||
@ -347,13 +347,13 @@ nsresult nsPluginStreamListenerPeer::InitializeEmbedded(nsIURI *aURL,
|
||||
}
|
||||
|
||||
// Called by NewFullPagePluginStream()
|
||||
nsresult nsPluginStreamListenerPeer::InitializeFullPage(nsIURI* aURL, nsIPluginInstance *aInstance)
|
||||
nsresult nsPluginStreamListenerPeer::InitializeFullPage(nsIURI* aURL, nsNPAPIPluginInstance *aInstance)
|
||||
{
|
||||
PLUGIN_LOG(PLUGIN_LOG_NORMAL,
|
||||
("nsPluginStreamListenerPeer::InitializeFullPage instance=%p\n",aInstance));
|
||||
|
||||
NS_ASSERTION(mInstance == nsnull, "nsPluginStreamListenerPeer::InitializeFullPage mInstance != nsnull");
|
||||
mInstance = aInstance;
|
||||
NS_ASSERTION(mPluginInstance == nsnull, "nsPluginStreamListenerPeer::InitializeFullPage mPluginInstance != nsnull");
|
||||
mPluginInstance = aInstance;
|
||||
|
||||
mURL = aURL;
|
||||
|
||||
@ -445,7 +445,7 @@ nsPluginStreamListenerPeer::SetupPluginCacheFile(nsIChannel* channel)
|
||||
// add this listenerPeer to list of stream peers for this instance
|
||||
// it'll delay release of listenerPeer until nsPluginInstanceTag::~nsPluginInstanceTag
|
||||
// and the temp file is going to stay alive until then
|
||||
nsPluginInstanceTag *instanceTag = pluginHost->FindInstanceTag(mInstance);
|
||||
nsPluginInstanceTag *instanceTag = pluginHost->FindInstanceTag(mPluginInstance);
|
||||
if (instanceTag)
|
||||
instanceTag->mStreams.AppendObject(this);
|
||||
|
||||
@ -484,8 +484,8 @@ nsPluginStreamListenerPeer::OnStartRequest(nsIRequest *request,
|
||||
|
||||
if (responseCode > 206) { // not normal
|
||||
PRBool bWantsAllNetworkStreams = PR_FALSE;
|
||||
mInstance->GetValueFromPlugin(NPPVpluginWantsAllNetworkStreams,
|
||||
(void*)&bWantsAllNetworkStreams);
|
||||
mPluginInstance->GetValueFromPlugin(NPPVpluginWantsAllNetworkStreams,
|
||||
(void*)&bWantsAllNetworkStreams);
|
||||
if (!bWantsAllNetworkStreams) {
|
||||
mRequestFailed = PR_TRUE;
|
||||
return NS_ERROR_FAILURE;
|
||||
@ -563,18 +563,20 @@ nsPluginStreamListenerPeer::OnStartRequest(nsIRequest *request,
|
||||
|
||||
NPWindow* window = nsnull;
|
||||
|
||||
// if we don't have an nsIPluginInstance (mInstance), it means
|
||||
// if we don't have an nsNPAPIPluginInstance (mPluginInstance), it means
|
||||
// we weren't able to load a plugin previously because we
|
||||
// didn't have the mimetype. Now that we do (aContentType),
|
||||
// we'll try again with SetUpPluginInstance()
|
||||
// which is called by InstantiateEmbeddedPlugin()
|
||||
// NOTE: we don't want to try again if we didn't get the MIME type this time
|
||||
|
||||
if (!mInstance && mOwner && !aContentType.IsEmpty()) {
|
||||
mOwner->GetInstance(getter_AddRefs(mInstance));
|
||||
|
||||
if (!mPluginInstance && mOwner && !aContentType.IsEmpty()) {
|
||||
nsCOMPtr<nsIPluginInstance> pluginInstCOMPtr;
|
||||
mOwner->GetInstance(getter_AddRefs(pluginInstCOMPtr));
|
||||
mPluginInstance = static_cast<nsNPAPIPluginInstance*>(pluginInstCOMPtr.get());
|
||||
|
||||
mOwner->GetWindow(window);
|
||||
if (!mInstance && window) {
|
||||
if (!mPluginInstance && window) {
|
||||
nsRefPtr<nsPluginHost> pluginHost = dont_AddRef(nsPluginHost::GetInst());
|
||||
|
||||
// determine if we need to try embedded again. FullPage takes a different code path
|
||||
@ -586,14 +588,14 @@ nsPluginStreamListenerPeer::OnStartRequest(nsIRequest *request,
|
||||
rv = pluginHost->SetUpPluginInstance(aContentType.get(), aURL, mOwner);
|
||||
|
||||
if (NS_OK == rv) {
|
||||
mOwner->GetInstance(getter_AddRefs(mInstance));
|
||||
if (mInstance) {
|
||||
mInstance->Start();
|
||||
mOwner->GetInstance(getter_AddRefs(pluginInstCOMPtr));
|
||||
mPluginInstance = static_cast<nsNPAPIPluginInstance*>(pluginInstCOMPtr.get());
|
||||
if (mPluginInstance) {
|
||||
mPluginInstance->Start();
|
||||
mOwner->CreateWidget();
|
||||
// If we've got a native window, the let the plugin know about it.
|
||||
if (window->window) {
|
||||
nsCOMPtr<nsIPluginInstance> inst = mInstance;
|
||||
((nsPluginNativeWindow*)window)->CallSetWindow(inst);
|
||||
((nsPluginNativeWindow*)window)->CallSetWindow(pluginInstCOMPtr);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -773,14 +775,14 @@ nsPluginStreamListenerPeer::SetStreamOffset(PRInt32 value)
|
||||
nsresult nsPluginStreamListenerPeer::ServeStreamAsFile(nsIRequest *request,
|
||||
nsISupports* aContext)
|
||||
{
|
||||
if (!mInstance)
|
||||
if (!mPluginInstance)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
// mInstance->Stop calls mPStreamListener->CleanUpStream(), so stream will be properly clean up
|
||||
mInstance->Stop();
|
||||
mInstance->Start();
|
||||
// mPluginInstance->Stop calls mPStreamListener->CleanUpStream(), so stream will be properly clean up
|
||||
mPluginInstance->Stop();
|
||||
mPluginInstance->Start();
|
||||
nsCOMPtr<nsIPluginInstanceOwner> owner;
|
||||
mInstance->GetOwner(getter_AddRefs(owner));
|
||||
mPluginInstance->GetOwner(getter_AddRefs(owner));
|
||||
if (owner) {
|
||||
NPWindow* window = nsnull;
|
||||
owner->GetWindow(window);
|
||||
@ -794,8 +796,8 @@ nsresult nsPluginStreamListenerPeer::ServeStreamAsFile(nsIRequest *request,
|
||||
}
|
||||
#endif
|
||||
if (window->window) {
|
||||
nsCOMPtr<nsIPluginInstance> inst = mInstance;
|
||||
((nsPluginNativeWindow*)window)->CallSetWindow(inst);
|
||||
nsCOMPtr<nsIPluginInstance> pluginInstCOMPtr = mPluginInstance.get();
|
||||
((nsPluginNativeWindow*)window)->CallSetWindow(pluginInstCOMPtr);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1067,8 +1069,8 @@ nsresult nsPluginStreamListenerPeer::SetUpStreamListener(nsIRequest *request,
|
||||
// NOTE: this should only happen when a stream was NOT created
|
||||
// with GetURL or PostURL (i.e. it's the initial stream we
|
||||
// send to the plugin as determined by the SRC or DATA attribute)
|
||||
if (!mPStreamListener && mInstance)
|
||||
rv = mInstance->NewStreamToPlugin(getter_AddRefs(mPStreamListener));
|
||||
if (!mPStreamListener && mPluginInstance)
|
||||
rv = mPluginInstance->NewStreamToPlugin(getter_AddRefs(mPStreamListener));
|
||||
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
@ -46,6 +46,7 @@
|
||||
#include "nsWeakReference.h"
|
||||
#include "nsNPAPIPluginStreamListener.h"
|
||||
#include "nsHashtable.h"
|
||||
#include "nsNPAPIPluginInstance.h"
|
||||
|
||||
class nsIChannel;
|
||||
|
||||
@ -98,21 +99,21 @@ public:
|
||||
|
||||
// Called by GetURL and PostURL (via NewStream)
|
||||
nsresult Initialize(nsIURI *aURL,
|
||||
nsIPluginInstance *aInstance,
|
||||
nsNPAPIPluginInstance *aInstance,
|
||||
nsIPluginStreamListener *aListener,
|
||||
PRInt32 requestCount = 1);
|
||||
|
||||
nsresult InitializeEmbedded(nsIURI *aURL,
|
||||
nsIPluginInstance* aInstance,
|
||||
nsNPAPIPluginInstance* aInstance,
|
||||
nsIPluginInstanceOwner *aOwner = nsnull);
|
||||
|
||||
nsresult InitializeFullPage(nsIURI* aURL, nsIPluginInstance *aInstance);
|
||||
nsresult InitializeFullPage(nsIURI* aURL, nsNPAPIPluginInstance *aInstance);
|
||||
|
||||
nsresult OnFileAvailable(nsIFile* aFile);
|
||||
|
||||
nsresult ServeStreamAsFile(nsIRequest *request, nsISupports *ctxt);
|
||||
|
||||
nsIPluginInstance *GetPluginInstance() { return mInstance; }
|
||||
nsNPAPIPluginInstance *GetPluginInstance() { return mPluginInstance; }
|
||||
|
||||
private:
|
||||
nsresult SetUpStreamListener(nsIRequest* request, nsIURI* aURL);
|
||||
@ -121,7 +122,6 @@ private:
|
||||
nsCOMPtr<nsIURI> mURL;
|
||||
nsCString mURLSpec; // Have to keep this member because GetURL hands out char*
|
||||
nsCOMPtr<nsIPluginInstanceOwner> mOwner;
|
||||
nsCOMPtr<nsIPluginInstance> mInstance;
|
||||
nsCOMPtr<nsIPluginStreamListener> mPStreamListener;
|
||||
|
||||
// Set to PR_TRUE if we request failed (like with a HTTP response of 404)
|
||||
@ -148,7 +148,7 @@ private:
|
||||
nsCString mContentType;
|
||||
PRBool mSeekable;
|
||||
PRUint32 mModified;
|
||||
nsCOMPtr<nsIPluginInstance> mPluginInstance;
|
||||
nsRefPtr<nsNPAPIPluginInstance> mPluginInstance;
|
||||
PRInt32 mStreamOffset;
|
||||
PRBool mStreamComplete;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user