<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[196515] trunk/Source/JavaScriptCore</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/196515">196515</a></dd>
<dt>Author</dt> <dd>bburg@apple.com</dd>
<dt>Date</dt> <dd>2016-02-12 14:35:45 -0800 (Fri, 12 Feb 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>Web Inspector: disambiguate the various identifier and connection types in RemoteInspector
https://bugs.webkit.org/show_bug.cgi?id=154130

Reviewed by Joseph Pecoraro.

There are multiple identifier types:
    - connection identifier, a string UUID for a remote debugger process.
    - session identifier, a string UUID for a remote driver/debugger instance.
    - page/target identifier, a number unique within a single process.

There are multiple connection types:
    - RemoteInspectorXPCConnection, a connection from RemoteInspectorXPCConnectionor to a relay.
    - RemoteConnectionToTarget, a class that bridges to targets' dispatch queues.

Use consistent variable and getter names so that these don't get confused and
so that the code is easier to read. This is especially an improvement when working
with multiple target types or connection types within the same function.

* inspector/remote/RemoteConnectionToTarget.h:
* inspector/remote/RemoteConnectionToTarget.mm:
Remove the member for m_identifier since we can ask the target for its target identifier
or use a default value via WTF::Optional. There's no reason to cache the value.

(Inspector::RemoteTargetHandleRunSourceWithInfo):
(Inspector::RemoteConnectionToTarget::targetIdentifier):
(Inspector::RemoteConnectionToTarget::destination):
(Inspector::RemoteConnectionToTarget::setup):
(Inspector::RemoteConnectionToTarget::sendMessageToFrontend):
Bail out if the target pointer was somehow cleared and we can't get a useful target identifier.

(Inspector::RemoteConnectionToTarget::RemoteConnectionToTarget): Deleted.
* inspector/remote/RemoteControllableTarget.h:
* inspector/remote/RemoteInspectionTarget.cpp:
(Inspector::RemoteInspectionTarget::pauseWaitingForAutomaticInspection):
(Inspector::RemoteInspectionTarget::unpauseForInitializedInspector):
* inspector/remote/RemoteInspector.h:
* inspector/remote/RemoteInspector.mm:
(Inspector::RemoteInspector::nextAvailableTargetIdentifier):
(Inspector::RemoteInspector::registerTarget):
(Inspector::RemoteInspector::unregisterTarget):
(Inspector::RemoteInspector::updateTarget):
(Inspector::RemoteInspector::updateAutomaticInspectionCandidate):
(Inspector::RemoteInspector::sendAutomaticInspectionCandidateMessage):
(Inspector::RemoteInspector::sendMessageToRemote):
(Inspector::RemoteInspector::setupFailed):
(Inspector::RemoteInspector::setupCompleted):
(Inspector::RemoteInspector::stopInternal):
(Inspector::RemoteInspector::setupXPCConnectionIfNeeded):
(Inspector::RemoteInspector::xpcConnectionFailed):
(Inspector::RemoteInspector::listingForInspectionTarget):
(Inspector::RemoteInspector::listingForAutomationTarget):
(Inspector::RemoteInspector::pushListingsNow):
(Inspector::RemoteInspector::pushListingsSoon):
(Inspector::RemoteInspector::updateHasActiveDebugSession):
(Inspector::RemoteInspector::receivedSetupMessage):
(Inspector::RemoteInspector::receivedDataMessage):
(Inspector::RemoteInspector::receivedDidCloseMessage):
(Inspector::RemoteInspector::receivedIndicateMessage):
(Inspector::RemoteInspector::receivedProxyApplicationSetupMessage):
(Inspector::RemoteInspector::receivedConnectionDiedMessage):
(Inspector::RemoteInspector::receivedAutomaticInspectionRejectMessage):
(Inspector::RemoteInspector::nextAvailableIdentifier): Deleted.
* inspector/remote/RemoteInspectorConstants.h:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceJavaScriptCoreChangeLog">trunk/Source/JavaScriptCore/ChangeLog</a></li>
<li><a href="#trunkSourceJavaScriptCoreinspectorremoteRemoteConnectionToTargeth">trunk/Source/JavaScriptCore/inspector/remote/RemoteConnectionToTarget.h</a></li>
<li><a href="#trunkSourceJavaScriptCoreinspectorremoteRemoteConnectionToTargetmm">trunk/Source/JavaScriptCore/inspector/remote/RemoteConnectionToTarget.mm</a></li>
<li><a href="#trunkSourceJavaScriptCoreinspectorremoteRemoteControllableTargeth">trunk/Source/JavaScriptCore/inspector/remote/RemoteControllableTarget.h</a></li>
<li><a href="#trunkSourceJavaScriptCoreinspectorremoteRemoteInspectionTargetcpp">trunk/Source/JavaScriptCore/inspector/remote/RemoteInspectionTarget.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoreinspectorremoteRemoteInspectorh">trunk/Source/JavaScriptCore/inspector/remote/RemoteInspector.h</a></li>
<li><a href="#trunkSourceJavaScriptCoreinspectorremoteRemoteInspectormm">trunk/Source/JavaScriptCore/inspector/remote/RemoteInspector.mm</a></li>
<li><a href="#trunkSourceJavaScriptCoreinspectorremoteRemoteInspectorConstantsh">trunk/Source/JavaScriptCore/inspector/remote/RemoteInspectorConstants.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ChangeLog (196514 => 196515)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ChangeLog        2016-02-12 22:34:42 UTC (rev 196514)
+++ trunk/Source/JavaScriptCore/ChangeLog        2016-02-12 22:35:45 UTC (rev 196515)
</span><span class="lines">@@ -1,3 +1,69 @@
</span><ins>+2016-02-12  Brian Burg  &lt;bburg@apple.com&gt;
+
+        Web Inspector: disambiguate the various identifier and connection types in RemoteInspector
+        https://bugs.webkit.org/show_bug.cgi?id=154130
+
+        Reviewed by Joseph Pecoraro.
+
+        There are multiple identifier types:
+            - connection identifier, a string UUID for a remote debugger process.
+            - session identifier, a string UUID for a remote driver/debugger instance.
+            - page/target identifier, a number unique within a single process.
+
+        There are multiple connection types:
+            - RemoteInspectorXPCConnection, a connection from RemoteInspectorXPCConnectionor to a relay.
+            - RemoteConnectionToTarget, a class that bridges to targets' dispatch queues.
+
+        Use consistent variable and getter names so that these don't get confused and
+        so that the code is easier to read. This is especially an improvement when working
+        with multiple target types or connection types within the same function.
+
+        * inspector/remote/RemoteConnectionToTarget.h:
+        * inspector/remote/RemoteConnectionToTarget.mm:
+        Remove the member for m_identifier since we can ask the target for its target identifier
+        or use a default value via WTF::Optional. There's no reason to cache the value.
+
+        (Inspector::RemoteTargetHandleRunSourceWithInfo):
+        (Inspector::RemoteConnectionToTarget::targetIdentifier):
+        (Inspector::RemoteConnectionToTarget::destination):
+        (Inspector::RemoteConnectionToTarget::setup):
+        (Inspector::RemoteConnectionToTarget::sendMessageToFrontend):
+        Bail out if the target pointer was somehow cleared and we can't get a useful target identifier.
+
+        (Inspector::RemoteConnectionToTarget::RemoteConnectionToTarget): Deleted.
+        * inspector/remote/RemoteControllableTarget.h:
+        * inspector/remote/RemoteInspectionTarget.cpp:
+        (Inspector::RemoteInspectionTarget::pauseWaitingForAutomaticInspection):
+        (Inspector::RemoteInspectionTarget::unpauseForInitializedInspector):
+        * inspector/remote/RemoteInspector.h:
+        * inspector/remote/RemoteInspector.mm:
+        (Inspector::RemoteInspector::nextAvailableTargetIdentifier):
+        (Inspector::RemoteInspector::registerTarget):
+        (Inspector::RemoteInspector::unregisterTarget):
+        (Inspector::RemoteInspector::updateTarget):
+        (Inspector::RemoteInspector::updateAutomaticInspectionCandidate):
+        (Inspector::RemoteInspector::sendAutomaticInspectionCandidateMessage):
+        (Inspector::RemoteInspector::sendMessageToRemote):
+        (Inspector::RemoteInspector::setupFailed):
+        (Inspector::RemoteInspector::setupCompleted):
+        (Inspector::RemoteInspector::stopInternal):
+        (Inspector::RemoteInspector::setupXPCConnectionIfNeeded):
+        (Inspector::RemoteInspector::xpcConnectionFailed):
+        (Inspector::RemoteInspector::listingForInspectionTarget):
+        (Inspector::RemoteInspector::listingForAutomationTarget):
+        (Inspector::RemoteInspector::pushListingsNow):
+        (Inspector::RemoteInspector::pushListingsSoon):
+        (Inspector::RemoteInspector::updateHasActiveDebugSession):
+        (Inspector::RemoteInspector::receivedSetupMessage):
+        (Inspector::RemoteInspector::receivedDataMessage):
+        (Inspector::RemoteInspector::receivedDidCloseMessage):
+        (Inspector::RemoteInspector::receivedIndicateMessage):
+        (Inspector::RemoteInspector::receivedProxyApplicationSetupMessage):
+        (Inspector::RemoteInspector::receivedConnectionDiedMessage):
+        (Inspector::RemoteInspector::receivedAutomaticInspectionRejectMessage):
+        (Inspector::RemoteInspector::nextAvailableIdentifier): Deleted.
+        * inspector/remote/RemoteInspectorConstants.h:
+
</ins><span class="cx"> 2016-02-12  Benjamin Poulain  &lt;benjamin@webkit.org&gt;
</span><span class="cx"> 
</span><span class="cx">         [JSC] On x86, improve the selection of which value are selected for the UseDef part of commutative operations
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreinspectorremoteRemoteConnectionToTargeth"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/inspector/remote/RemoteConnectionToTarget.h (196514 => 196515)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/inspector/remote/RemoteConnectionToTarget.h        2016-02-12 22:34:42 UTC (rev 196514)
+++ trunk/Source/JavaScriptCore/inspector/remote/RemoteConnectionToTarget.h        2016-02-12 22:35:45 UTC (rev 196515)
</span><span class="lines">@@ -54,7 +54,7 @@
</span><span class="cx">     virtual void close();
</span><span class="cx">     virtual void targetClosed();
</span><span class="cx"> 
</span><del>-    unsigned identifier() const { return m_identifier; }
</del><ins>+    Optional&lt;unsigned&gt; targetIdentifier() const;
</ins><span class="cx">     NSString *connectionIdentifier() const;
</span><span class="cx">     NSString *destination() const;
</span><span class="cx"> 
</span><span class="lines">@@ -86,7 +86,6 @@
</span><span class="cx">     Lock m_queueMutex;
</span><span class="cx"> 
</span><span class="cx">     RemoteControllableTarget* m_target { nullptr };
</span><del>-    unsigned m_identifier { 0 };
</del><span class="cx">     RetainPtr&lt;NSString&gt; m_connectionIdentifier;
</span><span class="cx">     RetainPtr&lt;NSString&gt; m_destination;
</span><span class="cx">     bool m_connected { false };
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreinspectorremoteRemoteConnectionToTargetmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/inspector/remote/RemoteConnectionToTarget.mm (196514 => 196515)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/inspector/remote/RemoteConnectionToTarget.mm        2016-02-12 22:34:42 UTC (rev 196514)
+++ trunk/Source/JavaScriptCore/inspector/remote/RemoteConnectionToTarget.mm        2016-02-12 22:35:45 UTC (rev 196515)
</span><span class="lines">@@ -32,6 +32,7 @@
</span><span class="cx"> #import &quot;RemoteAutomationTarget.h&quot;
</span><span class="cx"> #import &quot;RemoteInspectionTarget.h&quot;
</span><span class="cx"> #import &lt;dispatch/dispatch.h&gt;
</span><ins>+#import &lt;wtf/Optional.h&gt;
</ins><span class="cx"> #import &lt;wtf/Vector.h&gt;
</span><span class="cx"> 
</span><span class="cx"> #if PLATFORM(IOS)
</span><span class="lines">@@ -92,13 +93,13 @@
</span><span class="cx"> 
</span><span class="cx"> static void RemoteTargetHandleRunSourceWithInfo(void* info)
</span><span class="cx"> {
</span><del>-    RemoteConnectionToTarget *connection = static_cast&lt;RemoteConnectionToTarget*&gt;(info);
</del><ins>+    RemoteConnectionToTarget *connectionToTarget = static_cast&lt;RemoteConnectionToTarget*&gt;(info);
</ins><span class="cx"> 
</span><span class="cx">     RemoteTargetQueue queueCopy;
</span><span class="cx">     {
</span><del>-        std::lock_guard&lt;Lock&gt; lock(connection-&gt;queueMutex());
-        queueCopy = connection-&gt;queue();
-        connection-&gt;clearQueue();
</del><ins>+        std::lock_guard&lt;Lock&gt; lock(connectionToTarget-&gt;queueMutex());
+        queueCopy = connectionToTarget-&gt;queue();
+        connectionToTarget-&gt;clearQueue();
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     for (const auto&amp; block : queueCopy)
</span><span class="lines">@@ -108,7 +109,6 @@
</span><span class="cx"> 
</span><span class="cx"> RemoteConnectionToTarget::RemoteConnectionToTarget(RemoteControllableTarget* target, NSString *connectionIdentifier, NSString *destination)
</span><span class="cx">     : m_target(target)
</span><del>-    , m_identifier(target-&gt;identifier())
</del><span class="cx">     , m_connectionIdentifier(connectionIdentifier)
</span><span class="cx">     , m_destination(destination)
</span><span class="cx"> {
</span><span class="lines">@@ -120,9 +120,9 @@
</span><span class="cx">     teardownRunLoop();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-NSString *RemoteConnectionToTarget::destination() const
</del><ins>+Optional&lt;unsigned&gt; RemoteConnectionToTarget::targetIdentifier() const
</ins><span class="cx"> {
</span><del>-    return [[m_destination copy] autorelease];
</del><ins>+    return m_target ? Optional&lt;unsigned&gt;(m_target-&gt;targetIdentifier()) : Nullopt;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> NSString *RemoteConnectionToTarget::connectionIdentifier() const
</span><span class="lines">@@ -130,6 +130,11 @@
</span><span class="cx">     return [[m_connectionIdentifier copy] autorelease];
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+NSString *RemoteConnectionToTarget::destination() const
+{
+    return [[m_destination copy] autorelease];
+}
+
</ins><span class="cx"> void RemoteConnectionToTarget::dispatchAsyncOnTarget(void (^block)())
</span><span class="cx"> {
</span><span class="cx">     if (m_runLoop) {
</span><span class="lines">@@ -159,7 +164,7 @@
</span><span class="cx">         {
</span><span class="cx">             std::lock_guard&lt;Lock&gt; lock(m_targetMutex);
</span><span class="cx">             if (!m_target || !m_target-&gt;remoteControlAllowed()) {
</span><del>-                RemoteInspector::singleton().setupFailed(m_identifier);
</del><ins>+                RemoteInspector::singleton().setupFailed(targetIdentifier().valueOr(0));
</ins><span class="cx">                 m_target = nullptr;
</span><span class="cx">             } else if (is&lt;RemoteInspectionTarget&gt;(m_target)) {
</span><span class="cx">                 auto castedTarget = downcast&lt;RemoteInspectionTarget&gt;(m_target);
</span><span class="lines">@@ -226,8 +231,10 @@
</span><span class="cx"> 
</span><span class="cx"> bool RemoteConnectionToTarget::sendMessageToFrontend(const String&amp; message)
</span><span class="cx"> {
</span><del>-    RemoteInspector::singleton().sendMessageToRemote(identifier(), message);
</del><ins>+    if (!m_target)
+        return false;
</ins><span class="cx"> 
</span><ins>+    RemoteInspector::singleton().sendMessageToRemote(targetIdentifier().value(), message);
</ins><span class="cx">     return true;
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreinspectorremoteRemoteControllableTargeth"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/inspector/remote/RemoteControllableTarget.h (196514 => 196515)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/inspector/remote/RemoteControllableTarget.h        2016-02-12 22:34:42 UTC (rev 196514)
+++ trunk/Source/JavaScriptCore/inspector/remote/RemoteControllableTarget.h        2016-02-12 22:35:45 UTC (rev 196515)
</span><span class="lines">@@ -46,8 +46,8 @@
</span><span class="cx">     virtual void connect(FrontendChannel*, bool isAutomaticConnection = false) = 0;
</span><span class="cx">     virtual void disconnect(FrontendChannel*) = 0;
</span><span class="cx"> 
</span><del>-    unsigned identifier() const { return m_identifier; }
-    void setIdentifier(unsigned identifier) { m_identifier = identifier; }
</del><ins>+    unsigned targetIdentifier() const { return m_identifier; }
+    void setTargetIdentifier(unsigned identifier) { m_identifier = identifier; }
</ins><span class="cx"> 
</span><span class="cx">     enum class Type { JavaScript, Web, Automation };
</span><span class="cx">     virtual Type type() const = 0;
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreinspectorremoteRemoteInspectionTargetcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/inspector/remote/RemoteInspectionTarget.cpp (196514 => 196515)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/inspector/remote/RemoteInspectionTarget.cpp        2016-02-12 22:34:42 UTC (rev 196514)
+++ trunk/Source/JavaScriptCore/inspector/remote/RemoteInspectionTarget.cpp        2016-02-12 22:35:45 UTC (rev 196515)
</span><span class="lines">@@ -53,18 +53,18 @@
</span><span class="cx"> 
</span><span class="cx"> void RemoteInspectionTarget::pauseWaitingForAutomaticInspection()
</span><span class="cx"> {
</span><del>-    ASSERT(identifier());
</del><ins>+    ASSERT(targetIdentifier());
</ins><span class="cx">     ASSERT(m_allowed);
</span><span class="cx">     ASSERT(automaticInspectionAllowed());
</span><span class="cx"> 
</span><span class="cx">     EventLoop loop;
</span><del>-    while (RemoteInspector::singleton().waitingForAutomaticInspection(identifier()) &amp;&amp; !loop.ended())
</del><ins>+    while (RemoteInspector::singleton().waitingForAutomaticInspection(targetIdentifier()) &amp;&amp; !loop.ended())
</ins><span class="cx">         loop.cycle();
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void RemoteInspectionTarget::unpauseForInitializedInspector()
</span><span class="cx"> {
</span><del>-    RemoteInspector::singleton().setupCompleted(identifier());
</del><ins>+    RemoteInspector::singleton().setupCompleted(targetIdentifier());
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> } // namespace Inspector
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreinspectorremoteRemoteInspectorh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/inspector/remote/RemoteInspector.h (196514 => 196515)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/inspector/remote/RemoteInspector.h        2016-02-12 22:34:42 UTC (rev 196514)
+++ trunk/Source/JavaScriptCore/inspector/remote/RemoteInspector.h        2016-02-12 22:35:45 UTC (rev 196515)
</span><span class="lines">@@ -62,14 +62,14 @@
</span><span class="cx">     void registerTarget(RemoteControllableTarget*);
</span><span class="cx">     void unregisterTarget(RemoteControllableTarget*);
</span><span class="cx">     void updateTarget(RemoteControllableTarget*);
</span><del>-    void sendMessageToRemote(unsigned identifier, const String&amp; message);
</del><ins>+    void sendMessageToRemote(unsigned targetIdentifier, const String&amp; message);
</ins><span class="cx"> 
</span><span class="cx">     void updateAutomaticInspectionCandidate(RemoteInspectionTarget*);
</span><span class="cx">     void setRemoteInspectorClient(RemoteInspector::Client*);
</span><span class="cx"> 
</span><del>-    void setupFailed(unsigned identifier);
-    void setupCompleted(unsigned identifier);
-    bool waitingForAutomaticInspection(unsigned identifier);
</del><ins>+    void setupFailed(unsigned targetIdentifier);
+    void setupCompleted(unsigned targetIdentifier);
+    bool waitingForAutomaticInspection(unsigned targetIdentifier);
</ins><span class="cx">     void clientCapabilitiesDidChange() { pushListingsSoon(); }
</span><span class="cx"> 
</span><span class="cx">     bool enabled() const { return m_enabled; }
</span><span class="lines">@@ -87,7 +87,7 @@
</span><span class="cx"> private:
</span><span class="cx">     RemoteInspector();
</span><span class="cx"> 
</span><del>-    unsigned nextAvailableIdentifier();
</del><ins>+    unsigned nextAvailableTargetIdentifier();
</ins><span class="cx"> 
</span><span class="cx">     enum class StopSource { API, XPCMessage };
</span><span class="cx">     void stopInternal(StopSource);
</span><span class="lines">@@ -127,15 +127,15 @@
</span><span class="cx">     Lock m_mutex;
</span><span class="cx"> 
</span><span class="cx">     HashMap&lt;unsigned, RemoteControllableTarget*&gt; m_targetMap;
</span><del>-    HashMap&lt;unsigned, RetainPtr&lt;NSDictionary&gt;&gt; m_listingMap;
-    HashMap&lt;unsigned, RefPtr&lt;RemoteConnectionToTarget&gt;&gt; m_connectionMap;
</del><ins>+    HashMap&lt;unsigned, RetainPtr&lt;NSDictionary&gt;&gt; m_targetListingMap;
+    HashMap&lt;unsigned, RefPtr&lt;RemoteConnectionToTarget&gt;&gt; m_targetConnectionMap;
</ins><span class="cx"> 
</span><del>-    RefPtr&lt;RemoteInspectorXPCConnection&gt; m_xpcConnection;
</del><ins>+    RefPtr&lt;RemoteInspectorXPCConnection&gt; m_relayConnection;
</ins><span class="cx"> 
</span><span class="cx">     RemoteInspector::Client* m_client { nullptr };
</span><span class="cx"> 
</span><span class="cx">     dispatch_queue_t m_xpcQueue;
</span><del>-    unsigned m_nextAvailableIdentifier { 1 };
</del><ins>+    unsigned m_nextAvailableTargetIdentifier { 1 };
</ins><span class="cx">     int m_notifyToken { 0 };
</span><span class="cx">     bool m_enabled { false };
</span><span class="cx">     bool m_hasActiveDebugSession { false };
</span><span class="lines">@@ -146,7 +146,7 @@
</span><span class="cx">     bool m_shouldSendParentProcessInformation { false };
</span><span class="cx">     bool m_automaticInspectionEnabled { false };
</span><span class="cx">     bool m_automaticInspectionPaused { false };
</span><del>-    unsigned m_automaticInspectionCandidateIdentifier { 0 };
</del><ins>+    unsigned m_automaticInspectionCandidateTargetIdentifier { 0 };
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> } // namespace Inspector
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreinspectorremoteRemoteInspectormm"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/inspector/remote/RemoteInspector.mm (196514 => 196515)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/inspector/remote/RemoteInspector.mm        2016-02-12 22:34:42 UTC (rev 196514)
+++ trunk/Source/JavaScriptCore/inspector/remote/RemoteInspector.mm        2016-02-12 22:35:45 UTC (rev 196515)
</span><span class="lines">@@ -101,13 +101,13 @@
</span><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-unsigned RemoteInspector::nextAvailableIdentifier()
</del><ins>+unsigned RemoteInspector::nextAvailableTargetIdentifier()
</ins><span class="cx"> {
</span><del>-    unsigned nextValidIdentifier;
</del><ins>+    unsigned nextValidTargetIdentifier;
</ins><span class="cx">     do {
</span><del>-        nextValidIdentifier = m_nextAvailableIdentifier++;
-    } while (!nextValidIdentifier || nextValidIdentifier == std::numeric_limits&lt;unsigned&gt;::max() || m_targetMap.contains(nextValidIdentifier));
-    return nextValidIdentifier;
</del><ins>+        nextValidTargetIdentifier = m_nextAvailableTargetIdentifier++;
+    } while (!nextValidTargetIdentifier || nextValidTargetIdentifier == std::numeric_limits&lt;unsigned&gt;::max() || m_targetMap.contains(nextValidTargetIdentifier));
+    return nextValidTargetIdentifier;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void RemoteInspector::registerTarget(RemoteControllableTarget* target)
</span><span class="lines">@@ -116,17 +116,17 @@
</span><span class="cx"> 
</span><span class="cx">     std::lock_guard&lt;Lock&gt; lock(m_mutex);
</span><span class="cx"> 
</span><del>-    unsigned identifier = nextAvailableIdentifier();
-    target-&gt;setIdentifier(identifier);
</del><ins>+    unsigned targetIdentifier = nextAvailableTargetIdentifier();
+    target-&gt;setTargetIdentifier(targetIdentifier);
</ins><span class="cx"> 
</span><span class="cx">     {
</span><del>-        auto result = m_targetMap.set(identifier, target);
</del><ins>+        auto result = m_targetMap.set(targetIdentifier, target);
</ins><span class="cx">         ASSERT_UNUSED(result, result.isNewEntry);
</span><span class="cx">     }
</span><del>-    
</del><ins>+
</ins><span class="cx">     // If remote control is not allowed, a null listing is returned.
</span><del>-    if (RetainPtr&lt;NSDictionary&gt; listing = listingForTarget(*target)) {
-        auto result = m_listingMap.set(identifier, listing);
</del><ins>+    if (RetainPtr&lt;NSDictionary&gt; targetListing = listingForTarget(*target)) {
+        auto result = m_targetListingMap.set(targetIdentifier, targetListing);
</ins><span class="cx">         ASSERT_UNUSED(result, result.isNewEntry);
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="lines">@@ -139,18 +139,18 @@
</span><span class="cx"> 
</span><span class="cx">     std::lock_guard&lt;Lock&gt; lock(m_mutex);
</span><span class="cx"> 
</span><del>-    unsigned identifier = target-&gt;identifier();
-    if (!identifier)
</del><ins>+    unsigned targetIdentifier = target-&gt;targetIdentifier();
+    if (!targetIdentifier)
</ins><span class="cx">         return;
</span><span class="cx"> 
</span><del>-    bool wasRemoved = m_targetMap.remove(identifier);
</del><ins>+    bool wasRemoved = m_targetMap.remove(targetIdentifier);
</ins><span class="cx">     ASSERT_UNUSED(wasRemoved, wasRemoved);
</span><span class="cx"> 
</span><span class="cx">     // The listing may never have been added if remote control isn't allowed.
</span><del>-    m_listingMap.remove(identifier);
</del><ins>+    m_targetListingMap.remove(targetIdentifier);
</ins><span class="cx"> 
</span><del>-    if (auto connection = m_connectionMap.take(identifier))
-        connection-&gt;targetClosed();
</del><ins>+    if (auto connectionToTarget = m_targetConnectionMap.take(targetIdentifier))
+        connectionToTarget-&gt;targetClosed();
</ins><span class="cx"> 
</span><span class="cx">     pushListingsSoon();
</span><span class="cx"> }
</span><span class="lines">@@ -161,18 +161,18 @@
</span><span class="cx"> 
</span><span class="cx">     std::lock_guard&lt;Lock&gt; lock(m_mutex);
</span><span class="cx"> 
</span><del>-    unsigned identifier = target-&gt;identifier();
-    if (!identifier)
</del><ins>+    unsigned targetIdentifier = target-&gt;targetIdentifier();
+    if (!targetIdentifier)
</ins><span class="cx">         return;
</span><span class="cx"> 
</span><span class="cx">     {
</span><del>-        auto result = m_targetMap.set(identifier, target);
</del><ins>+        auto result = m_targetMap.set(targetIdentifier, target);
</ins><span class="cx">         ASSERT_UNUSED(result, !result.isNewEntry);
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     // If the target has just allowed remote control, then the listing won't exist yet.
</span><del>-    if (RetainPtr&lt;NSDictionary&gt; listing = listingForTarget(*target))
-        m_listingMap.set(identifier, listing);
</del><ins>+    if (RetainPtr&lt;NSDictionary&gt; targetListing = listingForTarget(*target))
+        m_targetListingMap.set(targetIdentifier, targetListing);
</ins><span class="cx"> 
</span><span class="cx">     pushListingsSoon();
</span><span class="cx"> }
</span><span class="lines">@@ -183,16 +183,16 @@
</span><span class="cx">     {
</span><span class="cx">         std::lock_guard&lt;Lock&gt; lock(m_mutex);
</span><span class="cx"> 
</span><del>-        unsigned identifier = target-&gt;identifier();
-        if (!identifier)
</del><ins>+        unsigned targetIdentifier = target-&gt;targetIdentifier();
+        if (!targetIdentifier)
</ins><span class="cx">             return;
</span><span class="cx"> 
</span><del>-        auto result = m_targetMap.set(identifier, target);
</del><ins>+        auto result = m_targetMap.set(targetIdentifier, target);
</ins><span class="cx">         ASSERT_UNUSED(result, !result.isNewEntry);
</span><span class="cx"> 
</span><span class="cx">         // If the target has just allowed remote control, then the listing won't exist yet.
</span><del>-        if (RetainPtr&lt;NSDictionary&gt; listing = listingForTarget(*target))
-            m_listingMap.set(identifier, listing);
</del><ins>+        if (RetainPtr&lt;NSDictionary&gt; targetListing = listingForTarget(*target))
+            m_targetListingMap.set(targetIdentifier, targetListing);
</ins><span class="cx"> 
</span><span class="cx">         // Don't allow automatic inspection unless it is allowed or we are stopped.
</span><span class="cx">         if (!m_automaticInspectionEnabled || !m_enabled) {
</span><span class="lines">@@ -201,19 +201,19 @@
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         // FIXME: We should handle multiple debuggables trying to pause at the same time on different threads.
</span><del>-        // To make this work we will need to change m_automaticInspectionCandidateIdentifier to be a per-thread value.
</del><ins>+        // To make this work we will need to change m_automaticInspectionCandidateTargetIdentifier to be a per-thread value.
</ins><span class="cx">         // Multiple attempts on the same thread should not be possible because our nested run loop is in a special RWI mode.
</span><span class="cx">         if (m_automaticInspectionPaused) {
</span><del>-            LOG_ERROR(&quot;Skipping Automatic Inspection Candidate with pageId(%u) because we are already paused waiting for pageId(%u)&quot;, identifier, m_automaticInspectionCandidateIdentifier);
</del><ins>+            LOG_ERROR(&quot;Skipping Automatic Inspection Candidate with pageId(%u) because we are already paused waiting for pageId(%u)&quot;, targetIdentifier, m_automaticInspectionCandidateTargetIdentifier);
</ins><span class="cx">             pushListingsSoon();
</span><span class="cx">             return;
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         m_automaticInspectionPaused = true;
</span><del>-        m_automaticInspectionCandidateIdentifier = identifier;
</del><ins>+        m_automaticInspectionCandidateTargetIdentifier = targetIdentifier;
</ins><span class="cx"> 
</span><span class="cx">         // If we are pausing before we have connected to webinspectord the candidate message will be sent as soon as the connection is established.
</span><del>-        if (m_xpcConnection) {
</del><ins>+        if (m_relayConnection) {
</ins><span class="cx">             pushListingsNow();
</span><span class="cx">             sendAutomaticInspectionCandidateMessage();
</span><span class="cx">         }
</span><span class="lines">@@ -221,8 +221,8 @@
</span><span class="cx">         // In case debuggers fail to respond, or we cannot connect to webinspectord, automatically continue after a short period of time.
</span><span class="cx">         dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.8 * NSEC_PER_SEC), dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
</span><span class="cx">             std::lock_guard&lt;Lock&gt; lock(m_mutex);
</span><del>-            if (m_automaticInspectionCandidateIdentifier == identifier) {
-                LOG_ERROR(&quot;Skipping Automatic Inspection Candidate with pageId(%u) because we failed to receive a response in time.&quot;, m_automaticInspectionCandidateIdentifier);
</del><ins>+            if (m_automaticInspectionCandidateTargetIdentifier == targetIdentifier) {
+                LOG_ERROR(&quot;Skipping Automatic Inspection Candidate with pageId(%u) because we failed to receive a response in time.&quot;, m_automaticInspectionCandidateTargetIdentifier);
</ins><span class="cx">                 m_automaticInspectionPaused = false;
</span><span class="cx">             }
</span><span class="cx">         });
</span><span class="lines">@@ -233,8 +233,8 @@
</span><span class="cx">     {
</span><span class="cx">         std::lock_guard&lt;Lock&gt; lock(m_mutex);
</span><span class="cx"> 
</span><del>-        ASSERT(m_automaticInspectionCandidateIdentifier);
-        m_automaticInspectionCandidateIdentifier = 0;
</del><ins>+        ASSERT(m_automaticInspectionCandidateTargetIdentifier);
+        m_automaticInspectionCandidateTargetIdentifier = 0;
</ins><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -255,52 +255,52 @@
</span><span class="cx">     ASSERT(m_enabled);
</span><span class="cx">     ASSERT(m_automaticInspectionEnabled);
</span><span class="cx">     ASSERT(m_automaticInspectionPaused);
</span><del>-    ASSERT(m_automaticInspectionCandidateIdentifier);
-    ASSERT(m_xpcConnection);
</del><ins>+    ASSERT(m_automaticInspectionCandidateTargetIdentifier);
+    ASSERT(m_relayConnection);
</ins><span class="cx"> 
</span><del>-    NSDictionary *details = @{WIRPageIdentifierKey: @(m_automaticInspectionCandidateIdentifier)};
-    m_xpcConnection-&gt;sendMessage(WIRAutomaticInspectionCandidateMessage, details);
</del><ins>+    NSDictionary *details = @{WIRTargetIdentifierKey: @(m_automaticInspectionCandidateTargetIdentifier)};
+    m_relayConnection-&gt;sendMessage(WIRAutomaticInspectionCandidateMessage, details);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void RemoteInspector::sendMessageToRemote(unsigned identifier, const String&amp; message)
</del><ins>+void RemoteInspector::sendMessageToRemote(unsigned targetIdentifier, const String&amp; message)
</ins><span class="cx"> {
</span><span class="cx">     std::lock_guard&lt;Lock&gt; lock(m_mutex);
</span><span class="cx"> 
</span><del>-    if (!m_xpcConnection)
</del><ins>+    if (!m_relayConnection)
</ins><span class="cx">         return;
</span><span class="cx"> 
</span><del>-    auto connection = m_connectionMap.get(identifier);
-    if (!connection)
</del><ins>+    auto targetConnection = m_targetConnectionMap.get(targetIdentifier);
+    if (!targetConnection)
</ins><span class="cx">         return;
</span><span class="cx"> 
</span><span class="cx">     NSDictionary *userInfo = @{
</span><span class="cx">         WIRRawDataKey: [static_cast&lt;NSString *&gt;(message) dataUsingEncoding:NSUTF8StringEncoding],
</span><del>-        WIRConnectionIdentifierKey: connection-&gt;connectionIdentifier(),
-        WIRDestinationKey: connection-&gt;destination()
</del><ins>+        WIRConnectionIdentifierKey: targetConnection-&gt;connectionIdentifier(),
+        WIRDestinationKey: targetConnection-&gt;destination()
</ins><span class="cx">     };
</span><span class="cx"> 
</span><del>-    m_xpcConnection-&gt;sendMessage(WIRRawDataMessage, userInfo);
</del><ins>+    m_relayConnection-&gt;sendMessage(WIRRawDataMessage, userInfo);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void RemoteInspector::setupFailed(unsigned identifier)
</del><ins>+void RemoteInspector::setupFailed(unsigned targetIdentifier)
</ins><span class="cx"> {
</span><span class="cx">     std::lock_guard&lt;Lock&gt; lock(m_mutex);
</span><span class="cx"> 
</span><del>-    m_connectionMap.remove(identifier);
</del><ins>+    m_targetConnectionMap.remove(targetIdentifier);
</ins><span class="cx"> 
</span><span class="cx">     updateHasActiveDebugSession();
</span><span class="cx"> 
</span><del>-    if (identifier == m_automaticInspectionCandidateIdentifier)
</del><ins>+    if (targetIdentifier == m_automaticInspectionCandidateTargetIdentifier)
</ins><span class="cx">         m_automaticInspectionPaused = false;
</span><span class="cx"> 
</span><span class="cx">     pushListingsSoon();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void RemoteInspector::setupCompleted(unsigned identifier)
</del><ins>+void RemoteInspector::setupCompleted(unsigned targetIdentifier)
</ins><span class="cx"> {
</span><span class="cx">     std::lock_guard&lt;Lock&gt; lock(m_mutex);
</span><span class="cx"> 
</span><del>-    if (identifier == m_automaticInspectionCandidateIdentifier)
</del><ins>+    if (targetIdentifier == m_automaticInspectionCandidateTargetIdentifier)
</ins><span class="cx">         m_automaticInspectionPaused = false;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -348,25 +348,25 @@
</span><span class="cx"> 
</span><span class="cx">     m_pushScheduled = false;
</span><span class="cx"> 
</span><del>-    for (auto connection : m_connectionMap.values())
-        connection-&gt;close();
-    m_connectionMap.clear();
</del><ins>+    for (auto targetConnection : m_targetConnectionMap.values())
+        targetConnection-&gt;close();
+    m_targetConnectionMap.clear();
</ins><span class="cx"> 
</span><span class="cx">     updateHasActiveDebugSession();
</span><span class="cx"> 
</span><span class="cx">     m_automaticInspectionPaused = false;
</span><span class="cx"> 
</span><del>-    if (m_xpcConnection) {
</del><ins>+    if (m_relayConnection) {
</ins><span class="cx">         switch (source) {
</span><span class="cx">         case StopSource::API:
</span><del>-            m_xpcConnection-&gt;close();
</del><ins>+            m_relayConnection-&gt;close();
</ins><span class="cx">             break;
</span><span class="cx">         case StopSource::XPCMessage:
</span><del>-            m_xpcConnection-&gt;closeFromMessage();
</del><ins>+            m_relayConnection-&gt;closeFromMessage();
</ins><span class="cx">             break;
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        m_xpcConnection = nullptr;
</del><ins>+        m_relayConnection = nullptr;
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     notify_cancel(m_notifyToken);
</span><span class="lines">@@ -376,18 +376,18 @@
</span><span class="cx"> {
</span><span class="cx">     std::lock_guard&lt;Lock&gt; lock(m_mutex);
</span><span class="cx"> 
</span><del>-    if (m_xpcConnection)
</del><ins>+    if (m_relayConnection)
</ins><span class="cx">         return;
</span><span class="cx"> 
</span><span class="cx">     xpc_connection_t connection = xpc_connection_create_mach_service(WIRXPCMachPortName, m_xpcQueue, 0);
</span><span class="cx">     if (!connection)
</span><span class="cx">         return;
</span><span class="cx"> 
</span><del>-    m_xpcConnection = adoptRef(new RemoteInspectorXPCConnection(connection, m_xpcQueue, this));
-    m_xpcConnection-&gt;sendMessage(@&quot;syn&quot;, nil); // Send a simple message to initialize the XPC connection.
</del><ins>+    m_relayConnection = adoptRef(new RemoteInspectorXPCConnection(connection, m_xpcQueue, this));
+    m_relayConnection-&gt;sendMessage(@&quot;syn&quot;, nil); // Send a simple message to initialize the XPC connection.
</ins><span class="cx">     xpc_release(connection);
</span><span class="cx"> 
</span><del>-    if (m_automaticInspectionCandidateIdentifier) {
</del><ins>+    if (m_automaticInspectionCandidateTargetIdentifier) {
</ins><span class="cx">         // We already have a debuggable waiting to be automatically inspected.
</span><span class="cx">         pushListingsNow();
</span><span class="cx">         sendAutomaticInspectionCandidateMessage();
</span><span class="lines">@@ -444,26 +444,26 @@
</span><span class="cx">         NSLog(@&quot;Unrecognized RemoteInspector XPC Message: %@&quot;, messageName);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void RemoteInspector::xpcConnectionFailed(RemoteInspectorXPCConnection* connection)
</del><ins>+void RemoteInspector::xpcConnectionFailed(RemoteInspectorXPCConnection* relayConnection)
</ins><span class="cx"> {
</span><span class="cx">     std::lock_guard&lt;Lock&gt; lock(m_mutex);
</span><span class="cx"> 
</span><del>-    ASSERT(connection == m_xpcConnection);
-    if (connection != m_xpcConnection)
</del><ins>+    ASSERT(relayConnection == m_relayConnection);
+    if (relayConnection != m_relayConnection)
</ins><span class="cx">         return;
</span><span class="cx"> 
</span><span class="cx">     m_pushScheduled = false;
</span><span class="cx"> 
</span><del>-    for (auto connection : m_connectionMap.values())
-        connection-&gt;close();
-    m_connectionMap.clear();
</del><ins>+    for (auto targetConnection : m_targetConnectionMap.values())
+        targetConnection-&gt;close();
+    m_targetConnectionMap.clear();
</ins><span class="cx"> 
</span><span class="cx">     updateHasActiveDebugSession();
</span><span class="cx"> 
</span><span class="cx">     m_automaticInspectionPaused = false;
</span><span class="cx"> 
</span><del>-    // The connection will close itself.
-    m_xpcConnection = nullptr;
</del><ins>+    // The XPC connection will close itself.
+    m_relayConnection = nullptr;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void RemoteInspector::xpcConnectionUnhandledMessage(RemoteInspectorXPCConnection*, xpc_object_t)
</span><span class="lines">@@ -493,7 +493,7 @@
</span><span class="cx">         return nil;
</span><span class="cx"> 
</span><span class="cx">     RetainPtr&lt;NSMutableDictionary&gt; listing = adoptNS([[NSMutableDictionary alloc] init]);
</span><del>-    [listing setObject:@(target.identifier()) forKey:WIRPageIdentifierKey];
</del><ins>+    [listing setObject:@(target.targetIdentifier()) forKey:WIRTargetIdentifierKey];
</ins><span class="cx"> 
</span><span class="cx">     switch (target.type()) {
</span><span class="cx">     case RemoteInspectionTarget::Type::JavaScript:
</span><span class="lines">@@ -510,8 +510,8 @@
</span><span class="cx">         break;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    if (auto* connection = m_connectionMap.get(target.identifier()))
-        [listing setObject:connection-&gt;connectionIdentifier() forKey:WIRConnectionIdentifierKey];
</del><ins>+    if (auto* connectionToTarget = m_targetConnectionMap.get(target.targetIdentifier()))
+        [listing setObject:connectionToTarget-&gt;connectionIdentifier() forKey:WIRConnectionIdentifierKey];
</ins><span class="cx"> 
</span><span class="cx">     if (target.hasLocalDebugger())
</span><span class="cx">         [listing setObject:@YES forKey:WIRHasLocalDebuggerKey];
</span><span class="lines">@@ -526,29 +526,29 @@
</span><span class="cx">     ASSERT(isMainThread());
</span><span class="cx"> 
</span><span class="cx">     RetainPtr&lt;NSMutableDictionary&gt; listing = adoptNS([[NSMutableDictionary alloc] init]);
</span><del>-    [listing setObject:@(target.identifier()) forKey:WIRPageIdentifierKey];
</del><ins>+    [listing setObject:@(target.targetIdentifier()) forKey:WIRTargetIdentifierKey];
</ins><span class="cx">     [listing setObject:target.name() forKey:WIRTitleKey];
</span><span class="cx">     [listing setObject:WIRTypeAutomation forKey:WIRTypeKey];
</span><span class="cx">     [listing setObject:@(target.isPaired()) forKey:WIRAutomationTargetIsPairedKey];
</span><span class="cx"> 
</span><del>-    if (auto connection = m_connectionMap.get(target.identifier()))
-        [listing setObject:connection-&gt;connectionIdentifier() forKey:WIRConnectionIdentifierKey];
</del><ins>+    if (auto connectionToTarget = m_targetConnectionMap.get(target.targetIdentifier()))
+        [listing setObject:connectionToTarget-&gt;connectionIdentifier() forKey:WIRConnectionIdentifierKey];
</ins><span class="cx"> 
</span><span class="cx">     return listing;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void RemoteInspector::pushListingsNow()
</span><span class="cx"> {
</span><del>-    ASSERT(m_xpcConnection);
-    if (!m_xpcConnection)
</del><ins>+    ASSERT(m_relayConnection);
+    if (!m_relayConnection)
</ins><span class="cx">         return;
</span><span class="cx"> 
</span><span class="cx">     m_pushScheduled = false;
</span><span class="cx"> 
</span><span class="cx">     RetainPtr&lt;NSMutableDictionary&gt; listings = adoptNS([[NSMutableDictionary alloc] init]);
</span><del>-    for (RetainPtr&lt;NSDictionary&gt; listing : m_listingMap.values()) {
-        NSString *identifier = [[listing.get() objectForKey:WIRPageIdentifierKey] stringValue];
-        [listings setObject:listing.get() forKey:identifier];
</del><ins>+    for (RetainPtr&lt;NSDictionary&gt; listing : m_targetListingMap.values()) {
+        NSString *targetIdentifierString = [[listing.get() objectForKey:WIRTargetIdentifierKey] stringValue];
+        [listings setObject:listing.get() forKey:targetIdentifierString];
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     RetainPtr&lt;NSMutableDictionary&gt; message = adoptNS([[NSMutableDictionary alloc] init]);
</span><span class="lines">@@ -557,12 +557,12 @@
</span><span class="cx">     BOOL isAllowed = m_client &amp;&amp; m_client-&gt;remoteAutomationAllowed();
</span><span class="cx">     [message setObject:@(isAllowed) forKey:WIRRemoteAutomationEnabledKey];
</span><span class="cx"> 
</span><del>-    m_xpcConnection-&gt;sendMessage(WIRListingMessage, message.get());
</del><ins>+    m_relayConnection-&gt;sendMessage(WIRListingMessage, message.get());
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void RemoteInspector::pushListingsSoon()
</span><span class="cx"> {
</span><del>-    if (!m_xpcConnection)
</del><ins>+    if (!m_relayConnection)
</ins><span class="cx">         return;
</span><span class="cx"> 
</span><span class="cx">     if (m_pushScheduled)
</span><span class="lines">@@ -580,7 +580,7 @@
</span><span class="cx"> 
</span><span class="cx"> void RemoteInspector::updateHasActiveDebugSession()
</span><span class="cx"> {
</span><del>-    bool hasActiveDebuggerSession = !m_connectionMap.isEmpty();
</del><ins>+    bool hasActiveDebuggerSession = !m_targetConnectionMap.isEmpty();
</ins><span class="cx">     if (hasActiveDebuggerSession == m_hasActiveDebugSession)
</span><span class="cx">         return;
</span><span class="cx"> 
</span><span class="lines">@@ -595,8 +595,8 @@
</span><span class="cx"> 
</span><span class="cx"> void RemoteInspector::receivedSetupMessage(NSDictionary *userInfo)
</span><span class="cx"> {
</span><del>-    unsigned identifier = [[userInfo objectForKey:WIRPageIdentifierKey] unsignedIntegerValue];
-    if (!identifier)
</del><ins>+    unsigned targetIdentifier = [[userInfo objectForKey:WIRTargetIdentifierKey] unsignedIntegerValue];
+    if (!targetIdentifier)
</ins><span class="cx">         return;
</span><span class="cx"> 
</span><span class="cx">     NSString *connectionIdentifier = [userInfo objectForKey:WIRConnectionIdentifierKey];
</span><span class="lines">@@ -607,33 +607,33 @@
</span><span class="cx">     if (!sender)
</span><span class="cx">         return;
</span><span class="cx"> 
</span><del>-    if (m_connectionMap.contains(identifier))
</del><ins>+    if (m_targetConnectionMap.contains(targetIdentifier))
</ins><span class="cx">         return;
</span><span class="cx"> 
</span><del>-    auto findResult = m_targetMap.find(identifier);
</del><ins>+    auto findResult = m_targetMap.find(targetIdentifier);
</ins><span class="cx">     if (findResult == m_targetMap.end())
</span><span class="cx">         return;
</span><span class="cx"> 
</span><span class="cx">     // Attempt to create a connection. This may fail if the page already has an inspector or if it disallows inspection.
</span><span class="cx">     RemoteControllableTarget* target = findResult-&gt;value;
</span><del>-    RefPtr&lt;RemoteConnectionToTarget&gt; connection = adoptRef(new RemoteConnectionToTarget(downcast&lt;RemoteInspectionTarget&gt;(target), connectionIdentifier, sender));
</del><ins>+    RefPtr&lt;RemoteConnectionToTarget&gt; connectionToTarget = adoptRef(new RemoteConnectionToTarget(downcast&lt;RemoteInspectionTarget&gt;(target), connectionIdentifier, sender));
</ins><span class="cx"> 
</span><span class="cx">     if (is&lt;RemoteInspectionTarget&gt;(target)) {
</span><del>-        bool isAutomaticInspection = m_automaticInspectionCandidateIdentifier == target-&gt;identifier();
</del><ins>+        bool isAutomaticInspection = m_automaticInspectionCandidateTargetIdentifier == target-&gt;targetIdentifier();
</ins><span class="cx">         bool automaticallyPause = [[userInfo objectForKey:WIRAutomaticallyPause] boolValue];
</span><span class="cx"> 
</span><del>-        if (!connection-&gt;setup(isAutomaticInspection, automaticallyPause)) {
-            connection-&gt;close();
</del><ins>+        if (!connectionToTarget-&gt;setup(isAutomaticInspection, automaticallyPause)) {
+            connectionToTarget-&gt;close();
</ins><span class="cx">             return;
</span><span class="cx">         }
</span><del>-        m_connectionMap.set(identifier, connection.release());
</del><ins>+        m_targetConnectionMap.set(targetIdentifier, connectionToTarget.release());
</ins><span class="cx">         updateHasActiveDebugSession();
</span><span class="cx">     } else if (is&lt;RemoteAutomationTarget&gt;(target)) {
</span><del>-        if (!connection-&gt;setup()) {
-            connection-&gt;close();
</del><ins>+        if (!connectionToTarget-&gt;setup()) {
+            connectionToTarget-&gt;close();
</ins><span class="cx">             return;
</span><span class="cx">         }
</span><del>-        m_connectionMap.set(identifier, connection.release());
</del><ins>+        m_targetConnectionMap.set(targetIdentifier, connectionToTarget.release());
</ins><span class="cx">         updateHasActiveDebugSession();
</span><span class="cx">     } else
</span><span class="cx">         ASSERT_NOT_REACHED();
</span><span class="lines">@@ -643,38 +643,38 @@
</span><span class="cx"> 
</span><span class="cx"> void RemoteInspector::receivedDataMessage(NSDictionary *userInfo)
</span><span class="cx"> {
</span><del>-    unsigned identifier = [[userInfo objectForKey:WIRPageIdentifierKey] unsignedIntegerValue];
-    if (!identifier)
</del><ins>+    unsigned targetIdentifier = [[userInfo objectForKey:WIRTargetIdentifierKey] unsignedIntegerValue];
+    if (!targetIdentifier)
</ins><span class="cx">         return;
</span><span class="cx"> 
</span><del>-    auto connection = m_connectionMap.get(identifier);
-    if (!connection)
</del><ins>+    auto connectionToTarget = m_targetConnectionMap.get(targetIdentifier);
+    if (!connectionToTarget)
</ins><span class="cx">         return;
</span><span class="cx"> 
</span><span class="cx">     NSData *data = [userInfo objectForKey:WIRSocketDataKey];
</span><span class="cx">     RetainPtr&lt;NSString&gt; message = adoptNS([[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]);
</span><del>-    connection-&gt;sendMessageToTarget(message.get());
</del><ins>+    connectionToTarget-&gt;sendMessageToTarget(message.get());
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void RemoteInspector::receivedDidCloseMessage(NSDictionary *userInfo)
</span><span class="cx"> {
</span><del>-    unsigned identifier = [[userInfo objectForKey:WIRPageIdentifierKey] unsignedIntegerValue];
-    if (!identifier)
</del><ins>+    unsigned targetIdentifier = [[userInfo objectForKey:WIRTargetIdentifierKey] unsignedIntegerValue];
+    if (!targetIdentifier)
</ins><span class="cx">         return;
</span><span class="cx"> 
</span><span class="cx">     NSString *connectionIdentifier = [userInfo objectForKey:WIRConnectionIdentifierKey];
</span><span class="cx">     if (!connectionIdentifier)
</span><span class="cx">         return;
</span><span class="cx"> 
</span><del>-    auto connection = m_connectionMap.get(identifier);
-    if (!connection)
</del><ins>+    auto connectionToTarget = m_targetConnectionMap.get(targetIdentifier);
+    if (!connectionToTarget)
</ins><span class="cx">         return;
</span><span class="cx"> 
</span><del>-    if (![connectionIdentifier isEqualToString:connection-&gt;connectionIdentifier()])
</del><ins>+    if (![connectionIdentifier isEqualToString:connectionToTarget-&gt;connectionIdentifier()])
</ins><span class="cx">         return;
</span><span class="cx"> 
</span><del>-    connection-&gt;close();
-    m_connectionMap.remove(identifier);
</del><ins>+    connectionToTarget-&gt;close();
+    m_targetConnectionMap.remove(targetIdentifier);
</ins><span class="cx"> 
</span><span class="cx">     updateHasActiveDebugSession();
</span><span class="cx"> 
</span><span class="lines">@@ -688,7 +688,7 @@
</span><span class="cx"> 
</span><span class="cx"> void RemoteInspector::receivedIndicateMessage(NSDictionary *userInfo)
</span><span class="cx"> {
</span><del>-    unsigned identifier = [[userInfo objectForKey:WIRPageIdentifierKey] unsignedIntegerValue];
</del><ins>+    unsigned identifier = [[userInfo objectForKey:WIRTargetIdentifierKey] unsignedIntegerValue];
</ins><span class="cx">     if (!identifier)
</span><span class="cx">         return;
</span><span class="cx"> 
</span><span class="lines">@@ -712,8 +712,8 @@
</span><span class="cx"> 
</span><span class="cx"> void RemoteInspector::receivedProxyApplicationSetupMessage(NSDictionary *)
</span><span class="cx"> {
</span><del>-    ASSERT(m_xpcConnection);
-    if (!m_xpcConnection)
</del><ins>+    ASSERT(m_relayConnection);
+    if (!m_relayConnection)
</ins><span class="cx">         return;
</span><span class="cx"> 
</span><span class="cx">     if (!m_parentProcessIdentifier || !m_parentProcessAuditData) {
</span><span class="lines">@@ -730,7 +730,7 @@
</span><span class="cx"> 
</span><span class="cx">     m_shouldSendParentProcessInformation = false;
</span><span class="cx"> 
</span><del>-    m_xpcConnection-&gt;sendMessage(WIRProxyApplicationSetupResponseMessage, @{
</del><ins>+    m_relayConnection-&gt;sendMessage(WIRProxyApplicationSetupResponseMessage, @{
</ins><span class="cx">         WIRProxyApplicationParentPIDKey: @(m_parentProcessIdentifier),
</span><span class="cx">         WIRProxyApplicationParentAuditDataKey: (NSData *)m_parentProcessAuditData.get(),
</span><span class="cx">     });
</span><span class="lines">@@ -742,8 +742,8 @@
</span><span class="cx">     if (!connectionIdentifier)
</span><span class="cx">         return;
</span><span class="cx"> 
</span><del>-    auto it = m_connectionMap.begin();
-    auto end = m_connectionMap.end();
</del><ins>+    auto it = m_targetConnectionMap.begin();
+    auto end = m_targetConnectionMap.end();
</ins><span class="cx">     for (; it != end; ++it) {
</span><span class="cx">         if ([connectionIdentifier isEqualToString:it-&gt;value-&gt;connectionIdentifier()])
</span><span class="cx">             break;
</span><span class="lines">@@ -754,7 +754,7 @@
</span><span class="cx"> 
</span><span class="cx">     auto connection = it-&gt;value;
</span><span class="cx">     connection-&gt;close();
</span><del>-    m_connectionMap.remove(it);
</del><ins>+    m_targetConnectionMap.remove(it);
</ins><span class="cx"> 
</span><span class="cx">     updateHasActiveDebugSession();
</span><span class="cx"> }
</span><span class="lines">@@ -769,10 +769,10 @@
</span><span class="cx"> 
</span><span class="cx"> void RemoteInspector::receivedAutomaticInspectionRejectMessage(NSDictionary *userInfo)
</span><span class="cx"> {
</span><del>-    unsigned rejectionIdentifier = [[userInfo objectForKey:WIRPageIdentifierKey] unsignedIntValue];
</del><ins>+    unsigned rejectionIdentifier = [[userInfo objectForKey:WIRTargetIdentifierKey] unsignedIntValue];
</ins><span class="cx"> 
</span><del>-    ASSERT(rejectionIdentifier == m_automaticInspectionCandidateIdentifier);
-    if (rejectionIdentifier == m_automaticInspectionCandidateIdentifier)
</del><ins>+    ASSERT(rejectionIdentifier == m_automaticInspectionCandidateTargetIdentifier);
+    if (rejectionIdentifier == m_automaticInspectionCandidateTargetIdentifier)
</ins><span class="cx">         m_automaticInspectionPaused = false;
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreinspectorremoteRemoteInspectorConstantsh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/inspector/remote/RemoteInspectorConstants.h (196514 => 196515)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/inspector/remote/RemoteInspectorConstants.h        2016-02-12 22:34:42 UTC (rev 196514)
+++ trunk/Source/JavaScriptCore/inspector/remote/RemoteInspectorConstants.h        2016-02-12 22:35:45 UTC (rev 196515)
</span><span class="lines">@@ -48,7 +48,8 @@
</span><span class="cx"> #define WIRHostApplicationIdentifierKey         @&quot;WIRHostApplicationIdentifierKey&quot;
</span><span class="cx"> #define WIRHostApplicationNameKey               @&quot;WIRHostApplicationNameKey&quot;
</span><span class="cx"> #define WIRConnectionIdentifierKey              @&quot;WIRConnectionIdentifierKey&quot;
</span><del>-#define WIRPageIdentifierKey                    @&quot;WIRPageIdentifierKey&quot;
</del><ins>+// COMPATABILITY(iOS 9): The key string is intentionally mismatched to support old relays.
+#define WIRTargetIdentifierKey                  @&quot;WIRPageIdentifierKey&quot;
</ins><span class="cx"> #define WIRHasLocalDebuggerKey                  @&quot;WIRHasLocalDebuggerKey&quot;
</span><span class="cx"> #define WIRTitleKey                             @&quot;WIRTitleKey&quot;
</span><span class="cx"> #define WIRURLKey                               @&quot;WIRURLKey&quot;
</span></span></pre>
</div>
</div>

</body>
</html>