Chromium Code Reviews
DescriptionCall WatcherManager functions on the IO thread.
Currently it is very difficult to correctly implement WatcherManager
if it needs async operations due to following two facts:
1. WatcherManager functions do not receive
storage::FileSystemOperationContext, while storage::AsyncFileUtil
methods do.
2. WatcherManager functions are called on the UI thread, while other
methods and destructors of its siblings (like
storage::FileSystemBackend and storage::AsyncFileUtil) are all called
on the IO thread.
Due to (1), we can't assume WatcherManager and its siblings are alive
after we post tasks to other threads in WatcherManager functions.
Typically we use weak pointers to avoid this kind of race conditions,
but due to (2) it is not possible because WatcherManager is destructed
on the IO thread.
This patch will fix the issue by requiring WatcherManager functions
to be called on the IO thread.
What this patch does are:
- Update private_api_file_system.{cc,h}, the only caller of
WatcherManager today, to call WatcherManager functions on the IO
thread.
- Update WatcherManager implementation for File System Providers
to post tasks to the UI thread.
- Update DCHECK / comments accordingly.
Note that MTPWatcherManager actually expects its functions to be
called on the IO thread and is broken today, so no change is needed.
BUG=chromium:692586
TEST=trybot
Review-Url: https://codereview.chromium.org/2712613002
Cr-Commit-Position: refs/heads/master@{#452768}
Committed: https://chromium.googlesource.com/chromium/src/+/bf45258a17f7f528b652a6b033c606787f8f9a0d
Patch Set 1 #Patch Set 2 : . #
Total comments: 5
Patch Set 3 : Rebased to ToT. #Patch Set 4 : Updated comments as per mtomasz's request. #
Total comments: 10
Patch Set 5 : Addressed hidehiko's comments. #
Dependent Patchsets: Messages
Total messages: 32 (21 generated)
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||