Changeset 206875 in webkit
- Timestamp:
- Oct 6, 2016 12:45:52 PM (8 years ago)
- Location:
- trunk/Source/JavaScriptCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r206870 r206875 1 2016-10-06 Brian Burg <bburg@apple.com> 2 3 Web Inspector: RemoteInspector should cache client capabilities for off-main thread usage 4 https://bugs.webkit.org/show_bug.cgi?id=163039 5 <rdar://problem/28571460> 6 7 Reviewed by Timothy Hatcher. 8 9 The fix in r206797 was incorrect because listings are always pushed out on the XPC connection queue. 10 Instead of delaying the listing needlessly, RemoteInspector should cache the capabilities of its 11 client while on the main thread, then use the cached struct data on the XPC connection queue rather 12 than directly accessing m_client. This is similar to how RemoteConnectionToTarget marshalls listing 13 information from arbitrary queues into m_targetListingMap, which can then be read from any queue. 14 15 * inspector/remote/RemoteInspector.h: 16 * inspector/remote/RemoteInspector.mm: 17 (Inspector::RemoteInspector::updateClientCapabilities): Cache the capabilities. 18 (Inspector::RemoteInspector::setRemoteInspectorClient): 19 Re-cache the capabilities. Scope the lock to avoid reentrant locking. 20 21 (Inspector::RemoteInspector::clientCapabilitiesDidChange): Cache the capabilities. 22 (Inspector::RemoteInspector::pushListingsNow): Use cached client capabilities. 23 (Inspector::RemoteInspector::receivedGetListingMessage): Revert the change in r206797. 24 (Inspector::RemoteInspector::receivedAutomationSessionRequestMessage): 25 1 26 2016-10-06 Yusuke Suzuki <utatane.tea@gmail.com> 2 27 -
trunk/Source/JavaScriptCore/inspector/remote/RemoteInspector.h
r204479 r206875 49 49 class Client { 50 50 public: 51 struct Capabilities { 52 bool remoteAutomationAllowed : 1; 53 }; 54 51 55 virtual ~Client() { } 52 56 virtual bool remoteAutomationAllowed() const = 0; … … 63 67 void sendMessageToRemote(unsigned targetIdentifier, const String& message); 64 68 65 void updateAutomaticInspectionCandidate(RemoteInspectionTarget*);66 69 void setRemoteInspectorClient(RemoteInspector::Client*); 70 void clientCapabilitiesDidChange(); 67 71 68 72 void setupFailed(unsigned targetIdentifier); 69 73 void setupCompleted(unsigned targetIdentifier); 70 74 bool waitingForAutomaticInspection(unsigned targetIdentifier); 71 void clientCapabilitiesDidChange() { pushListingsSoon(); }75 void updateAutomaticInspectionCandidate(RemoteInspectionTarget*); 72 76 73 77 bool enabled() const { return m_enabled; } … … 100 104 101 105 void updateHasActiveDebugSession(); 106 void updateClientCapabilities(); 102 107 103 108 void sendAutomaticInspectionCandidateMessage(); … … 133 138 134 139 RemoteInspector::Client* m_client { nullptr }; 140 Optional<RemoteInspector::Client::Capabilities> m_clientCapabilities; 135 141 136 142 dispatch_queue_t m_xpcQueue; -
trunk/Source/JavaScriptCore/inspector/remote/RemoteInspector.mm
r206797 r206875 250 250 } 251 251 252 void RemoteInspector::updateClientCapabilities() 253 { 254 ASSERT(isMainThread()); 255 256 std::lock_guard<Lock> lock(m_mutex); 257 258 if (!m_client) 259 m_clientCapabilities = Nullopt; 260 else { 261 RemoteInspector::Client::Capabilities updatedCapabilities = { 262 m_client->remoteAutomationAllowed() // remoteAutomationAllowed 263 }; 264 265 m_clientCapabilities = updatedCapabilities; 266 } 267 } 268 252 269 void RemoteInspector::setRemoteInspectorClient(RemoteInspector::Client* client) 253 270 { … … 255 272 ASSERT(!m_client); 256 273 257 std::lock_guard<Lock> lock(m_mutex); 258 m_client = client; 274 { 275 std::lock_guard<Lock> lock(m_mutex); 276 m_client = client; 277 } 259 278 260 279 // Send an updated listing that includes whether the client allows remote automation. 280 updateClientCapabilities(); 261 281 pushListingsSoon(); 262 282 } … … 320 340 // We don't take the lock to check this because we assume it will be checked repeatedly. 321 341 return m_automaticInspectionPaused; 342 } 343 344 void RemoteInspector::clientCapabilitiesDidChange() 345 { 346 updateClientCapabilities(); 347 pushListingsSoon(); 322 348 } 323 349 … … 568 594 [message setObject:listings.get() forKey:WIRListingKey]; 569 595 570 BOOL isAllowed = m_client && m_client->remoteAutomationAllowed();596 BOOL isAllowed = m_clientCapabilities && m_clientCapabilities->remoteAutomationAllowed; 571 597 [message setObject:@(isAllowed) forKey:WIRRemoteAutomationEnabledKey]; 572 598 … … 697 723 void RemoteInspector::receivedGetListingMessage(NSDictionary *) 698 724 { 699 pushListings Soon();725 pushListingsNow(); 700 726 } 701 727 … … 795 821 return; 796 822 797 if (!m_client ->remoteAutomationAllowed())823 if (!m_clientCapabilities || !m_clientCapabilities->remoteAutomationAllowed) 798 824 return; 799 825
Note: See TracChangeset
for help on using the changeset viewer.