Bug 174166

Summary: FileMonitor should not be ref counted
Product: WebKit Reporter: Brent Fulgham <bfulgham>
Component: WebCore Misc.Assignee: Chris Dumez <cdumez>
Severity: Normal CC: achristensen, beidson, bfulgham, cdumez, ggaren
Priority: P2    
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Description Flags
Patch none

Description Brent Fulgham 2017-07-05 11:30:14 PDT
The current API for FileMonitor is fragile, because it requires the user to manually stop the monitor to make sure it is properly cleaned up.

This was done to make sure the event handler would never be left with a dangling this pointer. Instead, we should vend a WeakPtr to the closure, and check it when processing events to see if the FileMonitor was destroyed. If it was, we don't need to take any action.

This will allow the object to properly terminate monitoring when the object goes out of scope.
Comment 1 Chris Dumez 2017-07-06 13:03:39 PDT
Created attachment 314745 [details]
Comment 2 Chris Dumez 2017-07-06 13:07:35 PDT
Created attachment 314746 [details]
Comment 3 Brent Fulgham 2017-07-06 14:42:42 PDT
Comment on attachment 314746 [details]

Looks good! Nice cleanup.
Comment 4 Brent Fulgham 2017-07-06 14:43:15 PDT
Comment on attachment 314746 [details]

View in context: https://bugs.webkit.org/attachment.cgi?id=314746&action=review

> Source/WebCore/platform/FileMonitor.cpp:-46
> -}

Much simpler!
Comment 5 Chris Dumez 2017-07-06 14:45:08 PDT
Comment on attachment 314746 [details]

Clearing flags on attachment: 314746

Committed r219219: <http://trac.webkit.org/changeset/219219>
Comment 6 Chris Dumez 2017-07-06 14:45:10 PDT
All reviewed patches have been landed.  Closing bug.