Changeset 35067 in webkit


Ignore:
Timestamp:
Jul 8, 2008 4:46:17 PM (16 years ago)
Author:
jhoneycutt@apple.com
Message:

2008-07-08 Jon Honeycutt <jhoneycutt@apple.com>

Reviewed by Anders.

Port r34988 to Mac: don't call NPP_DestroyStream if NPP_NewStream was
unsuccessful.

  • Plugins/WebBaseNetscapePluginStream.h: Added new member, newStreamSuccessful.
  • Plugins/WebBaseNetscapePluginStream.mm: (-[WebBaseNetscapePluginStream initWithRequestURL:plugin:notifyData:sendNotification:]): Initialize new member. (-[WebBaseNetscapePluginStream startStreamResponseURL:expectedContentLength:lastModifiedDate:MIMEType:headers:]): If NPP_NewStream is successful, set newStreamSuccessful to YES. (-[WebBaseNetscapePluginStream _destroyStream]): Only call NPP_DestroyStream if newStreamSuccessful is true.

Port r34988 to Mac: allow tests to define JavaScript to execute when
NPP_DestroyStream or NPP_URLNotify is called.

  • DumpRenderTree/TestNetscapePlugIn.subproj/main.cpp: (NPP_New): Remove initialization that happens in pluginAllocate. Look for new arguments onStreamDestroy and onURLNotify. (NPP_Destroy): Free onStreamDestroy and onURLNotify. (executeScript): Code moved from onStreamLoad. (NPP_NewStream): Call executeScript. (NPP_DestroyStream): Same. (NPP_URLNotify): Same.
Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebKit/mac/ChangeLog

    r35061 r35067  
     12008-07-08  Jon Honeycutt  <jhoneycutt@apple.com>
     2
     3        Reviewed by Anders.
     4
     5        Port r34988 to Mac: don't call NPP_DestroyStream if NPP_NewStream was
     6        unsuccessful.
     7
     8        * Plugins/WebBaseNetscapePluginStream.h: Added new member,
     9        newStreamSuccessful.
     10        * Plugins/WebBaseNetscapePluginStream.mm:
     11        (-[WebBaseNetscapePluginStream initWithRequestURL:plugin:notifyData:sendNotification:]): Initialize new member.
     12        (-[WebBaseNetscapePluginStream startStreamResponseURL:expectedContentLength:lastModifiedDate:MIMEType:headers:]): If NPP_NewStream is successful, set
     13        newStreamSuccessful to YES.
     14        (-[WebBaseNetscapePluginStream _destroyStream]): Only call
     15        NPP_DestroyStream if newStreamSuccessful is true.
     16
    1172008-07-08  Dan Bernstein  <mitz@apple.com>
    218
  • trunk/WebKit/mac/Plugins/WebBaseNetscapePluginStream.h

    r30897 r35067  
    5555    NPReason reason;
    5656    BOOL isTerminated;
    57        
     57    BOOL newStreamSuccessful;
     58 
    5859    NPP_NewStreamProcPtr NPP_NewStream;
    5960    NPP_DestroyStreamProcPtr NPP_DestroyStream;
  • trunk/WebKit/mac/Plugins/WebBaseNetscapePluginStream.mm

    r30897 r35067  
    119119    sendNotification = flag;
    120120    fileDescriptor = -1;
     121    newStreamSuccessful = NO;
    121122
    122123    streams().add(&stream, thePlugin);
     
    278279        return;
    279280    }
     281
     282    newStreamSuccessful = YES;
    280283
    281284    switch (transferMode) {
     
    400403        }
    401404
    402         NPError npErr;
    403         WebBaseNetscapePluginView *pv = pluginView;
    404         [pv willCallPlugInFunction];
    405         npErr = NPP_DestroyStream(plugin, &stream, reason);
    406         [pv didCallPlugInFunction];
    407         LOG(Plugins, "NPP_DestroyStream responseURL=%@ error=%d", responseURL, npErr);
     405        if (newStreamSuccessful) {
     406            NPError npErr;
     407            WebBaseNetscapePluginView *pv = pluginView;
     408            [pv willCallPlugInFunction];
     409            npErr = NPP_DestroyStream(plugin, &stream, reason);
     410            [pv didCallPlugInFunction];
     411            LOG(Plugins, "NPP_DestroyStream responseURL=%@ error=%d", responseURL, npErr);
     412        }
    408413
    409414        free(headers);
  • trunk/WebKitTools/ChangeLog

    r35048 r35067  
     12008-07-08  Jon Honeycutt  <jhoneycutt@apple.com>
     2
     3        Reviewed by Anders.
     4
     5        Port r34988 to Mac: allow tests to define JavaScript to execute when
     6        NPP_DestroyStream or NPP_URLNotify is called.
     7
     8        * DumpRenderTree/TestNetscapePlugIn.subproj/main.cpp:
     9        (NPP_New): Remove initialization that happens in pluginAllocate. Look
     10        for new arguments onStreamDestroy and onURLNotify.
     11        (NPP_Destroy): Free onStreamDestroy and onURLNotify.
     12        (executeScript): Code moved from onStreamLoad.
     13        (NPP_NewStream): Call executeScript.
     14        (NPP_DestroyStream): Same.
     15        (NPP_URLNotify): Same.
     16
    1172008-07-07  Beth Dakin  <bdakin@apple.com>
    218
  • trunk/WebKitTools/DumpRenderTree/TestNetscapePlugIn.subproj/main.cpp

    r33019 r35067  
    8585    if (browser->version >= 14) {
    8686        PluginObject* obj = (PluginObject*)browser->createobject(instance, getPluginClass());
    87    
    88         obj->onStreamLoad = NULL;
    89        
     87 
    9088        for (int i = 0; i < argc; i++) {
    9189            if (strcasecmp(argn[i], "onstreamload") == 0 && !obj->onStreamLoad)
    9290                obj->onStreamLoad = strdup(argv[i]);
     91            else if (strcasecmp(argn[i], "onStreamDestroy") == 0 && !obj->onStreamDestroy)
     92                obj->onStreamDestroy = strdup(argv[i]);
     93            else if (strcasecmp(argn[i], "onURLNotify") == 0 && !obj->onURLNotify)
     94                obj->onURLNotify = strdup(argv[i]);
    9395            else if (strcasecmp(argn[i], "src") == 0 &&
    9496                     strcasecmp(argv[i], "data:application/x-webkit-test-netscape,returnerrorfromnewstream") == 0)
     
    110112        if (obj->onStreamLoad)
    111113            free(obj->onStreamLoad);
     114
     115        if (obj->onStreamDestroy)
     116            free(obj->onStreamDestroy);
     117
     118        if (obj->onURLNotify)
     119            free(obj->onURLNotify);
    112120       
    113121        if (obj->logDestroy)
     
    133141}
    134142
     143static void executeScript(const PluginObject* obj, const char* script)
     144{
     145    NPObject *windowScriptObject;
     146    browser->getvalue(obj->npp, NPNVWindowNPObject, &windowScriptObject);
     147
     148    NPString npScript;
     149    npScript.UTF8Characters = script;
     150    npScript.UTF8Length = strlen(script);
     151
     152    NPVariant browserResult;
     153    browser->evaluate(obj->npp, windowScriptObject, &npScript, &browserResult);
     154    browser->releasevariantvalue(&browserResult);
     155}
     156
    135157NPError NPP_NewStream(NPP instance, NPMIMEType type, NPStream *stream, NPBool seekable, uint16 *stype)
    136158{
     
    145167        notifyStream(obj, stream->url, stream->headers);
    146168
    147     if (obj->onStreamLoad) {
    148         NPObject *windowScriptObject;
    149         browser->getvalue(obj->npp, NPNVWindowNPObject, &windowScriptObject);
    150                
    151         NPString script;
    152         script.UTF8Characters = obj->onStreamLoad;
    153         script.UTF8Length = strlen(obj->onStreamLoad);
    154        
    155         NPVariant browserResult;
    156         browser->evaluate(obj->npp, windowScriptObject, &script, &browserResult);
    157         browser->releasevariantvalue(&browserResult);
    158     }
    159    
     169    if (obj->onStreamLoad)
     170        executeScript(obj, obj->onStreamLoad);
     171
    160172    return NPERR_NO_ERROR;
    161173}
     
    163175NPError NPP_DestroyStream(NPP instance, NPStream *stream, NPReason reason)
    164176{
     177    PluginObject* obj = (PluginObject*)instance->pdata;
     178
     179    if (obj->onStreamDestroy)
     180        executeScript(obj, obj->onStreamDestroy);
     181
    165182    return NPERR_NO_ERROR;
    166183}
     
    286303{
    287304    PluginObject* obj = static_cast<PluginObject*>(instance->pdata);
    288        
     305 
     306     if (obj->onURLNotify)
     307         executeScript(obj, obj->onURLNotify);
     308
    289309    handleCallback(obj, url, reason, notifyData);
    290310}
Note: See TracChangeset for help on using the changeset viewer.