Revert bug 634534 because of test failures (test_visibility.html timing out, and neverending.sjs data leaking into other plugin tests?)

This commit is contained in:
Benjamin Smedberg 2011-02-23 16:04:35 -05:00
parent b70550d556
commit 7c6b002c22
9 changed files with 46 additions and 230 deletions

View File

@ -361,7 +361,7 @@ nsNPAPIPluginStreamListener::OnStartBinding(nsIPluginStreamInfo* pluginInfo)
return NS_OK;
}
void
nsresult
nsNPAPIPluginStreamListener::SuspendRequest()
{
NS_ASSERTION(!mIsSuspended,
@ -369,18 +369,19 @@ nsNPAPIPluginStreamListener::SuspendRequest()
nsCOMPtr<nsINPAPIPluginStreamInfo> pluginInfoNPAPI =
do_QueryInterface(mStreamInfo);
nsIRequest *request;
if (!pluginInfoNPAPI) {
return;
if (!pluginInfoNPAPI || !(request = pluginInfoNPAPI->GetRequest())) {
NS_ERROR("Trying to suspend a non-suspendable stream!");
return NS_ERROR_FAILURE;
}
nsresult rv = StartDataPump();
if (NS_FAILED(rv))
return;
NS_ENSURE_SUCCESS(rv, rv);
mIsSuspended = PR_TRUE;
pluginInfoNPAPI->SuspendRequests();
return request->Suspend();
}
void
@ -389,7 +390,11 @@ nsNPAPIPluginStreamListener::ResumeRequest()
nsCOMPtr<nsINPAPIPluginStreamInfo> pluginInfoNPAPI =
do_QueryInterface(mStreamInfo);
pluginInfoNPAPI->ResumeRequests();
nsIRequest *request = pluginInfoNPAPI->GetRequest();
// request can be null if the network stream is done.
if (request)
request->Resume();
mIsSuspended = PR_FALSE;
}
@ -604,7 +609,7 @@ nsNPAPIPluginStreamListener::OnDataAvailable(nsIPluginStreamInfo* pluginInfo,
if (numtowrite <= 0 ||
(!mIsPluginInitJSStream && PluginInitJSLoadInProgress())) {
if (!mIsSuspended) {
SuspendRequest();
rv = SuspendRequest();
}
// Break out of the inner loop, but keep going through the
@ -671,7 +676,7 @@ nsNPAPIPluginStreamListener::OnDataAvailable(nsIPluginStreamInfo* pluginInfo,
// resume the request.
if (mIsSuspended || ++zeroBytesWriteCount == 3) {
if (!mIsSuspended) {
SuspendRequest();
rv = SuspendRequest();
}
// Break out of the for loop, but keep going through the
@ -753,8 +758,9 @@ nsNPAPIPluginStreamListener::OnStopBinding(nsIPluginStreamInfo* pluginInfo,
nsCOMPtr<nsINPAPIPluginStreamInfo> pluginInfoNPAPI =
do_QueryInterface(mStreamInfo);
if (pluginInfoNPAPI) {
pluginInfoNPAPI->CancelRequests(status);
nsIRequest *request;
if (pluginInfoNPAPI && (request = pluginInfoNPAPI->GetRequest())) {
request->Cancel(status);
}
}

View File

@ -45,7 +45,7 @@
#include "nsIRequest.h"
#include "nsITimer.h"
#include "nsAutoPtr.h"
#include "nsCOMArray.h"
#include "nsCOMPtr.h"
#include "nsIOutputStream.h"
#include "nsIPluginInstanceOwner.h"
#include "nsString.h"
@ -69,48 +69,13 @@ class nsINPAPIPluginStreamInfo : public nsIPluginStreamInfo
public:
NS_DECLARE_STATIC_IID_ACCESSOR(NS_INPAPIPLUGINSTREAMINFO_IID)
void TrackRequest(nsIRequest* request)
nsIRequest *GetRequest()
{
mRequests.AppendObject(request);
}
void ReplaceRequest(nsIRequest* oldRequest, nsIRequest* newRequest)
{
PRInt32 i = mRequests.IndexOfObject(oldRequest);
if (i == -1) {
NS_ASSERTION(mRequests.Count() == 0,
"Only our initial stream should be unknown!");
mRequests.AppendObject(oldRequest);
}
else {
mRequests.ReplaceObjectAt(newRequest, i);
}
}
void CancelRequests(nsresult status)
{
// Copy the array to avoid modification during the loop.
nsCOMArray<nsIRequest> requestsCopy(mRequests);
for (PRInt32 i = 0; i < requestsCopy.Count(); ++i)
requestsCopy[i]->Cancel(status);
}
void SuspendRequests() {
nsCOMArray<nsIRequest> requestsCopy(mRequests);
for (PRInt32 i = 0; i < requestsCopy.Count(); ++i)
requestsCopy[i]->Suspend();
}
void ResumeRequests() {
nsCOMArray<nsIRequest> requestsCopy(mRequests);
for (PRInt32 i = 0; i < requestsCopy.Count(); ++i)
requestsCopy[i]->Resume();
return mRequest;
}
protected:
friend class nsPluginByteRangeStreamListener;
nsCOMArray<nsIRequest> mRequests;
nsCOMPtr<nsIRequest> mRequest;
};
NS_DEFINE_STATIC_IID_ACCESSOR(nsINPAPIPluginStreamInfo,
@ -156,7 +121,7 @@ public:
nsresult CleanUpStream(NPReason reason);
void CallURLNotify(NPReason reason);
void SetCallNotify(PRBool aCallNotify) { mCallNotify = aCallNotify; }
void SuspendRequest();
nsresult SuspendRequest();
void ResumeRequest();
nsresult StartDataPump();
void StopDataPump();

View File

@ -3341,8 +3341,6 @@ nsresult nsPluginHost::NewPluginURLStream(const nsString& aURL,
rv = AddHeadersToChannel(aHeadersData, aHeadersDataLen, httpChannel);
}
rv = channel->AsyncOpen(listenerPeer, nsnull);
if (NS_SUCCEEDED(rv))
listenerPeer->TrackRequest(channel);
return rv;
}

View File

@ -51,7 +51,6 @@
#include "nsIURI.h"
#include "nsPluginHost.h"
#include "nsIByteRangeRequest.h"
#include "nsIMultiPartChannel.h"
#include "nsIInputStreamTee.h"
#include "nsPrintfCString.h"
#include "nsIContentUtils.h"
@ -63,10 +62,7 @@
// nsPluginByteRangeStreamListener
class nsPluginByteRangeStreamListener
: public nsIStreamListener
, public nsIInterfaceRequestor
{
class nsPluginByteRangeStreamListener : public nsIStreamListener {
public:
nsPluginByteRangeStreamListener(nsIWeakReference* aWeakPtr);
virtual ~nsPluginByteRangeStreamListener();
@ -74,7 +70,6 @@ public:
NS_DECL_ISUPPORTS
NS_DECL_NSIREQUESTOBSERVER
NS_DECL_NSISTREAMLISTENER
NS_DECL_NSIINTERFACEREQUESTOR
private:
nsCOMPtr<nsIStreamListener> mStreamConverter;
@ -82,11 +77,7 @@ private:
PRBool mRemoveMagicNumber;
};
NS_IMPL_ISUPPORTS3(nsPluginByteRangeStreamListener,
nsIRequestObserver,
nsIStreamListener,
nsIInterfaceRequestor)
NS_IMPL_ISUPPORTS1(nsPluginByteRangeStreamListener, nsIStreamListener)
nsPluginByteRangeStreamListener::nsPluginByteRangeStreamListener(nsIWeakReference* aWeakPtr)
{
mWeakPtrPluginStreamListenerPeer = aWeakPtr;
@ -99,22 +90,6 @@ nsPluginByteRangeStreamListener::~nsPluginByteRangeStreamListener()
mWeakPtrPluginStreamListenerPeer = 0;
}
/**
* Unwrap any byte-range requests so that we can check whether the base channel
* is being tracked properly.
*/
static nsCOMPtr<nsIRequest>
GetBaseRequest(nsIRequest* r)
{
nsCOMPtr<nsIMultiPartChannel> mp = do_QueryInterface(r);
if (!mp)
return r;
nsCOMPtr<nsIChannel> base;
mp->GetBaseChannel(getter_AddRefs(base));
return already_AddRefed<nsIRequest>(base.forget());
}
NS_IMETHODIMP
nsPluginByteRangeStreamListener::OnStartRequest(nsIRequest *request, nsISupports *ctxt)
{
@ -124,12 +99,6 @@ nsPluginByteRangeStreamListener::OnStartRequest(nsIRequest *request, nsISupports
if (!finalStreamListener)
return NS_ERROR_FAILURE;
nsPluginStreamListenerPeer *pslp =
static_cast<nsPluginStreamListenerPeer*>(finalStreamListener.get());
NS_ASSERTION(pslp->mRequests.IndexOfObject(GetBaseRequest(request)) != -1,
"Untracked byte-range request?");
nsCOMPtr<nsIStreamConverterService> serv = do_GetService(NS_STREAMCONVERTERSERVICE_CONTRACTID, &rv);
if (NS_SUCCEEDED(rv)) {
rv = serv->AsyncConvertData(MULTIPART_BYTERANGES,
@ -156,6 +125,10 @@ nsPluginByteRangeStreamListener::OnStartRequest(nsIRequest *request, nsISupports
return NS_ERROR_FAILURE;
}
// get nsPluginStreamListenerPeer* ptr from finalStreamListener
nsPluginStreamListenerPeer *pslp =
reinterpret_cast<nsPluginStreamListenerPeer*>(finalStreamListener.get());
if (responseCode != 200) {
PRBool bWantsAllNetworkStreams = PR_FALSE;
pslp->GetPluginInstance()->
@ -186,13 +159,6 @@ nsPluginByteRangeStreamListener::OnStopRequest(nsIRequest *request, nsISupports
if (!finalStreamListener)
return NS_ERROR_FAILURE;
nsPluginStreamListenerPeer *pslp =
static_cast<nsPluginStreamListenerPeer*>(finalStreamListener.get());
PRBool found = pslp->mRequests.RemoveObject(request);
if (!found) {
NS_ERROR("OnStopRequest received for untracked byte-range request!");
}
if (mRemoveMagicNumber) {
// remove magic number from container
nsCOMPtr<nsISupportsPRUint32> container = do_QueryInterface(ctxt);
@ -256,18 +222,6 @@ nsPluginByteRangeStreamListener::OnDataAvailable(nsIRequest *request, nsISupport
return mStreamConverter->OnDataAvailable(request, ctxt, inStr, sourceOffset, count);
}
NS_IMETHODIMP
nsPluginByteRangeStreamListener::GetInterface(const nsIID& aIID, void** result)
{
// Forward interface requests to our parent
nsCOMPtr<nsIInterfaceRequestor> finalStreamListener = do_QueryReferent(mWeakPtrPluginStreamListenerPeer);
if (!finalStreamListener)
return NS_ERROR_FAILURE;
return finalStreamListener->GetInterface(aIID, result);
}
// nsPRUintKey
class nsPRUintKey : public nsHashKey {
@ -343,7 +297,8 @@ nsPluginStreamListenerPeer::~nsPluginStreamListenerPeer()
// Called as a result of GetURL and PostURL
nsresult nsPluginStreamListenerPeer::Initialize(nsIURI *aURL,
nsNPAPIPluginInstance *aInstance,
nsIPluginStreamListener* aListener)
nsIPluginStreamListener* aListener,
PRInt32 requestCount)
{
#ifdef PLUGIN_LOGGING
nsCAutoString urlSpec;
@ -362,7 +317,7 @@ nsresult nsPluginStreamListenerPeer::Initialize(nsIURI *aURL,
mPStreamListener = static_cast<nsNPAPIPluginStreamListener*>(aListener);
mPStreamListener->SetStreamListenerPeer(this);
mPendingRequests = 1;
mPendingRequests = requestCount;
mDataForwardToRequest = new nsHashtable(16, PR_FALSE);
if (!mDataForwardToRequest)
@ -517,12 +472,6 @@ nsPluginStreamListenerPeer::OnStartRequest(nsIRequest *request,
{
nsresult rv = NS_OK;
if (mRequests.IndexOfObject(GetBaseRequest(request)) == -1) {
NS_ASSERTION(mRequests.Count() == 0,
"Only our initial stream should be unknown!");
TrackRequest(request);
}
if (mHaveFiredOnStartRequest) {
return NS_OK;
}
@ -601,6 +550,8 @@ nsPluginStreamListenerPeer::OnStartRequest(nsIRequest *request,
mLength = length;
}
mRequest = request;
nsCAutoString aContentType; // XXX but we already got the type above!
rv = channel->GetContentType(aContentType);
if (NS_FAILED(rv))
@ -824,10 +775,7 @@ nsPluginStreamListenerPeer::RequestRead(NPByteRange* rangeList)
if (NS_FAILED(rv))
return rv;
rv = channel->AsyncOpen(converter, container);
if (NS_SUCCEEDED(rv))
TrackRequest(channel);
return rv;
return channel->AsyncOpen(converter, container);
}
NS_IMETHODIMP
@ -916,9 +864,6 @@ NS_IMETHODIMP nsPluginStreamListenerPeer::OnDataAvailable(nsIRequest *request,
PRUint32 sourceOffset,
PRUint32 aLength)
{
NS_ASSERTION(mRequests.IndexOfObject(GetBaseRequest(request)) != -1,
"Received OnDataAvailable for untracked request.");
if (mRequestFailed)
return NS_ERROR_FAILURE;
@ -940,6 +885,8 @@ NS_IMETHODIMP nsPluginStreamListenerPeer::OnDataAvailable(nsIRequest *request,
if (!mPStreamListener)
return NS_ERROR_FAILURE;
mRequest = request;
const char * url = nsnull;
GetURL(&url);
@ -1022,14 +969,6 @@ NS_IMETHODIMP nsPluginStreamListenerPeer::OnStopRequest(nsIRequest *request,
{
nsresult rv = NS_OK;
nsCOMPtr<nsIMultiPartChannel> mp = do_QueryInterface(request);
if (!mp) {
PRBool found = mRequests.RemoveObject(request);
if (!found) {
NS_ERROR("Received OnStopRequest for untracked request.");
}
}
PLUGIN_LOG(PLUGIN_LOG_NOISY,
("nsPluginStreamListenerPeer::OnStopRequest this=%p aStatus=%d request=%p\n",
this, aStatus, request));
@ -1134,6 +1073,7 @@ NS_IMETHODIMP nsPluginStreamListenerPeer::OnStopRequest(nsIRequest *request,
if (NS_SUCCEEDED(aStatus)) {
mStreamComplete = PR_TRUE;
}
mRequest = NULL;
return NS_OK;
}
@ -1344,47 +1284,6 @@ nsPluginStreamListenerPeer::GetInterface(const nsIID& aIID, void** result)
return GetInterfaceGlobal(aIID, result);
}
/**
* Proxy class which forwards async redirect notifications back to the necko
* callback, keeping nsPluginStreamListenerPeer::mRequests in sync with
* which channel is active.
*/
class ChannelRedirectProxyCallback : public nsIAsyncVerifyRedirectCallback
{
public:
ChannelRedirectProxyCallback(nsINPAPIPluginStreamInfo* listener,
nsIAsyncVerifyRedirectCallback* parent,
nsIChannel* oldChannel,
nsIChannel* newChannel)
: mWeakListener(do_GetWeakReference(listener))
, mParent(parent)
, mOldChannel(oldChannel)
, mNewChannel(newChannel)
{
}
NS_DECL_ISUPPORTS
NS_IMETHODIMP OnRedirectVerifyCallback(nsresult result)
{
if (NS_SUCCEEDED(result)) {
nsCOMPtr<nsINPAPIPluginStreamInfo> listener = do_QueryReferent(mWeakListener);
if (listener)
listener->ReplaceRequest(mOldChannel, mNewChannel);
}
return mParent->OnRedirectVerifyCallback(result);
}
private:
nsWeakPtr mWeakListener;
nsCOMPtr<nsIAsyncVerifyRedirectCallback> mParent;
nsCOMPtr<nsIChannel> mOldChannel;
nsCOMPtr<nsIChannel> mNewChannel;
};
NS_IMPL_ISUPPORTS1(ChannelRedirectProxyCallback, nsIAsyncVerifyRedirectCallback)
NS_IMETHODIMP
nsPluginStreamListenerPeer::AsyncOnChannelRedirect(nsIChannel *oldChannel, nsIChannel *newChannel,
PRUint32 flags, nsIAsyncVerifyRedirectCallback* callback)
@ -1394,11 +1293,8 @@ nsPluginStreamListenerPeer::AsyncOnChannelRedirect(nsIChannel *oldChannel, nsICh
return NS_ERROR_FAILURE;
}
nsCOMPtr<nsIAsyncVerifyRedirectCallback> proxyCallback =
new ChannelRedirectProxyCallback(this, callback, oldChannel, newChannel);
// Give NPAPI a chance to control redirects.
bool notificationHandled = mPStreamListener->HandleRedirectNotification(oldChannel, newChannel, proxyCallback);
bool notificationHandled = mPStreamListener->HandleRedirectNotification(oldChannel, newChannel, callback);
if (notificationHandled) {
return NS_OK;
}
@ -1435,5 +1331,5 @@ nsPluginStreamListenerPeer::AsyncOnChannelRedirect(nsIChannel *oldChannel, nsICh
return rv;
}
return channelEventSink->AsyncOnChannelRedirect(oldChannel, newChannel, flags, proxyCallback);
return channelEventSink->AsyncOnChannelRedirect(oldChannel, newChannel, flags, callback);
}

View File

@ -109,7 +109,8 @@ public:
// Called by GetURL and PostURL (via NewStream)
nsresult Initialize(nsIURI *aURL,
nsNPAPIPluginInstance *aInstance,
nsIPluginStreamListener *aListener);
nsIPluginStreamListener *aListener,
PRInt32 requestCount = 1);
nsresult InitializeEmbedded(nsIURI *aURL,
nsNPAPIPluginInstance* aInstance,

View File

@ -70,7 +70,6 @@ _MOCHITEST_FILES = \
test_pluginstream_poststream.html \
test_pluginstream_seek.html \
test_pluginstream_newstream.html \
test_pluginstream_seek_close.html \
test_fullpage.html \
loremipsum.xtest \
loremipsum.xtest^headers^ \

View File

@ -1,38 +0,0 @@
<body>
<head>
<title>NPAPI Seekable NPStream Test</title>
<script type="text/javascript"
src="/MochiKit/packed.js"></script>
<script type="text/javascript"
src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css"
href="/tests/SimpleTest/test.css" />
</head>
<body>
<p id="display"></p>
<iframe id="testframe" name="testframe" onload="frameLoaded()"></iframe>
<!--
- Tests a seekable stream. Calls NPN_RequestRead with the specified
- range, and verifies that an NPP_Write call is made with the correct
- parameters, including the buffer data for the byte range. Once all
- calls to NPP_Write have finished, the plugin calls NPN_DestroyStream
- and then displays the entire stream's content in a browser frame via
- NPN_GetURL.
-->
<embed src="neverending.sjs" streammode="seek" closestream
frame="testframe" streamchunksize="1024" range="100,100"
id="embedtest" style="width: 400px; height: 100px;"
type="application/x-test"></embed>
<script class="testbody" type="application/javascript">
SimpleTest.waitForExplicitFinish();
function frameLoaded() {
ok(true, "We didn't crash");
SimpleTest.finish();
}
</script>
</body>
</html>

View File

@ -739,7 +739,6 @@ NPP_New(NPMIMEType pluginType, NPP instance, uint16_t mode, int16_t argc, char*
instanceData->focusState = ACTIVATION_STATE_UNKNOWN;
instanceData->focusEventCount = 0;
instanceData->eventModel = 0;
instanceData->closeStream = false;
instance->pdata = instanceData;
TestNPObject* scriptableObject = (TestNPObject*)NPN_CreateObject(instance, &sNPClass);
@ -855,9 +854,6 @@ NPP_New(NPMIMEType pluginType, NPP instance, uint16_t mode, int16_t argc, char*
strcmp(argv[i], "false") == 0) {
instanceData->cleanupWidget = false;
}
if (!strcmp(argn[i], "closestream")) {
instanceData->closeStream = true;
}
}
if (!browserSupportsWindowless || !pluginSupportsWindowlessMode()) {
@ -1120,6 +1116,7 @@ NPP_WriteReady(NPP instance, NPStream* stream)
int32_t
NPP_Write(NPP instance, NPStream* stream, int32_t offset, int32_t len, void* buffer)
{
printf("NPP_Write, offset=%d, len=%d, end=%d\n", offset, len, stream->end);
InstanceData* instanceData = (InstanceData*)(instance->pdata);
instanceData->writeCount++;
@ -1166,18 +1163,11 @@ NPP_Write(NPP instance, NPStream* stream, int32_t offset, int32_t len, void* buf
return len;
}
if (instanceData->closeStream) {
instanceData->closeStream = false;
if (instanceData->testrange != NULL) {
NPError err = NPN_RequestRead(stream, instanceData->testrange);
}
NPN_DestroyStream(instance, stream, NPRES_USER_BREAK);
}
else if (instanceData->streamMode == NP_SEEK &&
stream->end != 0 &&
stream->end == ((uint32_t)instanceData->streamBufSize + len)) {
// If the complete stream has been written, and we're doing a seek test,
// then call NPN_RequestRead.
if (instanceData->streamMode == NP_SEEK &&
stream->end != 0 &&
stream->end == ((uint32_t)instanceData->streamBufSize + len)) {
// prevent recursion
instanceData->streamMode = NP_NORMAL;

View File

@ -137,7 +137,6 @@ typedef struct InstanceData {
ActivationState focusState;
int32_t focusEventCount;
int32_t eventModel;
bool closeStream;
} InstanceData;
void notifyDidPaint(InstanceData* instanceData);