Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(32)

Issue 52005: Implement recursive DirectoryWatcher watches on Linux (Closed)

Created:
11 years, 9 months ago by j.dinata
Modified:
9 years, 7 months ago
Reviewers:
Paweł Hajdan Jr.
CC:
chromium-reviews_googlegroups.com
Visibility:
Public.

Description

From phadjan's 3nd review On directory_watcher_inotify.cc Refactor: Move notification logic to DirectoryWatcherImpl. Run watchSubtree on a seperate thread. Track Inode, instead of FilePath. Fire Callback functions appropriately. On directory_watcher_unittest.cc Remove redundant test. Fix MoveDirectoryAcrossWatchResursive. http://crbug.com/8968

Patch Set 1 #

Total comments: 13

Patch Set 2 : '' #

Total comments: 33

Patch Set 3 : '' #

Total comments: 31

Patch Set 4 : '' #

Total comments: 24

Patch Set 5 : '' #

Unified diffs Side-by-side diffs Delta from patch set Stats (+108 lines, -31 lines) Patch
M base/directory_watcher_inotify.cc View 1 2 3 4 11 chunks +63 lines, -27 lines 0 comments Download
M base/directory_watcher_unittest.cc View 2 3 4 2 chunks +45 lines, -4 lines 0 comments Download

Messages

Total messages: 7 (0 generated)
Paweł Hajdan Jr.
Thanks again for working on this. I'm a bit worried that you still did not ...
11 years, 9 months ago (2009-03-23 16:43:37 UTC) #1
j.dinata
Hi Pawel, This is my follow up on your first review. I haven't done more ...
11 years, 9 months ago (2009-03-27 23:24:45 UTC) #2
Paweł Hajdan Jr.
That's a progress, that's good. You probably see a lot of comments here, but now ...
11 years, 9 months ago (2009-03-28 19:01:11 UTC) #3
j.dinata
Hi Pawel, I have updates from your 2'nd review. I am hitting an intermittent problems ...
11 years, 8 months ago (2009-04-04 21:44:46 UTC) #4
Paweł Hajdan Jr.
Many comments, but I see the progress and I think it's going in good direction. ...
11 years, 8 months ago (2009-04-05 10:33:05 UTC) #5
j.dinata
Hi Pawel, Here is another iteration. http://codereview.chromium.org/52005/diff/4001/4002 File base/directory_watcher_inotify.cc (right): http://codereview.chromium.org/52005/diff/4001/4002#newcode410 Line 410: InotifyReader::Watch child_watch ...
11 years, 8 months ago (2009-04-06 21:20:11 UTC) #6
Paweł Hajdan Jr.
11 years, 8 months ago (2009-04-14 15:19:00 UTC) #7
Some comments. There are still some issues I didn't comment about, but this
patch already took very long to produce, and I think it would be better to
change the approach a bit.

Please upload a separate review issue that would allow recursive watches, but
without support for dynamically adding/removing watches upon directory changes
(events from InotifyReader). That should be simple, and I think that patch can
be landed quickly. Then we will see what can be done about the rest.

http://codereview.chromium.org/52005/diff/6003/6004
File base/directory_watcher_inotify.cc (right):

http://codereview.chromium.org/52005/diff/6003/6004#newcode47
Line 47: Watch AddWatch(const FilePath& path, DirectoryWatcherImpl* watcher,
bool recursive);
Now the bool recursive parameter is not needed. Good!

http://codereview.chromium.org/52005/diff/6003/6004#newcode60
Line 60: typedef std::multiset<DirectoryWatcherImpl*> WatcherSet;
Now some assumptions changed, so it doesn't have to be multiset. Let's change to
std::set...

http://codereview.chromium.org/52005/diff/6003/6004#newcode66
Line 66: // Multiset is used because there may be many DirectoryWatcherImpls for
same path
And now this comment can be removed.

http://codereview.chromium.org/52005/diff/6003/6004#newcode96
Line 96: void handleEvent (inotify_event* event, FilePath changed_path);
nit: should be HandleEvent. Also please remove the changed_path parameter.

http://codereview.chromium.org/52005/diff/6003/6004#newcode110
Line 110: // Callback for InotifyReader to tell about new directory creation.
This comment is no longer true.

http://codereview.chromium.org/52005/diff/6003/6004#newcode113
Line 113: // Callback for InotifyReader to tell about new directory deletion.
As above.

http://codereview.chromium.org/52005/diff/6003/6004#newcode176
Line 176: const FilePath& path)
nit: please align this line

http://codereview.chromium.org/52005/diff/6003/6004#newcode350
Line 350: if (!event->len)
This check is now not needed here.

http://codereview.chromium.org/52005/diff/6003/6004#newcode378
Line 378: ino_t DirectoryWatcherImpl::getInode(const FilePath path) const {
I'm not sure if this function shouldn't be moved elsewhere, but let's leave it
for now.

http://codereview.chromium.org/52005/diff/6003/6004#newcode380
Line 380: int result=stat(path.value().c_str(), &buffer);
nit: spaces around "="
http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml?showone=Horizo...

http://codereview.chromium.org/52005/diff/6003/6004#newcode382
Line 382: DLOG(WARNING) << " Failed to stat: " << path.value() <<
strerror(errno);
I would prefer a signature more like
bool ...::getInode(const FilePath& path, ino_t* inode) const;

Then it would return true on success, which gives us explicit error handling.

http://codereview.chromium.org/52005/diff/6003/6004#newcode391
Line 391: new DirectoryWatcherImplNotifyTask(delegate_, changed_path));
changed_path should be the same path that was used for Watch. That's the
contract of DirectoryWatcher. The delegate receives the path that was being
watched, not necessarily the more specific path inside the subtree.

Then you don't need the changed_path parameter.

http://codereview.chromium.org/52005/diff/6003/6004#newcode396
Line 396: if (event->mask & IN_CLOSE_WRITE) {
Looks like this if branch is not needed. IN_CREATE, IN_DELETE and IN_CLOSE_WRITE
seem to be mutually exclusive.

http://codereview.chromium.org/52005/diff/6003/6004#newcode398
Line 398: event->mask & IN_MOVE && event->mask & IN_MOVED_TO) {
IN_MOVE includes IN_MOVED_TO

http://codereview.chromium.org/52005/diff/6003/6004#newcode399
Line 399: if (recursive_) {
I would add a DCHECK here that event->name is not empty.

http://codereview.chromium.org/52005/diff/6003/6004#newcode404
Line 404: event->mask & IN_MOVE && event->mask & IN_MOVED_FROM) {
IN_MOVE includes IN_MOVED_FROM

http://codereview.chromium.org/52005/diff/6003/6004#newcode409
Line 409: bool DirectoryWatcherImpl::isPathCovered(const FilePath& path) const {
nit: first character should be upcase too, so IsPathCovered... or maybe better
IsPathWatched.

http://codereview.chromium.org/52005/diff/6003/6004#newcode410
Line 410: return path_covered_.find(getInode(path))!=path_covered_.end();
nit: spaces around "!=".

http://codereview.chromium.org/52005/diff/6003/6004#newcode415
Line 415: if (!recursive_)
Do DCHECK(recursive) instead. The caller makes that check, and we want to be
sure that it does it correctly.

http://codereview.chromium.org/52005/diff/6003/6004#newcode419
Line 419: if (!absolute_path.IsAbsolute()) {
This check is not needed. We actually don't need this absolute_path, because now
we use inodes.

http://codereview.chromium.org/52005/diff/6003/6004#newcode429
Line 429: if (child_watch != InotifyReader::kInvalidWatch)
DLOG if couldn't add child_watch

http://codereview.chromium.org/52005/diff/6003/6004#newcode512
Line 512: if (!absolute_path.IsAbsolute()) {
This absolute path part is not needed.

http://codereview.chromium.org/52005/diff/6003/6004#newcode546
Line 546: base::Thread thread("traverse_subtree");
Oh, that's bad. Actually no code runs on this thread, and it will be stopped on
function exit. Better use WorkerPool and extract FileEnumerator part of this
method into a separate Task.

http://codereview.chromium.org/52005/diff/6003/6004#newcode552
Line 552: bool no_failure = true;
bool success would be much more intuitive.

Powered by Google App Engine
This is Rietveld 408576698