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 445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
456 if (!message_loop()->BelongsToCurrentThread()) { | 456 if (!message_loop()->BelongsToCurrentThread()) { |
457 message_loop()->PostTask(FROM_HERE, | 457 message_loop()->PostTask(FROM_HERE, |
458 Bind(&FilePathWatcher::CancelWatch, | 458 Bind(&FilePathWatcher::CancelWatch, |
459 make_scoped_refptr(this))); | 459 make_scoped_refptr(this))); |
460 } else { | 460 } else { |
461 CancelOnMessageLoopThread(); | 461 CancelOnMessageLoopThread(); |
462 } | 462 } |
463 } | 463 } |
464 | 464 |
465 void FilePathWatcherImpl::CancelOnMessageLoopThread() { | 465 void FilePathWatcherImpl::CancelOnMessageLoopThread() { |
| 466 DCHECK(message_loop()->BelongsToCurrentThread()); |
466 set_cancelled(); | 467 set_cancelled(); |
467 | 468 |
468 if (!callback_.is_null()) { | 469 if (!callback_.is_null()) { |
469 MessageLoop::current()->RemoveDestructionObserver(this); | 470 MessageLoop::current()->RemoveDestructionObserver(this); |
470 callback_.Reset(); | 471 callback_.Reset(); |
471 } | 472 } |
472 | 473 |
473 for (size_t i = 0; i < watches_.size(); ++i) | 474 for (size_t i = 0; i < watches_.size(); ++i) |
474 g_inotify_reader.Get().RemoveWatch(watches_[i].watch, this); | 475 g_inotify_reader.Get().RemoveWatch(watches_[i].watch, this); |
475 watches_.clear(); | 476 watches_.clear(); |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
659 return watches_[watches_.size() - 1].subdir.empty(); | 660 return watches_[watches_.size() - 1].subdir.empty(); |
660 } | 661 } |
661 | 662 |
662 } // namespace | 663 } // namespace |
663 | 664 |
664 FilePathWatcher::FilePathWatcher() { | 665 FilePathWatcher::FilePathWatcher() { |
665 impl_ = new FilePathWatcherImpl(); | 666 impl_ = new FilePathWatcherImpl(); |
666 } | 667 } |
667 | 668 |
668 } // namespace base | 669 } // namespace base |
OLD | NEW |