Changeset 86522 in webkit


Ignore:
Timestamp:
May 15, 2011 8:29:59 PM (13 years ago)
Author:
andersca@apple.com
Message:

2011-05-15 Anders Carlsson <andersca@apple.com>

Reviewed by Maciej Stachowiak.

Pass the window NPObject identifier in the plug-in creation parameters
https://bugs.webkit.org/show_bug.cgi?id=60865

This avoids a synchronous call when the plug-in wants to get the NPObject that
corresponds to the window.

  • PluginProcess/PluginControllerProxy.cpp: (WebKit::PluginControllerProxy::initialize): Change this to take the PluginCreationParameters. Initialize the window NPObject.

(WebKit::PluginControllerProxy::windowScriptNPObject):
Just return the window NPObject; it's already been initialized.

  • PluginProcess/PluginControllerProxy.h:
  • PluginProcess/PluginCreationParameters.cpp: (WebKit::PluginCreationParameters::PluginCreationParameters): (WebKit::PluginCreationParameters::encode): (WebKit::PluginCreationParameters::decode):
  • PluginProcess/PluginCreationParameters.h: Add the window NPObject ID.
  • PluginProcess/WebProcessConnection.cpp: (WebKit::WebProcessConnection::createPlugin): Pass the creation parameters to PluginControllerProxy::initialize.
  • WebProcess/Plugins/PluginProxy.cpp: (WebKit::PluginProxy::initialize): Initialize the window NPObject ID.
  • WebProcess/Plugins/PluginProxy.messages.in: Remove the GetWindowScriptNPObject message.
Location:
trunk/Source/WebKit2
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r86516 r86522  
     12011-05-15  Anders Carlsson  <andersca@apple.com>
     2
     3        Reviewed by Maciej Stachowiak.
     4
     5        Pass the window NPObject identifier in the plug-in creation parameters
     6        https://bugs.webkit.org/show_bug.cgi?id=60865
     7
     8        This avoids a synchronous call when the plug-in wants to get the NPObject that
     9        corresponds to the window.
     10
     11        * PluginProcess/PluginControllerProxy.cpp:
     12        (WebKit::PluginControllerProxy::initialize):
     13        Change this to take the PluginCreationParameters. Initialize the window NPObject.
     14
     15        (WebKit::PluginControllerProxy::windowScriptNPObject):
     16        Just return the window NPObject; it's already been initialized.
     17
     18        * PluginProcess/PluginControllerProxy.h:
     19        * PluginProcess/PluginCreationParameters.cpp:
     20        (WebKit::PluginCreationParameters::PluginCreationParameters):
     21        (WebKit::PluginCreationParameters::encode):
     22        (WebKit::PluginCreationParameters::decode):
     23        * PluginProcess/PluginCreationParameters.h:
     24        Add the window NPObject ID.
     25
     26        * PluginProcess/WebProcessConnection.cpp:
     27        (WebKit::WebProcessConnection::createPlugin):
     28        Pass the creation parameters to PluginControllerProxy::initialize.
     29
     30        * WebProcess/Plugins/PluginProxy.cpp:
     31        (WebKit::PluginProxy::initialize):
     32        Initialize the window NPObject ID.
     33
     34        * WebProcess/Plugins/PluginProxy.messages.in:
     35        Remove the GetWindowScriptNPObject message.
     36
    1372011-05-15  Anders Carlsson  <andersca@apple.com>
    238
  • trunk/Source/WebKit2/PluginProcess/PluginControllerProxy.cpp

    r86489 r86522  
    8686}
    8787
    88 bool PluginControllerProxy::initialize(const Plugin::Parameters& parameters)
     88bool PluginControllerProxy::initialize(const PluginCreationParameters& creationParameters)
    8989{
    9090    ASSERT(!m_plugin);
     
    9797    }
    9898
    99     if (!m_plugin->initialize(this, parameters)) {
     99    m_windowNPObject = m_connection->npRemoteObjectMap()->createNPObjectProxy(creationParameters.windowNPObjectID, m_plugin.get());
     100    ASSERT(m_windowNPObject);
     101
     102    if (!m_plugin->initialize(this, creationParameters.parameters)) {
    100103        // Get the plug-in so we can pass it to removePluginControllerProxy. The pointer is only
    101104        // used as an identifier so it's OK to just get a weak reference.
     
    230233NPObject* PluginControllerProxy::windowScriptNPObject()
    231234{
    232     if (!m_windowNPObject) {
    233         uint64_t windowScriptNPObjectID = 0;
    234 
    235         if (!m_connection->connection()->sendSync(Messages::PluginProxy::GetWindowScriptNPObject(), Messages::PluginProxy::GetWindowScriptNPObject::Reply(windowScriptNPObjectID), m_pluginInstanceID))
    236             return 0;
    237 
    238         if (!windowScriptNPObjectID)
    239             return 0;
    240 
    241         m_windowNPObject = m_connection->npRemoteObjectMap()->createNPObjectProxy(windowScriptNPObjectID, m_plugin.get());
    242         ASSERT(m_windowNPObject);
    243     }
    244 
    245235    retainNPObject(m_windowNPObject);
    246236    return m_windowNPObject;
  • trunk/Source/WebKit2/PluginProcess/PluginControllerProxy.h

    r86489 r86522  
    6262    uint64_t pluginInstanceID() const { return m_pluginInstanceID; }
    6363
    64     bool initialize(const Plugin::Parameters&);
     64    bool initialize(const PluginCreationParameters&);
    6565    void destroy();
    6666
  • trunk/Source/WebKit2/PluginProcess/PluginCreationParameters.cpp

    r86489 r86522  
    3535PluginCreationParameters::PluginCreationParameters()
    3636    : pluginInstanceID(0)
     37    , windowNPObjectID(0)
    3738    , isPrivateBrowsingEnabled(false)
    3839#if USE(ACCELERATED_COMPOSITING)
     
    4546{
    4647    encoder->encode(pluginInstanceID);
     48    encoder->encode(windowNPObjectID);
    4749    encoder->encode(parameters);
    4850    encoder->encode(userAgent);
     
    5759{
    5860    if (!decoder->decode(result.pluginInstanceID) || !result.pluginInstanceID)
     61        return false;
     62
     63    if (!decoder->decode(result.windowNPObjectID))
    5964        return false;
    6065
  • trunk/Source/WebKit2/PluginProcess/PluginCreationParameters.h

    r86489 r86522  
    4747    uint64_t pluginInstanceID;
    4848
     49    // The ID of the window NPObject.
     50    uint64_t windowNPObjectID;
     51
    4952    // The parameters passed to the plug-in.
    5053    Plugin::Parameters parameters;
  • trunk/Source/WebKit2/PluginProcess/WebProcessConnection.cpp

    r86489 r86522  
    174174
    175175    // Now try to initialize the plug-in.
    176     result = pluginControllerProxyPtr->initialize(creationParameters.parameters);
     176    result = pluginControllerProxyPtr->initialize(creationParameters);
    177177
    178178    if (!result)
  • trunk/Source/WebKit2/WebProcess/Plugins/PluginProxy.cpp

    r86489 r86522  
    102102    PluginCreationParameters creationParameters;
    103103    creationParameters.pluginInstanceID = m_pluginInstanceID;
     104    creationParameters.windowNPObjectID = windowNPObjectID();
    104105    creationParameters.parameters = parameters;
    105106    creationParameters.userAgent = pluginController->userAgent();
     
    411412}
    412413
    413 void PluginProxy::getWindowScriptNPObject(uint64_t& windowScriptNPObjectID)
     414uint64_t PluginProxy::windowNPObjectID()
    414415{
    415416    NPObject* windowScriptNPObject = m_pluginController->windowScriptNPObject();
    416     if (!windowScriptNPObject) {
    417         windowScriptNPObjectID = 0;
    418         return;
    419     }
    420 
    421     windowScriptNPObjectID = m_connection->npRemoteObjectMap()->registerNPObject(windowScriptNPObject, this);
     417    if (!windowScriptNPObject)
     418        return 0;
     419
     420    uint64_t windowNPObjectID = m_connection->npRemoteObjectMap()->registerNPObject(windowScriptNPObject, this);
    422421    releaseNPObject(windowScriptNPObject);
     422
     423    return windowNPObjectID;
    423424}
    424425
  • trunk/Source/WebKit2/WebProcess/Plugins/PluginProxy.h

    r86467 r86522  
    106106
    107107    bool needsBackingStore() const;
     108    uint64_t windowNPObjectID();
    108109
    109110    // Message handlers.
     
    114115    void setCookiesForURL(const String& urlString, const String& cookieString);
    115116    void getAuthenticationInfo(const WebCore::ProtectionSpace&, bool& returnValue, String& username, String& password);
    116     void getWindowScriptNPObject(uint64_t& windowScriptNPObjectID);
    117117    void getPluginElementNPObject(uint64_t& pluginElementNPObjectID);
    118118    void evaluate(const NPVariantData& npObjectAsVariantData, const String& scriptString, bool allowPopups, bool& returnValue, NPVariantData& resultData);
  • trunk/Source/WebKit2/WebProcess/Plugins/PluginProxy.messages.in

    r86169 r86522  
    4242    GetAuthenticationInfo(WebCore::ProtectionSpace protectionSpace) -> (bool returnValue, WTF::String username, WTF::String password)
    4343
    44     # Gets a reference to the window NPObject.
    45     GetWindowScriptNPObject() -> (uint64_t windowScriptNPObjectID)
    46 
    4744    # Gets a reference to the plug-in element NPObject.
    4845    GetPluginElementNPObject() -> (uint64_t pluginElementNPObjectID)
Note: See TracChangeset for help on using the changeset viewer.