$typeTransform{"PassRefPtr"} = {
"forwardHeader" => "wtf/PassRefPtr.h",
};
+$typeTransform{"RefCounted"} = {
+ "forwardHeader" => "wtf/RefCounted.h",
+};
$typeTransform{"InspectorFrontendChannel"} = {
"forward" => "InspectorFrontendChannel",
"header" => "InspectorFrontendChannel.h",
my $namespace;
my $backendClassName;
+my $backendClassDeclaration;
my $backendJSStubName;
my %backendTypes;
my @backendMethods;
$frontendTypes{"PassRefPtr"} = 1;
$backendClassName = "InspectorBackendDispatcher";
+ $backendClassDeclaration = "InspectorBackendDispatcher: public RefCounted<InspectorBackendDispatcher>";
$backendJSStubName = "InspectorBackendStub";
$backendTypes{"Inspector"} = 1;
$backendTypes{"InspectorFrontendChannel"} = 1;
$backendTypes{"PassRefPtr"} = 1;
+ $backendTypes{"RefCounted"} = 1;
$backendTypes{"Object"} = 1;
}
}
push(@function, " ${functionName}Message->setObject(\"params\", paramsObject);");
}
- push(@function, " m_inspectorFrontendChannel->sendMessageToFrontend(${functionName}Message->toJSONString());");
+ push(@function, " if (m_inspectorFrontendChannel)");
+ push(@function, " m_inspectorFrontendChannel->sendMessageToFrontend(${functionName}Message->toJSONString());");
push(@function, "}");
push(@function, "");
push(@frontendMethodsImpl, @function);
push(@function, " responseMessage->setObject(\"result\", result);");
push(@function, "");
push(@function, " responseMessage->setNumber(\"id\", callId);");
- push(@function, " m_inspectorFrontendChannel->sendMessageToFrontend(responseMessage->toJSONString());");
+ push(@function, " if (m_inspectorFrontendChannel)");
+ push(@function, " m_inspectorFrontendChannel->sendMessageToFrontend(responseMessage->toJSONString());");
push(@function, "}");
push(@function, "");
push(@backendMethodsImpl, @function);
message->setNumber("id", *callId);
else
message->setValue("id", InspectorValue::null());
- m_inspectorFrontendChannel->sendMessageToFrontend(message->toJSONString());
+ if (m_inspectorFrontendChannel)
+ m_inspectorFrontendChannel->sendMessageToFrontend(message->toJSONString());
}
EOF
return split("\n", $reportProtocolError);
my $backendDispatcherBody = << "EOF";
void ${backendClassName}::dispatch(const String& message)
{
+ RefPtr<${backendClassName}> protect = this;
typedef void (${backendClassName}::*CallHandler)(long callId, InspectorObject* messageObject);
typedef HashMap<String, CallHandler> DispatchMap;
DEFINE_STATIC_LOCAL(DispatchMap, dispatchMap, );
sub generateHeader
{
my $className = shift;
+ my $classDeclaration = shift;
my $types = shift;
my $constructor = shift;
my $constants = shift;
typedef String ErrorString;
-class $className {
+class $classDeclaration {
public:
$constructor
push(@backendHead, @fieldInitializers);
push(@backendHead, " { }");
push(@backendHead, "");
+ push(@backendHead, " void clearFrontend() { m_inspectorFrontendChannel = 0; }");
+ push(@backendHead, "");
push(@backendHead, " enum CommonErrorCode {");
push(@backendHead, " ParseError = 0,");
push(@backendHead, " InvalidRequest,");
undef($SOURCE);
open(my $HEADER, ">$outputHeadersDir/$frontendClassName.h") || die "Couldn't open file $outputHeadersDir/$frontendClassName.h";
- print $HEADER generateHeader($frontendClassName, \%frontendTypes, $frontendConstructor, \@frontendConstantDeclarations, \@frontendMethods, join("\n", @frontendFooter));
+ print $HEADER generateHeader($frontendClassName, $frontendClassName, \%frontendTypes, $frontendConstructor, \@frontendConstantDeclarations, \@frontendMethods, join("\n", @frontendFooter));
close($HEADER);
undef($HEADER);
undef($SOURCE);
open($HEADER, ">$outputHeadersDir/$backendClassName.h") || die "Couldn't open file $outputHeadersDir/$backendClassName.h";
- print $HEADER join("\n", generateHeader($backendClassName, \%backendTypes, $backendConstructor, \@backendConstantDeclarations, \@backendMethods, join("\n", @backendFooter)));
+ print $HEADER join("\n", generateHeader($backendClassName, $backendClassDeclaration, \%backendTypes, $backendConstructor, \@backendConstantDeclarations, \@backendMethods, join("\n", @backendFooter)));
close($HEADER);
undef($HEADER);