Web Inspector: FrontendChannel should know its own connection type
authorbburg@apple.com <bburg@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 27 Aug 2015 17:42:45 +0000 (17:42 +0000)
committerbburg@apple.com <bburg@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 27 Aug 2015 17:42:45 +0000 (17:42 +0000)
https://bugs.webkit.org/show_bug.cgi?id=148482

Reviewed by Joseph Pecoraro.

Source/JavaScriptCore:

* inspector/InspectorFrontendChannel.h: Add connectionType().
* inspector/remote/RemoteInspectorDebuggableConnection.h:

Source/WebCore:

To prepare for multiple attached frontends, the frontend connection should
be able to report its type rather than explicitly setting connection type
via a getter.

No behavior change, no new tests.

* inspector/InspectorController.cpp:
(WebCore::InspectorController::hasLocalFrontend): Ask the channel what it is.
(WebCore::InspectorController::hasRemoteFrontend): Ask the channel what it is.
(WebCore::InspectorController::connectFrontend): Use hasRemoteFrotend().
(WebCore::InspectorController::disconnectFrontend): Use hasRemoteFrontend().
(WebCore::InspectorController::InspectorController): Deleted.
* inspector/InspectorController.h: Initialize a few members here.
(WebCore::InspectorController::hasFrontend): Deleted, it was unused.
(WebCore::InspectorController::setHasRemoteFrontend): Deleted.
* inspector/WorkerInspectorController.cpp:
* page/PageDebuggable.cpp:
(WebCore::PageDebuggable::connect):
(WebCore::PageDebuggable::disconnect):
* testing/Internals.cpp: Add connectionType().

Source/WebKit/mac:

* WebCoreSupport/WebInspectorClient.h: add connectionType().

Source/WebKit/win:

* WebCoreSupport/WebInspectorClient.h: add connectionType().

Source/WebKit2:

* WebProcess/WebPage/WebInspector.h: add connectionType().

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

15 files changed:
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/inspector/InspectorFrontendChannel.h
Source/JavaScriptCore/inspector/remote/RemoteInspectorDebuggableConnection.h
Source/WebCore/ChangeLog
Source/WebCore/inspector/InspectorController.cpp
Source/WebCore/inspector/InspectorController.h
Source/WebCore/inspector/WorkerInspectorController.cpp
Source/WebCore/page/PageDebuggable.cpp
Source/WebCore/testing/Internals.cpp
Source/WebKit/mac/ChangeLog
Source/WebKit/mac/WebCoreSupport/WebInspectorClient.h
Source/WebKit/win/ChangeLog
Source/WebKit/win/WebCoreSupport/WebInspectorClient.h
Source/WebKit2/ChangeLog
Source/WebKit2/WebProcess/WebPage/WebInspector.h

index b381937..ce97cdc 100644 (file)
@@ -1,3 +1,13 @@
+2015-08-27  Brian Burg  <bburg@apple.com>
+
+        Web Inspector: FrontendChannel should know its own connection type
+        https://bugs.webkit.org/show_bug.cgi?id=148482
+
+        Reviewed by Joseph Pecoraro.
+
+        * inspector/InspectorFrontendChannel.h: Add connectionType().
+        * inspector/remote/RemoteInspectorDebuggableConnection.h:
+
 2015-08-26  Filip Pizlo  <fpizlo@apple.com>
 
         Node::origin should always be set, and the dead zone due to SSA Phis can just use exitOK=false
index a2bf6f3..5023a82 100644 (file)
@@ -32,7 +32,14 @@ namespace Inspector {
 
 class FrontendChannel {
 public:
+
+    enum class ConnectionType {
+        Remote,
+        Local
+    };
+
     virtual ~FrontendChannel() { }
+    virtual ConnectionType connectionType() const = 0;
     virtual bool sendMessageToFrontend(const String& message) = 0;
 };
 
index e5e5d4f..00d6121 100644 (file)
@@ -92,6 +92,8 @@ public:
     void sendMessageToBackend(NSString *);
     virtual bool sendMessageToFrontend(const String&) override;
 
+    virtual ConnectionType connectionType() const override { return ConnectionType::Remote; }
+
     Lock& queueMutex() { return m_queueMutex; }
     RemoteInspectorQueue queue() const { return m_queue; }
     void clearQueue() { m_queue.clear(); }
index a54027e..7db6b20 100644 (file)
@@ -1,3 +1,31 @@
+2015-08-27  Brian Burg  <bburg@apple.com>
+
+        Web Inspector: FrontendChannel should know its own connection type
+        https://bugs.webkit.org/show_bug.cgi?id=148482
+
+        Reviewed by Joseph Pecoraro.
+
+        To prepare for multiple attached frontends, the frontend connection should
+        be able to report its type rather than explicitly setting connection type
+        via a getter.
+
+        No behavior change, no new tests.
+
+        * inspector/InspectorController.cpp:
+        (WebCore::InspectorController::hasLocalFrontend): Ask the channel what it is.
+        (WebCore::InspectorController::hasRemoteFrontend): Ask the channel what it is.
+        (WebCore::InspectorController::connectFrontend): Use hasRemoteFrotend().
+        (WebCore::InspectorController::disconnectFrontend): Use hasRemoteFrontend().
+        (WebCore::InspectorController::InspectorController): Deleted.
+        * inspector/InspectorController.h: Initialize a few members here.
+        (WebCore::InspectorController::hasFrontend): Deleted, it was unused.
+        (WebCore::InspectorController::setHasRemoteFrontend): Deleted.
+        * inspector/WorkerInspectorController.cpp:
+        * page/PageDebuggable.cpp:
+        (WebCore::PageDebuggable::connect):
+        (WebCore::PageDebuggable::disconnect):
+        * testing/Internals.cpp: Add connectionType().
+
 2015-08-27  Eric Carlson  <eric.carlson@apple.com>
 
         Media Session: MediaSession constructor 'kind' argument optional
index bc80bca..3b0123d 100644 (file)
@@ -86,16 +86,9 @@ InspectorController::InspectorController(Page& page, InspectorClient* inspectorC
     : m_instrumentingAgents(InstrumentingAgents::create(*this))
     , m_injectedScriptManager(std::make_unique<WebInjectedScriptManager>(*this, WebInjectedScriptHost::create()))
     , m_overlay(std::make_unique<InspectorOverlay>(page, inspectorClient))
-    , m_frontendChannel(nullptr)
     , m_executionStopwatch(Stopwatch::create())
     , m_page(page)
     , m_inspectorClient(inspectorClient)
-    , m_inspectorFrontendClient(nullptr)
-    , m_isUnderTest(false)
-    , m_isAutomaticInspection(false)
-#if ENABLE(REMOTE_INSPECTOR)
-    , m_hasRemoteFrontend(false)
-#endif
 {
     ASSERT_ARG(inspectorClient, inspectorClient);
 
@@ -197,20 +190,12 @@ void InspectorController::setInspectorFrontendClient(InspectorFrontendClient* in
 
 bool InspectorController::hasLocalFrontend() const
 {
-#if ENABLE(REMOTE_INSPECTOR)
-    return hasFrontend() && !m_hasRemoteFrontend;
-#else
-    return hasFrontend();
-#endif
+    return m_frontendChannel && m_frontendChannel->connectionType() == FrontendChannel::ConnectionType::Local;
 }
 
 bool InspectorController::hasRemoteFrontend() const
 {
-#if ENABLE(REMOTE_INSPECTOR)
-    return m_hasRemoteFrontend;
-#else
-    return false;
-#endif
+    return m_frontendChannel && m_frontendChannel->connectionType() == FrontendChannel::ConnectionType::Remote;
 }
 
 bool InspectorController::hasInspectorFrontendClient() const
@@ -250,7 +235,7 @@ void InspectorController::connectFrontend(Inspector::FrontendChannel* frontendCh
     InspectorInstrumentation::frontendCreated();
 
 #if ENABLE(REMOTE_INSPECTOR)
-    if (!m_hasRemoteFrontend)
+    if (!hasRemoteFrontend())
         m_page.remoteInspectorInformationDidChange();
 #endif
 }
@@ -260,6 +245,11 @@ void InspectorController::disconnectFrontend(DisconnectReason reason)
     if (!m_frontendChannel)
         return;
 
+#if ENABLE(REMOTE_INSPECTOR)
+    if (!hasRemoteFrontend())
+        m_page.remoteInspectorInformationDidChange();
+#endif
+
     m_agents.willDestroyFrontendAndBackend(reason);
 
     m_backendDispatcher->clearFrontend();
@@ -272,11 +262,6 @@ void InspectorController::disconnectFrontend(DisconnectReason reason)
     m_overlay->freePage();
     InspectorInstrumentation::frontendDeleted();
     InspectorInstrumentation::unregisterInstrumentingAgents(*m_instrumentingAgents);
-
-#if ENABLE(REMOTE_INSPECTOR)
-    if (!m_hasRemoteFrontend)
-        m_page.remoteInspectorInformationDidChange();
-#endif
 }
 
 void InspectorController::show()
index 830d563..ceb3de2 100644 (file)
@@ -94,7 +94,6 @@ public:
 
     WEBCORE_EXPORT void dispatchMessageFromFrontend(const String& message);
 
-    bool hasFrontend() const { return !!m_frontendChannel; }
     bool hasLocalFrontend() const;
     bool hasRemoteFrontend() const;
 
@@ -102,10 +101,6 @@ public:
     WEBCORE_EXPORT void disconnectFrontend(Inspector::DisconnectReason);
     void setProcessId(long);
 
-#if ENABLE(REMOTE_INSPECTOR)
-    void setHasRemoteFrontend(bool hasRemote) { m_hasRemoteFrontend = hasRemote; }
-#endif
-
     void inspect(Node*);
     WEBCORE_EXPORT void drawHighlight(GraphicsContext&) const;
     WEBCORE_EXPORT void getHighlight(Highlight&, InspectorOverlay::CoordinateSystem) const;
@@ -155,21 +150,17 @@ private:
     InspectorTimelineAgent* m_timelineAgent;
 
     RefPtr<Inspector::BackendDispatcher> m_backendDispatcher;
-    Inspector::FrontendChannel* m_frontendChannel;
+    Inspector::FrontendChannel* m_frontendChannel { nullptr };
     Ref<WTF::Stopwatch> m_executionStopwatch;
     Page& m_page;
     InspectorClient* m_inspectorClient;
-    InspectorFrontendClient* m_inspectorFrontendClient;
+    InspectorFrontendClient* m_inspectorFrontendClient { nullptr };
     Inspector::AgentRegistry m_agents;
     Vector<InspectorInstrumentationCookie, 2> m_injectedScriptInstrumentationCookies;
-    bool m_isUnderTest;
-    bool m_isAutomaticInspection;
-
-#if ENABLE(REMOTE_INSPECTOR)
-    bool m_hasRemoteFrontend;
-#endif
+    bool m_isUnderTest { false };
+    bool m_isAutomaticInspection { false };
 };
 
-}
+} // namespace WebCore
 
 #endif // !defined(InspectorController_h)
index d834e0e..12ced46 100644 (file)
@@ -62,6 +62,8 @@ public:
     explicit PageInspectorProxy(WorkerGlobalScope& workerGlobalScope)
         : m_workerGlobalScope(workerGlobalScope) { }
     virtual ~PageInspectorProxy() { }
+
+    virtual ConnectionType connectionType() const override { return ConnectionType::Local; }
 private:
     virtual bool sendMessageToFrontend(const String& message) override
     {
index 676c4ca..fe7b294 100644 (file)
@@ -77,15 +77,13 @@ void PageDebuggable::connect(Inspector::FrontendChannel* channel, bool isAutomat
         m_forcedDeveloperExtrasEnabled = false;
 
     InspectorController& inspectorController = m_page.inspectorController();
-    inspectorController.setHasRemoteFrontend(true);
-    inspectorController.connectFrontend(reinterpret_cast<Inspector::FrontendChannel*>(channel), isAutomaticInspection);
+    inspectorController.connectFrontend(channel, isAutomaticInspection);
 }
 
 void PageDebuggable::disconnect()
 {
     InspectorController& inspectorController = m_page.inspectorController();
     inspectorController.disconnectFrontend(Inspector::DisconnectReason::InspectorDestroyed);
-    inspectorController.setHasRemoteFrontend(false);
 
     if (m_forcedDeveloperExtrasEnabled) {
         m_forcedDeveloperExtrasEnabled = false;
index 3c916bf..5acfc15 100644 (file)
@@ -238,6 +238,7 @@ public:
     explicit InspectorFrontendChannelDummy(Page*);
     virtual ~InspectorFrontendChannelDummy() { }
     virtual bool sendMessageToFrontend(const String& message) override;
+    virtual ConnectionType connectionType() const override { return ConnectionType::Local; }
 
 private:
     Page* m_frontendPage;
index 24ebaf3..3c6e164 100644 (file)
@@ -1,3 +1,12 @@
+2015-08-27  Brian Burg  <bburg@apple.com>
+
+        Web Inspector: FrontendChannel should know its own connection type
+        https://bugs.webkit.org/show_bug.cgi?id=148482
+
+        Reviewed by Joseph Pecoraro.
+
+        * WebCoreSupport/WebInspectorClient.h: add connectionType().
+
 2015-08-26  Beth Dakin  <bdakin@apple.com>
 
         REGRESSION: Safari navigates after a cancelled force click
index 1e0bbab..c50dbb7 100644 (file)
@@ -85,6 +85,7 @@ public:
     virtual void didSetSearchingForNode(bool) override;
 
     virtual bool sendMessageToFrontend(const String&) override;
+    virtual ConnectionType connectionType() const override { return ConnectionType::Local; }
 
     bool inspectorStartsAttached();
     void setInspectorStartsAttached(bool);
index c3c611a..ac22760 100644 (file)
@@ -1,3 +1,12 @@
+2015-08-27  Brian Burg  <bburg@apple.com>
+
+        Web Inspector: FrontendChannel should know its own connection type
+        https://bugs.webkit.org/show_bug.cgi?id=148482
+
+        Reviewed by Joseph Pecoraro.
+
+        * WebCoreSupport/WebInspectorClient.h: add connectionType().
+
 2015-08-23  Andy Estes  <aestes@apple.com>
 
         [Content Filtering] REGRESSION (r182356): Provisional URL is incorrect in didReceiveServerRedirectForProvisionalLoadForFrame when Content Filtering is enabled
index 09e878f..9fb386e 100644 (file)
@@ -64,7 +64,8 @@ public:
     virtual void highlight();
     virtual void hideHighlight();
 
-    virtual bool sendMessageToFrontend(const WTF::String&);
+    virtual bool sendMessageToFrontend(const WTF::String&) override;
+    virtual ConnectionType connectionType() const override { return ConnectionType::Local; }
 
     bool inspectorStartsAttached();
     void setInspectorStartsAttached(bool);
index 6923ab0..e8a2d6c 100644 (file)
@@ -1,3 +1,12 @@
+2015-08-27  Brian Burg  <bburg@apple.com>
+
+        Web Inspector: FrontendChannel should know its own connection type
+        https://bugs.webkit.org/show_bug.cgi?id=148482
+
+        Reviewed by Joseph Pecoraro.
+
+        * WebProcess/WebPage/WebInspector.h: add connectionType().
+
 2015-08-27  Csaba Osztrogon√°c  <ossy@webkit.org>
 
         [EFL] REGRESSION: 50+ layout tests crash
index 62488e8..04008e1 100644 (file)
@@ -46,6 +46,7 @@ public:
     void updateDockingAvailability();
 
     virtual bool sendMessageToFrontend(const String& message) override;
+    virtual ConnectionType connectionType() const override { return ConnectionType::Local; }
 
     // Implemented in generated WebInspectorMessageReceiver.cpp
     void didReceiveMessage(IPC::Connection&, IPC::MessageDecoder&) override;