Title: [206875] trunk/Source/_javascript_Core
- Revision
- 206875
- Author
- [email protected]
- Date
- 2016-10-06 12:45:52 -0700 (Thu, 06 Oct 2016)
Log Message
Web Inspector: RemoteInspector should cache client capabilities for off-main thread usage
https://bugs.webkit.org/show_bug.cgi?id=163039
<rdar://problem/28571460>
Reviewed by Timothy Hatcher.
The fix in r206797 was incorrect because listings are always pushed out on the XPC connection queue.
Instead of delaying the listing needlessly, RemoteInspector should cache the capabilities of its
client while on the main thread, then use the cached struct data on the XPC connection queue rather
than directly accessing m_client. This is similar to how RemoteConnectionToTarget marshalls listing
information from arbitrary queues into m_targetListingMap, which can then be read from any queue.
* inspector/remote/RemoteInspector.h:
* inspector/remote/RemoteInspector.mm:
(Inspector::RemoteInspector::updateClientCapabilities): Cache the capabilities.
(Inspector::RemoteInspector::setRemoteInspectorClient):
Re-cache the capabilities. Scope the lock to avoid reentrant locking.
(Inspector::RemoteInspector::clientCapabilitiesDidChange): Cache the capabilities.
(Inspector::RemoteInspector::pushListingsNow): Use cached client capabilities.
(Inspector::RemoteInspector::receivedGetListingMessage): Revert the change in r206797.
(Inspector::RemoteInspector::receivedAutomationSessionRequestMessage):
Modified Paths
Diff
Modified: trunk/Source/_javascript_Core/ChangeLog (206874 => 206875)
--- trunk/Source/_javascript_Core/ChangeLog 2016-10-06 19:17:44 UTC (rev 206874)
+++ trunk/Source/_javascript_Core/ChangeLog 2016-10-06 19:45:52 UTC (rev 206875)
@@ -1,3 +1,28 @@
+2016-10-06 Brian Burg <[email protected]>
+
+ Web Inspector: RemoteInspector should cache client capabilities for off-main thread usage
+ https://bugs.webkit.org/show_bug.cgi?id=163039
+ <rdar://problem/28571460>
+
+ Reviewed by Timothy Hatcher.
+
+ The fix in r206797 was incorrect because listings are always pushed out on the XPC connection queue.
+ Instead of delaying the listing needlessly, RemoteInspector should cache the capabilities of its
+ client while on the main thread, then use the cached struct data on the XPC connection queue rather
+ than directly accessing m_client. This is similar to how RemoteConnectionToTarget marshalls listing
+ information from arbitrary queues into m_targetListingMap, which can then be read from any queue.
+
+ * inspector/remote/RemoteInspector.h:
+ * inspector/remote/RemoteInspector.mm:
+ (Inspector::RemoteInspector::updateClientCapabilities): Cache the capabilities.
+ (Inspector::RemoteInspector::setRemoteInspectorClient):
+ Re-cache the capabilities. Scope the lock to avoid reentrant locking.
+
+ (Inspector::RemoteInspector::clientCapabilitiesDidChange): Cache the capabilities.
+ (Inspector::RemoteInspector::pushListingsNow): Use cached client capabilities.
+ (Inspector::RemoteInspector::receivedGetListingMessage): Revert the change in r206797.
+ (Inspector::RemoteInspector::receivedAutomationSessionRequestMessage):
+
2016-10-06 Yusuke Suzuki <[email protected]>
[WebCore][JSC] Use new @throwTypeError and @throwRangeError intrinsics
Modified: trunk/Source/_javascript_Core/inspector/remote/RemoteInspector.h (206874 => 206875)
--- trunk/Source/_javascript_Core/inspector/remote/RemoteInspector.h 2016-10-06 19:17:44 UTC (rev 206874)
+++ trunk/Source/_javascript_Core/inspector/remote/RemoteInspector.h 2016-10-06 19:45:52 UTC (rev 206875)
@@ -48,6 +48,10 @@
public:
class Client {
public:
+ struct Capabilities {
+ bool remoteAutomationAllowed : 1;
+ };
+
virtual ~Client() { }
virtual bool remoteAutomationAllowed() const = 0;
virtual void requestAutomationSession(const String& sessionIdentifier) = 0;
@@ -62,13 +66,13 @@
void updateTarget(RemoteControllableTarget*);
void sendMessageToRemote(unsigned targetIdentifier, const String& message);
- void updateAutomaticInspectionCandidate(RemoteInspectionTarget*);
void setRemoteInspectorClient(RemoteInspector::Client*);
+ void clientCapabilitiesDidChange();
void setupFailed(unsigned targetIdentifier);
void setupCompleted(unsigned targetIdentifier);
bool waitingForAutomaticInspection(unsigned targetIdentifier);
- void clientCapabilitiesDidChange() { pushListingsSoon(); }
+ void updateAutomaticInspectionCandidate(RemoteInspectionTarget*);
bool enabled() const { return m_enabled; }
bool hasActiveDebugSession() const { return m_hasActiveDebugSession; }
@@ -99,6 +103,7 @@
void pushListingsSoon();
void updateHasActiveDebugSession();
+ void updateClientCapabilities();
void sendAutomaticInspectionCandidateMessage();
@@ -132,6 +137,7 @@
RefPtr<RemoteInspectorXPCConnection> m_relayConnection;
RemoteInspector::Client* m_client { nullptr };
+ Optional<RemoteInspector::Client::Capabilities> m_clientCapabilities;
dispatch_queue_t m_xpcQueue;
unsigned m_nextAvailableTargetIdentifier { 1 };
Modified: trunk/Source/_javascript_Core/inspector/remote/RemoteInspector.mm (206874 => 206875)
--- trunk/Source/_javascript_Core/inspector/remote/RemoteInspector.mm 2016-10-06 19:17:44 UTC (rev 206874)
+++ trunk/Source/_javascript_Core/inspector/remote/RemoteInspector.mm 2016-10-06 19:45:52 UTC (rev 206875)
@@ -249,15 +249,35 @@
}
}
+void RemoteInspector::updateClientCapabilities()
+{
+ ASSERT(isMainThread());
+
+ std::lock_guard<Lock> lock(m_mutex);
+
+ if (!m_client)
+ m_clientCapabilities = 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;
+ {
+ std::lock_guard<Lock> lock(m_mutex);
+ m_client = client;
+ }
// Send an updated listing that includes whether the client allows remote automation.
+ updateClientCapabilities();
pushListingsSoon();
}
@@ -321,6 +341,12 @@
return m_automaticInspectionPaused;
}
+void RemoteInspector::clientCapabilitiesDidChange()
+{
+ updateClientCapabilities();
+ pushListingsSoon();
+}
+
void RemoteInspector::start()
{
std::lock_guard<Lock> lock(m_mutex);
@@ -567,7 +593,7 @@
RetainPtr<NSMutableDictionary> message = adoptNS([[NSMutableDictionary alloc] init]);
[message setObject:listings.get() forKey:WIRListingKey];
- BOOL isAllowed = m_client && m_client->remoteAutomationAllowed();
+ BOOL isAllowed = m_clientCapabilities && m_clientCapabilities->remoteAutomationAllowed;
[message setObject:@(isAllowed) forKey:WIRRemoteAutomationEnabledKey];
m_relayConnection->sendMessage(WIRListingMessage, message.get());
@@ -696,7 +722,7 @@
void RemoteInspector::receivedGetListingMessage(NSDictionary *)
{
- pushListingsSoon();
+ pushListingsNow();
}
void RemoteInspector::receivedIndicateMessage(NSDictionary *userInfo)
@@ -794,7 +820,7 @@
if (!m_client)
return;
- if (!m_client->remoteAutomationAllowed())
+ if (!m_clientCapabilities || !m_clientCapabilities->remoteAutomationAllowed)
return;
NSString *suggestedSessionIdentifier = [userInfo objectForKey:WIRSessionIdentifierKey];
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes