Changeset 65804 in webkit


Ignore:
Timestamp:
Aug 23, 2010 5:28:01 AM (14 years ago)
Author:
loislo@chromium.org
Message:

2010-08-23 Sheriff Bot <webkit.review.bot@gmail.com>

Unreviewed, rolling out r65803.
http://trac.webkit.org/changeset/65803
https://bugs.webkit.org/show_bug.cgi?id=44416

windows build failed (Requested by loislo on #webkit).

  • inspector/CodeGeneratorInspector.pm:
  • inspector/Inspector.idl:
  • inspector/InspectorController.cpp:
  • inspector/InspectorController.h:
  • inspector/InspectorFrontendClientLocal.cpp: (WebCore::InspectorFrontendClientLocal::setAttachedWindow):
  • inspector/InspectorValues.h:
  • inspector/front-end/Callback.js: (WebInspector.Callback.prototype.processResponse):
  • inspector/front-end/inspector.js: (WebInspector.dispatch.delayDispatch): (WebInspector.dispatch): (WebInspector_syncDispatch): (WebInspector.dispatchMessageFromBackend): (WebInspector.reportProtocolError):
Location:
trunk/WebCore
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r65803 r65804  
     12010-08-23  Sheriff Bot  <webkit.review.bot@gmail.com>
     2
     3        Unreviewed, rolling out r65803.
     4        http://trac.webkit.org/changeset/65803
     5        https://bugs.webkit.org/show_bug.cgi?id=44416
     6
     7        windows build failed (Requested by loislo on #webkit).
     8
     9        * inspector/CodeGeneratorInspector.pm:
     10        * inspector/Inspector.idl:
     11        * inspector/InspectorController.cpp:
     12        * inspector/InspectorController.h:
     13        * inspector/InspectorFrontendClientLocal.cpp:
     14        (WebCore::InspectorFrontendClientLocal::setAttachedWindow):
     15        * inspector/InspectorValues.h:
     16        * inspector/front-end/Callback.js:
     17        (WebInspector.Callback.prototype.processResponse):
     18        * inspector/front-end/inspector.js:
     19        (WebInspector.dispatch.delayDispatch):
     20        (WebInspector.dispatch):
     21        (WebInspector_syncDispatch):
     22        (WebInspector.dispatchMessageFromBackend):
     23        (WebInspector.reportProtocolError):
     24
    1252010-08-23  Ilya Tikhonovsky  <loislo@chromium.org>
    226
  • trunk/WebCore/inspector/CodeGeneratorInspector.pm

    r65803 r65804  
    1818    "forward" => "InspectorBackend",
    1919    "header" => "InspectorBackend.h",
    20     "domainAccessor" => "m_inspectorController->inspectorBackend()",
     20    "handlerAccessor" => "m_inspectorController->inspectorBackend()",
    2121};
    2222$typeTransform{"Controller"} = {
    2323    "forwardHeader" => "InspectorController.h",
    24     "domainAccessor" => "m_inspectorController",
     24    "handlerAccessor" => "m_inspectorController",
    2525};
    2626$typeTransform{"Debug"} = {
    2727    "forward" => "InspectorDebuggerAgent",
    2828    "header" => "InspectorDebuggerAgent.h",
    29     "domainAccessor" => "m_inspectorController->debuggerAgent()",
     29    "handlerAccessor" => "m_inspectorController->debuggerAgent()",
    3030};
    3131$typeTransform{"DOM"} = {
    3232    "forward" => "InspectorDOMAgent",
    3333    "header" => "InspectorDOMAgent.h",
    34     "domainAccessor" => "m_inspectorController->domAgent()",
     34    "handlerAccessor" => "m_inspectorController->domAgent()",
    3535};
    3636$typeTransform{"ApplicationCache"} = {
    3737    "forward" => "InspectorApplicationCacheAgent",
    3838    "header" => "InspectorApplicationCacheAgent.h",
    39     "domainAccessor" => "m_inspectorController->applicationCacheAgent()",
     39    "handlerAccessor" => "m_inspectorController->applicationCacheAgent()",
    4040};
    4141$typeTransform{"Profiler"} = {
    4242    "forward" => "InspectorProfilerAgent",
    4343    "header" => "InspectorProfilerAgent.h",
    44     "domainAccessor" => "m_inspectorController->profilerAgent()",
     44    "handlerAccessor" => "m_inspectorController->profilerAgent()",
    4545};
    4646$typeTransform{"Frontend"} = {
     
    5757    "forward" => "InspectorObject",
    5858    "header" => "InspectorValues.h",
    59     "JSONType" => "Object"
     59    "accessorSuffix" => "Object"
    6060};
    6161$typeTransform{"Array"} = {
     
    6565    "forward" => "InspectorArray",
    6666    "header" => "InspectorValues.h",
    67     "JSONType" => "Array"
     67    "accessorSuffix" => "Array"
    6868};
    6969$typeTransform{"Value"} = {
     
    7373    "forward" => "InspectorValue",
    7474    "header" => "InspectorValues.h",
    75     "JSONType" => "Value"
     75    "accessorSuffix" => "Value"
    7676};
    7777$typeTransform{"String"} = {
     
    8080    "forwardHeader" => "wtf/Forward.h",
    8181    "header" => "PlatformString.h",
    82     "JSONType" => "String"
     82    "accessorSuffix" => "String"
    8383};
    8484$typeTransform{"long"} = {
     
    8888    "forward" => "",
    8989    "header" => "",
    90     "JSONType" => "Number"
     90    "accessorSuffix" => "Number"
    9191};
    9292$typeTransform{"int"} = {
     
    9696    "forward" => "",
    9797    "header" => "",
    98     "JSONType" => "Number",
     98    "accessorSuffix" => "Number",
    9999};
    100100$typeTransform{"unsigned long"} = {
     
    104104    "forward" => "",
    105105    "header" => "",
    106     "JSONType" => "Number"
     106    "accessorSuffix" => "Number"
    107107};
    108108$typeTransform{"unsigned int"} = {
     
    112112    "forward" => "",
    113113    "header" => "",
    114     "JSONType" => "Number"
     114    "accessorSuffix" => "Number"
    115115};
    116116$typeTransform{"boolean"} = {
     
    120120    "forward" => "",
    121121    "header" => "",
    122     "JSONType" => "Bool"
     122    "accessorSuffix" => "Bool"
    123123};
    124124$typeTransform{"void"} = {
     
    162162my @frontendConstantDefinitions;
    163163my $frontendFooter;
     164
     165my $callId = new domSignature(); # it is just structure for describing parameters from IDLStructure.pm.
     166$callId->type("long");
     167$callId->name("callId");
    164168
    165169# Default constructor
     
    219223    $backendTypes{"InspectorClient"} = 1;
    220224    $backendTypes{"PassRefPtr"} = 1;
    221     $backendTypes{"Object"} = 1;
    222 
     225    $backendTypes{"Array"} = 1;
     226
     227    push(@backendMethodsImpl, generateBackendPrivateFunctions());
    223228    push(@backendMethodsImpl, generateBackendMessageParser());
    224229    generateFunctions($interface);
     
    255260    map($frontendTypes{$_->type} = 1, @argsFiltered); # register required types.
    256261    my $arguments = join(", ", map($typeTransform{$_->type}->{"param"} . " " . $_->name, @argsFiltered)); # prepare arguments for function signature.
     262    my @pushArguments = map("    arguments->push" . $typeTransform{$_->type}->{"accessorSuffix"} . "(" . $_->name . ");", @argsFiltered);
    257263
    258264    my $signature = "    void ${functionName}(${arguments});";
     
    263269        push(@function, "void ${frontendClassName}::${functionName}(${arguments})");
    264270        push(@function, "{");
    265         push(@function, "    RefPtr<InspectorObject> ${functionName}Message = InspectorObject::create();");
    266         push(@function, "    ${functionName}Message->setString(\"type\", \"event\");");
    267         push(@function, "    ${functionName}Message->setString(\"event\", \"$functionName\");");
    268         push(@function, "    RefPtr<InspectorObject> payloadDataObject = InspectorObject::create();");
    269         my @pushArguments = map("    payloadDataObject->set" . $typeTransform{$_->type}->{"JSONType"} . "(\"" . $_->name . "\", " . $_->name . ");", @argsFiltered);
     271        push(@function, "    RefPtr<InspectorArray> arguments = InspectorArray::create();");
     272        push(@function, "    arguments->pushString(\"$functionName\");");
    270273        push(@function, @pushArguments);
    271         push(@function, "    ${functionName}Message->setObject(\"data\", payloadDataObject);");
    272         push(@function, "    m_inspectorClient->sendMessageToFrontend(${functionName}Message->toJSONString());");
     274        push(@function, "    m_inspectorClient->sendMessageToFrontend(arguments->toJSONString());");
    273275
    274276        push(@function, "}");
     
    278280}
    279281
     282sub generateBackendPrivateFunctions
     283{
     284    my $privateFunctions = << "EOF";
     285static String formatWrongArgumentsCountMessage(unsigned expected, unsigned actual)
     286{
     287    return String::format("Wrong number of parameters: %d (expected: %d)", actual, expected);
     288}
     289
     290static String formatWrongArgumentTypeMessage(unsigned position, const char* name, const char* expectedType)
     291{
     292    return String::format("Failed to convert parameter %d (%s) to %s", position, name, expectedType);
     293}
     294EOF
     295    return split("\n", $privateFunctions);
     296}
     297
    280298sub generateBackendFunction
    281299{
     
    288306
    289307    map($backendTypes{$_->type} = 1, @{$function->parameters}); # register required types
    290     my @inArgs = grep($_->direction eq "in" && !($_->name eq "callId") , @{$function->parameters});
     308    my @inArgs = grep($_->direction eq "in", @{$function->parameters});
    291309    my @outArgs = grep($_->direction eq "out", @{$function->parameters});
    292310
    293     my $signature = "    void ${functionName}(long callId, InspectorObject* requestMessageObject);";
     311    my $signature = "    void ${functionName}(PassRefPtr<InspectorArray> args);";
    294312    !$backendMethods{${signature}} || die "Duplicate function was detected for signature '$signature'.";
    295313    $backendMethods{${signature}} = $functionName;
    296314
    297315    my @function;
    298     my $requestMessageObject = scalar(@inArgs) ? " requestMessageObject" : "";
    299     push(@function, "void ${backendClassName}::${functionName}(long callId, InspectorObject*$requestMessageObject)");
     316    push(@function, "void ${backendClassName}::${functionName}(PassRefPtr<InspectorArray> args)");
    300317    push(@function, "{");
    301     push(@function, "    RefPtr<InspectorArray> protocolErrors = InspectorArray::create();");
     318    push(@function, "    long callId = 0;");
    302319    push(@function, "");
    303320
    304     my $domain = $function->signature->extendedAttributes->{"handler"} || "Controller";
    305     my $domainAccessor = $typeTransform{$domain}->{"domainAccessor"};
    306     $backendTypes{$domain} = 1;
    307     push(@function, "    if (!$domainAccessor)");
    308     push(@function, "        protocolErrors->pushString(String::format(\"Error: %s handler is not available.\", \"$domain\"));");
     321    my $expectedParametersCount = scalar(@inArgs);
     322    my $expectedParametersCountWithMethodName = scalar(@inArgs) + 1;
     323    push(@function, "    if (args->length() != $expectedParametersCountWithMethodName) {");
     324    push(@function, "        ASSERT_NOT_REACHED();");
     325    push(@function, "        reportProtocolError(callId, ${functionName}Cmd, formatWrongArgumentsCountMessage(args->length() - 1, $expectedParametersCount));");
     326    push(@function, "        return;");
     327    push(@function, "    }");
    309328    push(@function, "");
    310329
    311     if (scalar(@inArgs)) {
    312         # declare variables for all 'in' args;
    313         push(@function, map("    " . $typeTransform{$_->type}->{"variable"} . " " . $_->name . ";", @inArgs));
    314 
     330    my $i = 1; # zero element is the method name.
     331    foreach my $parameter (@inArgs) {
     332        my $type = $parameter->type;
     333        my $argumentType = $typeTransform{$type}->{"variable"};
     334        push(@function, "    $argumentType " . $parameter->name . ";") if !($parameter->name eq "callId");
     335        push(@function, "    if (!args->get($i)->as" . $typeTransform{$type}->{"accessorSuffix"} . "(&" . $parameter->name . ")) {");
     336        push(@function, "        ASSERT_NOT_REACHED();");
     337        push(@function, "        reportProtocolError(callId, ${functionName}Cmd, formatWrongArgumentTypeMessage($i, \"" . $parameter->name . "\", \"$type\"));");
     338        push(@function, "        return;");
     339        push(@function, "    }");
    315340        push(@function, "");
    316         push(@function, "    RefPtr<InspectorObject> argumentsContainer;");
    317         push(@function, "    if (!(argumentsContainer = requestMessageObject->getObject(\"arguments\"))) {");
    318         push(@function, "        ASSERT_NOT_REACHED();");
    319         push(@function, "        protocolErrors->pushString(String::format(\"Error: arguments object was not found.\"));");
    320         push(@function, "    } else {");
    321         push(@function, "        InspectorObject::const_iterator argumentsEndIterator = argumentsContainer->end();");
    322 
    323         foreach my $parameter (@inArgs) {
    324             my $name = $parameter->name;
    325             my $type = $parameter->type;
    326             my $variableType = $typeTransform{$type}->{"variable"};
    327             my $JSONType = $typeTransform{$type}->{"JSONType"};
    328 
    329             push(@function, "");
    330             push(@function, "        InspectorObject::const_iterator ${name}ValueIterator = argumentsContainer->find(\"$name\");");
    331             push(@function, "        if (${name}ValueIterator == argumentsEndIterator) {");
    332             push(@function, "            ASSERT_NOT_REACHED();");
    333             push(@function, "            protocolErrors->pushString(String::format(\"Error: Argument '%s' with type '%s' was not found.\", \"$name\", \"$JSONType\"));");
    334             push(@function, "        } else {");
    335             push(@function, "            if (!${name}ValueIterator->second->as$JSONType(&$name)) {");
    336             push(@function, "                ASSERT_NOT_REACHED();");
    337             push(@function, "                protocolErrors->pushString(String::format(\"Error: Argument '%s' has wrong type. It should be '%s'.\", \"$name\", \"$JSONType\"));");
    338             push(@function, "            }");
    339             push(@function, "        }");
    340         }
    341         push(@function, "    }");
    342     }
     341        ++$i;
     342    }
     343
     344    my $handler = $function->signature->extendedAttributes->{"handler"} || "Controller";
     345    my $handlerAccessor = $typeTransform{$handler}->{"handlerAccessor"};
     346    $backendTypes{$handler} = 1;
     347    push(@function, "    if (!$handlerAccessor) {");
     348    push(@function, "        reportProtocolError(callId, ${functionName}Cmd, \"Error: $handler handler is not available.\");");
     349    push(@function, "        return;");
     350    push(@function, "    }");
     351    push(@function, "");
     352
    343353
    344354    foreach (@outArgs) { # declare local variables for out arguments.
    345355        my $initializer = $typeTransform{$_->type}->{"defaultValue"} ? " = " . $typeTransform{$_->type}->{"defaultValue"} : "";
    346         push(@function, "        " . $typeTransform{$_->type}->{"variable"} . " " . $_->name . "$initializer;");
    347     }
    348 
    349     my $args = join(", ", (map($_->name, @inArgs), map("&" . $_->name, @outArgs)));
    350     push(@function, "    if (!protocolErrors->length())");
    351     push(@function, "        $domainAccessor->$functionName($args);");
    352     push(@function, "");
    353 
    354     push(@function, "    // use InspectorFrontend as a marker of WebInspector availability");
    355     push(@function, "    if (callId && m_inspectorController->hasFrontend()) {");
    356     push(@function, "        RefPtr<InspectorObject> responseMessage = InspectorObject::create();");
    357     push(@function, "        responseMessage->setNumber(\"seq\", callId);");
    358     push(@function, "        responseMessage->setString(\"type\", \"response\");");
    359     push(@function, "        responseMessage->setString(\"domain\", \"$domain\");");
    360     push(@function, "        responseMessage->setString(\"command\", \"$functionName\");");
    361     push(@function, "        responseMessage->setBool(\"success\", !protocolErrors->length());");
    362     push(@function, "");
    363     push(@function, "        if (protocolErrors->length())");
    364     push(@function, "            responseMessage->setArray(\"errors\", protocolErrors);");
    365     if (scalar(@outArgs)) {
    366         push(@function, "        else {");
    367         push(@function, "            RefPtr<InspectorObject> responseData = InspectorObject::create();");
    368         push(@function, map("            responseData->set" . $typeTransform{$_->type}->{"JSONType"} . "(\"" . $_->name . "\", " . $_->name . ");", @outArgs));
    369         push(@function, "            responseMessage->setObject(\"data\", responseData);");
    370         push(@function, "        }");
    371     }
    372     push(@function, "        m_inspectorController->inspectorClient()->sendMessageToFrontend(responseMessage->toJSONString());");
    373     push(@function, "    }");
    374 
    375 
     356        push(@function, "    " . $typeTransform{$_->type}->{"variable"} . " " . $_->name . "$initializer;");
     357    }
     358
     359    my $args = join(", ", (grep(!($_ eq "callId"), map($_->name, @inArgs)), map("&" . $_->name, @outArgs)));
     360    push(@function, "    $handlerAccessor->$functionName($args);");
     361
     362    # The results of function call should be transfered back to frontend.
     363    if (scalar(grep($_->name eq "callId", @inArgs))) {
     364        my @pushArguments = map("        arguments->push" . $typeTransform{$_->type}->{"accessorSuffix"} . "(" . $_->name . ");", @outArgs);
     365
     366        push(@function, "");
     367        push(@function, "    // use InspectorFrontend as a marker of WebInspector availability");
     368        push(@function, "    if (m_inspectorController->hasFrontend()) {");
     369        push(@function, "        RefPtr<InspectorArray> arguments = InspectorArray::create();");
     370        push(@function, "        arguments->pushString(\"processResponse\");");
     371        push(@function, "        arguments->pushNumber(callId);");
     372        push(@function, @pushArguments);
     373        push(@function, "        m_inspectorController->inspectorClient()->sendMessageToFrontend(arguments->toJSONString());");
     374        push(@function, "    }");
     375    }
    376376    push(@function, "}");
    377377    push(@function, "");
     
    385385void ${backendClassName}::reportProtocolError(const long callId, const String& method, const String& errorText) const
    386386{
    387     RefPtr<InspectorObject> message = InspectorObject::create();
    388     message->setNumber("seq", callId);
    389     message->setString("type", "error");
    390     message->setString("domain", "inspectorProtocol");
    391     message->setString("command", method);
    392     message->setBool("success", false);
    393     RefPtr<InspectorArray> errors = InspectorArray::create();
    394     errors->pushString(errorText);
    395     message->setArray("errors", errors);
    396     m_inspectorController->inspectorClient()->sendMessageToFrontend(message->toJSONString());
     387    RefPtr<InspectorArray> arguments = InspectorArray::create();
     388    arguments->pushString("reportProtocolError");
     389    arguments->pushNumber(callId);
     390    arguments->pushString(method);
     391    arguments->pushString(errorText);
     392    m_inspectorController->inspectorClient()->sendMessageToFrontend(arguments->toJSONString());
    397393}
    398394EOF
    399395    return split("\n", $reportProtocolError);
    400396}
    401 
    402397
    403398sub generateBackendDispatcher
     
    411406void ${backendClassName}::dispatch(const String& message)
    412407{
    413     typedef void (${backendClassName}::*CallHandler)(long callId, InspectorObject* messageObject);
     408    typedef void (${backendClassName}::*CallHandler)(PassRefPtr<InspectorArray> args);
    414409    typedef HashMap<String, CallHandler> DispatchMap;
    415410    DEFINE_STATIC_LOCAL(DispatchMap, dispatchMap, );
    416     long callId = 0;
    417 
    418411    if (dispatchMap.isEmpty()) {
    419412$mapEntries
     
    423416    if (!parsedMessage) {
    424417        ASSERT_NOT_REACHED();
    425         reportProtocolError(callId, "dispatch", "Error: Invalid message format. Message should be in JSON format.");
     418        reportProtocolError(0, "dispatch", "Error: Invalid message format. Message should be in JSON format.");
    426419        return;
    427420    }
    428421
    429     RefPtr<InspectorObject> messageObject = parsedMessage->asObject();
    430     if (!messageObject) {
     422    RefPtr<InspectorArray> messageArray = parsedMessage->asArray();
     423    if (!messageArray) {
    431424        ASSERT_NOT_REACHED();
    432         reportProtocolError(callId, "dispatch", "Error: Invalid message format. The message should be a JSONified object.");
     425        reportProtocolError(0, "dispatch", "Error: Invalid message format. The message should be a JSONified array of arguments.");
    433426        return;
    434427    }
    435428
    436     RefPtr<InspectorValue> callIdValue = messageObject->get("seq");
    437     if (!callIdValue) {
     429    if (!messageArray->length()) {
    438430        ASSERT_NOT_REACHED();
    439         reportProtocolError(callId, "dispatch", "Error: Invalid message format. 'seq' property was not found in the request.");
     431        reportProtocolError(0, "dispatch", "Error: Invalid message format. Empty message was received.");
    440432        return;
    441433    }
    442434
    443     if (!callIdValue->asNumber(&callId)) {
     435    String methodName;
     436    if (!messageArray->get(0)->asString(&methodName)) {
    444437        ASSERT_NOT_REACHED();
    445         reportProtocolError(callId, "dispatch", "Error: Invalid message format. the type of 'seq' property should be number.");
     438        reportProtocolError(0, "dispatch", "Error: Invalid message format. The first element of the message should be method name.");
    446439        return;
    447440    }
    448441
    449     RefPtr<InspectorValue> commandValue = messageObject->get("command");
    450     if (!commandValue) {
    451         ASSERT_NOT_REACHED();
    452         reportProtocolError(callId, "dispatch", "Error: Invalid message format. 'command' property wasn't found.");
    453         return;
    454     }
    455 
    456     String command;
    457     if (!commandValue->asString(&command)) {
    458         ASSERT_NOT_REACHED();
    459         reportProtocolError(callId, "dispatch", "Error: Invalid message format. The type of 'command' property should be string.");
    460         return;
    461     }
    462 
    463     HashMap<String, CallHandler>::iterator it = dispatchMap.find(command);
     442    HashMap<String, CallHandler>::iterator it = dispatchMap.find(methodName);
    464443    if (it == dispatchMap.end()) {
    465444        ASSERT_NOT_REACHED();
    466         reportProtocolError(callId, "dispatch", String::format("Error: Invalid command was received. '%s' wasn't found.", command.utf8().data()));
     445        reportProtocolError(0, "dispatch", String::format("Error: Invalid method name. '%s' wasn't found.", methodName.utf8().data()));
    467446        return;
    468447    }
    469448
    470     ((*this).*it->second)(callId, messageObject.get());
     449    ((*this).*it->second)(messageArray);
    471450}
    472451EOF
     
    482461    if (!value)
    483462        return false;
    484 
    485     RefPtr<InspectorObject> object = value->asObject();
    486     if (!object)
     463    RefPtr<InspectorArray> array = value->asArray();
     464    if (!array)
    487465        return false;
    488466
    489     RefPtr<InspectorValue> commandValue = object->get("command");
    490     if (!commandValue)
     467    if (!array->length())
    491468        return false;
    492 
    493     return commandValue->asString(result);
    494 }
    495 
     469    return array->get(0)->asString(result);
     470}
    496471EOF
    497472    return split("\n", $messageParserBody);
     
    502477    my $interface = shift;
    503478    my @backendFunctions = grep(!$_->signature->extendedAttributes->{"notify"}, @{$interface->functions});
    504     my @JSStubs;
    505 
    506     foreach my $function (@backendFunctions) {
    507         my $name = $function->signature->name;
    508         my $domain = $function->signature->extendedAttributes->{"handler"};
    509         my $argumentNames = join(",", map("\"" . $_->name . "\": null", grep($_->direction eq "in", @{$function->parameters})));
    510         push(@JSStubs, "    this._registerDelegate('{" .
    511             "\"seq\": 0, " .
    512             "\"type\": \"request\", " .
    513             "\"domain\": \"$domain\", " .
    514             "\"command\": \"$name\", " .
    515             "\"arguments\": {$argumentNames}" .
    516         "}');");
    517     }
     479    my @JSStubs = map("    this._registerDelegate(\"" . $_->signature->name . "\");", @backendFunctions);
    518480
    519481    my $JSStubs = join("\n", @JSStubs);
     
    527489
    528490WebInspector.InspectorBackendStub.prototype = {
    529     _registerDelegate: function(commandInfo)
     491    _registerDelegate: function(methodName)
    530492    {
    531         var commandObject = JSON.parse(commandInfo);
    532         this[commandObject.command] = this.sendMessageToBackend.bind(this, commandInfo);
     493        this[methodName] = this.sendMessageToBackend.bind(this, methodName);
    533494    },
    534495
    535496    sendMessageToBackend: function()
    536497    {
    537         var args = Array.prototype.slice.call(arguments);
    538         var request = JSON.parse(args.shift());
    539         for (var key in request.arguments) {
    540             if (key === "callId")
    541                 request.seq = args.shift();
    542             else
    543                 request.arguments[key] = args.shift();
    544         }
    545         if (args.length === 1 && typeof args[0] === "function")
    546             request.seq = WebInspector.Callback.wrap(args[0]);
    547 
    548         var message = JSON.stringify(request);
     498        var message = JSON.stringify(Array.prototype.slice.call(arguments));
    549499        InspectorFrontendHost.sendMessageToBackend(message);
    550500    }
  • trunk/WebCore/inspector/Inspector.idl

    r65803 r65804  
    5858        [notify] void searchingForNodeWasEnabled();
    5959        [notify] void searchingForNodeWasDisabled();
    60         [notify] void setAttachedWindow(out boolean attached);
    6160        [notify] void setChildNodes(out long parentId, out Array nodes);
    6261        [notify] void setDetachedRoot(out Object root);
  • trunk/WebCore/inspector/InspectorController.cpp

    r65803 r65804  
    421421}
    422422
    423 void InspectorController::setAttachedWindow(bool attached)
    424 {
    425     if (!m_remoteFrontend) {
    426         ASSERT_NOT_REACHED();
    427         return;
    428     }
    429     m_remoteFrontend->setAttachedWindow(attached);
    430 }
    431 
    432423void InspectorController::inspectedWindowScriptObjectCleared(Frame* frame)
    433424{
  • trunk/WebCore/inspector/InspectorController.h

    r65803 r65804  
    148148    void setInspectorFrontendClient(PassOwnPtr<InspectorFrontendClient> client);
    149149    bool hasInspectorFrontendClient() const { return m_inspectorFrontendClient; }
    150     void setAttachedWindow(bool attached);
    151150
    152151    void inspectedWindowScriptObjectCleared(Frame*);
  • trunk/WebCore/inspector/InspectorFrontendClientLocal.cpp

    r65803 r65804  
    122122void InspectorFrontendClientLocal::setAttachedWindow(bool attached)
    123123{
    124     m_inspectorController->setAttachedWindow(attached);
     124    ScriptObject webInspectorObj;
     125    if (!ScriptGlobalObject::get(m_frontendScriptState, "WebInspector", webInspectorObj)) {
     126        ASSERT_NOT_REACHED();
     127        return;
     128    }
     129    ScriptFunctionCall function(webInspectorObj, "dispatch");
     130    function.appendArgument("setAttachedWindow");
     131    function.appendArgument(attached);
     132    function.call();
    125133}
    126134
  • trunk/WebCore/inspector/InspectorValues.h

    r65803 r65804  
    177177    void setArray(const String& name, PassRefPtr<InspectorArray>);
    178178
    179     const_iterator find(const String& name) const;
    180179    bool getBool(const String& name, bool* output) const;
    181180    bool getNumber(const String& name, double* output) const;
     
    226225};
    227226
    228 inline InspectorObject::const_iterator InspectorObject::find(const String& name) const
    229 {
    230     return m_data.find(name);
    231 }
    232 
    233227inline void InspectorObject::setBool(const String& name, bool value)
    234228{
  • trunk/WebCore/inspector/front-end/Callback.js

    r65803 r65804  
    4343    },
    4444
    45     processResponse: function(callbackId, args)
     45    processResponse: function(callbackId, opt_vararg)
    4646    {
     47        var args = Array.prototype.slice.call(arguments, 1);
    4748        var callback = this._callbacks[callbackId];
    4849        callback.apply(null, args);
  • trunk/WebCore/inspector/front-end/inspector.js

    r65803 r65804  
    590590window.addEventListener("load", windowLoaded, false);
    591591
    592 WebInspector.dispatch = function(message) {
     592WebInspector.dispatch = function() {
     593    var methodName = arguments[0];
     594    var parameters = Array.prototype.slice.call(arguments, 1);
     595
    593596    // We'd like to enforce asynchronous interaction between the inspector controller and the frontend.
    594597    // This is important to LayoutTests.
    595598    function delayDispatch()
    596599    {
    597         WebInspector_syncDispatch(message);
     600        if (!(methodName in WebInspector)) {
     601            console.error("Attempted to dispatch unimplemented WebInspector method: %s", methodName);
     602            return;
     603        }
     604
     605        WebInspector[methodName].apply(WebInspector, parameters);
    598606        WebInspector.pendingDispatches--;
    599607    }
     
    605613WebInspector_syncDispatch = function(message)
    606614{
    607     var messageObject = (typeof message === "string") ? JSON.parse(message) : message;
    608     if (messageObject.type === "response" && !messageObject.success) {
    609         WebInspector.removeResponseCallbackEntry(messageObject.seq)
    610         WebInspector.reportProtocolError(messageObject);
    611         return;
    612     }
    613 
    614     var arguments = [];
    615     if (messageObject.data)
    616         for (var key in messageObject.data)
    617             arguments.push(messageObject.data[key]);
    618 
    619     if (messageObject.type === "event") {
    620         if (!messageObject.event in WebInspector) {
    621             console.error("Attempted to dispatch unimplemented WebInspector method: %s", messageObject.event);
    622             return;
    623         }
    624         WebInspector[messageObject.event].apply(WebInspector, arguments);
    625     }
    626 
    627     if (messageObject.type === "response")
    628         WebInspector.processResponse(messageObject.seq, arguments);
    629 }
    630 
    631 WebInspector.dispatchMessageFromBackend = function(messageObject)
    632 {
    633     WebInspector.dispatch(messageObject);
    634 }
    635 
    636 WebInspector.reportProtocolError = function(messageObject)
    637 {
    638     console.error("Error: InspectorBackend." + messageObject.command + " failed.");
    639     for (var error in messageObject.errors)
    640         console.error("    " + error);
    641     WebInspector.removeResponseCallbackEntry(messageObject.seq);
     615    var args = JSON.parse(message);
     616    var methodName = args[0];
     617    var parameters = args.slice(1);
     618    WebInspector[methodName].apply(WebInspector, parameters);
     619}
     620
     621WebInspector.dispatchMessageFromBackend = function(arguments)
     622{
     623    WebInspector.dispatch.apply(this, arguments);
     624}
     625
     626WebInspector.reportProtocolError = function(callId, methodName, errorText)
     627{
     628    console.error("InspectorBackend." + methodName + " failed with error text: '" + errorText + "'");
     629    WebInspector.removeResponseCallbackEntry(callId);
    642630}
    643631
Note: See TracChangeset for help on using the changeset viewer.