зеркало из https://github.com/mozilla/gecko-dev.git
Landing fix for bug 347805. Add support for passing information about failed HTTP streams to plugins. Patch by dbalev@adobe.com, r+sr=jst@mozilla.org
This commit is contained in:
Родитель
9f4d177ce3
Коммит
819bfbb804
|
@ -120,7 +120,7 @@
|
|||
/*----------------------------------------------------------------------*/
|
||||
|
||||
#define NP_VERSION_MAJOR 0
|
||||
#define NP_VERSION_MINOR 19
|
||||
#define NP_VERSION_MINOR 20
|
||||
|
||||
|
||||
/* The OS/2 version of Netscape uses RC_DATA to define the
|
||||
|
@ -411,7 +411,14 @@ typedef enum {
|
|||
* NPN_MemAlloc() to allocate memory for the string data. Introduced
|
||||
* in Mozilla 1.8b2 (NPAPI minor version 15).
|
||||
*/
|
||||
NPPVformValue = 16
|
||||
NPPVformValue = 16,
|
||||
|
||||
NPPVpluginUrlRequestsDisplayedBool = 17,
|
||||
|
||||
/* Checks if the plugin is interested in receiving the http body of
|
||||
* all http requests (including failed ones, http status != 200).
|
||||
*/
|
||||
NPPVpluginWantsAllNetworkStreams = 18
|
||||
#ifdef XP_MACOSX
|
||||
/* Used for negotiating drawing models */
|
||||
, NPPVpluginDrawingModel = 1000
|
||||
|
@ -658,6 +665,7 @@ enum NPEventType {
|
|||
#define NPVERS_HAS_RESPONSE_HEADERS 17
|
||||
#define NPVERS_HAS_NPOBJECT_ENUM 18
|
||||
#define NPVERS_HAS_PLUGIN_THREAD_ASYNC_CALL 19
|
||||
#define NPVERS_HAS_ALL_NETWORK_STREAMS 20
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
/* Function Prototypes */
|
||||
|
|
|
@ -201,7 +201,8 @@ enum nsPluginInstanceVariable {
|
|||
nsPluginInstanceVariable_CallSetWindowAfterDestroyBool = 6,
|
||||
nsPluginInstanceVariable_ScriptableInstance = 10,
|
||||
nsPluginInstanceVariable_ScriptableIID = 11,
|
||||
nsPluginInstanceVariable_NeedsXEmbed = 14
|
||||
nsPluginInstanceVariable_NeedsXEmbed = 14,
|
||||
nsPluginInstanceVariable_WantsAllNetworkStreams = 18
|
||||
#ifdef XP_MACOSX
|
||||
, nsPluginInstanceVariable_DrawingModel = 20
|
||||
#endif
|
||||
|
|
|
@ -2457,7 +2457,12 @@ _setvalue(NPP npp, NPPVariable variable, void *result)
|
|||
NPBool bCached = (result != nsnull);
|
||||
return inst->SetCached(bCached);
|
||||
}
|
||||
|
||||
|
||||
case NPPVpluginWantsAllNetworkStreams: {
|
||||
PRBool bWantsAllNetworkStreams = (result != nsnull);
|
||||
return inst->SetWantsAllNetworkStreams(bWantsAllNetworkStreams);
|
||||
}
|
||||
|
||||
#ifdef XP_MACOSX
|
||||
case NPPVpluginDrawingModel: {
|
||||
if (inst) {
|
||||
|
|
|
@ -833,6 +833,7 @@ ns4xPluginInstance::ns4xPluginInstance(NPPluginFuncs* callbacks,
|
|||
mStarted(PR_FALSE),
|
||||
mCached(PR_FALSE),
|
||||
mIsJavaPlugin(PR_FALSE),
|
||||
mWantsAllNetworkStreams(PR_FALSE),
|
||||
mInPluginInitCall(PR_FALSE),
|
||||
fLibrary(aLibrary),
|
||||
mStreams(nsnull)
|
||||
|
@ -1437,6 +1438,13 @@ NPError ns4xPluginInstance::SetTransparent(PRBool aTransparent)
|
|||
return NPERR_NO_ERROR;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
NPError ns4xPluginInstance::SetWantsAllNetworkStreams(PRBool aWantsAllNetworkStreams)
|
||||
{
|
||||
mWantsAllNetworkStreams = aWantsAllNetworkStreams;
|
||||
return NPERR_NO_ERROR;
|
||||
}
|
||||
|
||||
#ifdef XP_MACOSX
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
void ns4xPluginInstance::SetDrawingModel(NPDrawingModel aModel)
|
||||
|
|
|
@ -115,6 +115,8 @@ public:
|
|||
|
||||
NPError SetTransparent(PRBool aTransparent);
|
||||
|
||||
NPError SetWantsAllNetworkStreams(PRBool aWantsAllNetworkStreams);
|
||||
|
||||
#ifdef XP_MACOSX
|
||||
void SetDrawingModel(NPDrawingModel aModel);
|
||||
NPDrawingModel GetDrawingModel();
|
||||
|
@ -187,6 +189,7 @@ protected:
|
|||
PRPackedBool mStarted;
|
||||
PRPackedBool mCached;
|
||||
PRPackedBool mIsJavaPlugin;
|
||||
PRPackedBool mWantsAllNetworkStreams;
|
||||
|
||||
public:
|
||||
// True while creating the plugin, or calling NPP_SetWindow() on
|
||||
|
|
|
@ -1312,6 +1312,8 @@ public:
|
|||
nsresult OnFileAvailable(nsIFile* aFile);
|
||||
|
||||
nsresult ServeStreamAsFile(nsIRequest *request, nsISupports *ctxt);
|
||||
|
||||
nsIPluginInstance *GetPluginInstance() { return mInstance; }
|
||||
|
||||
private:
|
||||
nsresult SetUpCache(nsIURI* aURL); // todo: see about removing this...
|
||||
|
@ -2030,7 +2032,7 @@ nsPluginStreamListenerPeer::OnStartRequest(nsIRequest *request,
|
|||
if (httpChannel) {
|
||||
PRUint32 responseCode = 0;
|
||||
rv = httpChannel->GetResponseStatus(&responseCode);
|
||||
if (NS_FAILED(rv) || responseCode > 206) { // not normal
|
||||
if (NS_FAILED(rv)) {
|
||||
// NPP_Notify() will be called from OnStopRequest
|
||||
// in ns4xPluginStreamListener::CleanUpStream
|
||||
// return error will cancel this request
|
||||
|
@ -2038,6 +2040,16 @@ nsPluginStreamListenerPeer::OnStartRequest(nsIRequest *request,
|
|||
mRequestFailed = PR_TRUE;
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
if (responseCode > 206) { // not normal
|
||||
PRBool bWantsAllNetworkStreams = PR_FALSE;
|
||||
mInstance->GetValue(nsPluginInstanceVariable_WantsAllNetworkStreams,
|
||||
(void *)&bWantsAllNetworkStreams);
|
||||
if(!bWantsAllNetworkStreams) {
|
||||
mRequestFailed = PR_TRUE;
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// do a little sanity check to make sure our frame isn't gone
|
||||
|
@ -7122,18 +7134,29 @@ nsPluginByteRangeStreamListener::OnStartRequest(nsIRequest *request, nsISupports
|
|||
|
||||
PRUint32 responseCode = 0;
|
||||
rv = httpChannel->GetResponseStatus(&responseCode);
|
||||
if (NS_FAILED(rv) || responseCode != 200) {
|
||||
if (NS_FAILED(rv)) {
|
||||
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()->
|
||||
GetValue(nsPluginInstanceVariable_WantsAllNetworkStreams,
|
||||
(void *)&bWantsAllNetworkStreams);
|
||||
if (!bWantsAllNetworkStreams){
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
// if server cannot continue with byte range (206 status) and sending us whole object (200 status)
|
||||
// reset this seekable stream & try serve it to plugin instance as a file
|
||||
mStreamConverter = finalStreamListener;
|
||||
mRemoveMagicNumber = PR_TRUE;
|
||||
|
||||
//get nsPluginStreamListenerPeer* ptr from finalStreamListener
|
||||
nsPluginStreamListenerPeer *pslp = reinterpret_cast<nsPluginStreamListenerPeer*>
|
||||
(finalStreamListener.get());
|
||||
rv = pslp->ServeStreamAsFile(request, ctxt);
|
||||
return rv;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче