2011-04-01 Sergey Vorobyev <sergeyvorobyev@google.com>
authoryurys@chromium.org <yurys@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 4 Apr 2011 09:38:02 +0000 (09:38 +0000)
committeryurys@chromium.org <yurys@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 4 Apr 2011 09:38:02 +0000 (09:38 +0000)
        Reviewed by Yury Semikhatsky.

        Web Inspector: Separate sendMessageToFrontend function
        from InspectorClient to individual interface.
        https://bugs.webkit.org/show_bug.cgi?id=57548

        Refactoring - covered with existing inspector tests.

        * GNUmakefile.am:
        * WebCore.gypi:
        * WebCore.vcproj/WebCore.vcproj:
        * WebCore.xcodeproj/project.pbxproj:
        * inspector/CodeGeneratorInspector.pm:
        * inspector/InspectorClient.h:
        * inspector/InspectorFrontendChannel.h: Added.
        (WebCore::InspectorFrontendChannel::~InspectorFrontendChannel):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@82810 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/GNUmakefile.am
Source/WebCore/WebCore.gypi
Source/WebCore/WebCore.vcproj/WebCore.vcproj
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/inspector/CodeGeneratorInspector.pm
Source/WebCore/inspector/InspectorClient.h
Source/WebCore/inspector/InspectorFrontendChannel.h [new file with mode: 0644]

index 8dca8cd..fe19fe4 100644 (file)
@@ -1,3 +1,22 @@
+2011-04-01  Sergey Vorobyev  <sergeyvorobyev@google.com>
+
+        Reviewed by Yury Semikhatsky.
+
+        Web Inspector: Separate sendMessageToFrontend function
+        from InspectorClient to individual interface.
+        https://bugs.webkit.org/show_bug.cgi?id=57548
+
+        Refactoring - covered with existing inspector tests.
+
+        * GNUmakefile.am:
+        * WebCore.gypi:
+        * WebCore.vcproj/WebCore.vcproj:
+        * WebCore.xcodeproj/project.pbxproj:
+        * inspector/CodeGeneratorInspector.pm:
+        * inspector/InspectorClient.h:
+        * inspector/InspectorFrontendChannel.h: Added.
+        (WebCore::InspectorFrontendChannel::~InspectorFrontendChannel):
+
 2011-04-04  Nico Weber  <thakis@chromium.org>
 
         Reviewed by Eric Seidel.
index 99d6841..0492d5a 100644 (file)
@@ -2024,6 +2024,7 @@ webcore_sources += \
        Source/WebCore/inspector/InspectorDOMStorageAgent.h \
        Source/WebCore/inspector/InspectorDOMStorageResource.cpp \
        Source/WebCore/inspector/InspectorDOMStorageResource.h \
+       Source/WebCore/inspector/InspectorFrontendChannel.h \
        Source/WebCore/inspector/InspectorFrontendClient.h \
        Source/WebCore/inspector/InspectorFrontendClientLocal.cpp \
        Source/WebCore/inspector/InspectorFrontendClientLocal.h \
index 6fd251f..2d55e1a 100644 (file)
             'inspector/InspectorDatabaseResource.h',
             'inspector/InspectorDebuggerAgent.cpp',
             'inspector/InspectorDebuggerAgent.h',
+            'inspector/InspectorFrontendChannel.h',
             'inspector/InspectorFrontendClientLocal.cpp',
             'inspector/InspectorFrontendHost.cpp',
             'inspector/InspectorFrontendHost.h',
index ba0498f..570d1fa 100755 (executable)
                                >
                        </File>
                        <File
+                               RelativePath="..\inspector\InspectorFrontendChannel.h"
+                               >
+                       </File>
+                       <File
                                RelativePath="..\inspector\InspectorFrontendClient.h"
                                >
                        </File>
index 6c99ec1..ce2ba26 100644 (file)
                1CFAE3230A6D6A3F0032593D /* libobjc.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 1CFAE3220A6D6A3F0032593D /* libobjc.dylib */; };
                20D629261253690B00081543 /* InspectorInstrumentation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 20D629241253690B00081543 /* InspectorInstrumentation.cpp */; };
                20D629271253690B00081543 /* InspectorInstrumentation.h in Headers */ = {isa = PBXBuildFile; fileRef = 20D629251253690B00081543 /* InspectorInstrumentation.h */; };
+               227777601345DEA9008EA455 /* InspectorFrontendChannel.h in Headers */ = {isa = PBXBuildFile; fileRef = 2277775F1345DEA9008EA455 /* InspectorFrontendChannel.h */; settings = {ATTRIBUTES = (Private, ); }; };
                22885E641301AE4C00526E68 /* JSDOMImplementationCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 22885E631301AE4C00526E68 /* JSDOMImplementationCustom.cpp */; };
                228C284510D82500009D0D0E /* ScriptWrappable.h in Headers */ = {isa = PBXBuildFile; fileRef = 228C284410D82500009D0D0E /* ScriptWrappable.h */; settings = {ATTRIBUTES = (Private, ); }; };
                245D80A313280E40003492A6 /* SQLCallbackWrapper.h in Headers */ = {isa = PBXBuildFile; fileRef = 245D80A213280E40003492A6 /* SQLCallbackWrapper.h */; };
                1CFAE3220A6D6A3F0032593D /* libobjc.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libobjc.dylib; path = /usr/lib/libobjc.dylib; sourceTree = "<absolute>"; };
                20D629241253690B00081543 /* InspectorInstrumentation.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InspectorInstrumentation.cpp; sourceTree = "<group>"; };
                20D629251253690B00081543 /* InspectorInstrumentation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InspectorInstrumentation.h; sourceTree = "<group>"; };
+               2277775F1345DEA9008EA455 /* InspectorFrontendChannel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InspectorFrontendChannel.h; sourceTree = "<group>"; };
                22885E631301AE4C00526E68 /* JSDOMImplementationCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSDOMImplementationCustom.cpp; sourceTree = "<group>"; };
                228C284410D82500009D0D0E /* ScriptWrappable.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScriptWrappable.h; sourceTree = "<group>"; };
                2442BBF81194C9D300D49469 /* HashChangeEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HashChangeEvent.h; sourceTree = "<group>"; };
                                7A74ECB9101839A600BF939E /* InspectorDOMStorageAgent.h */,
                                41F061730F5F00AC00A07EAC /* InspectorDOMStorageResource.cpp */,
                                41F061720F5F00AC00A07EAC /* InspectorDOMStorageResource.h */,
+                               2277775F1345DEA9008EA455 /* InspectorFrontendChannel.h */,
                                F344C7121125B82C00F26EEE /* InspectorFrontendClient.h */,
                                F344C75711294FF600F26EEE /* InspectorFrontendClientLocal.cpp */,
                                F344C75211294D9D00F26EEE /* InspectorFrontendClientLocal.h */,
                                B885E8D511E06DD2009FFBF4 /* InspectorApplicationCacheAgent.h in Headers */,
                                4F707A9A11EF679400ACDA69 /* InspectorBackendDispatcher.h in Headers */,
                                F3D4C47912E07663003DA150 /* InspectorBrowserDebuggerAgent.h in Headers */,
+                               227777601345DEA9008EA455 /* InspectorFrontendChannel.h in Headers */,
                                1C81B95C0E97330800266E07 /* InspectorClient.h in Headers */,
                                F3335BF912E07DC300D33011 /* InspectorConsoleAgent.h in Headers */,
                                F3F5CF1112ED81A80084C569 /* InspectorConsoleInstrumentation.h in Headers */,
index 6dedccf..a9ebf38 100644 (file)
@@ -90,13 +90,13 @@ $typeTransform{"Frontend"} = {
     "forward" => "InspectorFrontend",
     "header" => "InspectorFrontend.h",
 };
-$typeTransform{"InspectorClient"} = {
-    "forward" => "InspectorClient",
-    "header" => "InspectorClient.h",
-};
 $typeTransform{"PassRefPtr"} = {
     "forwardHeader" => "wtf/PassRefPtr.h",
 };
+$typeTransform{"InspectorFrontendChannel"} = {
+    "forward" => "InspectorFrontendChannel",
+    "header" => "InspectorFrontendChannel.h",
+};
 $typeTransform{"Object"} = {
     "param" => "PassRefPtr<InspectorObject>",
     "variable" => "RefPtr<InspectorObject>",
@@ -261,17 +261,17 @@ sub GenerateModule
     $namespace =~ s/core/WebCore/;
 
     $frontendClassName = "InspectorFrontend";
-    $frontendConstructor = "    ${frontendClassName}(InspectorClient*);";
+    $frontendConstructor = "    ${frontendClassName}(InspectorFrontendChannel*);";
     push(@frontendFooter, "private:");
-    push(@frontendFooter, "    InspectorClient* m_inspectorClient;");
+    push(@frontendFooter, "    InspectorFrontendChannel* m_inspectorFrontendChannel;");
     $frontendTypes{"String"} = 1;
-    $frontendTypes{"InspectorClient"} = 1;
+    $frontendTypes{"InspectorFrontendChannel"} = 1;
     $frontendTypes{"PassRefPtr"} = 1;
 
     $backendClassName = "InspectorBackendDispatcher";
     $backendJSStubName = "InspectorBackendStub";
     $backendTypes{"Inspector"} = 1;
-    $backendTypes{"InspectorClient"} = 1;
+    $backendTypes{"InspectorFrontendChannel"} = 1;
     $backendTypes{"PassRefPtr"} = 1;
     $backendTypes{"Object"} = 1;
 }
@@ -300,10 +300,12 @@ sub generateAgentDeclaration
     my $agentName = $interface->name;
     push(@frontendMethods, "    class ${agentName} {");
     push(@frontendMethods, "    public:");
-    push(@frontendMethods, "        ${agentName}(InspectorClient* inspectorClient) : m_inspectorClient(inspectorClient) { }");
+    push(@frontendMethods, "        ${agentName}(InspectorFrontendChannel* inspectorFrontendChannel) : m_inspectorFrontendChannel(inspectorFrontendChannel) { }");
     push(@frontendMethods, @{$agent->{methodDeclarations}});
+    push(@frontendMethods, "        void setInspectorFrontendChannel(InspectorFrontendChannel* inspectorFrontendChannel) { m_inspectorFrontendChannel = inspectorFrontendChannel; }");
+    push(@frontendMethods, "        InspectorFrontendChannel* getInspectorFrontendChannel() { return m_inspectorFrontendChannel; }");
     push(@frontendMethods, "    private:");
-    push(@frontendMethods, "        InspectorClient* m_inspectorClient;");
+    push(@frontendMethods, "        InspectorFrontendChannel* m_inspectorFrontendChannel;");
     push(@frontendMethods, "    };");
     push(@frontendMethods, "");
 
@@ -319,10 +321,10 @@ sub generateAgentDeclaration
 sub generateFrontendConstructorImpl
 {
     my @frontendConstructorImpl;
-    push(@frontendConstructorImpl, "${frontendClassName}::${frontendClassName}(InspectorClient* inspectorClient)");
-    push(@frontendConstructorImpl, "    : m_inspectorClient(inspectorClient)");
+    push(@frontendConstructorImpl, "${frontendClassName}::${frontendClassName}(InspectorFrontendChannel* inspectorFrontendChannel)");
+    push(@frontendConstructorImpl, "    : m_inspectorFrontendChannel(inspectorFrontendChannel)");
     foreach my $agentField (@frontendAgentFields) {
-        push(@frontendConstructorImpl, "    , ${agentField}(inspectorClient)");
+        push(@frontendConstructorImpl, "    , ${agentField}(inspectorFrontendChannel)");
     }
     push(@frontendConstructorImpl, "{");
     push(@frontendConstructorImpl, "}");
@@ -374,7 +376,7 @@ sub generateFrontendFunction
     my @pushArguments = map("    dataObject->set" . typeTraits($_->type, "JSONType") . "(\"" . $_->name . "\", " . $_->name . ");", @argsFiltered);
     push(@function, @pushArguments);
     push(@function, "    ${functionName}Message->setObject(\"data\", dataObject);");
-    push(@function, "    m_inspectorClient->sendMessageToFrontend(${functionName}Message->toJSONString());");
+    push(@function, "    m_inspectorFrontendChannel->sendMessageToFrontend(${functionName}Message->toJSONString());");
     push(@function, "}");
     push(@function, "");
     push(@frontendMethodsImpl, @function);
@@ -474,7 +476,7 @@ sub generateBackendFunction
         push(@function, "            responseMessage->setObject(\"body\", responseBody);");
         push(@function, "        }");
     }
-    push(@function, "        m_inspectorClient->sendMessageToFrontend(responseMessage->toJSONString());");
+    push(@function, "        m_inspectorFrontendChannel->sendMessageToFrontend(responseMessage->toJSONString());");
     push(@function, "    }");
 
 
@@ -494,7 +496,7 @@ void ${backendClassName}::reportProtocolError(const long callId, const String& e
     RefPtr<InspectorArray> errors = InspectorArray::create();
     errors->pushString(errorText);
     message->setArray("protocolErrors", errors);
-    m_inspectorClient->sendMessageToFrontend(message->toJSONString());
+    m_inspectorFrontendChannel->sendMessageToFrontend(message->toJSONString());
 }
 EOF
     return split("\n", $reportProtocolError);
@@ -930,9 +932,9 @@ sub generateBackendAgentFieldsAndConstructor
     my @arguments;
     my @fieldInitializers;
 
-    push(@arguments, "InspectorClient* inspectorClient");
-    push(@fieldInitializers, "        : m_inspectorClient(inspectorClient)");
-    push(@backendFooter, "    InspectorClient* m_inspectorClient;");
+    push(@arguments, "InspectorFrontendChannel* inspectorFrontendChannel");
+    push(@fieldInitializers, "        : m_inspectorFrontendChannel(inspectorFrontendChannel)");
+    push(@backendFooter, "    InspectorFrontendChannel* m_inspectorFrontendChannel;");
 
     foreach my $domain (sort keys %backendDomains) {
         # Add agent field declaration to the footer.
index d24ce4d..551a488 100644 (file)
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2007 Apple Inc.  All rights reserved.
+ * Copyright (C) 2011 Google Inc.  All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -26,6 +27,7 @@
 #ifndef InspectorClient_h
 #define InspectorClient_h
 
+#include "InspectorFrontendChannel.h"
 #include <wtf/Forward.h>
 
 namespace WebCore {
@@ -34,7 +36,7 @@ class InspectorController;
 class Node;
 class Page;
 
-class InspectorClient {
+class InspectorClient : public InspectorFrontendChannel {
 public:
     virtual ~InspectorClient() { }
 
@@ -45,8 +47,6 @@ public:
     virtual void highlight(Node*) = 0;
     virtual void hideHighlight() = 0;
 
-    virtual bool sendMessageToFrontend(const String& message) = 0;
-
     // Navigation can cause some WebKit implementations to change the view / page / inspector controller instance.
     // However, there are some inspector controller states that should survive navigation (such as tracking resources
     // or recording timeline). Following callbacks allow embedders to track these states.
diff --git a/Source/WebCore/inspector/InspectorFrontendChannel.h b/Source/WebCore/inspector/InspectorFrontendChannel.h
new file mode 100644 (file)
index 0000000..f531110
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2011 Google Inc.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#ifndef InspectorFrontendChannel_h
+#define InspectorFrontendChannel_h
+
+#if ENABLE(INSPECTOR)
+
+#include <wtf/Forward.h>
+
+namespace WebCore {
+
+class InspectorFrontendChannel {
+public:
+    virtual ~InspectorFrontendChannel() { }
+    virtual bool sendMessageToFrontend(const String& message) = 0;
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(INSPECTOR)
+
+#endif // !defined(InspectorFrontendChannel_h)