Fix for bug 82415 nsIPluginStreamListener changed! r=dougt sr=attinasi a=dbaron
git-svn-id: svn://10.0.0.236/trunk@96096 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -45,6 +45,7 @@ nsplugin.h
|
||||
nsplugindefs.h
|
||||
nsICookieStorage.h
|
||||
nsIPluginStreamListener.h
|
||||
nsIPluginStreamListener2.h
|
||||
nsIPluginStreamInfo.h
|
||||
nsIPluginInputStream.h
|
||||
nsIPluginInputStream2.h
|
||||
|
||||
@@ -48,6 +48,7 @@ EXPORTS = \
|
||||
nsIPluginInputStream.h \
|
||||
nsIPluginInputStream2.h \
|
||||
nsIPluginStreamListener.h \
|
||||
nsIPluginStreamListener2.h \
|
||||
nsIPluginStreamInfo.h \
|
||||
nsplugin.h \
|
||||
nsplugindefs.h \
|
||||
|
||||
@@ -34,6 +34,7 @@ EXPORTS = \
|
||||
nsIPluginTagInfo2.h \
|
||||
nsIWindowlessPlugInstPeer.h \
|
||||
nsIPluginStreamListener.h \
|
||||
nsIPluginStreamListener2.h \
|
||||
nsIPluginStreamInfo.h \
|
||||
nsplugin.h \
|
||||
nsplugindefs.h \
|
||||
|
||||
@@ -82,7 +82,7 @@ public:
|
||||
* @return The return value is currently ignored.
|
||||
*/
|
||||
NS_IMETHOD
|
||||
OnDataAvailable(nsIPluginStreamInfo* pluginInfo, nsIInputStream* input, PRUint32 sourceOffset, PRUint32 length) = 0;
|
||||
OnDataAvailable(nsIPluginStreamInfo* pluginInfo, nsIInputStream* input, PRUint32 length) = 0;
|
||||
|
||||
NS_IMETHOD
|
||||
OnFileAvailable(nsIPluginStreamInfo* pluginInfo, const char* fileName) = 0;
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
|
||||
* This is a temporary internal interface...see bug 82415
|
||||
* XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
|
||||
|
||||
*/
|
||||
|
||||
#ifndef nsIPluginStreamListener2_h___
|
||||
#define nsIPluginStreamListener2_h___
|
||||
|
||||
#include "nsplugindefs.h"
|
||||
#include "nsISupports.h"
|
||||
#include "nsIPluginStreamListener.h"
|
||||
#include "nsIPluginStreamInfo.h"
|
||||
#include "nsIInputStream.h"
|
||||
|
||||
#define NS_IPLUGINSTREAMLISTENER2_IID \
|
||||
{ /* dfc67e80-1dd1-11b2-a6ae-f99f07cc1f63 */ \
|
||||
0xdfc67e80, \
|
||||
0x1dd1, \
|
||||
0x11b2, \
|
||||
{0xa6, 0xae, 0xf9, 0x9f, 0x07, 0xcc, 0x1f, 0x63} \
|
||||
}
|
||||
|
||||
/**
|
||||
* The nsIPluginStreamListener interface defines the minimum set of functionality that
|
||||
* the browser will support if it allows plugins. Plugins can call QueryInterface
|
||||
* to determine if a plugin manager implements more specific APIs or other
|
||||
* browser interfaces for the plugin to use (e.g. nsINetworkManager).
|
||||
*
|
||||
* This is an extended interface to allow for offset requests in OnDataAvail
|
||||
* see bugzilla 82415.
|
||||
*/
|
||||
class nsIPluginStreamListener2 : public nsIPluginStreamListener {
|
||||
public:
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IPLUGINSTREAMLISTENER2_IID)
|
||||
|
||||
/**
|
||||
* Notify the client that data is available in the input stream. This
|
||||
* method is called whenver data is written into the input stream by the
|
||||
* networking library...<BR><BR>
|
||||
*
|
||||
* @param aIStream The input stream containing the data. This stream can
|
||||
* be either a blocking or non-blocking stream.
|
||||
* @param offset location of this chunk of data from the start of the stream
|
||||
* @param length The amount of data that was just pushed into the stream.
|
||||
* @return The return value is currently ignored.
|
||||
*/
|
||||
NS_IMETHOD
|
||||
OnDataAvailable(nsIPluginStreamInfo* pluginInfo, nsIInputStream* input, PRUint32 offset, PRUint32 length) = 0;
|
||||
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#endif /* nsIPluginStreamListener2_h___ */
|
||||
@@ -45,6 +45,7 @@ static NS_DEFINE_IID(kCPluginManagerCID, NS_PLUGINMANAGER_CID);
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static NS_DEFINE_IID(kIPluginStreamListenerIID, NS_IPLUGINSTREAMLISTENER_IID);
|
||||
static NS_DEFINE_IID(kIPluginStreamListener2IID, NS_IPLUGINSTREAMLISTENER2_IID);
|
||||
|
||||
ns4xPluginStreamListener::ns4xPluginStreamListener(nsIPluginInstance* inst,
|
||||
void* notifyData)
|
||||
@@ -66,7 +67,8 @@ ns4xPluginStreamListener::~ns4xPluginStreamListener(void)
|
||||
NS_IF_RELEASE(mInst);
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS(ns4xPluginStreamListener, kIPluginStreamListenerIID);
|
||||
NS_IMPL_ISUPPORTS2(ns4xPluginStreamListener, nsIPluginStreamListener,
|
||||
nsIPluginStreamListener2);
|
||||
|
||||
NS_IMETHODIMP
|
||||
ns4xPluginStreamListener::OnStartBinding(nsIPluginStreamInfo* pluginInfo)
|
||||
@@ -144,6 +146,124 @@ ns4xPluginStreamListener::OnStartBinding(nsIPluginStreamInfo* pluginInfo)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
ns4xPluginStreamListener::OnDataAvailable(nsIPluginStreamInfo* pluginInfo,
|
||||
nsIInputStream* input,
|
||||
PRUint32 length)
|
||||
{
|
||||
if (!mInst || !mInst->IsStarted())
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
const NPPluginFuncs *callbacks = nsnull;
|
||||
NPP npp;
|
||||
|
||||
mInst->GetCallbacks(&callbacks);
|
||||
mInst->GetNPP(&npp);
|
||||
|
||||
if(!callbacks || !npp->pdata)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
PRUint32 numtowrite = 0;
|
||||
PRUint32 amountRead = 0;
|
||||
PRInt32 writeCount = 0;
|
||||
PRUint32 leftToRead = 0; // just in case OnDataaAvail tries to overflow our buffer
|
||||
PRBool createdHere = PR_FALSE; // we did malloc in locally, so we must free locally
|
||||
|
||||
pluginInfo->GetURL(&mNPStream.url);
|
||||
pluginInfo->GetLastModified((PRUint32*)&(mNPStream.lastmodified));
|
||||
|
||||
if (callbacks->write == nsnull || length == 0)
|
||||
return NS_OK; // XXX ?
|
||||
|
||||
if (nsnull == mStreamBuffer)
|
||||
{
|
||||
// create the buffer here because we failed in OnStartBinding
|
||||
// XXX why don't we always get an OnStartBinding? This will protect us.
|
||||
mStreamBuffer = (char*) PR_Malloc(length);
|
||||
if (!mStreamBuffer)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
createdHere = PR_TRUE;
|
||||
}
|
||||
|
||||
if (length > MAX_PLUGIN_NECKO_BUFFER) // what if Necko gives us a lot of data?
|
||||
{
|
||||
leftToRead = length - MAX_PLUGIN_NECKO_BUFFER; // break it up
|
||||
length = MAX_PLUGIN_NECKO_BUFFER;
|
||||
}
|
||||
nsresult rv = input->Read(mStreamBuffer, length, &amountRead);
|
||||
if (NS_FAILED(rv))
|
||||
goto error;
|
||||
|
||||
// amountRead tells us how many bytes were put in the buffer
|
||||
// WriteReady returns to us how many bytes the plugin is
|
||||
// ready to handle - we have to keep calling WriteReady and
|
||||
// Write until the buffer is empty
|
||||
while (amountRead > 0)
|
||||
{
|
||||
if (callbacks->writeready != NULL)
|
||||
{
|
||||
PRLibrary* lib = nsnull;
|
||||
PRBool started = PR_FALSE;
|
||||
lib = mInst->fLibrary;
|
||||
|
||||
NS_TRY_SAFE_CALL_RETURN(numtowrite, CallNPP_WriteReadyProc(callbacks->writeready,
|
||||
npp,
|
||||
&mNPStream), lib);
|
||||
|
||||
// if WriteReady returned 0, the plugin is not ready to handle
|
||||
// the data, return FAILURE for now
|
||||
if (numtowrite <= 0) {
|
||||
rv = NS_ERROR_FAILURE;
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (numtowrite > amountRead)
|
||||
numtowrite = amountRead;
|
||||
}
|
||||
else
|
||||
{
|
||||
// if WriteReady is not supported by the plugin,
|
||||
// just write the whole buffer
|
||||
numtowrite = length;
|
||||
}
|
||||
|
||||
if (numtowrite > 0)
|
||||
{
|
||||
PRLibrary* lib = mInst->fLibrary;
|
||||
|
||||
NS_TRY_SAFE_CALL_RETURN(writeCount, CallNPP_WriteProc(callbacks->write,
|
||||
npp,
|
||||
&mNPStream,
|
||||
mPosition,
|
||||
numtowrite,
|
||||
(void *)mStreamBuffer), lib);
|
||||
if (writeCount < 0) {
|
||||
rv = NS_ERROR_FAILURE;
|
||||
goto error;
|
||||
}
|
||||
|
||||
amountRead -= numtowrite;
|
||||
mPosition += numtowrite;
|
||||
}
|
||||
}
|
||||
|
||||
rv = NS_OK;
|
||||
|
||||
error:
|
||||
if (PR_TRUE == createdHere) // cleanup buffer if we made it locally
|
||||
{
|
||||
PR_Free(mStreamBuffer);
|
||||
mStreamBuffer=nsnull;
|
||||
}
|
||||
|
||||
if (leftToRead > 0) // if we have more to read in this pass, do it recursivly
|
||||
{
|
||||
OnDataAvailable(pluginInfo, input, leftToRead);
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
ns4xPluginStreamListener::OnDataAvailable(nsIPluginStreamInfo* pluginInfo,
|
||||
nsIInputStream* input,
|
||||
|
||||
@@ -23,12 +23,12 @@
|
||||
#ifndef ns4xPluginStreamListener_h__
|
||||
#define ns4xPluginStreamListener_h__
|
||||
|
||||
#include "nsIPluginStreamListener.h"
|
||||
#include "nsIPluginStreamListener2.h"
|
||||
#include "nsIPluginStreamInfo.h"
|
||||
|
||||
#define MAX_PLUGIN_NECKO_BUFFER 16384
|
||||
|
||||
class ns4xPluginStreamListener : public nsIPluginStreamListener
|
||||
class ns4xPluginStreamListener : public nsIPluginStreamListener2
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
@@ -40,6 +40,10 @@ public:
|
||||
NS_IMETHOD OnStopBinding(nsIPluginStreamInfo* pluginInfo, nsresult status);
|
||||
NS_IMETHOD GetStreamType(nsPluginStreamType *result);
|
||||
|
||||
NS_IMETHOD OnDataAvailable(nsIPluginStreamInfo* pluginInfo,
|
||||
nsIInputStream* input,
|
||||
PRUint32 length);
|
||||
|
||||
// ns4xPluginStreamListener specific methods:
|
||||
ns4xPluginStreamListener(nsIPluginInstance* inst, void* notifyData);
|
||||
virtual ~ns4xPluginStreamListener();
|
||||
|
||||
@@ -41,6 +41,7 @@
|
||||
#include "nsIStreamListener.h"
|
||||
#include "nsIInputStream.h"
|
||||
#include "nsIOutputStream.h"
|
||||
#include "nsIPluginStreamListener2.h"
|
||||
#include "nsIURL.h"
|
||||
#include "nsXPIDLString.h"
|
||||
#include "nsIPref.h"
|
||||
@@ -1095,7 +1096,7 @@ nsPluginStreamInfo::MakeByteRangeString(nsByteRange* aRangeList, char** rangeReq
|
||||
|
||||
// XXX needs to be fixed for negative offsets
|
||||
nsCString firstbyte; firstbyte.AppendInt(range->offset);
|
||||
nsCString lastbyte; firstbyte.AppendInt(range->offset + range->length - 1);
|
||||
nsCString lastbyte; lastbyte.AppendInt(range->offset + range->length - 1);
|
||||
|
||||
PL_strcat(string, firstbyte.get());
|
||||
PL_strcat(string, "-");
|
||||
@@ -1113,7 +1114,6 @@ nsPluginStreamInfo::MakeByteRangeString(nsByteRange* aRangeList, char** rangeReq
|
||||
|
||||
*rangeRequest = string;
|
||||
*numRequests = requestCnt;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1704,10 +1704,16 @@ NS_IMETHODIMP nsPluginStreamListenerPeer::OnDataAvailable(nsIRequest *request,
|
||||
mDataForwardToRequest->Put(&key, (void*) (amtForwardToPlugin+aLength));
|
||||
}
|
||||
|
||||
rv = mPStreamListener->OnDataAvailable((nsIPluginStreamInfo*)mPluginStreamInfo,
|
||||
nsCOMPtr<nsIPluginStreamListener2> PStreamListener2 = do_QueryInterface(mPStreamListener);
|
||||
if (PStreamListener2)
|
||||
rv = PStreamListener2->OnDataAvailable((nsIPluginStreamInfo*)mPluginStreamInfo,
|
||||
aIStream,
|
||||
absoluteOffset+amtForwardToPlugin,
|
||||
aLength);
|
||||
else
|
||||
rv = mPStreamListener->OnDataAvailable((nsIPluginStreamInfo*)mPluginStreamInfo,
|
||||
aIStream,
|
||||
aLength);
|
||||
|
||||
// if a plugin returns an error, the peer must kill the stream
|
||||
// else the stream and PluginStreamListener leak
|
||||
@@ -1887,6 +1893,11 @@ nsresult nsPluginStreamListenerPeer::SetUpStreamListener(nsIRequest *request,
|
||||
{
|
||||
if (0 == PL_strcmp(range.get(), "bytes"))
|
||||
bSeekable = PR_TRUE;
|
||||
/* XXX FIX-ME (see Bug 83183)
|
||||
This is a hack to keep byte range request streams open but it casues a leak.
|
||||
A good place to release would probablybe when the instance is stopped.
|
||||
*/
|
||||
NS_ADDREF(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -45,6 +45,7 @@ static NS_DEFINE_IID(kCPluginManagerCID, NS_PLUGINMANAGER_CID);
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static NS_DEFINE_IID(kIPluginStreamListenerIID, NS_IPLUGINSTREAMLISTENER_IID);
|
||||
static NS_DEFINE_IID(kIPluginStreamListener2IID, NS_IPLUGINSTREAMLISTENER2_IID);
|
||||
|
||||
ns4xPluginStreamListener::ns4xPluginStreamListener(nsIPluginInstance* inst,
|
||||
void* notifyData)
|
||||
@@ -66,7 +67,8 @@ ns4xPluginStreamListener::~ns4xPluginStreamListener(void)
|
||||
NS_IF_RELEASE(mInst);
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS(ns4xPluginStreamListener, kIPluginStreamListenerIID);
|
||||
NS_IMPL_ISUPPORTS2(ns4xPluginStreamListener, nsIPluginStreamListener,
|
||||
nsIPluginStreamListener2);
|
||||
|
||||
NS_IMETHODIMP
|
||||
ns4xPluginStreamListener::OnStartBinding(nsIPluginStreamInfo* pluginInfo)
|
||||
@@ -144,6 +146,124 @@ ns4xPluginStreamListener::OnStartBinding(nsIPluginStreamInfo* pluginInfo)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
ns4xPluginStreamListener::OnDataAvailable(nsIPluginStreamInfo* pluginInfo,
|
||||
nsIInputStream* input,
|
||||
PRUint32 length)
|
||||
{
|
||||
if (!mInst || !mInst->IsStarted())
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
const NPPluginFuncs *callbacks = nsnull;
|
||||
NPP npp;
|
||||
|
||||
mInst->GetCallbacks(&callbacks);
|
||||
mInst->GetNPP(&npp);
|
||||
|
||||
if(!callbacks || !npp->pdata)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
PRUint32 numtowrite = 0;
|
||||
PRUint32 amountRead = 0;
|
||||
PRInt32 writeCount = 0;
|
||||
PRUint32 leftToRead = 0; // just in case OnDataaAvail tries to overflow our buffer
|
||||
PRBool createdHere = PR_FALSE; // we did malloc in locally, so we must free locally
|
||||
|
||||
pluginInfo->GetURL(&mNPStream.url);
|
||||
pluginInfo->GetLastModified((PRUint32*)&(mNPStream.lastmodified));
|
||||
|
||||
if (callbacks->write == nsnull || length == 0)
|
||||
return NS_OK; // XXX ?
|
||||
|
||||
if (nsnull == mStreamBuffer)
|
||||
{
|
||||
// create the buffer here because we failed in OnStartBinding
|
||||
// XXX why don't we always get an OnStartBinding? This will protect us.
|
||||
mStreamBuffer = (char*) PR_Malloc(length);
|
||||
if (!mStreamBuffer)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
createdHere = PR_TRUE;
|
||||
}
|
||||
|
||||
if (length > MAX_PLUGIN_NECKO_BUFFER) // what if Necko gives us a lot of data?
|
||||
{
|
||||
leftToRead = length - MAX_PLUGIN_NECKO_BUFFER; // break it up
|
||||
length = MAX_PLUGIN_NECKO_BUFFER;
|
||||
}
|
||||
nsresult rv = input->Read(mStreamBuffer, length, &amountRead);
|
||||
if (NS_FAILED(rv))
|
||||
goto error;
|
||||
|
||||
// amountRead tells us how many bytes were put in the buffer
|
||||
// WriteReady returns to us how many bytes the plugin is
|
||||
// ready to handle - we have to keep calling WriteReady and
|
||||
// Write until the buffer is empty
|
||||
while (amountRead > 0)
|
||||
{
|
||||
if (callbacks->writeready != NULL)
|
||||
{
|
||||
PRLibrary* lib = nsnull;
|
||||
PRBool started = PR_FALSE;
|
||||
lib = mInst->fLibrary;
|
||||
|
||||
NS_TRY_SAFE_CALL_RETURN(numtowrite, CallNPP_WriteReadyProc(callbacks->writeready,
|
||||
npp,
|
||||
&mNPStream), lib);
|
||||
|
||||
// if WriteReady returned 0, the plugin is not ready to handle
|
||||
// the data, return FAILURE for now
|
||||
if (numtowrite <= 0) {
|
||||
rv = NS_ERROR_FAILURE;
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (numtowrite > amountRead)
|
||||
numtowrite = amountRead;
|
||||
}
|
||||
else
|
||||
{
|
||||
// if WriteReady is not supported by the plugin,
|
||||
// just write the whole buffer
|
||||
numtowrite = length;
|
||||
}
|
||||
|
||||
if (numtowrite > 0)
|
||||
{
|
||||
PRLibrary* lib = mInst->fLibrary;
|
||||
|
||||
NS_TRY_SAFE_CALL_RETURN(writeCount, CallNPP_WriteProc(callbacks->write,
|
||||
npp,
|
||||
&mNPStream,
|
||||
mPosition,
|
||||
numtowrite,
|
||||
(void *)mStreamBuffer), lib);
|
||||
if (writeCount < 0) {
|
||||
rv = NS_ERROR_FAILURE;
|
||||
goto error;
|
||||
}
|
||||
|
||||
amountRead -= numtowrite;
|
||||
mPosition += numtowrite;
|
||||
}
|
||||
}
|
||||
|
||||
rv = NS_OK;
|
||||
|
||||
error:
|
||||
if (PR_TRUE == createdHere) // cleanup buffer if we made it locally
|
||||
{
|
||||
PR_Free(mStreamBuffer);
|
||||
mStreamBuffer=nsnull;
|
||||
}
|
||||
|
||||
if (leftToRead > 0) // if we have more to read in this pass, do it recursivly
|
||||
{
|
||||
OnDataAvailable(pluginInfo, input, leftToRead);
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
ns4xPluginStreamListener::OnDataAvailable(nsIPluginStreamInfo* pluginInfo,
|
||||
nsIInputStream* input,
|
||||
|
||||
@@ -23,12 +23,12 @@
|
||||
#ifndef ns4xPluginStreamListener_h__
|
||||
#define ns4xPluginStreamListener_h__
|
||||
|
||||
#include "nsIPluginStreamListener.h"
|
||||
#include "nsIPluginStreamListener2.h"
|
||||
#include "nsIPluginStreamInfo.h"
|
||||
|
||||
#define MAX_PLUGIN_NECKO_BUFFER 16384
|
||||
|
||||
class ns4xPluginStreamListener : public nsIPluginStreamListener
|
||||
class ns4xPluginStreamListener : public nsIPluginStreamListener2
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
@@ -40,6 +40,10 @@ public:
|
||||
NS_IMETHOD OnStopBinding(nsIPluginStreamInfo* pluginInfo, nsresult status);
|
||||
NS_IMETHOD GetStreamType(nsPluginStreamType *result);
|
||||
|
||||
NS_IMETHOD OnDataAvailable(nsIPluginStreamInfo* pluginInfo,
|
||||
nsIInputStream* input,
|
||||
PRUint32 length);
|
||||
|
||||
// ns4xPluginStreamListener specific methods:
|
||||
ns4xPluginStreamListener(nsIPluginInstance* inst, void* notifyData);
|
||||
virtual ~ns4xPluginStreamListener();
|
||||
|
||||
@@ -41,6 +41,7 @@
|
||||
#include "nsIStreamListener.h"
|
||||
#include "nsIInputStream.h"
|
||||
#include "nsIOutputStream.h"
|
||||
#include "nsIPluginStreamListener2.h"
|
||||
#include "nsIURL.h"
|
||||
#include "nsXPIDLString.h"
|
||||
#include "nsIPref.h"
|
||||
@@ -1095,7 +1096,7 @@ nsPluginStreamInfo::MakeByteRangeString(nsByteRange* aRangeList, char** rangeReq
|
||||
|
||||
// XXX needs to be fixed for negative offsets
|
||||
nsCString firstbyte; firstbyte.AppendInt(range->offset);
|
||||
nsCString lastbyte; firstbyte.AppendInt(range->offset + range->length - 1);
|
||||
nsCString lastbyte; lastbyte.AppendInt(range->offset + range->length - 1);
|
||||
|
||||
PL_strcat(string, firstbyte.get());
|
||||
PL_strcat(string, "-");
|
||||
@@ -1113,7 +1114,6 @@ nsPluginStreamInfo::MakeByteRangeString(nsByteRange* aRangeList, char** rangeReq
|
||||
|
||||
*rangeRequest = string;
|
||||
*numRequests = requestCnt;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1704,10 +1704,16 @@ NS_IMETHODIMP nsPluginStreamListenerPeer::OnDataAvailable(nsIRequest *request,
|
||||
mDataForwardToRequest->Put(&key, (void*) (amtForwardToPlugin+aLength));
|
||||
}
|
||||
|
||||
rv = mPStreamListener->OnDataAvailable((nsIPluginStreamInfo*)mPluginStreamInfo,
|
||||
nsCOMPtr<nsIPluginStreamListener2> PStreamListener2 = do_QueryInterface(mPStreamListener);
|
||||
if (PStreamListener2)
|
||||
rv = PStreamListener2->OnDataAvailable((nsIPluginStreamInfo*)mPluginStreamInfo,
|
||||
aIStream,
|
||||
absoluteOffset+amtForwardToPlugin,
|
||||
aLength);
|
||||
else
|
||||
rv = mPStreamListener->OnDataAvailable((nsIPluginStreamInfo*)mPluginStreamInfo,
|
||||
aIStream,
|
||||
aLength);
|
||||
|
||||
// if a plugin returns an error, the peer must kill the stream
|
||||
// else the stream and PluginStreamListener leak
|
||||
@@ -1887,6 +1893,11 @@ nsresult nsPluginStreamListenerPeer::SetUpStreamListener(nsIRequest *request,
|
||||
{
|
||||
if (0 == PL_strcmp(range.get(), "bytes"))
|
||||
bSeekable = PR_TRUE;
|
||||
/* XXX FIX-ME (see Bug 83183)
|
||||
This is a hack to keep byte range request streams open but it casues a leak.
|
||||
A good place to release would probablybe when the instance is stopped.
|
||||
*/
|
||||
NS_ADDREF(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -45,6 +45,7 @@ nsplugin.h
|
||||
nsplugindefs.h
|
||||
nsICookieStorage.h
|
||||
nsIPluginStreamListener.h
|
||||
nsIPluginStreamListener2.h
|
||||
nsIPluginStreamInfo.h
|
||||
nsIPluginInputStream.h
|
||||
nsIPluginInputStream2.h
|
||||
|
||||
@@ -48,6 +48,7 @@ EXPORTS = \
|
||||
nsIPluginInputStream.h \
|
||||
nsIPluginInputStream2.h \
|
||||
nsIPluginStreamListener.h \
|
||||
nsIPluginStreamListener2.h \
|
||||
nsIPluginStreamInfo.h \
|
||||
nsplugin.h \
|
||||
nsplugindefs.h \
|
||||
|
||||
@@ -34,6 +34,7 @@ EXPORTS = \
|
||||
nsIPluginTagInfo2.h \
|
||||
nsIWindowlessPlugInstPeer.h \
|
||||
nsIPluginStreamListener.h \
|
||||
nsIPluginStreamListener2.h \
|
||||
nsIPluginStreamInfo.h \
|
||||
nsplugin.h \
|
||||
nsplugindefs.h \
|
||||
|
||||
@@ -82,7 +82,7 @@ public:
|
||||
* @return The return value is currently ignored.
|
||||
*/
|
||||
NS_IMETHOD
|
||||
OnDataAvailable(nsIPluginStreamInfo* pluginInfo, nsIInputStream* input, PRUint32 sourceOffset, PRUint32 length) = 0;
|
||||
OnDataAvailable(nsIPluginStreamInfo* pluginInfo, nsIInputStream* input, PRUint32 length) = 0;
|
||||
|
||||
NS_IMETHOD
|
||||
OnFileAvailable(nsIPluginStreamInfo* pluginInfo, const char* fileName) = 0;
|
||||
|
||||
76
mozilla/modules/plugin/public/nsIPluginStreamListener2.h
Normal file
76
mozilla/modules/plugin/public/nsIPluginStreamListener2.h
Normal file
@@ -0,0 +1,76 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
|
||||
* This is a temporary internal interface...see bug 82415
|
||||
* XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
|
||||
|
||||
*/
|
||||
|
||||
#ifndef nsIPluginStreamListener2_h___
|
||||
#define nsIPluginStreamListener2_h___
|
||||
|
||||
#include "nsplugindefs.h"
|
||||
#include "nsISupports.h"
|
||||
#include "nsIPluginStreamListener.h"
|
||||
#include "nsIPluginStreamInfo.h"
|
||||
#include "nsIInputStream.h"
|
||||
|
||||
#define NS_IPLUGINSTREAMLISTENER2_IID \
|
||||
{ /* dfc67e80-1dd1-11b2-a6ae-f99f07cc1f63 */ \
|
||||
0xdfc67e80, \
|
||||
0x1dd1, \
|
||||
0x11b2, \
|
||||
{0xa6, 0xae, 0xf9, 0x9f, 0x07, 0xcc, 0x1f, 0x63} \
|
||||
}
|
||||
|
||||
/**
|
||||
* The nsIPluginStreamListener interface defines the minimum set of functionality that
|
||||
* the browser will support if it allows plugins. Plugins can call QueryInterface
|
||||
* to determine if a plugin manager implements more specific APIs or other
|
||||
* browser interfaces for the plugin to use (e.g. nsINetworkManager).
|
||||
*
|
||||
* This is an extended interface to allow for offset requests in OnDataAvail
|
||||
* see bugzilla 82415.
|
||||
*/
|
||||
class nsIPluginStreamListener2 : public nsIPluginStreamListener {
|
||||
public:
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IPLUGINSTREAMLISTENER2_IID)
|
||||
|
||||
/**
|
||||
* Notify the client that data is available in the input stream. This
|
||||
* method is called whenver data is written into the input stream by the
|
||||
* networking library...<BR><BR>
|
||||
*
|
||||
* @param aIStream The input stream containing the data. This stream can
|
||||
* be either a blocking or non-blocking stream.
|
||||
* @param offset location of this chunk of data from the start of the stream
|
||||
* @param length The amount of data that was just pushed into the stream.
|
||||
* @return The return value is currently ignored.
|
||||
*/
|
||||
NS_IMETHOD
|
||||
OnDataAvailable(nsIPluginStreamInfo* pluginInfo, nsIInputStream* input, PRUint32 offset, PRUint32 length) = 0;
|
||||
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#endif /* nsIPluginStreamListener2_h___ */
|
||||
@@ -322,7 +322,6 @@ public:
|
||||
NS_IMETHOD
|
||||
OnDataAvailable(nsIPluginStreamInfo* pluginInfo,
|
||||
nsIInputStream* input,
|
||||
PRUint32 sourceOffset,
|
||||
PRUint32 length);
|
||||
|
||||
NS_IMETHOD
|
||||
@@ -828,7 +827,6 @@ SimplePluginStreamListener::OnStartBinding(nsIPluginStreamInfo* pluginInfo)
|
||||
NS_METHOD
|
||||
SimplePluginStreamListener::OnDataAvailable(nsIPluginStreamInfo* pluginInfo,
|
||||
nsIInputStream* input,
|
||||
PRUint32 sourceOffset,
|
||||
PRUint32 length)
|
||||
{
|
||||
#ifdef NS_DEBUG
|
||||
|
||||
@@ -322,7 +322,6 @@ public:
|
||||
NS_IMETHOD
|
||||
OnDataAvailable(nsIPluginStreamInfo* pluginInfo,
|
||||
nsIInputStream* input,
|
||||
PRUint32 sourceOffset,
|
||||
PRUint32 length);
|
||||
|
||||
NS_IMETHOD
|
||||
@@ -828,7 +827,6 @@ SimplePluginStreamListener::OnStartBinding(nsIPluginStreamInfo* pluginInfo)
|
||||
NS_METHOD
|
||||
SimplePluginStreamListener::OnDataAvailable(nsIPluginStreamInfo* pluginInfo,
|
||||
nsIInputStream* input,
|
||||
PRUint32 sourceOffset,
|
||||
PRUint32 length)
|
||||
{
|
||||
#ifdef NS_DEBUG
|
||||
|
||||
Reference in New Issue
Block a user