OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/files/file_path_watcher.h" | 5 #include "base/files/file_path_watcher.h" |
6 | 6 |
7 #include <errno.h> | 7 #include <errno.h> |
8 #include <string.h> | 8 #include <string.h> |
9 #include <sys/inotify.h> | 9 #include <sys/inotify.h> |
10 #include <sys/ioctl.h> | 10 #include <sys/ioctl.h> |
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
344 // Report the following events: | 344 // Report the following events: |
345 // - The target or a direct child of the target got changed (in case the | 345 // - The target or a direct child of the target got changed (in case the |
346 // watched path refers to a directory). | 346 // watched path refers to a directory). |
347 // - One of the parent directories got moved or deleted, since the target | 347 // - One of the parent directories got moved or deleted, since the target |
348 // disappears in this case. | 348 // disappears in this case. |
349 // - One of the parent directories appears. The event corresponding to | 349 // - One of the parent directories appears. The event corresponding to |
350 // the target appearing might have been missed in this case, so | 350 // the target appearing might have been missed in this case, so |
351 // recheck. | 351 // recheck. |
352 if (target_changed || | 352 if (target_changed || |
353 (change_on_target_path && !created) || | 353 (change_on_target_path && !created) || |
354 (change_on_target_path && file_util::PathExists(target_))) { | 354 (change_on_target_path && PathExists(target_))) { |
355 callback_.Run(target_, false); | 355 callback_.Run(target_, false); |
356 return; | 356 return; |
357 } | 357 } |
358 } | 358 } |
359 } | 359 } |
360 } | 360 } |
361 | 361 |
362 bool FilePathWatcherImpl::Watch(const FilePath& path, | 362 bool FilePathWatcherImpl::Watch(const FilePath& path, |
363 bool recursive, | 363 bool recursive, |
364 const FilePathWatcher::Callback& callback) { | 364 const FilePathWatcher::Callback& callback) { |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
478 return true; | 478 return true; |
479 } | 479 } |
480 | 480 |
481 } // namespace | 481 } // namespace |
482 | 482 |
483 FilePathWatcher::FilePathWatcher() { | 483 FilePathWatcher::FilePathWatcher() { |
484 impl_ = new FilePathWatcherImpl(); | 484 impl_ = new FilePathWatcherImpl(); |
485 } | 485 } |
486 | 486 |
487 } // namespace base | 487 } // namespace base |
OLD | NEW |