Changeset 204245 in webkit
- Timestamp:
- Aug 7, 2016, 1:50:43 PM (10 years ago)
- Location:
- trunk
- Files:
-
- 10 edited
-
Source/WebKit2/ChangeLog (modified) (1 diff)
-
Source/WebKit2/Shared/API/Cocoa/RemoteObjectRegistry.h (modified) (2 diffs)
-
Source/WebKit2/Shared/API/Cocoa/RemoteObjectRegistry.messages.in (modified) (1 diff)
-
Source/WebKit2/Shared/API/Cocoa/RemoteObjectRegistry.mm (modified) (2 diffs)
-
Source/WebKit2/Shared/API/Cocoa/_WKRemoteObjectRegistry.mm (modified) (2 diffs)
-
Source/WebKit2/Shared/API/Cocoa/_WKRemoteObjectRegistryInternal.h (modified) (1 diff)
-
Tools/ChangeLog (modified) (1 diff)
-
Tools/TestWebKitAPI/Tests/WebKit2Cocoa/RemoteObjectRegistry.h (modified) (1 diff)
-
Tools/TestWebKitAPI/Tests/WebKit2Cocoa/RemoteObjectRegistry.mm (modified) (2 diffs)
-
Tools/TestWebKitAPI/Tests/WebKit2Cocoa/RemoteObjectRegistryPlugIn.mm (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit2/ChangeLog
r204243 r204245 1 2016-08-07 Dan Bernstein <mitz@apple.com> 2 3 [Cocoa] Reply block leaks if the remote object doesn’t call it 4 https://bugs.webkit.org/show_bug.cgi?id=160642 5 6 Reviewed by Sam Weinig. 7 8 * Shared/API/Cocoa/RemoteObjectRegistry.h: Declared new member functions. 9 * Shared/API/Cocoa/RemoteObjectRegistry.messages.in: Added ReleaseUnusedReplyBlock message. 10 * Shared/API/Cocoa/RemoteObjectRegistry.mm: 11 (WebKit::RemoteObjectRegistry::sendUnusedReply): Send the ReleaseUnusedReplyBlock message. 12 (WebKit::RemoteObjectRegistry::releaseUnusedReplyBlock): Message receiver that call through 13 to -_releaseReplyWithID:. 14 15 * Shared/API/Cocoa/_WKRemoteObjectRegistry.mm: 16 (-[_WKRemoteObjectRegistry _invokeMethod:]): Define a ReplyBlockCallChecker object and 17 capture an instance of it in the reply block we pass to the exported object. Have that 18 block set a flag on the checker when it’s called. If the checker gets destroyed without 19 the block having been called, which means that the block got destroyed without being 20 called, call sendUnusedReply to let the other side know that the block will not be invoked. 21 (-[_WKRemoteObjectRegistry _releaseReplyWithID:]): Added. Removed the pending reply from the 22 map, which release the block. 23 * Shared/API/Cocoa/_WKRemoteObjectRegistryInternal.h: 24 1 25 2016-08-07 Chris Dumez <cdumez@apple.com> 2 26 -
trunk/Source/WebKit2/Shared/API/Cocoa/RemoteObjectRegistry.h
r197563 r204245 47 47 void sendInvocation(const RemoteObjectInvocation&); 48 48 void sendReplyBlock(uint64_t replyID, const UserData& blockInvocation); 49 void sendUnusedReply(uint64_t replyID); 49 50 50 51 private: … … 55 56 void invokeMethod(const RemoteObjectInvocation&); 56 57 void callReplyBlock(uint64_t replyID, const UserData& blockInvocation); 58 void releaseUnusedReplyBlock(uint64_t replyID); 57 59 58 60 _WKRemoteObjectRegistry *m_remoteObjectRegistry; -
trunk/Source/WebKit2/Shared/API/Cocoa/RemoteObjectRegistry.messages.in
r192185 r204245 24 24 InvokeMethod(WebKit::RemoteObjectInvocation invocation) 25 25 CallReplyBlock(uint64_t replyID, WebKit::UserData blockInvocation); 26 ReleaseUnusedReplyBlock(uint64_t replyID); 26 27 } -
trunk/Source/WebKit2/Shared/API/Cocoa/RemoteObjectRegistry.mm
r192189 r204245 55 55 } 56 56 57 void RemoteObjectRegistry::sendUnusedReply(uint64_t replyID) 58 { 59 m_messageSender.send(Messages::RemoteObjectRegistry::ReleaseUnusedReplyBlock(replyID)); 60 } 61 57 62 void RemoteObjectRegistry::invokeMethod(const RemoteObjectInvocation& invocation) 58 63 { … … 69 74 } 70 75 76 void RemoteObjectRegistry::releaseUnusedReplyBlock(uint64_t replyID) 77 { 78 #if WK_API_ENABLED 79 [m_remoteObjectRegistry _releaseReplyWithID:replyID]; 80 #endif 81 } 71 82 } // namespace WebKit -
trunk/Source/WebKit2/Shared/API/Cocoa/_WKRemoteObjectRegistry.mm
r204232 r204245 217 217 RetainPtr<_WKRemoteObjectRegistry> remoteObjectRegistry = self; 218 218 uint64_t replyID = replyInfo->replyID; 219 id replyBlock = __NSMakeSpecialForwardingCaptureBlock(wireBlockSignature._typeString.UTF8String, [interface, remoteObjectRegistry, replyID](NSInvocation *invocation) { 219 220 class ReplyBlockCallChecker : public WTF::ThreadSafeRefCounted<ReplyBlockCallChecker> { 221 public: 222 static Ref<ReplyBlockCallChecker> create(_WKRemoteObjectRegistry *registry, uint64_t replyID) { return adoptRef(*new ReplyBlockCallChecker(registry, replyID)); } 223 224 ~ReplyBlockCallChecker() 225 { 226 if (!m_didCallReplyBlock) 227 m_remoteObjectRegistry->_remoteObjectRegistry->sendUnusedReply(m_replyID); 228 } 229 230 void didCallReplyBlock() { m_didCallReplyBlock = true; } 231 232 private: 233 ReplyBlockCallChecker(_WKRemoteObjectRegistry *registry, uint64_t replyID) 234 : m_remoteObjectRegistry(registry) 235 , m_replyID(replyID) 236 { 237 } 238 239 RetainPtr<_WKRemoteObjectRegistry> m_remoteObjectRegistry; 240 uint64_t m_replyID = 0; 241 bool m_didCallReplyBlock = false; 242 }; 243 244 RefPtr<ReplyBlockCallChecker> checker = ReplyBlockCallChecker::create(self, replyID); 245 id replyBlock = __NSMakeSpecialForwardingCaptureBlock(wireBlockSignature._typeString.UTF8String, [interface, remoteObjectRegistry, replyID, checker](NSInvocation *invocation) { 220 246 auto encoder = adoptNS([[WKRemoteObjectEncoder alloc] init]); 221 247 [encoder encodeObject:invocation forKey:invocationKey]; 222 248 223 249 remoteObjectRegistry->_remoteObjectRegistry->sendReplyBlock(replyID, UserData([encoder rootObjectDictionary])); 250 checker->didCallReplyBlock(); 224 251 }); 225 252 … … 271 298 } 272 299 300 - (void)_releaseReplyWithID:(uint64_t)replyID 301 { 302 _pendingReplies.remove(replyID); 303 } 304 273 305 @end 274 306 -
trunk/Source/WebKit2/Shared/API/Cocoa/_WKRemoteObjectRegistryInternal.h
r192185 r204245 49 49 50 50 - (void)_callReplyWithID:(uint64_t)replyID blockInvocation:(const WebKit::UserData&)blockInvocation; 51 - (void)_releaseReplyWithID:(uint64_t)replyID; 51 52 52 53 @end -
trunk/Tools/ChangeLog
r204243 r204245 1 2016-08-07 Dan Bernstein <mitz@apple.com> 2 3 [Cocoa] Reply block leaks if the remote object doesn’t call it 4 https://bugs.webkit.org/show_bug.cgi?id=160642 5 6 Reviewed by Sam Weinig. 7 8 * TestWebKitAPI/Tests/WebKit2Cocoa/RemoteObjectRegistry.h: Declared a new method. 9 * TestWebKitAPI/Tests/WebKit2Cocoa/RemoteObjectRegistry.mm: 10 (TEST): Added a test case that checks that the reply block is released even when it’s not 11 called. 12 * TestWebKitAPI/Tests/WebKit2Cocoa/RemoteObjectRegistryPlugIn.mm: 13 (-[RemoteObjectRegistryPlugIn doNotCallCompletionHandler:]): Implement new method by not 14 calling the completion handler. 15 1 16 2016-08-07 Chris Dumez <cdumez@apple.com> 2 17 -
trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/RemoteObjectRegistry.h
r204188 r204245 36 36 - (void)selectionAndClickInformationForClickAtPoint:(NSValue *)pointValue completionHandler:(void (^)(NSDictionary *))completionHandler; 37 37 - (void)takeRange:(NSRange)range completionHandler:(void (^)(NSUInteger location, NSUInteger length))completionHandler; 38 - (void)doNotCallCompletionHandler:(void (^)())completionHandler; 38 39 39 40 @end -
trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/RemoteObjectRegistry.mm
r204188 r204245 36 36 #import <WebKit/_WKRemoteObjectInterface.h> 37 37 #import <WebKit/_WKRemoteObjectRegistry.h> 38 #import <wtf/RefCounted.h> 38 39 #import <wtf/RetainPtr.h> 39 40 … … 83 84 }]; 84 85 TestWebKitAPI::Util::run(&isDone); 86 87 isDone = false; 88 89 class DoneWhenDestroyed : public RefCounted<DoneWhenDestroyed> { 90 public: 91 ~DoneWhenDestroyed() { isDone = true; } 92 }; 93 94 { 95 RefPtr<DoneWhenDestroyed> doneWhenDestroyed = adoptRef(*new DoneWhenDestroyed); 96 [object doNotCallCompletionHandler:[doneWhenDestroyed]() { 97 }]; 98 } 99 100 TestWebKitAPI::Util::run(&isDone); 85 101 } 86 102 } -
trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/RemoteObjectRegistryPlugIn.mm
r204188 r204245 82 82 } 83 83 84 - (void)doNotCallCompletionHandler:(void (^)())completionHandler 85 { 86 } 87 84 88 @end 85 89
Note:
See TracChangeset
for help on using the changeset viewer.