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()); | |
467 set_cancelled(); | 466 set_cancelled(); |
468 | 467 |
469 if (!callback_.is_null()) { | 468 if (!callback_.is_null()) { |
470 MessageLoop::current()->RemoveDestructionObserver(this); | 469 MessageLoop::current()->RemoveDestructionObserver(this); |
471 callback_.Reset(); | 470 callback_.Reset(); |
472 } | 471 } |
473 | 472 |
474 for (size_t i = 0; i < watches_.size(); ++i) | 473 for (size_t i = 0; i < watches_.size(); ++i) |
475 g_inotify_reader.Get().RemoveWatch(watches_[i].watch, this); | 474 g_inotify_reader.Get().RemoveWatch(watches_[i].watch, this); |
476 watches_.clear(); | 475 watches_.clear(); |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
660 return watches_[watches_.size() - 1].subdir.empty(); | 659 return watches_[watches_.size() - 1].subdir.empty(); |
661 } | 660 } |
662 | 661 |
663 } // namespace | 662 } // namespace |
664 | 663 |
665 FilePathWatcher::FilePathWatcher() { | 664 FilePathWatcher::FilePathWatcher() { |
666 impl_ = new FilePathWatcherImpl(); | 665 impl_ = new FilePathWatcherImpl(); |
667 } | 666 } |
668 | 667 |
669 } // namespace base | 668 } // namespace base |
OLD | NEW |