Changeset 68445 in webkit


Ignore:
Timestamp:
Sep 27, 2010 4:38:21 PM (14 years ago)
Author:
andersca@apple.com
Message:

Add WebProcessConnection CreatePlugin message
https://bugs.webkit.org/show_bug.cgi?id=46668

Reviewed by Adam Roben.

  • DerivedSources.make:

Add WebProcessConnection.

  • Platform/CoreIPC/HandleMessage.h:

Add handleMessage overload for a sync message with two input parameters
and one output parameter.

(CoreIPC::handleMessage):

  • Platform/CoreIPC/MessageID.h:

Add MessageClassWebProcessConnection.

  • PluginProcess/WebProcessConnection.cpp:

(WebKit::WebProcessConnection::createPlugin):
Add stub.

  • PluginProcess/WebProcessConnection.messages.in: Added.
  • Scripts/webkit2/messages.py:

Include headers directly for types that we believe are nested structs.

  • Scripts/webkit2/messages_unittest.py:

Update expected results.

  • WebKit2.xcodeproj/project.pbxproj:

Add new files.

Location:
trunk/WebKit2
Files:
1 added
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebKit2/ChangeLog

    r68435 r68445  
    5050        * WebProcess/mac/WebProcessMainMac.mm:
    5151        (WebKit::WebProcessMain):
     52
     532010-09-27  Anders Carlsson  <andersca@apple.com>
     54
     55        Reviewed by Adam Roben.
     56
     57        Add WebProcessConnection CreatePlugin message
     58        https://bugs.webkit.org/show_bug.cgi?id=46668
     59
     60        * DerivedSources.make:
     61        Add WebProcessConnection.
     62
     63        * Platform/CoreIPC/HandleMessage.h:
     64        Add handleMessage overload for a sync message with two input parameters
     65        and one output parameter.
     66
     67        (CoreIPC::handleMessage):
     68        * Platform/CoreIPC/MessageID.h:
     69        Add MessageClassWebProcessConnection.
     70
     71        * PluginProcess/WebProcessConnection.cpp:
     72        (WebKit::WebProcessConnection::createPlugin):
     73        Add stub.
     74
     75        * PluginProcess/WebProcessConnection.messages.in: Added.
     76        * Scripts/webkit2/messages.py:
     77        Include headers directly for types that we believe are nested structs.
     78
     79        * Scripts/webkit2/messages_unittest.py:
     80        Update expected results.
     81
     82        * WebKit2.xcodeproj/project.pbxproj:
     83        Add new files.
    5284
    53852010-09-27  Anders Carlsson  <andersca@apple.com>
  • trunk/WebKit2/DerivedSources.make

    r68309 r68445  
    99    PluginProcessProxy \
    1010    WebPage \
     11    WebProcessConnection \
    1112#
    1213
  • trunk/WebKit2/Platform/CoreIPC/HandleMessage.h

    r68079 r68445  
    4949}
    5050
     51template<typename T, typename C, typename P1, typename P2, typename R1>
     52void handleMessage(ArgumentDecoder* arguments, ArgumentEncoder* reply, C* object, void (C::*function)(P1, P2, R1&))
     53{
     54    typename RemoveReference<typename T::FirstArgumentType>::Type firstArgument;
     55    if (!arguments->decode(firstArgument))
     56        return;
     57
     58    typename RemoveReference<typename T::SecondArgumentType>::Type secondArgument;
     59    if (!arguments->decode(secondArgument))
     60        return;
     61   
     62    typename RemoveReference<typename T::Reply::FirstArgumentType>::Type firstReplyArgument;
     63    (object->*function)(firstArgument, secondArgument, firstReplyArgument);
     64    reply->encode(firstReplyArgument);
     65}
     66
    5167} // namespace CoreIPC
    5268
  • trunk/WebKit2/Platform/CoreIPC/MessageID.h

    r68309 r68445  
    5252    // Messages sent by the plug-in process to the UI process.
    5353    MessageClassPluginProcessProxy,
     54
     55    // Messages sent by the web process to the plug-in process.
     56    MessageClassWebProcessConnection,
    5457};
    5558
  • trunk/WebKit2/PluginProcess/WebProcessConnection.cpp

    r68350 r68445  
    6868}
    6969
     70void WebProcessConnection::createPlugin(uint64_t pluginInstanceID, const Plugin::Parameters&, bool& result)
     71{
     72}
    7073
    7174} // namespace WebKit
  • trunk/WebKit2/PluginProcess/WebProcessConnection.h

    r68267 r68445  
    3030
    3131#include "Connection.h"
     32#include "Plugin.h"
    3233#include <wtf/RefCounted.h>
    3334
     
    5253    virtual void didReceiveInvalidMessage(CoreIPC::Connection*, CoreIPC::MessageID);
    5354
     55    // Message handlers.
     56    CoreIPC::SyncReplyMode didReceiveSyncWebProcessConnectionMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*, CoreIPC::ArgumentEncoder*);
     57    void createPlugin(uint64_t pluginInstanceID, const Plugin::Parameters&, bool& result);
     58
    5459    RefPtr<CoreIPC::Connection> m_connection;
    5560};
  • trunk/WebKit2/Scripts/webkit2/messages.py

    r68428 r68445  
    207207
    208208
    209 def forward_declarations(receiver):
     209def forward_declarations_and_headers(receiver):
    210210    types_by_namespace = collections.defaultdict(set)
    211     for parameter in receiver.iterparameters():
    212         type = parameter.type
    213         split = type.split('::')
    214         if len(split) != 2:
    215             continue
    216         namespace = split[0]
    217         inner_type = split[1]
    218         types_by_namespace[namespace].add(inner_type)
    219     return '\n'.join([forward_declarations_for_namespace(namespace, types) for (namespace, types) in sorted(types_by_namespace.iteritems())])
    220 
    221 
    222 def generate_messages_header(file):
    223     receiver = MessageReceiver.parse(file)
    224     header_guard = messages_header_filename(receiver).replace('.', '_')
    225211
    226212    headers = set([
     
    229215    ])
    230216
     217    for parameter in receiver.iterparameters():
     218        type = parameter.type
     219        split = type.split('::')
     220
     221        if len(split) == 2:
     222            namespace = split[0]
     223            inner_type = split[1]
     224            types_by_namespace[namespace].add(inner_type)
     225        elif len(split) > 2:
     226            # We probably have a nested struct, which means we can't forward declare it.
     227            # Include its header instead.
     228            headers.update(headers_for_type(type))
     229
     230    forward_declarations = '\n'.join([forward_declarations_for_namespace(namespace, types) for (namespace, types) in sorted(types_by_namespace.iteritems())])
     231    headers = ['#include %s\n' % header for header in sorted(headers)]
     232
     233    return (forward_declarations, headers)
     234
     235def generate_messages_header(file):
     236    receiver = MessageReceiver.parse(file)
     237    header_guard = messages_header_filename(receiver).replace('.', '_')
     238
    231239    result = []
    232240
     
    240248        result.append('#if %s\n\n' % receiver.condition)
    241249
    242     result += ['#include %s\n' % header for header in sorted(headers)]
    243     result.append('\n')
    244 
    245     result.append(forward_declarations(receiver))
     250    forward_declarations, headers = forward_declarations_and_headers(receiver)
     251
     252    result += headers
     253    result.append('\n')
     254
     255    result.append(forward_declarations)
    246256    result.append('\n')
    247257
     
    300310def headers_for_type(type):
    301311    special_cases = {
    302         'CoreIPC::MachPort': '"MachPort.h"',
    303312        'WTF::String': '<wtf/text/WTFString.h>',
    304313        'WebKit::WebKeyboardEvent': '"WebEvent.h"',
     
    313322    # resolution operator (::).
    314323    split = type.split('::')
    315     if len(split) != 2:
     324    if len(split) < 2:
    316325        return []
    317     if split[0] == 'WebKit':
     326    if split[0] == 'WebKit' or split[0] == 'CoreIPC':
    318327        return ['"%s.h"' % split[1]]
    319328    return ['<%s/%s.h>' % tuple(split)]
  • trunk/WebKit2/Scripts/webkit2/messages_unittest.py

    r68428 r68445  
    6161    SendInts(Vector<uint64_t> ints)
    6262
     63    CreatePlugin(uint64_t pluginInstanceID, WebKit::Plugin::Parameters parameters) -> (bool result)
    6364    RunJavaScriptAlert(uint64_t frameID, WTF::String message) -> ()
    6465    GetPlugins(bool refresh) -> (Vector<WebCore::PluginInfo> plugins)
     
    123124            'condition': None,
    124125            'base_class': 'CoreIPC::Arguments1<const Vector<uint64_t>&>',
     126        },
     127        {
     128            'name': 'CreatePlugin',
     129            'parameters': (
     130                ('uint64_t', 'pluginInstanceID'),
     131                ('WebKit::Plugin::Parameters', 'parameters')
     132            ),
     133            'reply_parameters': (
     134                ('bool', 'result'),
     135            ),
     136            'condition': None,
     137            'base_class': 'CoreIPC::Arguments2<uint64_t, const WebKit::Plugin::Parameters&>',
     138            'reply_base_class': 'CoreIPC::Arguments1<bool>',
    125139        },
    126140        {
     
    231245#include "Arguments.h"
    232246#include "MessageID.h"
     247#include "Plugin.h"
    233248
    234249namespace CoreIPC {
     
    257272    SendDoubleAndFloatID,
    258273    SendIntsID,
     274    CreatePluginID,
    259275    RunJavaScriptAlertID,
    260276    GetPluginsID,
     
    305321    explicit SendInts(const Vector<uint64_t>& ints)
    306322        : CoreIPC::Arguments1<const Vector<uint64_t>&>(ints)
     323    {
     324    }
     325};
     326
     327struct CreatePlugin : CoreIPC::Arguments2<uint64_t, const WebKit::Plugin::Parameters&> {
     328    static const Kind messageID = CreatePluginID;
     329    typedef CoreIPC::Arguments1<bool&> Reply;
     330    CreatePlugin(uint64_t pluginInstanceID, const WebKit::Plugin::Parameters& parameters)
     331        : CoreIPC::Arguments2<uint64_t, const WebKit::Plugin::Parameters&>(pluginInstanceID, parameters)
    307332    {
    308333    }
     
    392417#include "HandleMessage.h"
    393418#include "MachPort.h"
     419#include "Plugin.h"
    394420#include "WebCoreArgumentCoders.h"
    395421#include "WebEvent.h"
     
    434460{
    435461    switch (messageID.get<Messages::WebPage::Kind>()) {
     462    case Messages::WebPage::CreatePluginID:
     463        CoreIPC::handleMessage<Messages::WebPage::CreatePlugin>(arguments, reply, this, &WebPage::createPlugin);
     464        return CoreIPC::AutomaticReply;
    436465    case Messages::WebPage::RunJavaScriptAlertID:
    437466        CoreIPC::handleMessage<Messages::WebPage::RunJavaScriptAlert>(arguments, reply, this, &WebPage::runJavaScriptAlert);
  • trunk/WebKit2/WebKit2.xcodeproj/project.pbxproj

    r68413 r68445  
    5757                1A043DC1124FF87500FFBFB5 /* PluginProxy.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A043DBF124FF87500FFBFB5 /* PluginProxy.h */; };
    5858                1A043DC2124FF87500FFBFB5 /* PluginProxy.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A043DC0124FF87500FFBFB5 /* PluginProxy.cpp */; };
     59                1A043F5A12514CF300FFBFB5 /* WebProcessConnection.messages.in in Resources */ = {isa = PBXBuildFile; fileRef = 1A043F5912514CF300FFBFB5 /* WebProcessConnection.messages.in */; };
     60                1A043F6912514D8B00FFBFB5 /* WebProcessConnectionMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A043F6712514D8B00FFBFB5 /* WebProcessConnectionMessageReceiver.cpp */; };
     61                1A043F6A12514D8B00FFBFB5 /* WebProcessConnectionMessages.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A043F6812514D8B00FFBFB5 /* WebProcessConnectionMessages.h */; };
    5962                1A0EC603124A9F2C007EF4A5 /* PluginProcessManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A0EC601124A9F2C007EF4A5 /* PluginProcessManager.h */; };
    6063                1A0EC604124A9F2C007EF4A5 /* PluginProcessManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A0EC602124A9F2C007EF4A5 /* PluginProcessManager.cpp */; };
     
    476479                1A043DBF124FF87500FFBFB5 /* PluginProxy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PluginProxy.h; sourceTree = "<group>"; };
    477480                1A043DC0124FF87500FFBFB5 /* PluginProxy.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PluginProxy.cpp; sourceTree = "<group>"; };
     481                1A043F5912514CF300FFBFB5 /* WebProcessConnection.messages.in */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = WebProcessConnection.messages.in; sourceTree = "<group>"; };
     482                1A043F6712514D8B00FFBFB5 /* WebProcessConnectionMessageReceiver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = WebProcessConnectionMessageReceiver.cpp; path = /Users/andersca/Build/Debug/DerivedSources/WebKit2/WebProcessConnectionMessageReceiver.cpp; sourceTree = "<absolute>"; };
     483                1A043F6812514D8B00FFBFB5 /* WebProcessConnectionMessages.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WebProcessConnectionMessages.h; path = /Users/andersca/Build/Debug/DerivedSources/WebKit2/WebProcessConnectionMessages.h; sourceTree = "<absolute>"; };
    478484                1A0EC601124A9F2C007EF4A5 /* PluginProcessManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PluginProcessManager.h; sourceTree = "<group>"; };
    479485                1A0EC602124A9F2C007EF4A5 /* PluginProcessManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PluginProcessManager.cpp; sourceTree = "<group>"; };
     
    953959                                1A043A08124D11A900FFBFB5 /* WebProcessConnection.cpp */,
    954960                                1A043A07124D11A900FFBFB5 /* WebProcessConnection.h */,
     961                                1A043F5912514CF300FFBFB5 /* WebProcessConnection.messages.in */,
    955962                        );
    956963                        path = PluginProcess;
     
    16401647                                C0CE729E1247E71D00BC0EC4 /* WebPageMessageReceiver.cpp */,
    16411648                                C0CE729F1247E71D00BC0EC4 /* WebPageMessages.h */,
     1649                                1A043F6712514D8B00FFBFB5 /* WebProcessConnectionMessageReceiver.cpp */,
     1650                                1A043F6812514D8B00FFBFB5 /* WebProcessConnectionMessages.h */,
    16421651                        );
    16431652                        name = "Derived Sources";
     
    18621871                                BC40783D1250FADD0068F20A /* WKEvent.h in Headers */,
    18631872                                1A043DC1124FF87500FFBFB5 /* PluginProxy.h in Headers */,
     1873                                1A043F6A12514D8B00FFBFB5 /* WebProcessConnectionMessages.h in Headers */,
    18641874                        );
    18651875                        runOnlyForDeploymentPostprocessing = 0;
     
    19111921                        buildConfigurationList = 1DEB91B108733DA50010E9CD /* Build configuration list for PBXProject "WebKit2" */;
    19121922                        compatibilityVersion = "Xcode 3.1";
     1923                        developmentRegion = English;
    19131924                        hasScannedForEncodings = 1;
    19141925                        knownRegions = (
     
    19461957                                8DC2EF530486A6940098B216 /* InfoPlist.strings in Resources */,
    19471958                                1A043B4D124D5E3600FFBFB5 /* PluginProcessProxy.messages.in in Resources */,
     1959                                1A043F5A12514CF300FFBFB5 /* WebProcessConnection.messages.in in Resources */,
    19481960                        );
    19491961                        runOnlyForDeploymentPostprocessing = 0;
     
    21472159                                1A043D92124FF02B00FFBFB5 /* BackingStoreMac.mm in Sources */,
    21482160                                1A043DC2124FF87500FFBFB5 /* PluginProxy.cpp in Sources */,
     2161                                1A043F6912514D8B00FFBFB5 /* WebProcessConnectionMessageReceiver.cpp in Sources */,
    21492162                        );
    21502163                        runOnlyForDeploymentPostprocessing = 0;
Note: See TracChangeset for help on using the changeset viewer.