Index: Source/WebCore/inspector/CodeGeneratorInspector.pm |
=================================================================== |
--- Source/WebCore/inspector/CodeGeneratorInspector.pm (revision 87486) |
+++ Source/WebCore/inspector/CodeGeneratorInspector.pm (working copy) |
@@ -93,6 +93,9 @@ |
$typeTransform{"PassRefPtr"} = { |
"forwardHeader" => "wtf/PassRefPtr.h", |
}; |
+$typeTransform{"RefCounted"} = { |
+ "forwardHeader" => "wtf/RefCounted.h", |
+}; |
$typeTransform{"InspectorFrontendChannel"} = { |
"forward" => "InspectorFrontendChannel", |
"header" => "InspectorFrontendChannel.h", |
@@ -213,6 +216,7 @@ |
my $namespace; |
my $backendClassName; |
+my $backendClassDeclaration; |
my $backendJSStubName; |
my %backendTypes; |
my @backendMethods; |
@@ -273,10 +277,12 @@ |
$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; |
} |
@@ -384,7 +390,8 @@ |
} |
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); |
@@ -489,7 +496,8 @@ |
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); |
@@ -530,7 +538,8 @@ |
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); |
@@ -581,6 +590,7 @@ |
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, ); |
@@ -880,6 +890,7 @@ |
sub generateHeader |
{ |
my $className = shift; |
+ my $classDeclaration = shift; |
my $types = shift; |
my $constructor = shift; |
my $constants = shift; |
@@ -906,7 +917,7 @@ |
typedef String ErrorString; |
-class $className { |
+class $classDeclaration { |
public: |
$constructor |
@@ -993,6 +1004,8 @@ |
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,"); |
@@ -1024,7 +1037,7 @@ |
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); |
@@ -1050,7 +1063,7 @@ |
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); |