Title: [212394] trunk
Revision
212394
Author
[email protected]
Date
2017-02-15 14:31:07 -0800 (Wed, 15 Feb 2017)

Log Message

Unreviewed, rolling out r212169.

Broke iOS WebInspector

Reverted changeset:

"WebInspector: refactor RemoteInspector to move cocoa specific
code to their own files"
https://bugs.webkit.org/show_bug.cgi?id=166681
http://trac.webkit.org/changeset/212169

Modified Paths

Added Paths

Removed Paths

Property Changed

Diff

Modified: trunk/Source/_javascript_Core/API/JSRemoteInspector.cpp (212393 => 212394)


--- trunk/Source/_javascript_Core/API/JSRemoteInspector.cpp	2017-02-15 21:50:10 UTC (rev 212393)
+++ trunk/Source/_javascript_Core/API/JSRemoteInspector.cpp	2017-02-15 22:31:07 UTC (rev 212394)
@@ -50,9 +50,9 @@
 #endif
 }
 
-void JSRemoteInspectorSetParentProcessInformation(pid_t pid, const uint8_t* auditData, size_t auditLength)
+void JSRemoteInspectorSetParentProcessInformation(pid_t pid, const UInt8* auditData, size_t auditLength)
 {
-#if ENABLE(REMOTE_INSPECTOR) && PLATFORM(COCOA)
+#if ENABLE(REMOTE_INSPECTOR)
     RetainPtr<CFDataRef> auditDataRef = adoptCF(CFDataCreate(kCFAllocatorDefault, auditData, auditLength));
     RemoteInspector::singleton().setParentProcessInformation(pid, auditDataRef);
 #else

Modified: trunk/Source/_javascript_Core/ChangeLog (212393 => 212394)


--- trunk/Source/_javascript_Core/ChangeLog	2017-02-15 21:50:10 UTC (rev 212393)
+++ trunk/Source/_javascript_Core/ChangeLog	2017-02-15 22:31:07 UTC (rev 212394)
@@ -1,3 +1,16 @@
+2017-02-15  Alex Christensen  <[email protected]>
+
+        Unreviewed, rolling out r212169.
+
+        Broke iOS WebInspector
+
+        Reverted changeset:
+
+        "WebInspector: refactor RemoteInspector to move cocoa specific
+        code to their own files"
+        https://bugs.webkit.org/show_bug.cgi?id=166681
+        http://trac.webkit.org/changeset/212169
+
 2017-02-15  Chris Dumez  <[email protected]>
 
         Expose Symbol.toPrimitive / valueOf on Location instances

Modified: trunk/Source/_javascript_Core/_javascript_Core.xcodeproj/project.pbxproj (212393 => 212394)


--- trunk/Source/_javascript_Core/_javascript_Core.xcodeproj/project.pbxproj	2017-02-15 21:50:10 UTC (rev 212393)
+++ trunk/Source/_javascript_Core/_javascript_Core.xcodeproj/project.pbxproj	2017-02-15 22:31:07 UTC (rev 212394)
@@ -1603,11 +1603,6 @@
 		9928FF3B18AC4AEC00B8CF12 /* JSReplayInputs.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9928FF3918AC4AEC00B8CF12 /* JSReplayInputs.cpp */; };
 		9928FF3C18AC4AEC00B8CF12 /* JSReplayInputs.h in Headers */ = {isa = PBXBuildFile; fileRef = 9928FF3A18AC4AEC00B8CF12 /* JSReplayInputs.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		992ABCF91BEA9BD2006403A0 /* RemoteAutomationTarget.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 992ABCF51BEA94CA006403A0 /* RemoteAutomationTarget.cpp */; };
-		992F56B41E4E84A40035953B /* RemoteConnectionToTargetCocoa.mm in Sources */ = {isa = PBXBuildFile; fileRef = 992F56B31E4E847D0035953B /* RemoteConnectionToTargetCocoa.mm */; };
-		992F56B51E4E84A80035953B /* RemoteInspectorCocoa.mm in Sources */ = {isa = PBXBuildFile; fileRef = 992F56B01E4E84790035953B /* RemoteInspectorCocoa.mm */; };
-		992F56B61E4E84AB0035953B /* RemoteInspectorXPCConnection.mm in Sources */ = {isa = PBXBuildFile; fileRef = 992F56B21E4E84790035953B /* RemoteInspectorXPCConnection.mm */; };
-		992F56B71E4E84B20035953B /* RemoteInspectorXPCConnection.h in Headers */ = {isa = PBXBuildFile; fileRef = 992F56B11E4E84790035953B /* RemoteInspectorXPCConnection.h */; settings = {ATTRIBUTES = (Private, ); }; };
-		995566861E4E8B0F00AAE13C /* RemoteInspector.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 995566851E4E8B0700AAE13C /* RemoteInspector.cpp */; };
 		9959E92B1BD17FA4001AA413 /* cssmin.py in Headers */ = {isa = PBXBuildFile; fileRef = 9959E9271BD17FA0001AA413 /* cssmin.py */; settings = {ATTRIBUTES = (Private, ); }; };
 		9959E92D1BD17FA4001AA413 /* jsmin.py in Headers */ = {isa = PBXBuildFile; fileRef = 9959E9291BD17FA0001AA413 /* jsmin.py */; settings = {ATTRIBUTES = (Private, ); }; };
 		9959E92E1BD17FA4001AA413 /* xxd.pl in Headers */ = {isa = PBXBuildFile; fileRef = 9959E92A1BD17FA0001AA413 /* xxd.pl */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -1784,8 +1779,12 @@
 		A5AB49DD1BEC8086007020FB /* PerGlobalObjectWrapperWorld.h in Headers */ = {isa = PBXBuildFile; fileRef = A5AB49DB1BEC8079007020FB /* PerGlobalObjectWrapperWorld.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		A5B6A74D18C6DBA600F11E91 /* ConsoleClient.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A5B6A74C18C6DBA600F11E91 /* ConsoleClient.cpp */; };
 		A5BA15E8182340B300A82E69 /* RemoteInspector.h in Headers */ = {isa = PBXBuildFile; fileRef = A5BA15E1182340B300A82E69 /* RemoteInspector.h */; settings = {ATTRIBUTES = (Private, ); }; };
+		A5BA15E9182340B300A82E69 /* RemoteInspector.mm in Sources */ = {isa = PBXBuildFile; fileRef = A5BA15E2182340B300A82E69 /* RemoteInspector.mm */; };
 		A5BA15EA182340B400A82E69 /* RemoteInspectorConstants.h in Headers */ = {isa = PBXBuildFile; fileRef = A5BA15E3182340B300A82E69 /* RemoteInspectorConstants.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		A5BA15EB182340B400A82E69 /* RemoteConnectionToTarget.h in Headers */ = {isa = PBXBuildFile; fileRef = A5BA15E4182340B300A82E69 /* RemoteConnectionToTarget.h */; };
+		A5BA15EC182340B400A82E69 /* RemoteConnectionToTarget.mm in Sources */ = {isa = PBXBuildFile; fileRef = A5BA15E5182340B300A82E69 /* RemoteConnectionToTarget.mm */; };
+		A5BA15ED182340B400A82E69 /* RemoteInspectorXPCConnection.h in Headers */ = {isa = PBXBuildFile; fileRef = A5BA15E6182340B300A82E69 /* RemoteInspectorXPCConnection.h */; settings = {ATTRIBUTES = (Private, ); }; };
+		A5BA15EE182340B400A82E69 /* RemoteInspectorXPCConnection.mm in Sources */ = {isa = PBXBuildFile; fileRef = A5BA15E7182340B300A82E69 /* RemoteInspectorXPCConnection.mm */; };
 		A5BA15F0182345AF00A82E69 /* RemoteInspectionTarget.h in Headers */ = {isa = PBXBuildFile; fileRef = A5BA15EF182345AF00A82E69 /* RemoteInspectionTarget.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		A5C3A1A518C0490200C9593A /* JSGlobalObjectConsoleClient.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A5C3A1A318C0490200C9593A /* JSGlobalObjectConsoleClient.cpp */; };
 		A5C3A1A618C0490200C9593A /* JSGlobalObjectConsoleClient.h in Headers */ = {isa = PBXBuildFile; fileRef = A5C3A1A418C0490200C9593A /* JSGlobalObjectConsoleClient.h */; };
@@ -4121,11 +4120,6 @@
 		9928FF3D18AC4B1C00B8CF12 /* JSInputs.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = JSInputs.json; sourceTree = "<group>"; };
 		992ABCF51BEA94CA006403A0 /* RemoteAutomationTarget.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RemoteAutomationTarget.cpp; sourceTree = "<group>"; };
 		992ABCF61BEA94CA006403A0 /* RemoteAutomationTarget.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RemoteAutomationTarget.h; sourceTree = "<group>"; };
-		992F56B01E4E84790035953B /* RemoteInspectorCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = RemoteInspectorCocoa.mm; sourceTree = "<group>"; };
-		992F56B11E4E84790035953B /* RemoteInspectorXPCConnection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RemoteInspectorXPCConnection.h; sourceTree = "<group>"; };
-		992F56B21E4E84790035953B /* RemoteInspectorXPCConnection.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = RemoteInspectorXPCConnection.mm; sourceTree = "<group>"; };
-		992F56B31E4E847D0035953B /* RemoteConnectionToTargetCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = RemoteConnectionToTargetCocoa.mm; sourceTree = "<group>"; };
-		995566851E4E8B0700AAE13C /* RemoteInspector.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RemoteInspector.cpp; sourceTree = "<group>"; };
 		9959E9271BD17FA0001AA413 /* cssmin.py */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.python; path = cssmin.py; sourceTree = "<group>"; };
 		9959E9291BD17FA0001AA413 /* jsmin.py */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.python; path = jsmin.py; sourceTree = "<group>"; };
 		9959E92A1BD17FA0001AA413 /* xxd.pl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.perl; path = xxd.pl; sourceTree = "<group>"; };
@@ -4303,8 +4297,12 @@
 		A5AB49DB1BEC8079007020FB /* PerGlobalObjectWrapperWorld.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PerGlobalObjectWrapperWorld.h; sourceTree = "<group>"; };
 		A5B6A74C18C6DBA600F11E91 /* ConsoleClient.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ConsoleClient.cpp; sourceTree = "<group>"; };
 		A5BA15E1182340B300A82E69 /* RemoteInspector.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RemoteInspector.h; sourceTree = "<group>"; };
+		A5BA15E2182340B300A82E69 /* RemoteInspector.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = RemoteInspector.mm; sourceTree = "<group>"; };
 		A5BA15E3182340B300A82E69 /* RemoteInspectorConstants.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RemoteInspectorConstants.h; sourceTree = "<group>"; };
 		A5BA15E4182340B300A82E69 /* RemoteConnectionToTarget.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RemoteConnectionToTarget.h; sourceTree = "<group>"; };
+		A5BA15E5182340B300A82E69 /* RemoteConnectionToTarget.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = RemoteConnectionToTarget.mm; sourceTree = "<group>"; };
+		A5BA15E6182340B300A82E69 /* RemoteInspectorXPCConnection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RemoteInspectorXPCConnection.h; sourceTree = "<group>"; };
+		A5BA15E7182340B300A82E69 /* RemoteInspectorXPCConnection.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = RemoteInspectorXPCConnection.mm; sourceTree = "<group>"; };
 		A5BA15EF182345AF00A82E69 /* RemoteInspectionTarget.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RemoteInspectionTarget.h; sourceTree = "<group>"; };
 		A5C3A1A318C0490200C9593A /* JSGlobalObjectConsoleClient.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSGlobalObjectConsoleClient.cpp; sourceTree = "<group>"; };
 		A5C3A1A418C0490200C9593A /* JSGlobalObjectConsoleClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSGlobalObjectConsoleClient.h; sourceTree = "<group>"; };
@@ -5044,7 +5042,6 @@
 			isa = PBXGroup;
 			children = (
 				0F9327591C20BCBA00CF6564 /* dynbench */,
-				932F5BE10822A1C700736975 /* jsc */,
 				0FF922CF14F46B130041A24E /* JSCLLIntOffsetsExtractor */,
 				141211200A48793C00480255 /* minidom */,
 				0F6183431C45F62A0072450B /* testair */,
@@ -5052,6 +5049,7 @@
 				0FEC85AD1BDB5CF10080FF74 /* testb3 */,
 				6511230514046A4C002B101D /* testRegExp */,
 				932F5BD90822A1C700736975 /* _javascript_Core.framework */,
+				932F5BE10822A1C700736975 /* jsc */,
 			);
 			name = Products;
 			sourceTree = "<group>";
@@ -6110,17 +6108,6 @@
 			path = disassembler/ARMv7;
 			sourceTree = "<group>";
 		};
-		7ACDDECF1E252ACA0097AFEB /* cocoa */ = {
-			isa = PBXGroup;
-			children = (
-				992F56B31E4E847D0035953B /* RemoteConnectionToTargetCocoa.mm */,
-				992F56B01E4E84790035953B /* RemoteInspectorCocoa.mm */,
-				992F56B11E4E84790035953B /* RemoteInspectorXPCConnection.h */,
-				992F56B21E4E84790035953B /* RemoteInspectorXPCConnection.mm */,
-			);
-			path = cocoa;
-			sourceTree = "<group>";
-		};
 		7B98D1331B60CD1E0023B1A4 /* wasm */ = {
 			isa = PBXGroup;
 			children = (
@@ -6837,9 +6824,9 @@
 				FE384EE21ADDB7AD0055DE2C /* JSDollarVM.h */,
 				FE384EE31ADDB7AD0055DE2C /* JSDollarVMPrototype.cpp */,
 				FE384EE41ADDB7AD0055DE2C /* JSDollarVMPrototype.h */,
-				86B5822C14D22F5F00A9C306 /* ProfileTreeNode.h */,
 				FE3022D01E3D739600BAC493 /* SigillCrashAnalyzer.cpp */,
 				FE3022D11E3D739600BAC493 /* SigillCrashAnalyzer.h */,
+				86B5822C14D22F5F00A9C306 /* ProfileTreeNode.h */,
 				86B5826A14D35D5100A9C306 /* TieredMMapArray.h */,
 				FE3022D41E42856700BAC493 /* VMInspector.cpp */,
 				FE3022D51E42856700BAC493 /* VMInspector.h */,
@@ -7123,10 +7110,10 @@
 				0FB1765F196B8F9E0091052A /* DFGPureValue.h */,
 				0F3A1BF71A9ECB7D000DE01A /* DFGPutStackSinkingPhase.cpp */,
 				0F3A1BF81A9ECB7D000DE01A /* DFGPutStackSinkingPhase.h */,
-				86EC9DC11328DF82002B2AD7 /* DFGRegisterBank.h */,
 				79FC8A071E32E9F000D88F0E /* DFGRegisteredStructure.h */,
 				7980C16A1E3A940E00B71615 /* DFGRegisteredStructureSet.cpp */,
 				7980C16B1E3A940E00B71615 /* DFGRegisteredStructureSet.h */,
+				86EC9DC11328DF82002B2AD7 /* DFGRegisterBank.h */,
 				0F2FCCF418A60070001A27F8 /* DFGSafepoint.cpp */,
 				0F2FCCF518A60070001A27F8 /* DFGSafepoint.h */,
 				A77A423C17A0BBFD00A8DB81 /* DFGSafeToExecute.h */,
@@ -7655,17 +7642,19 @@
 		A5BA15E01823409D00A82E69 /* remote */ = {
 			isa = PBXGroup;
 			children = (
-				7ACDDECF1E252ACA0097AFEB /* cocoa */,
 				992ABCF51BEA94CA006403A0 /* RemoteAutomationTarget.cpp */,
 				992ABCF61BEA94CA006403A0 /* RemoteAutomationTarget.h */,
 				A5BA15E4182340B300A82E69 /* RemoteConnectionToTarget.h */,
+				A5BA15E5182340B300A82E69 /* RemoteConnectionToTarget.mm */,
 				998ED6721BED659A00DD8017 /* RemoteControllableTarget.cpp */,
 				998ED6731BED659A00DD8017 /* RemoteControllableTarget.h */,
 				A594558E18245EDE00CC3843 /* RemoteInspectionTarget.cpp */,
 				A5BA15EF182345AF00A82E69 /* RemoteInspectionTarget.h */,
-				995566851E4E8B0700AAE13C /* RemoteInspector.cpp */,
 				A5BA15E1182340B300A82E69 /* RemoteInspector.h */,
+				A5BA15E2182340B300A82E69 /* RemoteInspector.mm */,
 				A5BA15E3182340B300A82E69 /* RemoteInspectorConstants.h */,
+				A5BA15E6182340B300A82E69 /* RemoteInspectorXPCConnection.h */,
+				A5BA15E7182340B300A82E69 /* RemoteInspectorXPCConnection.mm */,
 			);
 			path = remote;
 			sourceTree = "<group>";
@@ -8108,6 +8097,7 @@
 				0F21C27D14BE727A00ADC64B /* CodeSpecializationKind.h in Headers */,
 				0F0B83A714BCF50700885B4F /* CodeType.h in Headers */,
 				0FA762051DB9242900B7A2FD /* CollectionScope.h in Headers */,
+				79FC8A081E32E9F000D88F0E /* DFGRegisteredStructure.h in Headers */,
 				A53243981856A489002ED692 /* CombinedDomains.json in Headers */,
 				BC18C3F30E16F5CD00B34460 /* CommonIdentifiers.h in Headers */,
 				0F15F15F14B7A73E005DE37D /* CommonSlowPaths.h in Headers */,
@@ -8302,8 +8292,6 @@
 				0FB17663196B8F9E0091052A /* DFGPureValue.h in Headers */,
 				0F3A1BFA1A9ECB7D000DE01A /* DFGPutStackSinkingPhase.h in Headers */,
 				86EC9DD11328DF82002B2AD7 /* DFGRegisterBank.h in Headers */,
-				79FC8A081E32E9F000D88F0E /* DFGRegisteredStructure.h in Headers */,
-				7980C16D1E3A940E00B71615 /* DFGRegisteredStructureSet.h in Headers */,
 				0F2FCCFC18A60070001A27F8 /* DFGSafepoint.h in Headers */,
 				A77A424317A0BBFD00A8DB81 /* DFGSafeToExecute.h in Headers */,
 				A741017F179DAF80002EB8BA /* DFGSaneStringGetByValSlowPathGenerator.h in Headers */,
@@ -8466,6 +8454,7 @@
 				0F86A26F1D6F7B3300CB0C92 /* GCTypeMap.h in Headers */,
 				9959E9311BD18272001AA413 /* generate-combined-inspector-json.py in Headers */,
 				C4703CC0192844960013FBEA /* generate-inspector-protocol-bindings.py in Headers */,
+				FE3022D91E43C93400BAC493 /* JSVirtualMachinePrivate.h in Headers */,
 				99DA00AF1BD5994E00F4575C /* generate-js-builtins.py in Headers */,
 				A5EA70EC19F5B3EA0098F5EC /* generate_cpp_alternate_backend_dispatcher_header.py in Headers */,
 				A5EF9B141A1D43F600702E90 /* generate_cpp_backend_dispatcher_header.py in Headers */,
@@ -8702,6 +8691,7 @@
 				A50E4B6418809DD50068A46D /* JSGlobalObjectRuntimeAgent.h in Headers */,
 				A503FA2A188F105900110F14 /* JSGlobalObjectScriptDebugServer.h in Headers */,
 				A513E5C0185BFACC007E95AD /* JSInjectedScriptHost.h in Headers */,
+				7980C16D1E3A940E00B71615 /* DFGRegisteredStructureSet.h in Headers */,
 				A513E5C2185BFACC007E95AD /* JSInjectedScriptHostPrototype.h in Headers */,
 				C442CB251A6CDB8C005D3D7C /* JSInputs.json in Headers */,
 				0F2B66F817B6B5AB00A7AE3F /* JSInt16Array.h in Headers */,
@@ -8781,7 +8771,6 @@
 				BC18C42C0E16F5CD00B34460 /* JSValueRef.h in Headers */,
 				86E3C615167BABD7006D760A /* JSVirtualMachine.h in Headers */,
 				86E3C61D167BABEE006D760A /* JSVirtualMachineInternal.h in Headers */,
-				FE3022D91E43C93400BAC493 /* JSVirtualMachinePrivate.h in Headers */,
 				A7CA3AE817DA41AE006538AF /* JSWeakMap.h in Headers */,
 				A7482E93116A7CAD003B0712 /* JSWeakObjectMapRefInternal.h in Headers */,
 				A7482B9311671147003B0712 /* JSWeakObjectMapRefPrivate.h in Headers */,
@@ -8819,6 +8808,7 @@
 				FE3913561B794F8F00EDAF71 /* LiveObjectList.h in Headers */,
 				70DE9A091BE7D69E005D89D9 /* LLIntAssembly.h in Headers */,
 				0F0FC45A14BD15F500B81154 /* LLIntCallLinkInfo.h in Headers */,
+				FE3022D31E3D73A500BAC493 /* SigillCrashAnalyzer.h in Headers */,
 				FE20CE9E15F04A9500DF3430 /* LLIntCLoop.h in Headers */,
 				0F4680CA14BBB16C00BFE272 /* LLIntCommon.h in Headers */,
 				0F4680D314BBD16700BFE272 /* LLIntData.h in Headers */,
@@ -8878,6 +8868,7 @@
 				A79D3ED9C5064DD0A8466A3A /* ModuleScopeData.h in Headers */,
 				0F1FB3991E1F65FB00A9BE50 /* MutatorScheduler.h in Headers */,
 				0FA762071DB9243300B7A2FD /* MutatorState.h in Headers */,
+				FE3022D71E42857300BAC493 /* VMInspector.h in Headers */,
 				BC02E9110E1839DB000F9297 /* NativeErrorConstructor.h in Headers */,
 				BC02E9130E1839DB000F9297 /* NativeErrorPrototype.h in Headers */,
 				147341D01DC02DB400AA29BA /* NativeExecutable.h in Headers */,
@@ -8987,7 +8978,7 @@
 				A5BA15F0182345AF00A82E69 /* RemoteInspectionTarget.h in Headers */,
 				A5BA15E8182340B300A82E69 /* RemoteInspector.h in Headers */,
 				A5BA15EA182340B400A82E69 /* RemoteInspectorConstants.h in Headers */,
-				992F56B71E4E84B20035953B /* RemoteInspectorXPCConnection.h in Headers */,
+				A5BA15ED182340B400A82E69 /* RemoteInspectorXPCConnection.h in Headers */,
 				0F24E55117EE274900ABB217 /* Repatch.h in Headers */,
 				869EBCB70E8C6D4A008722CC /* ResultType.h in Headers */,
 				70B0A9D11A9B66460001306A /* RuntimeFlags.h in Headers */,
@@ -9017,7 +9008,6 @@
 				0FEE98411A8865B700754E93 /* SetupVarargsFrame.h in Headers */,
 				DC17E8181C9C91D9008A6AB3 /* ShadowChicken.h in Headers */,
 				DC17E8191C9C91DB008A6AB3 /* ShadowChickenInlines.h in Headers */,
-				FE3022D31E3D73A500BAC493 /* SigillCrashAnalyzer.h in Headers */,
 				0F2B670517B6B5AB00A7AE3F /* SimpleTypedArrayController.h in Headers */,
 				14BA78F113AAB88F005B7C2C /* SlotVisitor.h in Headers */,
 				C2160FE715F7E95E00942DFC /* SlotVisitorInlines.h in Headers */,
@@ -9136,7 +9126,6 @@
 				658D3A5619638268003C45D6 /* VMEntryRecord.h in Headers */,
 				FE5932A8183C5A2600A1ECCC /* VMEntryScope.h in Headers */,
 				0F5AE2C41DF4F2800066EFE1 /* VMInlines.h in Headers */,
-				FE3022D71E42857300BAC493 /* VMInspector.h in Headers */,
 				53F40E931D5A4AB30099A1B6 /* WasmB3IRGenerator.h in Headers */,
 				AD4B1DFA1DF244E20071AE32 /* WasmBinding.h in Headers */,
 				53FD04D41D7AB291003287D3 /* WasmCallingConvention.h in Headers */,
@@ -9746,6 +9735,7 @@
 				0F9630391D4192C6005609D9 /* AllocatorAttributes.cpp in Sources */,
 				147F39BD107EC37600427A48 /* ArgList.cpp in Sources */,
 				79A228351D35D71E00D8E067 /* ArithProfile.cpp in Sources */,
+				FE3022D61E42857300BAC493 /* VMInspector.cpp in Sources */,
 				0F743BAA16B88249009F9277 /* ARM64Disassembler.cpp in Sources */,
 				86D3B2C310156BDE002865E7 /* ARMAssembler.cpp in Sources */,
 				65C02850171795E200351E35 /* ARMv7Disassembler.cpp in Sources */,
@@ -10015,7 +10005,6 @@
 				0F2B9CEC19D0BA7D00B1D1B5 /* DFGPromotedHeapLocation.cpp in Sources */,
 				0FB17662196B8F9E0091052A /* DFGPureValue.cpp in Sources */,
 				0F3A1BF91A9ECB7D000DE01A /* DFGPutStackSinkingPhase.cpp in Sources */,
-				7980C16C1E3A940E00B71615 /* DFGRegisteredStructureSet.cpp in Sources */,
 				0F2FCCFB18A60070001A27F8 /* DFGSafepoint.cpp in Sources */,
 				86EC9DD21328DF82002B2AD7 /* DFGSpeculativeJIT.cpp in Sources */,
 				86880F1F14328BB900B08D42 /* DFGSpeculativeJIT32_64.cpp in Sources */,
@@ -10069,6 +10058,7 @@
 				14AD91171DCA97FD0014F9FE /* EvalCodeBlock.cpp in Sources */,
 				147341E21DC2CE9600AA29BA /* EvalExecutable.cpp in Sources */,
 				A54982031891D0B00081E5B8 /* EventLoop.cpp in Sources */,
+				7980C16C1E3A940E00B71615 /* DFGRegisteredStructureSet.cpp in Sources */,
 				FE1C0FFF1B194FD100B53FCA /* Exception.cpp in Sources */,
 				FE80C19B1D776A98008510C0 /* ExceptionEventLocation.cpp in Sources */,
 				0F12DE0F1979D5FD0006FF4E /* ExceptionFuzz.cpp in Sources */,
@@ -10441,6 +10431,7 @@
 				79B00CBE1C6AB07E0088C65D /* ProxyObject.cpp in Sources */,
 				79160DBD1C8E3EC8008C085A /* ProxyRevoke.cpp in Sources */,
 				0F15CD221BA5F9860031FFD3 /* PutByIdFlags.cpp in Sources */,
+				FE3022D21E3D73A500BAC493 /* SigillCrashAnalyzer.cpp in Sources */,
 				0F9332A314CA7DD70085F3C6 /* PutByIdStatus.cpp in Sources */,
 				0F93B4A918B92C4D00178A3F /* PutByIdVariant.cpp in Sources */,
 				0FF60AC316740F8800029779 /* ReduceWhitespace.cpp in Sources */,
@@ -10458,12 +10449,11 @@
 				0FC3141518146D7000033232 /* RegisterSet.cpp in Sources */,
 				A57D23ED1891B5540031C7FA /* RegularExpression.cpp in Sources */,
 				992ABCF91BEA9BD2006403A0 /* RemoteAutomationTarget.cpp in Sources */,
-				992F56B41E4E84A40035953B /* RemoteConnectionToTargetCocoa.mm in Sources */,
+				A5BA15EC182340B400A82E69 /* RemoteConnectionToTarget.mm in Sources */,
 				998ED6741BED70AC00DD8017 /* RemoteControllableTarget.cpp in Sources */,
 				A594558F18245EFD00CC3843 /* RemoteInspectionTarget.cpp in Sources */,
-				995566861E4E8B0F00AAE13C /* RemoteInspector.cpp in Sources */,
-				992F56B51E4E84A80035953B /* RemoteInspectorCocoa.mm in Sources */,
-				992F56B61E4E84AB0035953B /* RemoteInspectorXPCConnection.mm in Sources */,
+				A5BA15E9182340B300A82E69 /* RemoteInspector.mm in Sources */,
+				A5BA15EE182340B400A82E69 /* RemoteInspectorXPCConnection.mm in Sources */,
 				0F24E55017EE274900ABB217 /* Repatch.cpp in Sources */,
 				527773DE1AAF83AC00BDE7E8 /* RuntimeType.cpp in Sources */,
 				0F7700921402FF3C0078EB39 /* SamplingCounter.cpp in Sources */,
@@ -10486,7 +10476,6 @@
 				A7299DA117D12848005F5FF9 /* SetPrototype.cpp in Sources */,
 				0FEE98431A89227500754E93 /* SetupVarargsFrame.cpp in Sources */,
 				DC17E8171C9C91D6008A6AB3 /* ShadowChicken.cpp in Sources */,
-				FE3022D21E3D73A500BAC493 /* SigillCrashAnalyzer.cpp in Sources */,
 				0F2B670417B6B5AB00A7AE3F /* SimpleTypedArrayController.cpp in Sources */,
 				C225494315F7DBAA0065E898 /* SlotVisitor.cpp in Sources */,
 				9330402C0E6A764000786E6A /* SmallStrings.cpp in Sources */,
@@ -10561,7 +10550,6 @@
 				0F952AA21DF7860D00E06FBD /* VisitRaceKey.cpp in Sources */,
 				E18E3A590DF9278C00D90B34 /* VM.cpp in Sources */,
 				FE5932A7183C5A2600A1ECCC /* VMEntryScope.cpp in Sources */,
-				FE3022D61E42857300BAC493 /* VMInspector.cpp in Sources */,
 				53F40E8F1D5902820099A1B6 /* WasmB3IRGenerator.cpp in Sources */,
 				AD4B1DF91DF244E20071AE32 /* WasmBinding.cpp in Sources */,
 				53FD04D31D7AB277003287D3 /* WasmCallingConvention.cpp in Sources */,

Modified: trunk/Source/_javascript_Core/PlatformMac.cmake (212393 => 212394)


--- trunk/Source/_javascript_Core/PlatformMac.cmake	2017-02-15 21:50:10 UTC (rev 212393)
+++ trunk/Source/_javascript_Core/PlatformMac.cmake	2017-02-15 22:31:07 UTC (rev 212394)
@@ -10,13 +10,10 @@
     API/ObjCCallbackFunction.mm
 
     inspector/remote/RemoteAutomationTarget.cpp
+    inspector/remote/RemoteConnectionToTarget.mm
     inspector/remote/RemoteControllableTarget.cpp
     inspector/remote/RemoteInspectionTarget.cpp
-    inspector/remote/RemoteInspector.cpp
-
-    inspector/remote/cocoa/RemoteConnectionToTargetCocoa.mm
-    inspector/remote/cocoa/RemoteInspectorCocoa.mm
-    inspector/remote/cocoa/RemoteInspectorXPCConnection.mm
+    inspector/remote/RemoteInspector.mm
 )
 add_definitions(-DSTATICALLY_LINKED_WITH_WTF -D__STDC_WANT_LIB_EXT1__)
 
@@ -28,7 +25,6 @@
 list(APPEND _javascript_Core_INCLUDE_DIRECTORIES
     ${_javascript_CORE_DIR}/disassembler/udis86
     ${_javascript_CORE_DIR}/icu
-    ${_javascript_CORE_DIR}/inspector/remote/cocoa
 )
 
 set(CMAKE_SHARED_LINKER_FLAGS ${CMAKE_SHARED_LINKER_FLAGS} "-compatibility_version 1 -current_version ${WEBKIT_MAC_VERSION}")

Modified: trunk/Source/_javascript_Core/inspector/remote/RemoteConnectionToTarget.h (212393 => 212394)


--- trunk/Source/_javascript_Core/inspector/remote/RemoteConnectionToTarget.h	2017-02-15 21:50:10 UTC (rev 212393)
+++ trunk/Source/_javascript_Core/inspector/remote/RemoteConnectionToTarget.h	2017-02-15 22:31:07 UTC (rev 212394)
@@ -27,40 +27,33 @@
 
 #if ENABLE(REMOTE_INSPECTOR)
 
-#include "InspectorFrontendChannel.h"
-#include <wtf/Lock.h>
-#include <wtf/ThreadSafeRefCounted.h>
+#import "InspectorFrontendChannel.h"
+#import "RemoteConnectionToTarget.h"
+#import "RemoteInspector.h"
+#import <mutex>
+#import <wtf/BlockPtr.h>
+#import <wtf/Lock.h>
+#import <wtf/RetainPtr.h>
+#import <wtf/ThreadSafeRefCounted.h>
 
-#if PLATFORM(COCOA)
-#include <wtf/BlockPtr.h>
-#include <wtf/RetainPtr.h>
-
 OBJC_CLASS NSString;
-#endif
 
 namespace Inspector {
 
-class RemoteControllableTarget;
-
-#if PLATFORM(COCOA)
 typedef Vector<BlockPtr<void ()>> RemoteTargetQueue;
-#endif
 
 class RemoteConnectionToTarget final : public ThreadSafeRefCounted<RemoteConnectionToTarget>, public FrontendChannel {
 public:
-#if PLATFORM(COCOA)
-    RemoteConnectionToTarget(RemoteControllableTarget*, NSString* connectionIdentifier, NSString* destination);
-#endif
+    RemoteConnectionToTarget(RemoteControllableTarget*, NSString *connectionIdentifier, NSString *destination);
     virtual ~RemoteConnectionToTarget();
 
     // Main API.
     bool setup(bool isAutomaticInspection = false, bool automaticallyPause = false);
-    void sendMessageToTarget(const String&);
+    void sendMessageToTarget(NSString *);
     void close();
     void targetClosed();
 
     std::optional<unsigned> targetIdentifier() const;
-#if PLATFORM(COCOA)
     NSString *connectionIdentifier() const;
     NSString *destination() const;
 
@@ -67,7 +60,6 @@
     Lock& queueMutex() { return m_queueMutex; }
     const RemoteTargetQueue& queue() const { return m_queue; }
     void clearQueue() { m_queue.clear(); }
-#endif
 
     // FrontendChannel overrides.
     ConnectionType connectionType() const override { return ConnectionType::Remote; }
@@ -74,13 +66,11 @@
     void sendMessageToFrontend(const String&) override;
 
 private:
-#if PLATFORM(COCOA)
     void dispatchAsyncOnTarget(void (^block)());
 
     void setupRunLoop();
     void teardownRunLoop();
     void queueTaskOnPrivateRunLoop(void (^block)());
-#endif
 
     // This connection from the RemoteInspector singleton to the InspectionTarget
     // can be used on multiple threads. So any access to the target
@@ -87,7 +77,6 @@
     // itself must take this mutex to ensure m_target is valid.
     Lock m_targetMutex;
 
-#if PLATFORM(COCOA)
     // If a target has a specific run loop it wants to evaluate on
     // we setup our run loop sources on that specific run loop.
     RetainPtr<CFRunLoopRef> m_runLoop;
@@ -94,15 +83,11 @@
     RetainPtr<CFRunLoopSourceRef> m_runLoopSource;
     RemoteTargetQueue m_queue;
     Lock m_queueMutex;
-#endif
 
     RemoteControllableTarget* m_target { nullptr };
-    bool m_connected { false };
-
-#if PLATFORM(COCOA)
     RetainPtr<NSString> m_connectionIdentifier;
     RetainPtr<NSString> m_destination;
-#endif
+    bool m_connected { false };
 };
 
 } // namespace Inspector

Copied: trunk/Source/_javascript_Core/inspector/remote/RemoteConnectionToTarget.mm (from rev 212168, trunk/Source/_javascript_Core/inspector/remote/RemoteConnectionToTarget.mm) (0 => 212394)


--- trunk/Source/_javascript_Core/inspector/remote/RemoteConnectionToTarget.mm	                        (rev 0)
+++ trunk/Source/_javascript_Core/inspector/remote/RemoteConnectionToTarget.mm	2017-02-15 22:31:07 UTC (rev 212394)
@@ -0,0 +1,283 @@
+/*
+ * Copyright (C) 2013, 2015 Apple 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 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 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.
+ */
+
+#import "config.h"
+#import "RemoteConnectionToTarget.h"
+
+#if ENABLE(REMOTE_INSPECTOR)
+
+#import "EventLoop.h"
+#import "RemoteAutomationTarget.h"
+#import "RemoteInspectionTarget.h"
+#import <dispatch/dispatch.h>
+#import <wtf/Optional.h>
+
+#if PLATFORM(IOS)
+#import <wtf/ios/WebCoreThread.h>
+#endif
+
+namespace Inspector {
+
+static StaticLock rwiQueueMutex;
+static CFRunLoopSourceRef rwiRunLoopSource;
+static RemoteTargetQueue* rwiQueue;
+
+static void RemoteTargetHandleRunSourceGlobal(void*)
+{
+    ASSERT(CFRunLoopGetCurrent() == CFRunLoopGetMain());
+    ASSERT(rwiRunLoopSource);
+    ASSERT(rwiQueue);
+
+    RemoteTargetQueue queueCopy;
+    {
+        std::lock_guard<StaticLock> lock(rwiQueueMutex);
+        queueCopy = *rwiQueue;
+        rwiQueue->clear();
+    }
+
+    for (const auto& block : queueCopy)
+        block();
+}
+
+static void RemoteTargetQueueTaskOnGlobalQueue(void (^task)())
+{
+    ASSERT(rwiRunLoopSource);
+    ASSERT(rwiQueue);
+
+    {
+        std::lock_guard<StaticLock> lock(rwiQueueMutex);
+        rwiQueue->append(task);
+    }
+
+    CFRunLoopSourceSignal(rwiRunLoopSource);
+    CFRunLoopWakeUp(CFRunLoopGetMain());
+}
+
+static void RemoteTargetInitializeGlobalQueue()
+{
+    static dispatch_once_t pred;
+    dispatch_once(&pred, ^{
+        rwiQueue = new RemoteTargetQueue;
+
+        CFRunLoopSourceContext runLoopSourceContext = {0, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, RemoteTargetHandleRunSourceGlobal};
+        rwiRunLoopSource = CFRunLoopSourceCreate(kCFAllocatorDefault, 1, &runLoopSourceContext);
+
+        // Add to the default run loop mode for default handling, and the JSContext remote inspector run loop mode when paused.
+        CFRunLoopAddSource(CFRunLoopGetMain(), rwiRunLoopSource, kCFRunLoopDefaultMode);
+        CFRunLoopAddSource(CFRunLoopGetMain(), rwiRunLoopSource, EventLoop::remoteInspectorRunLoopMode());
+    });
+}
+
+static void RemoteTargetHandleRunSourceWithInfo(void* info)
+{
+    RemoteConnectionToTarget *connectionToTarget = static_cast<RemoteConnectionToTarget*>(info);
+
+    RemoteTargetQueue queueCopy;
+    {
+        std::lock_guard<Lock> lock(connectionToTarget->queueMutex());
+        queueCopy = connectionToTarget->queue();
+        connectionToTarget->clearQueue();
+    }
+
+    for (const auto& block : queueCopy)
+        block();
+}
+
+
+RemoteConnectionToTarget::RemoteConnectionToTarget(RemoteControllableTarget* target, NSString *connectionIdentifier, NSString *destination)
+    : m_target(target)
+    , m_connectionIdentifier(connectionIdentifier)
+    , m_destination(destination)
+{
+    setupRunLoop();
+}
+
+RemoteConnectionToTarget::~RemoteConnectionToTarget()
+{
+    teardownRunLoop();
+}
+
+std::optional<unsigned> RemoteConnectionToTarget::targetIdentifier() const
+{
+    return m_target ? std::optional<unsigned>(m_target->targetIdentifier()) : std::nullopt;
+}
+
+NSString *RemoteConnectionToTarget::connectionIdentifier() const
+{
+    return [[m_connectionIdentifier copy] autorelease];
+}
+
+NSString *RemoteConnectionToTarget::destination() const
+{
+    return [[m_destination copy] autorelease];
+}
+
+void RemoteConnectionToTarget::dispatchAsyncOnTarget(void (^block)())
+{
+    if (m_runLoop) {
+        queueTaskOnPrivateRunLoop(block);
+        return;
+    }
+
+#if PLATFORM(IOS)
+    if (WebCoreWebThreadIsEnabled && WebCoreWebThreadIsEnabled()) {
+        WebCoreWebThreadRun(block);
+        return;
+    }
+#endif
+
+    RemoteTargetQueueTaskOnGlobalQueue(block);
+}
+
+bool RemoteConnectionToTarget::setup(bool isAutomaticInspection, bool automaticallyPause)
+{
+    std::lock_guard<Lock> lock(m_targetMutex);
+
+    if (!m_target)
+        return false;
+
+    ref();
+    dispatchAsyncOnTarget(^{
+        {
+            std::lock_guard<Lock> lock(m_targetMutex);
+            if (!m_target || !m_target->remoteControlAllowed()) {
+                RemoteInspector::singleton().setupFailed(targetIdentifier().value_or(0));
+                m_target = nullptr;
+            } else if (is<RemoteInspectionTarget>(m_target)) {
+                auto castedTarget = downcast<RemoteInspectionTarget>(m_target);
+                castedTarget->connect(this, isAutomaticInspection);
+                m_connected = true;
+
+                if (automaticallyPause)
+                    castedTarget->pause();
+            } else if (is<RemoteAutomationTarget>(m_target)) {
+                auto castedTarget = downcast<RemoteAutomationTarget>(m_target);
+                castedTarget->connect(this);
+                m_connected = true;
+            }
+        }
+        deref();
+    });
+
+    return true;
+}
+
+void RemoteConnectionToTarget::targetClosed()
+{
+    std::lock_guard<Lock> lock(m_targetMutex);
+
+    m_target = nullptr;
+}
+
+void RemoteConnectionToTarget::close()
+{
+    ref();
+    dispatchAsyncOnTarget(^{
+        {
+            std::lock_guard<Lock> lock(m_targetMutex);
+
+            if (m_target) {
+                if (m_connected)
+                    m_target->disconnect(this);
+
+                m_target = nullptr;
+            }
+        }
+        deref();
+    });
+}
+
+void RemoteConnectionToTarget::sendMessageToTarget(NSString *message)
+{
+    ref();
+    dispatchAsyncOnTarget(^{
+        {
+            RemoteControllableTarget* target = nullptr;
+            {
+                std::lock_guard<Lock> lock(m_targetMutex);
+                if (!m_target)
+                    return;
+                target = m_target;
+            }
+
+            target->dispatchMessageFromRemote(message);
+        }
+        deref();
+    });
+}
+
+void RemoteConnectionToTarget::sendMessageToFrontend(const String& message)
+{
+    if (!targetIdentifier())
+        return;
+
+    RemoteInspector::singleton().sendMessageToRemote(targetIdentifier().value(), message);
+}
+
+void RemoteConnectionToTarget::setupRunLoop()
+{
+    CFRunLoopRef targetRunLoop = m_target->targetRunLoop();
+    if (!targetRunLoop) {
+        RemoteTargetInitializeGlobalQueue();
+        return;
+    }
+
+    m_runLoop = targetRunLoop;
+
+    CFRunLoopSourceContext runLoopSourceContext = {0, this, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, RemoteTargetHandleRunSourceWithInfo};
+    m_runLoopSource = adoptCF(CFRunLoopSourceCreate(kCFAllocatorDefault, 1, &runLoopSourceContext));
+
+    CFRunLoopAddSource(m_runLoop.get(), m_runLoopSource.get(), kCFRunLoopDefaultMode);
+    CFRunLoopAddSource(m_runLoop.get(), m_runLoopSource.get(), EventLoop::remoteInspectorRunLoopMode());
+}
+
+void RemoteConnectionToTarget::teardownRunLoop()
+{
+    if (!m_runLoop)
+        return;
+
+    CFRunLoopRemoveSource(m_runLoop.get(), m_runLoopSource.get(), kCFRunLoopDefaultMode);
+    CFRunLoopRemoveSource(m_runLoop.get(), m_runLoopSource.get(), EventLoop::remoteInspectorRunLoopMode());
+
+    m_runLoop = nullptr;
+    m_runLoopSource = nullptr;
+}
+
+void RemoteConnectionToTarget::queueTaskOnPrivateRunLoop(void (^block)())
+{
+    ASSERT(m_runLoop);
+
+    {
+        std::lock_guard<Lock> lock(m_queueMutex);
+        m_queue.append(block);
+    }
+
+    CFRunLoopSourceSignal(m_runLoopSource.get());
+    CFRunLoopWakeUp(m_runLoop.get());
+}
+
+} // namespace Inspector
+
+#endif // ENABLE(REMOTE_INSPECTOR)

Modified: trunk/Source/_javascript_Core/inspector/remote/RemoteControllableTarget.h (212393 => 212394)


--- trunk/Source/_javascript_Core/inspector/remote/RemoteControllableTarget.h	2017-02-15 21:50:10 UTC (rev 212393)
+++ trunk/Source/_javascript_Core/inspector/remote/RemoteControllableTarget.h	2017-02-15 22:31:07 UTC (rev 212394)
@@ -27,13 +27,10 @@
 
 #if ENABLE(REMOTE_INSPECTOR)
 
+#include <CoreFoundation/CFRunLoop.h>
 #include <wtf/TypeCasts.h>
 #include <wtf/text/WTFString.h>
 
-#if USE(CF)
-#include <CoreFoundation/CFRunLoop.h>
-#endif
-
 namespace Inspector {
 
 class FrontendChannel;
@@ -56,10 +53,8 @@
     virtual bool remoteControlAllowed() const = 0;
     virtual void dispatchMessageFromRemote(const String& message) = 0;
 
-#if USE(CF)
     // The dispatch block will be scheduled on a global run loop if null is returned.
     virtual CFRunLoopRef targetRunLoop() { return nullptr; }
-#endif
 private:
     unsigned m_identifier {0};
 };

Modified: trunk/Source/_javascript_Core/inspector/remote/RemoteInspectionTarget.h (212393 => 212394)


--- trunk/Source/_javascript_Core/inspector/remote/RemoteInspectionTarget.h	2017-02-15 21:50:10 UTC (rev 212393)
+++ trunk/Source/_javascript_Core/inspector/remote/RemoteInspectionTarget.h	2017-02-15 22:31:07 UTC (rev 212394)
@@ -41,10 +41,8 @@
     bool remoteDebuggingAllowed() const { return m_allowed; }
     void setRemoteDebuggingAllowed(bool);
 
-#if USE(CF)
     CFRunLoopRef targetRunLoop() override { return m_runLoop.get(); }
     void setTargetRunLoop(CFRunLoopRef runLoop) { m_runLoop = runLoop; }
-#endif
 
     virtual String name() const { return String(); } // _javascript_ and Web
     virtual String url() const { return String(); } // Web
@@ -61,9 +59,7 @@
     bool remoteControlAllowed() const override;
 private:
     bool m_allowed {false};
-#if USE(CF)
     RetainPtr<CFRunLoopRef> m_runLoop;
-#endif
 };
 
 } // namespace Inspector

Deleted: trunk/Source/_javascript_Core/inspector/remote/RemoteInspector.cpp (212393 => 212394)


--- trunk/Source/_javascript_Core/inspector/remote/RemoteInspector.cpp	2017-02-15 21:50:10 UTC (rev 212393)
+++ trunk/Source/_javascript_Core/inspector/remote/RemoteInspector.cpp	2017-02-15 22:31:07 UTC (rev 212394)
@@ -1,224 +0,0 @@
-/*
- * Copyright (C) 2013-2016 Apple 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 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 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.
- */
-
-#include "config.h"
-#include "RemoteInspector.h"
-
-#if ENABLE(REMOTE_INSPECTOR)
-
-#include "RemoteAutomationTarget.h"
-#include "RemoteConnectionToTarget.h"
-#include "RemoteInspectionTarget.h"
-#include "RemoteInspectorConstants.h"
-#include <wtf/MainThread.h>
-#include <wtf/text/WTFString.h>
-
-namespace Inspector {
-
-bool RemoteInspector::startEnabled = true;
-
-void RemoteInspector::startDisabled()
-{
-    RemoteInspector::startEnabled = false;
-}
-
-unsigned RemoteInspector::nextAvailableTargetIdentifier()
-{
-    unsigned nextValidTargetIdentifier;
-    do {
-        nextValidTargetIdentifier = m_nextAvailableTargetIdentifier++;
-    } while (!nextValidTargetIdentifier || nextValidTargetIdentifier == std::numeric_limits<unsigned>::max() || m_targetMap.contains(nextValidTargetIdentifier));
-    return nextValidTargetIdentifier;
-}
-
-void RemoteInspector::registerTarget(RemoteControllableTarget* target)
-{
-    ASSERT_ARG(target, target);
-
-    std::lock_guard<Lock> lock(m_mutex);
-
-    unsigned targetIdentifier = nextAvailableTargetIdentifier();
-    target->setTargetIdentifier(targetIdentifier);
-
-    {
-        auto result = m_targetMap.set(targetIdentifier, target);
-        ASSERT_UNUSED(result, result.isNewEntry);
-    }
-
-    // If remote control is not allowed, a null listing is returned.
-    if (auto targetListing = listingForTarget(*target)) {
-        auto result = m_targetListingMap.set(targetIdentifier, targetListing);
-        ASSERT_UNUSED(result, result.isNewEntry);
-    }
-
-    pushListingsSoon();
-}
-
-void RemoteInspector::unregisterTarget(RemoteControllableTarget* target)
-{
-    ASSERT_ARG(target, target);
-
-    std::lock_guard<Lock> lock(m_mutex);
-
-    unsigned targetIdentifier = target->targetIdentifier();
-    if (!targetIdentifier)
-        return;
-
-    bool wasRemoved = m_targetMap.remove(targetIdentifier);
-    ASSERT_UNUSED(wasRemoved, wasRemoved);
-
-    // The listing may never have been added if remote control isn't allowed.
-    m_targetListingMap.remove(targetIdentifier);
-
-    if (auto connectionToTarget = m_targetConnectionMap.take(targetIdentifier))
-        connectionToTarget->targetClosed();
-
-    pushListingsSoon();
-}
-
-void RemoteInspector::updateTarget(RemoteControllableTarget* target)
-{
-    ASSERT_ARG(target, target);
-
-    std::lock_guard<Lock> lock(m_mutex);
-
-    unsigned targetIdentifier = target->targetIdentifier();
-    if (!targetIdentifier)
-        return;
-
-    {
-        auto result = m_targetMap.set(targetIdentifier, target);
-        ASSERT_UNUSED(result, !result.isNewEntry);
-    }
-
-    // If the target has just allowed remote control, then the listing won't exist yet.
-    // If the target has no identifier remove the old listing.
-    if (auto targetListing = listingForTarget(*target))
-        m_targetListingMap.set(targetIdentifier, targetListing);
-    else
-        m_targetListingMap.remove(targetIdentifier);
-
-    pushListingsSoon();
-}
-
-void RemoteInspector::updateClientCapabilities()
-{
-    ASSERT(isMainThread());
-
-    std::lock_guard<Lock> lock(m_mutex);
-
-    if (!m_client)
-        m_clientCapabilities = std::nullopt;
-    else {
-        RemoteInspector::Client::Capabilities updatedCapabilities = {
-            m_client->remoteAutomationAllowed() // remoteAutomationAllowed
-        };
-
-        m_clientCapabilities = updatedCapabilities;
-    }
-}
-
-void RemoteInspector::setRemoteInspectorClient(RemoteInspector::Client* client)
-{
-    ASSERT_ARG(client, client);
-    ASSERT(!m_client);
-
-    {
-        std::lock_guard<Lock> lock(m_mutex);
-        m_client = client;
-    }
-
-    // Send an updated listing that includes whether the client allows remote automation.
-    updateClientCapabilities();
-    pushListingsSoon();
-}
-
-void RemoteInspector::setupFailed(unsigned targetIdentifier)
-{
-    std::lock_guard<Lock> lock(m_mutex);
-
-    m_targetConnectionMap.remove(targetIdentifier);
-
-    if (targetIdentifier == m_automaticInspectionCandidateTargetIdentifier)
-        m_automaticInspectionPaused = false;
-
-    updateHasActiveDebugSession();
-    updateTargetListing(targetIdentifier);
-    pushListingsSoon();
-}
-
-void RemoteInspector::setupCompleted(unsigned targetIdentifier)
-{
-    std::lock_guard<Lock> lock(m_mutex);
-
-    if (targetIdentifier == m_automaticInspectionCandidateTargetIdentifier)
-        m_automaticInspectionPaused = false;
-}
-
-bool RemoteInspector::waitingForAutomaticInspection(unsigned)
-{
-    // We don't take the lock to check this because we assume it will be checked repeatedly.
-    return m_automaticInspectionPaused;
-}
-
-void RemoteInspector::clientCapabilitiesDidChange()
-{
-    updateClientCapabilities();
-    pushListingsSoon();
-}
-
-void RemoteInspector::stop()
-{
-    std::lock_guard<Lock> lock(m_mutex);
-
-    stopInternal(StopSource::API);
-}
-
-TargetListing RemoteInspector::listingForTarget(const RemoteControllableTarget& target) const
-{
-    if (is<RemoteInspectionTarget>(target))
-        return listingForInspectionTarget(downcast<RemoteInspectionTarget>(target));
-    if (is<RemoteAutomationTarget>(target))
-        return listingForAutomationTarget(downcast<RemoteAutomationTarget>(target));
-
-    ASSERT_NOT_REACHED();
-    return nullptr;
-}
-
-void RemoteInspector::updateHasActiveDebugSession()
-{
-    bool hasActiveDebuggerSession = !m_targetConnectionMap.isEmpty();
-    if (hasActiveDebuggerSession == m_hasActiveDebugSession)
-        return;
-
-    m_hasActiveDebugSession = hasActiveDebuggerSession;
-
-    // FIXME: Expose some way to access this state in an embedder.
-    // Legacy iOS WebKit 1 had a notification. This will need to be smarter with WebKit2.
-}
-
-} // namespace Inspector
-
-#endif // ENABLE(REMOTE_INSPECTOR)

Modified: trunk/Source/_javascript_Core/inspector/remote/RemoteInspector.h (212393 => 212394)


--- trunk/Source/_javascript_Core/inspector/remote/RemoteInspector.h	2017-02-15 21:50:10 UTC (rev 212393)
+++ trunk/Source/_javascript_Core/inspector/remote/RemoteInspector.h	2017-02-15 22:31:07 UTC (rev 212394)
@@ -27,18 +27,14 @@
 
 #if ENABLE(REMOTE_INSPECTOR)
 
-#include <wtf/Forward.h>
-#include <wtf/HashMap.h>
-#include <wtf/Lock.h>
+#import "RemoteInspectorXPCConnection.h"
+#import <wtf/Forward.h>
+#import <wtf/HashMap.h>
+#import <wtf/Lock.h>
+#import <wtf/RetainPtr.h>
 
-#if PLATFORM(COCOA)
-#include "RemoteInspectorXPCConnection.h"
-#include <wtf/RetainPtr.h>
-
 OBJC_CLASS NSDictionary;
 OBJC_CLASS NSString;
-typedef RetainPtr<NSDictionary> TargetListing;
-#endif
 
 namespace Inspector {
 
@@ -48,11 +44,7 @@
 class RemoteInspectionTarget;
 class RemoteInspectorClient;
 
-class JS_EXPORT_PRIVATE RemoteInspector final
-#if PLATFORM(COCOA)
-    : public RemoteInspectorXPCConnection::Client
-#endif
-{
+class JS_EXPORT_PRIVATE RemoteInspector final : public RemoteInspectorXPCConnection::Client {
 public:
     class Client {
     public:
@@ -88,13 +80,11 @@
     void start();
     void stop();
 
-#if PLATFORM(COCOA)
     bool hasParentProcessInformation() const { return m_parentProcessIdentifier != 0; }
     pid_t parentProcessIdentifier() const { return m_parentProcessIdentifier; }
     RetainPtr<CFDataRef> parentProcessAuditData() const { return m_parentProcessAuditData; }
     void setParentProcessInformation(pid_t, RetainPtr<CFDataRef> auditData);
     void setParentProcessInfomationIsDelayed();
-#endif
 
 private:
     RemoteInspector();
@@ -104,14 +94,11 @@
     enum class StopSource { API, XPCMessage };
     void stopInternal(StopSource);
 
-#if PLATFORM(COCOA)
     void setupXPCConnectionIfNeeded();
-#endif
 
-    TargetListing listingForTarget(const RemoteControllableTarget&) const;
-    TargetListing listingForInspectionTarget(const RemoteInspectionTarget&) const;
-    TargetListing listingForAutomationTarget(const RemoteAutomationTarget&) const;
-
+    RetainPtr<NSDictionary> listingForTarget(const RemoteControllableTarget&) const;
+    RetainPtr<NSDictionary> listingForInspectionTarget(const RemoteInspectionTarget&) const;
+    RetainPtr<NSDictionary> listingForAutomationTarget(const RemoteAutomationTarget&) const;
     void pushListingsNow();
     void pushListingsSoon();
 
@@ -123,7 +110,6 @@
 
     void sendAutomaticInspectionCandidateMessage();
 
-#if PLATFORM(COCOA)
     void xpcConnectionReceivedMessage(RemoteInspectorXPCConnection*, NSString *messageName, NSDictionary *userInfo) override;
     void xpcConnectionFailed(RemoteInspectorXPCConnection*) override;
     void xpcConnectionUnhandledMessage(RemoteInspectorXPCConnection*, xpc_object_t) override;
@@ -138,7 +124,6 @@
     void receivedAutomaticInspectionConfigurationMessage(NSDictionary *userInfo);
     void receivedAutomaticInspectionRejectMessage(NSDictionary *userInfo);
     void receivedAutomationSessionRequestMessage(NSDictionary *userInfo);
-#endif
 
     static bool startEnabled;
 
@@ -149,19 +134,15 @@
     Lock m_mutex;
 
     HashMap<unsigned, RemoteControllableTarget*> m_targetMap;
+    HashMap<unsigned, RetainPtr<NSDictionary>> m_targetListingMap;
     HashMap<unsigned, RefPtr<RemoteConnectionToTarget>> m_targetConnectionMap;
-    HashMap<unsigned, TargetListing> m_targetListingMap;
 
-#if PLATFORM(COCOA)
     RefPtr<RemoteInspectorXPCConnection> m_relayConnection;
-#endif
 
     RemoteInspector::Client* m_client { nullptr };
     std::optional<RemoteInspector::Client::Capabilities> m_clientCapabilities;
 
-#if PLATFORM(COCOA)
     dispatch_queue_t m_xpcQueue;
-#endif
     unsigned m_nextAvailableTargetIdentifier { 1 };
     int m_notifyToken { 0 };
     bool m_enabled { false };
@@ -169,9 +150,7 @@
     bool m_pushScheduled { false };
 
     pid_t m_parentProcessIdentifier { 0 };
-#if PLATFORM(COCOA)
     RetainPtr<CFDataRef> m_parentProcessAuditData;
-#endif
     bool m_shouldSendParentProcessInformation { false };
     bool m_automaticInspectionEnabled { false };
     bool m_automaticInspectionPaused { false };

Copied: trunk/Source/_javascript_Core/inspector/remote/RemoteInspector.mm (from rev 212168, trunk/Source/_javascript_Core/inspector/remote/RemoteInspector.mm) (0 => 212394)


--- trunk/Source/_javascript_Core/inspector/remote/RemoteInspector.mm	                        (rev 0)
+++ trunk/Source/_javascript_Core/inspector/remote/RemoteInspector.mm	2017-02-15 22:31:07 UTC (rev 212394)
@@ -0,0 +1,857 @@
+/*
+ * Copyright (C) 2013-2016 Apple 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 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 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.
+ */
+
+#import "config.h"
+#import "RemoteInspector.h"
+
+#if ENABLE(REMOTE_INSPECTOR)
+
+#import "InitializeThreading.h"
+#import "RemoteAutomationTarget.h"
+#import "RemoteConnectionToTarget.h"
+#import "RemoteInspectionTarget.h"
+#import "RemoteInspectorConstants.h"
+#import <Foundation/Foundation.h>
+#import <dispatch/dispatch.h>
+#import <notify.h>
+#import <wtf/Assertions.h>
+#import <wtf/MainThread.h>
+#import <wtf/NeverDestroyed.h>
+#import <wtf/spi/darwin/SandboxSPI.h>
+#import <wtf/spi/darwin/XPCSPI.h>
+#import <wtf/text/WTFString.h>
+
+namespace Inspector {
+
+static bool canAccessWebInspectorMachPort()
+{
+    return sandbox_check(getpid(), "mach-lookup", static_cast<enum sandbox_filter_type>(SANDBOX_FILTER_GLOBAL_NAME | SANDBOX_CHECK_NO_REPORT), WIRXPCMachPortName) == 0;
+}
+
+static bool globalAutomaticInspectionState()
+{
+    int token = 0;
+    if (notify_register_check(WIRAutomaticInspectionEnabledState, &token) != NOTIFY_STATUS_OK)
+        return false;
+
+    uint64_t automaticInspectionEnabled = 0;
+    notify_get_state(token, &automaticInspectionEnabled);
+    return automaticInspectionEnabled == 1;
+}
+
+bool RemoteInspector::startEnabled = true;
+
+void RemoteInspector::startDisabled()
+{
+    RemoteInspector::startEnabled = false;
+}
+
+RemoteInspector& RemoteInspector::singleton()
+{
+    static NeverDestroyed<RemoteInspector> shared;
+
+    static dispatch_once_t once;
+    dispatch_once(&once, ^{
+        if (canAccessWebInspectorMachPort()) {
+            dispatch_block_t initialize = ^{
+                WTF::initializeMainThread();
+                JSC::initializeThreading();
+                if (RemoteInspector::startEnabled)
+                    shared.get().start();
+            };
+
+            if ([NSThread isMainThread])
+                initialize();
+            else {
+                // FIXME: This means that we may miss an auto-attach to a JSContext created on a non-main thread.
+                // The main thread initialization is required for certain WTF values that need to be initialized
+                // on the "real" main thread. We should investigate a better way to handle this.
+                dispatch_async(dispatch_get_main_queue(), initialize);
+            }
+        }
+    });
+
+    return shared;
+}
+
+RemoteInspector::RemoteInspector()
+    : m_xpcQueue(dispatch_queue_create("com.apple._javascript_Core.remote-inspector-xpc", DISPATCH_QUEUE_SERIAL))
+{
+}
+
+unsigned RemoteInspector::nextAvailableTargetIdentifier()
+{
+    unsigned nextValidTargetIdentifier;
+    do {
+        nextValidTargetIdentifier = m_nextAvailableTargetIdentifier++;
+    } while (!nextValidTargetIdentifier || nextValidTargetIdentifier == std::numeric_limits<unsigned>::max() || m_targetMap.contains(nextValidTargetIdentifier));
+    return nextValidTargetIdentifier;
+}
+
+void RemoteInspector::registerTarget(RemoteControllableTarget* target)
+{
+    ASSERT_ARG(target, target);
+
+    std::lock_guard<Lock> lock(m_mutex);
+
+    unsigned targetIdentifier = nextAvailableTargetIdentifier();
+    target->setTargetIdentifier(targetIdentifier);
+
+    {
+        auto result = m_targetMap.set(targetIdentifier, target);
+        ASSERT_UNUSED(result, result.isNewEntry);
+    }
+
+    // If remote control is not allowed, a null listing is returned.
+    if (RetainPtr<NSDictionary> targetListing = listingForTarget(*target)) {
+        auto result = m_targetListingMap.set(targetIdentifier, targetListing);
+        ASSERT_UNUSED(result, result.isNewEntry);
+    }
+
+    pushListingsSoon();
+}
+
+void RemoteInspector::unregisterTarget(RemoteControllableTarget* target)
+{
+    ASSERT_ARG(target, target);
+
+    std::lock_guard<Lock> lock(m_mutex);
+
+    unsigned targetIdentifier = target->targetIdentifier();
+    if (!targetIdentifier)
+        return;
+
+    bool wasRemoved = m_targetMap.remove(targetIdentifier);
+    ASSERT_UNUSED(wasRemoved, wasRemoved);
+
+    // The listing may never have been added if remote control isn't allowed.
+    m_targetListingMap.remove(targetIdentifier);
+
+    if (auto connectionToTarget = m_targetConnectionMap.take(targetIdentifier))
+        connectionToTarget->targetClosed();
+
+    pushListingsSoon();
+}
+
+void RemoteInspector::updateTarget(RemoteControllableTarget* target)
+{
+    ASSERT_ARG(target, target);
+
+    std::lock_guard<Lock> lock(m_mutex);
+
+    unsigned targetIdentifier = target->targetIdentifier();
+    if (!targetIdentifier)
+        return;
+
+    {
+        auto result = m_targetMap.set(targetIdentifier, target);
+        ASSERT_UNUSED(result, !result.isNewEntry);
+    }
+
+    // If the target has just allowed remote control, then the listing won't exist yet.
+    // If the target has no identifier remove the old listing.
+    if (RetainPtr<NSDictionary> targetListing = listingForTarget(*target))
+        m_targetListingMap.set(targetIdentifier, targetListing);
+    else
+        m_targetListingMap.remove(targetIdentifier);
+
+    pushListingsSoon();
+}
+
+void RemoteInspector::updateAutomaticInspectionCandidate(RemoteInspectionTarget* target)
+{
+    ASSERT_ARG(target, target);
+    {
+        std::lock_guard<Lock> lock(m_mutex);
+
+        unsigned targetIdentifier = target->targetIdentifier();
+        if (!targetIdentifier)
+            return;
+
+        auto result = m_targetMap.set(targetIdentifier, target);
+        ASSERT_UNUSED(result, !result.isNewEntry);
+
+        // If the target has just allowed remote control, then the listing won't exist yet.
+        // If the target has no identifier remove the old listing.
+        if (RetainPtr<NSDictionary> targetListing = listingForTarget(*target))
+            m_targetListingMap.set(targetIdentifier, targetListing);
+        else
+            m_targetListingMap.remove(targetIdentifier);
+
+        // Don't allow automatic inspection unless it is allowed or we are stopped.
+        if (!m_automaticInspectionEnabled || !m_enabled) {
+            pushListingsSoon();
+            return;
+        }
+
+        // FIXME: We should handle multiple debuggables trying to pause at the same time on different threads.
+        // To make this work we will need to change m_automaticInspectionCandidateTargetIdentifier to be a per-thread value.
+        // Multiple attempts on the same thread should not be possible because our nested run loop is in a special RWI mode.
+        if (m_automaticInspectionPaused) {
+            LOG_ERROR("Skipping Automatic Inspection Candidate with pageId(%u) because we are already paused waiting for pageId(%u)", targetIdentifier, m_automaticInspectionCandidateTargetIdentifier);
+            pushListingsSoon();
+            return;
+        }
+
+        m_automaticInspectionPaused = true;
+        m_automaticInspectionCandidateTargetIdentifier = targetIdentifier;
+
+        // If we are pausing before we have connected to webinspectord the candidate message will be sent as soon as the connection is established.
+        if (m_relayConnection) {
+            pushListingsNow();
+            sendAutomaticInspectionCandidateMessage();
+        }
+
+        // In case debuggers fail to respond, or we cannot connect to webinspectord, automatically continue after a short period of time.
+#if PLATFORM(WATCHOS)
+        int64_t debuggerTimeoutDelay = 5;
+#else
+        int64_t debuggerTimeoutDelay = 1;
+#endif
+        dispatch_after(dispatch_time(DISPATCH_TIME_NOW, debuggerTimeoutDelay * NSEC_PER_SEC), dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+            std::lock_guard<Lock> lock(m_mutex);
+            if (m_automaticInspectionCandidateTargetIdentifier == targetIdentifier) {
+                LOG_ERROR("Skipping Automatic Inspection Candidate with pageId(%u) because we failed to receive a response in time.", m_automaticInspectionCandidateTargetIdentifier);
+                m_automaticInspectionPaused = false;
+            }
+        });
+    }
+
+    target->pauseWaitingForAutomaticInspection();
+
+    {
+        std::lock_guard<Lock> lock(m_mutex);
+
+        ASSERT(m_automaticInspectionCandidateTargetIdentifier);
+        m_automaticInspectionCandidateTargetIdentifier = 0;
+    }
+}
+
+void RemoteInspector::updateClientCapabilities()
+{
+    ASSERT(isMainThread());
+
+    std::lock_guard<Lock> lock(m_mutex);
+
+    if (!m_client)
+        m_clientCapabilities = std::nullopt;
+    else {
+        RemoteInspector::Client::Capabilities updatedCapabilities = {
+            m_client->remoteAutomationAllowed() // remoteAutomationAllowed
+        };
+
+        m_clientCapabilities = updatedCapabilities;
+    }
+}
+
+void RemoteInspector::setRemoteInspectorClient(RemoteInspector::Client* client)
+{
+    ASSERT_ARG(client, client);
+    ASSERT(!m_client);
+
+    {
+        std::lock_guard<Lock> lock(m_mutex);
+        m_client = client;
+    }
+
+    // Send an updated listing that includes whether the client allows remote automation.
+    updateClientCapabilities();
+    pushListingsSoon();
+}
+
+void RemoteInspector::sendAutomaticInspectionCandidateMessage()
+{
+    ASSERT(m_enabled);
+    ASSERT(m_automaticInspectionEnabled);
+    ASSERT(m_automaticInspectionPaused);
+    ASSERT(m_automaticInspectionCandidateTargetIdentifier);
+    ASSERT(m_relayConnection);
+
+    NSDictionary *details = @{WIRTargetIdentifierKey: @(m_automaticInspectionCandidateTargetIdentifier)};
+    m_relayConnection->sendMessage(WIRAutomaticInspectionCandidateMessage, details);
+}
+
+void RemoteInspector::sendMessageToRemote(unsigned targetIdentifier, const String& message)
+{
+    std::lock_guard<Lock> lock(m_mutex);
+
+    if (!m_relayConnection)
+        return;
+
+    auto targetConnection = m_targetConnectionMap.get(targetIdentifier);
+    if (!targetConnection)
+        return;
+
+    NSDictionary *userInfo = @{
+        WIRRawDataKey: [static_cast<NSString *>(message) dataUsingEncoding:NSUTF8StringEncoding],
+        WIRConnectionIdentifierKey: targetConnection->connectionIdentifier(),
+        WIRDestinationKey: targetConnection->destination()
+    };
+
+    m_relayConnection->sendMessage(WIRRawDataMessage, userInfo);
+}
+
+void RemoteInspector::setupFailed(unsigned targetIdentifier)
+{
+    std::lock_guard<Lock> lock(m_mutex);
+
+    m_targetConnectionMap.remove(targetIdentifier);
+
+    if (targetIdentifier == m_automaticInspectionCandidateTargetIdentifier)
+        m_automaticInspectionPaused = false;
+
+    updateHasActiveDebugSession();
+    updateTargetListing(targetIdentifier);
+    pushListingsSoon();
+}
+
+void RemoteInspector::setupCompleted(unsigned targetIdentifier)
+{
+    std::lock_guard<Lock> lock(m_mutex);
+
+    if (targetIdentifier == m_automaticInspectionCandidateTargetIdentifier)
+        m_automaticInspectionPaused = false;
+}
+
+bool RemoteInspector::waitingForAutomaticInspection(unsigned)
+{
+    // We don't take the lock to check this because we assume it will be checked repeatedly.
+    return m_automaticInspectionPaused;
+}
+
+void RemoteInspector::clientCapabilitiesDidChange()
+{
+    updateClientCapabilities();
+    pushListingsSoon();
+}
+
+void RemoteInspector::start()
+{
+    std::lock_guard<Lock> lock(m_mutex);
+
+    if (m_enabled)
+        return;
+
+    m_enabled = true;
+
+    // Load the initial automatic inspection state when first started, so we know it before we have even connected to webinspectord.
+    static dispatch_once_t once;
+    dispatch_once(&once, ^{
+        m_automaticInspectionEnabled = globalAutomaticInspectionState();
+    });
+
+    notify_register_dispatch(WIRServiceAvailableNotification, &m_notifyToken, m_xpcQueue, ^(int) {
+        RemoteInspector::singleton().setupXPCConnectionIfNeeded();
+    });
+
+    notify_post(WIRServiceAvailabilityCheckNotification);
+}
+
+void RemoteInspector::stop()
+{
+    std::lock_guard<Lock> lock(m_mutex);
+
+    stopInternal(StopSource::API);
+}
+
+void RemoteInspector::stopInternal(StopSource source)
+{
+    if (!m_enabled)
+        return;
+
+    m_enabled = false;
+
+    m_pushScheduled = false;
+
+    for (auto targetConnection : m_targetConnectionMap.values())
+        targetConnection->close();
+    m_targetConnectionMap.clear();
+
+    updateHasActiveDebugSession();
+
+    m_automaticInspectionPaused = false;
+
+    if (m_relayConnection) {
+        switch (source) {
+        case StopSource::API:
+            m_relayConnection->close();
+            break;
+        case StopSource::XPCMessage:
+            m_relayConnection->closeFromMessage();
+            break;
+        }
+
+        m_relayConnection = nullptr;
+    }
+
+    notify_cancel(m_notifyToken);
+}
+
+void RemoteInspector::setupXPCConnectionIfNeeded()
+{
+    std::lock_guard<Lock> lock(m_mutex);
+
+    if (m_relayConnection)
+        return;
+
+    xpc_connection_t connection = xpc_connection_create_mach_service(WIRXPCMachPortName, m_xpcQueue, 0);
+    if (!connection)
+        return;
+
+    m_relayConnection = adoptRef(new RemoteInspectorXPCConnection(connection, m_xpcQueue, this));
+    m_relayConnection->sendMessage(@"syn", nil); // Send a simple message to initialize the XPC connection.
+    xpc_release(connection);
+
+    if (m_automaticInspectionCandidateTargetIdentifier) {
+        // We already have a debuggable waiting to be automatically inspected.
+        pushListingsNow();
+        sendAutomaticInspectionCandidateMessage();
+    } else
+        pushListingsSoon();
+}
+
+#pragma mark - Proxy Application Information
+
+void RemoteInspector::setParentProcessInformation(pid_t pid, RetainPtr<CFDataRef> auditData)
+{
+    std::lock_guard<Lock> lock(m_mutex);
+
+    if (m_parentProcessIdentifier || m_parentProcessAuditData)
+        return;
+
+    m_parentProcessIdentifier = pid;
+    m_parentProcessAuditData = auditData;
+
+    if (m_shouldSendParentProcessInformation)
+        receivedProxyApplicationSetupMessage(nil);
+}
+
+#pragma mark - RemoteInspectorXPCConnection::Client
+
+void RemoteInspector::xpcConnectionReceivedMessage(RemoteInspectorXPCConnection*, NSString *messageName, NSDictionary *userInfo)
+{
+    std::lock_guard<Lock> lock(m_mutex);
+
+    if ([messageName isEqualToString:WIRPermissionDenied]) {
+        stopInternal(StopSource::XPCMessage);
+        return;
+    }
+
+    if ([messageName isEqualToString:WIRSocketDataMessage])
+        receivedDataMessage(userInfo);
+    else if ([messageName isEqualToString:WIRSocketSetupMessage])
+        receivedSetupMessage(userInfo);
+    else if ([messageName isEqualToString:WIRWebPageCloseMessage])
+        receivedDidCloseMessage(userInfo);
+    else if ([messageName isEqualToString:WIRApplicationGetListingMessage])
+        receivedGetListingMessage(userInfo);
+    else if ([messageName isEqualToString:WIRIndicateMessage])
+        receivedIndicateMessage(userInfo);
+    else if ([messageName isEqualToString:WIRProxyApplicationSetupMessage])
+        receivedProxyApplicationSetupMessage(userInfo);
+    else if ([messageName isEqualToString:WIRConnectionDiedMessage])
+        receivedConnectionDiedMessage(userInfo);
+    else if ([messageName isEqualToString:WIRAutomaticInspectionConfigurationMessage])
+        receivedAutomaticInspectionConfigurationMessage(userInfo);
+    else if ([messageName isEqualToString:WIRAutomaticInspectionRejectMessage])
+        receivedAutomaticInspectionRejectMessage(userInfo);
+    else if ([messageName isEqualToString:WIRAutomationSessionRequestMessage])
+        receivedAutomationSessionRequestMessage(userInfo);
+    else
+        NSLog(@"Unrecognized RemoteInspector XPC Message: %@", messageName);
+}
+
+void RemoteInspector::xpcConnectionFailed(RemoteInspectorXPCConnection* relayConnection)
+{
+    std::lock_guard<Lock> lock(m_mutex);
+
+    ASSERT(relayConnection == m_relayConnection);
+    if (relayConnection != m_relayConnection)
+        return;
+
+    m_pushScheduled = false;
+
+    for (auto targetConnection : m_targetConnectionMap.values())
+        targetConnection->close();
+    m_targetConnectionMap.clear();
+
+    updateHasActiveDebugSession();
+
+    m_automaticInspectionPaused = false;
+
+    // The XPC connection will close itself.
+    m_relayConnection = nullptr;
+}
+
+void RemoteInspector::xpcConnectionUnhandledMessage(RemoteInspectorXPCConnection*, xpc_object_t)
+{
+    // Intentionally ignored.
+}
+
+#pragma mark - Listings
+
+RetainPtr<NSDictionary> RemoteInspector::listingForTarget(const RemoteControllableTarget& target) const
+{
+    if (is<RemoteInspectionTarget>(target))
+        return listingForInspectionTarget(downcast<RemoteInspectionTarget>(target));
+    if (is<RemoteAutomationTarget>(target))
+        return listingForAutomationTarget(downcast<RemoteAutomationTarget>(target));
+
+    ASSERT_NOT_REACHED();
+    return nil;
+}
+
+RetainPtr<NSDictionary> RemoteInspector::listingForInspectionTarget(const RemoteInspectionTarget& target) const
+{
+    // Must collect target information on the WebThread, Main, or Worker thread since RemoteTargets are
+    // implemented by non-threadsafe JSC / WebCore classes such as JSGlobalObject or WebCore::Page.
+
+    if (!target.remoteDebuggingAllowed())
+        return nil;
+
+    RetainPtr<NSMutableDictionary> listing = adoptNS([[NSMutableDictionary alloc] init]);
+    [listing setObject:@(target.targetIdentifier()) forKey:WIRTargetIdentifierKey];
+
+    switch (target.type()) {
+    case RemoteInspectionTarget::Type::_javascript_:
+        [listing setObject:target.name() forKey:WIRTitleKey];
+        [listing setObject:WIRTypeJavaScript forKey:WIRTypeKey];
+        break;
+    case RemoteInspectionTarget::Type::Web:
+        [listing setObject:target.url() forKey:WIRURLKey];
+        [listing setObject:target.name() forKey:WIRTitleKey];
+        [listing setObject:WIRTypeWeb forKey:WIRTypeKey];
+        break;
+    default:
+        ASSERT_NOT_REACHED();
+        break;
+    }
+
+    if (auto* connectionToTarget = m_targetConnectionMap.get(target.targetIdentifier()))
+        [listing setObject:connectionToTarget->connectionIdentifier() forKey:WIRConnectionIdentifierKey];
+
+    if (target.hasLocalDebugger())
+        [listing setObject:@YES forKey:WIRHasLocalDebuggerKey];
+
+    return listing;
+}
+
+RetainPtr<NSDictionary> RemoteInspector::listingForAutomationTarget(const RemoteAutomationTarget& target) const
+{
+    // Must collect target information on the WebThread or Main thread since RemoteTargets are
+    // implemented by non-threadsafe JSC / WebCore classes such as JSGlobalObject or WebCore::Page.
+    ASSERT(isMainThread());
+
+    RetainPtr<NSMutableDictionary> listing = adoptNS([[NSMutableDictionary alloc] init]);
+    [listing setObject:@(target.targetIdentifier()) forKey:WIRTargetIdentifierKey];
+    [listing setObject:target.name() forKey:WIRSessionIdentifierKey];
+    [listing setObject:WIRTypeAutomation forKey:WIRTypeKey];
+    [listing setObject:@(target.isPaired()) forKey:WIRAutomationTargetIsPairedKey];
+
+    if (auto connectionToTarget = m_targetConnectionMap.get(target.targetIdentifier()))
+        [listing setObject:connectionToTarget->connectionIdentifier() forKey:WIRConnectionIdentifierKey];
+
+    return listing;
+}
+
+void RemoteInspector::pushListingsNow()
+{
+    ASSERT(m_relayConnection);
+    if (!m_relayConnection)
+        return;
+
+    m_pushScheduled = false;
+
+    RetainPtr<NSMutableDictionary> listings = adoptNS([[NSMutableDictionary alloc] init]);
+    for (RetainPtr<NSDictionary> listing : m_targetListingMap.values()) {
+        NSString *targetIdentifierString = [[listing.get() objectForKey:WIRTargetIdentifierKey] stringValue];
+        [listings setObject:listing.get() forKey:targetIdentifierString];
+    }
+
+    RetainPtr<NSMutableDictionary> message = adoptNS([[NSMutableDictionary alloc] init]);
+    [message setObject:listings.get() forKey:WIRListingKey];
+
+    BOOL isAllowed = m_clientCapabilities && m_clientCapabilities->remoteAutomationAllowed;
+    [message setObject:@(isAllowed) forKey:WIRRemoteAutomationEnabledKey];
+
+    m_relayConnection->sendMessage(WIRListingMessage, message.get());
+}
+
+void RemoteInspector::pushListingsSoon()
+{
+    if (!m_relayConnection)
+        return;
+
+    if (m_pushScheduled)
+        return;
+
+    m_pushScheduled = true;
+    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.2 * NSEC_PER_SEC), dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+        std::lock_guard<Lock> lock(m_mutex);
+        if (m_pushScheduled)
+            pushListingsNow();
+    });
+}
+
+#pragma mark - Update Listing with lock
+
+void RemoteInspector::updateTargetListing(unsigned targetIdentifier)
+{
+    auto target = m_targetMap.get(targetIdentifier);
+    if (!target)
+        return;
+
+    updateTargetListing(*target);
+}
+
+void RemoteInspector::updateTargetListing(const RemoteControllableTarget& target)
+{
+    RetainPtr<NSDictionary> targetListing = listingForTarget(target);
+    if (!targetListing)
+        return;
+
+    m_targetListingMap.set(target.targetIdentifier(), targetListing);
+}
+
+#pragma mark - Active Debugger Sessions
+
+void RemoteInspector::updateHasActiveDebugSession()
+{
+    bool hasActiveDebuggerSession = !m_targetConnectionMap.isEmpty();
+    if (hasActiveDebuggerSession == m_hasActiveDebugSession)
+        return;
+
+    m_hasActiveDebugSession = hasActiveDebuggerSession;
+
+    // FIXME: Expose some way to access this state in an embedder.
+    // Legacy iOS WebKit 1 had a notification. This will need to be smarter with WebKit2.
+}
+
+#pragma mark - Received XPC Messages
+
+void RemoteInspector::receivedSetupMessage(NSDictionary *userInfo)
+{
+    unsigned targetIdentifier = [[userInfo objectForKey:WIRTargetIdentifierKey] unsignedIntegerValue];
+    if (!targetIdentifier)
+        return;
+
+    NSString *connectionIdentifier = [userInfo objectForKey:WIRConnectionIdentifierKey];
+    if (!connectionIdentifier)
+        return;
+
+    NSString *sender = [userInfo objectForKey:WIRSenderKey];
+    if (!sender)
+        return;
+
+    if (m_targetConnectionMap.contains(targetIdentifier))
+        return;
+
+    auto findResult = m_targetMap.find(targetIdentifier);
+    if (findResult == m_targetMap.end())
+        return;
+
+    // Attempt to create a connection. This may fail if the page already has an inspector or if it disallows inspection.
+    RemoteControllableTarget* target = findResult->value;
+    auto connectionToTarget = adoptRef(*new RemoteConnectionToTarget(target, connectionIdentifier, sender));
+
+    if (is<RemoteInspectionTarget>(target)) {
+        bool isAutomaticInspection = m_automaticInspectionCandidateTargetIdentifier == target->targetIdentifier();
+        bool automaticallyPause = [[userInfo objectForKey:WIRAutomaticallyPause] boolValue];
+
+        if (!connectionToTarget->setup(isAutomaticInspection, automaticallyPause)) {
+            connectionToTarget->close();
+            return;
+        }
+        m_targetConnectionMap.set(targetIdentifier, WTFMove(connectionToTarget));
+    } else if (is<RemoteAutomationTarget>(target)) {
+        if (!connectionToTarget->setup()) {
+            connectionToTarget->close();
+            return;
+        }
+        m_targetConnectionMap.set(targetIdentifier, WTFMove(connectionToTarget));
+    } else
+        ASSERT_NOT_REACHED();
+
+    updateHasActiveDebugSession();
+    updateTargetListing(*target);
+    pushListingsSoon();
+}
+
+void RemoteInspector::receivedDataMessage(NSDictionary *userInfo)
+{
+    unsigned targetIdentifier = [[userInfo objectForKey:WIRTargetIdentifierKey] unsignedIntegerValue];
+    if (!targetIdentifier)
+        return;
+
+    auto connectionToTarget = m_targetConnectionMap.get(targetIdentifier);
+    if (!connectionToTarget)
+        return;
+
+    NSData *data = "" objectForKey:WIRSocketDataKey];
+    RetainPtr<NSString> message = adoptNS([[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]);
+    connectionToTarget->sendMessageToTarget(message.get());
+}
+
+void RemoteInspector::receivedDidCloseMessage(NSDictionary *userInfo)
+{
+    unsigned targetIdentifier = [[userInfo objectForKey:WIRTargetIdentifierKey] unsignedIntegerValue];
+    if (!targetIdentifier)
+        return;
+
+    NSString *connectionIdentifier = [userInfo objectForKey:WIRConnectionIdentifierKey];
+    if (!connectionIdentifier)
+        return;
+
+    auto connectionToTarget = m_targetConnectionMap.get(targetIdentifier);
+    if (!connectionToTarget)
+        return;
+
+    if (![connectionIdentifier isEqualToString:connectionToTarget->connectionIdentifier()])
+        return;
+
+    connectionToTarget->close();
+    m_targetConnectionMap.remove(targetIdentifier);
+
+    updateHasActiveDebugSession();
+    updateTargetListing(targetIdentifier);
+    pushListingsSoon();
+}
+
+void RemoteInspector::receivedGetListingMessage(NSDictionary *)
+{
+    pushListingsNow();
+}
+
+void RemoteInspector::receivedIndicateMessage(NSDictionary *userInfo)
+{
+    unsigned identifier = [[userInfo objectForKey:WIRTargetIdentifierKey] unsignedIntegerValue];
+    if (!identifier)
+        return;
+
+    BOOL indicateEnabled = [[userInfo objectForKey:WIRIndicateEnabledKey] boolValue];
+
+    callOnWebThreadOrDispatchAsyncOnMainThread(^{
+        RemoteControllableTarget* target = nullptr;
+        {
+            std::lock_guard<Lock> lock(m_mutex);
+
+            auto findResult = m_targetMap.find(identifier);
+            if (findResult == m_targetMap.end())
+                return;
+
+            target = findResult->value;
+        }
+        if (is<RemoteInspectionTarget>(target))
+            downcast<RemoteInspectionTarget>(target)->setIndicating(indicateEnabled);
+    });
+}
+
+void RemoteInspector::receivedProxyApplicationSetupMessage(NSDictionary *)
+{
+    ASSERT(m_relayConnection);
+    if (!m_relayConnection)
+        return;
+
+    if (!m_parentProcessIdentifier || !m_parentProcessAuditData) {
+        // We are a proxy application without parent process information.
+        // Wait a bit for the information, but give up after a second.
+        m_shouldSendParentProcessInformation = true;
+        dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 1 * NSEC_PER_SEC), dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+            std::lock_guard<Lock> lock(m_mutex);
+            if (m_shouldSendParentProcessInformation)
+                stopInternal(StopSource::XPCMessage);
+        });
+        return;
+    }
+
+    m_shouldSendParentProcessInformation = false;
+
+    m_relayConnection->sendMessage(WIRProxyApplicationSetupResponseMessage, @{
+        WIRProxyApplicationParentPIDKey: @(m_parentProcessIdentifier),
+        WIRProxyApplicationParentAuditDataKey: (NSData *)m_parentProcessAuditData.get(),
+    });
+}
+
+void RemoteInspector::receivedConnectionDiedMessage(NSDictionary *userInfo)
+{
+    NSString *connectionIdentifier = [userInfo objectForKey:WIRConnectionIdentifierKey];
+    if (!connectionIdentifier)
+        return;
+
+    auto it = m_targetConnectionMap.begin();
+    auto end = m_targetConnectionMap.end();
+    for (; it != end; ++it) {
+        if ([connectionIdentifier isEqualToString:it->value->connectionIdentifier()])
+            break;
+    }
+
+    if (it == end)
+        return;
+
+    auto connection = it->value;
+    unsigned targetIdentifier = connection->targetIdentifier().value_or(0);
+    connection->close();
+    m_targetConnectionMap.remove(it);
+
+    updateHasActiveDebugSession();
+    updateTargetListing(targetIdentifier);
+    pushListingsSoon();
+}
+
+void RemoteInspector::receivedAutomaticInspectionConfigurationMessage(NSDictionary *userInfo)
+{
+    m_automaticInspectionEnabled = [[userInfo objectForKey:WIRAutomaticInspectionEnabledKey] boolValue];
+
+    if (!m_automaticInspectionEnabled && m_automaticInspectionPaused)
+        m_automaticInspectionPaused = false;
+}
+
+void RemoteInspector::receivedAutomaticInspectionRejectMessage(NSDictionary *userInfo)
+{
+    unsigned rejectionIdentifier = [[userInfo objectForKey:WIRTargetIdentifierKey] unsignedIntValue];
+
+    ASSERT(rejectionIdentifier == m_automaticInspectionCandidateTargetIdentifier);
+    if (rejectionIdentifier == m_automaticInspectionCandidateTargetIdentifier)
+        m_automaticInspectionPaused = false;
+}
+
+void RemoteInspector::receivedAutomationSessionRequestMessage(NSDictionary *userInfo)
+{
+    if (!m_client)
+        return;
+
+    if (!m_clientCapabilities || !m_clientCapabilities->remoteAutomationAllowed)
+        return;
+
+    NSString *suggestedSessionIdentifier = [userInfo objectForKey:WIRSessionIdentifierKey];
+    if (!suggestedSessionIdentifier)
+        return;
+
+    m_client->requestAutomationSession(suggestedSessionIdentifier);
+}
+
+} // namespace Inspector
+
+#endif // ENABLE(REMOTE_INSPECTOR)

Copied: trunk/Source/_javascript_Core/inspector/remote/RemoteInspectorXPCConnection.h (from rev 212168, trunk/Source/_javascript_Core/inspector/remote/RemoteInspectorXPCConnection.h) (0 => 212394)


--- trunk/Source/_javascript_Core/inspector/remote/RemoteInspectorXPCConnection.h	                        (rev 0)
+++ trunk/Source/_javascript_Core/inspector/remote/RemoteInspectorXPCConnection.h	2017-02-15 22:31:07 UTC (rev 212394)
@@ -0,0 +1,77 @@
+/*
+ * Copyright (C) 2013 Apple 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 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 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.
+ */
+
+#pragma once
+
+#if ENABLE(REMOTE_INSPECTOR)
+
+#import <dispatch/dispatch.h>
+#import <wtf/Lock.h>
+#import <wtf/ThreadSafeRefCounted.h>
+#import <wtf/spi/darwin/XPCSPI.h>
+
+OBJC_CLASS NSDictionary;
+OBJC_CLASS NSString;
+
+namespace Inspector {
+
+class RemoteInspectorXPCConnection : public ThreadSafeRefCounted<RemoteInspectorXPCConnection> {
+public:
+    class Client {
+    public:
+        virtual ~Client() { }
+        virtual void xpcConnectionReceivedMessage(RemoteInspectorXPCConnection*, NSString *messageName, NSDictionary *userInfo) = 0;
+        virtual void xpcConnectionFailed(RemoteInspectorXPCConnection*) = 0;
+        virtual void xpcConnectionUnhandledMessage(RemoteInspectorXPCConnection*, xpc_object_t) = 0;
+    };
+
+    RemoteInspectorXPCConnection(xpc_connection_t, dispatch_queue_t, Client*);
+    virtual ~RemoteInspectorXPCConnection();
+
+    void close();
+    void closeFromMessage();
+    void sendMessage(NSString *messageName, NSDictionary *userInfo);
+
+private:
+    NSDictionary *deserializeMessage(xpc_object_t);
+    void handleEvent(xpc_object_t);
+    void closeOnQueue();
+
+    // We handle XPC events on the queue, but a client may call close() on any queue.
+    // We make sure that m_client is thread safe and immediately cleared in close().
+    Lock m_mutex;
+
+    xpc_connection_t m_connection;
+    dispatch_queue_t m_queue;
+    Client* m_client;
+    bool m_closed { false };
+#if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200)
+    bool m_validated { false };
+#endif
+};
+
+} // namespace Inspector
+
+#endif // ENABLE(REMOTE_INSPECTOR)

Copied: trunk/Source/_javascript_Core/inspector/remote/RemoteInspectorXPCConnection.mm (from rev 212168, trunk/Source/_javascript_Core/inspector/remote/RemoteInspectorXPCConnection.mm) (0 => 212394)


--- trunk/Source/_javascript_Core/inspector/remote/RemoteInspectorXPCConnection.mm	                        (rev 0)
+++ trunk/Source/_javascript_Core/inspector/remote/RemoteInspectorXPCConnection.mm	2017-02-15 22:31:07 UTC (rev 212394)
@@ -0,0 +1,222 @@
+/*
+ * Copyright (C) 2013 Apple 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 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 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.
+ */
+
+#import "config.h"
+#import "RemoteInspectorXPCConnection.h"
+
+#if ENABLE(REMOTE_INSPECTOR)
+
+#import <Foundation/Foundation.h>
+#import <mutex>
+#import <wtf/Assertions.h>
+#import <wtf/Lock.h>
+#import <wtf/Ref.h>
+#import <wtf/RetainPtr.h>
+#import <wtf/spi/cocoa/SecuritySPI.h>
+#import <wtf/spi/darwin/XPCSPI.h>
+
+#if USE(APPLE_INTERNAL_SDK)
+#import <CoreFoundation/CFXPCBridge.h>
+#else
+extern "C" {
+    xpc_object_t _CFXPCCreateXPCMessageWithCFObject(CFTypeRef);
+    CFTypeRef _CFXPCCreateCFObjectFromXPCMessage(xpc_object_t);
+}
+#endif
+
+#if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200)
+static bool auditTokenHasEntitlement(audit_token_t token, NSString *entitlement)
+{
+    auto task = adoptCF(SecTaskCreateWithAuditToken(kCFAllocatorDefault, token));
+    if (!task)
+        return false;
+
+    auto value = adoptCF(SecTaskCopyValueForEntitlement(task.get(), (CFStringRef)entitlement, nullptr));
+    if (!value)
+        return false;
+
+    if (CFGetTypeID(value.get()) != CFBooleanGetTypeID())
+        return false;
+
+    return CFBooleanGetValue(static_cast<CFBooleanRef>(value.get()));
+}
+#endif
+
+namespace Inspector {
+
+// Constants private to this file for message serialization on both ends.
+#define RemoteInspectorXPCConnectionMessageNameKey @"messageName"
+#define RemoteInspectorXPCConnectionUserInfoKey @"userInfo"
+#define RemoteInspectorXPCConnectionSerializedMessageKey "msgData"
+
+RemoteInspectorXPCConnection::RemoteInspectorXPCConnection(xpc_connection_t connection, dispatch_queue_t queue, Client* client)
+    : m_connection(connection)
+    , m_queue(queue)
+    , m_client(client)
+{
+    dispatch_retain(m_queue);
+
+    xpc_retain(m_connection);
+    xpc_connection_set_target_queue(m_connection, m_queue);
+    xpc_connection_set_event_handler(m_connection, ^(xpc_object_t object) {
+        handleEvent(object);
+    });
+
+    // Balanced by deref when the xpc_connection receives XPC_ERROR_CONNECTION_INVALID.
+    ref();
+
+    xpc_connection_resume(m_connection);
+}
+
+RemoteInspectorXPCConnection::~RemoteInspectorXPCConnection()
+{
+    ASSERT(!m_client);
+    ASSERT(!m_connection);
+    ASSERT(m_closed);
+}
+
+void RemoteInspectorXPCConnection::close()
+{
+    std::lock_guard<Lock> lock(m_mutex);
+    closeFromMessage();
+}
+
+void RemoteInspectorXPCConnection::closeFromMessage()
+{
+    m_closed = true;
+    m_client = nullptr;
+
+    dispatch_async(m_queue, ^{
+        std::lock_guard<Lock> lock(m_mutex);
+        // This will trigger one last XPC_ERROR_CONNECTION_INVALID event on the queue and deref us.
+        closeOnQueue();
+    });
+}
+
+void RemoteInspectorXPCConnection::closeOnQueue()
+{
+    if (m_connection) {
+        xpc_connection_cancel(m_connection);
+        xpc_release(m_connection);
+        m_connection = nullptr;
+    }
+
+    if (m_queue) {
+        dispatch_release(m_queue);
+        m_queue = nullptr;
+    }
+}
+
+NSDictionary *RemoteInspectorXPCConnection::deserializeMessage(xpc_object_t object)
+{
+    if (xpc_get_type(object) != XPC_TYPE_DICTIONARY)
+        return nil;
+
+    xpc_object_t xpcDictionary = xpc_dictionary_get_value(object, RemoteInspectorXPCConnectionSerializedMessageKey);
+    if (!xpcDictionary || xpc_get_type(xpcDictionary) != XPC_TYPE_DICTIONARY) {
+        std::lock_guard<Lock> lock(m_mutex);
+        if (m_client)
+            m_client->xpcConnectionUnhandledMessage(this, object);
+        return nil;
+    }
+
+    RetainPtr<CFDictionaryRef> dictionary = adoptCF((CFDictionaryRef)_CFXPCCreateCFObjectFromXPCMessage(xpcDictionary));
+    ASSERT_WITH_MESSAGE(dictionary, "Unable to deserialize xpc message");
+    return (NSDictionary *)dictionary.autorelease();
+}
+
+void RemoteInspectorXPCConnection::handleEvent(xpc_object_t object)
+{
+    if (xpc_get_type(object) == XPC_TYPE_ERROR) {
+        {
+            std::lock_guard<Lock> lock(m_mutex);
+            if (m_client)
+                m_client->xpcConnectionFailed(this);
+
+            m_closed = true;
+            m_client = nullptr;
+            closeOnQueue();
+        }
+
+        if (object == XPC_ERROR_CONNECTION_INVALID) {
+            // This is the last event we will ever receive from the connection.
+            // This balances the ref() in the constructor.
+            deref();
+        }
+        return;
+    }
+
+#if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200)
+    if (!m_validated) {
+        audit_token_t token;
+        xpc_connection_get_audit_token(m_connection, &token);
+        if (!auditTokenHasEntitlement(token, @"com.apple.private.webinspector.webinspectord")) {
+            std::lock_guard<Lock> lock(m_mutex);
+            // This will trigger one last XPC_ERROR_CONNECTION_INVALID event on the queue and deref us.
+            closeOnQueue();
+            return;
+        }
+        m_validated = true;
+    }
+#endif
+
+    NSDictionary *dataDictionary = deserializeMessage(object);
+    if (!dataDictionary)
+        return;
+
+    NSString *message = [dataDictionary objectForKey:RemoteInspectorXPCConnectionMessageNameKey];
+    NSDictionary *userInfo = [dataDictionary objectForKey:RemoteInspectorXPCConnectionUserInfoKey];
+    std::lock_guard<Lock> lock(m_mutex);
+    if (m_client)
+        m_client->xpcConnectionReceivedMessage(this, message, userInfo);
+}
+
+void RemoteInspectorXPCConnection::sendMessage(NSString *messageName, NSDictionary *userInfo)
+{
+    ASSERT(!m_closed);
+    if (m_closed)
+        return;
+
+    NSMutableDictionary *dictionary = [NSMutableDictionary dictionaryWithObject:messageName forKey:RemoteInspectorXPCConnectionMessageNameKey];
+    if (userInfo)
+        [dictionary setObject:userInfo forKey:RemoteInspectorXPCConnectionUserInfoKey];
+
+    xpc_object_t xpcDictionary = _CFXPCCreateXPCMessageWithCFObject((CFDictionaryRef)dictionary);
+    ASSERT_WITH_MESSAGE(xpcDictionary && xpc_get_type(xpcDictionary) == XPC_TYPE_DICTIONARY, "Unable to serialize xpc message");
+    if (!xpcDictionary)
+        return;
+
+    xpc_object_t msg = xpc_dictionary_create(nullptr, nullptr, 0);
+    xpc_dictionary_set_value(msg, RemoteInspectorXPCConnectionSerializedMessageKey, xpcDictionary);
+    xpc_release(xpcDictionary);
+
+    xpc_connection_send_message(m_connection, msg);
+
+    xpc_release(msg);
+}
+
+} // namespace Inspector
+
+#endif // ENABLE(REMOTE_INSPECTOR)

Modified: trunk/Source/WebKit2/ChangeLog (212393 => 212394)


--- trunk/Source/WebKit2/ChangeLog	2017-02-15 21:50:10 UTC (rev 212393)
+++ trunk/Source/WebKit2/ChangeLog	2017-02-15 22:31:07 UTC (rev 212394)
@@ -1,3 +1,16 @@
+2017-02-15  Alex Christensen  <[email protected]>
+
+        Unreviewed, rolling out r212169.
+
+        Broke iOS WebInspector
+
+        Reverted changeset:
+
+        "WebInspector: refactor RemoteInspector to move cocoa specific
+        code to their own files"
+        https://bugs.webkit.org/show_bug.cgi?id=166681
+        http://trac.webkit.org/changeset/212169
+
 2017-02-15  Anders Carlsson  <[email protected]>
 
         Modernize DragClient::startDrag somewhat

Modified: trunk/Source/WebKit2/WebProcess/WebProcess.cpp (212393 => 212394)


--- trunk/Source/WebKit2/WebProcess/WebProcess.cpp	2017-02-15 21:50:10 UTC (rev 212393)
+++ trunk/Source/WebKit2/WebProcess/WebProcess.cpp	2017-02-15 22:31:07 UTC (rev 212394)
@@ -370,7 +370,7 @@
     setEnabledServices(parameters.hasImageServices, parameters.hasSelectionServices, parameters.hasRichContentServices);
 #endif
 
-#if ENABLE(REMOTE_INSPECTOR) && PLATFORM(COCOA)
+#if ENABLE(REMOTE_INSPECTOR)
     audit_token_t auditToken;
     if (parentProcessConnection()->getAuditToken(auditToken)) {
         RetainPtr<CFDataRef> auditData = adoptCF(CFDataCreate(nullptr, (const UInt8*)&auditToken, sizeof(auditToken)));

Modified: trunk/Tools/ChangeLog (212393 => 212394)


--- trunk/Tools/ChangeLog	2017-02-15 21:50:10 UTC (rev 212393)
+++ trunk/Tools/ChangeLog	2017-02-15 22:31:07 UTC (rev 212394)
@@ -1,3 +1,16 @@
+2017-02-15  Alex Christensen  <[email protected]>
+
+        Unreviewed, rolling out r212169.
+
+        Broke iOS WebInspector
+
+        Reverted changeset:
+
+        "WebInspector: refactor RemoteInspector to move cocoa specific
+        code to their own files"
+        https://bugs.webkit.org/show_bug.cgi?id=166681
+        http://trac.webkit.org/changeset/212169
+
 2017-02-15  Jonathan Bedard  <[email protected]>
 
         webkitpy: Fix DarwinPort._get_crash_log()
Index: trunk/Tools/Scripts/webkitpy/benchmark_runner/data/patches/Animometer.patch
===================================================================
--- trunk/Tools/Scripts/webkitpy/benchmark_runner/data/patches/Animometer.patch	2017-02-15 21:50:10 UTC (rev 212393)
+++ trunk/Tools/Scripts/webkitpy/benchmark_runner/data/patches/Animometer.patch	2017-02-15 22:31:07 UTC (rev 212394)

Property changes: trunk/Tools/Scripts/webkitpy/benchmark_runner/data/patches/Animometer.patch


Deleted: svn:mergeinfo

-/trunk/Tools/Scripts/webkitpy/benchmark_runner/data/patches/Animometer.patch:53455 \ No newline at end of property
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to