| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 405 void FilePathWatcherImpl::Cancel() { | 405 void FilePathWatcherImpl::Cancel() { |
| 406 if (!delegate_) { | 406 if (!delegate_) { |
| 407 // Watch was never called, or the |message_loop_| thread is already gone. | 407 // Watch was never called, or the |message_loop_| thread is already gone. |
| 408 set_cancelled(); | 408 set_cancelled(); |
| 409 return; | 409 return; |
| 410 } | 410 } |
| 411 | 411 |
| 412 // Switch to the message_loop_ if necessary so we can access |watches_|. | 412 // Switch to the message_loop_ if necessary so we can access |watches_|. |
| 413 if (!message_loop()->BelongsToCurrentThread()) { | 413 if (!message_loop()->BelongsToCurrentThread()) { |
| 414 message_loop()->PostTask(FROM_HERE, | 414 message_loop()->PostTask(FROM_HERE, |
| 415 new FilePathWatcher::CancelTask(this)); | 415 base::Bind(&FilePathWatcher::CancelWatch, |
| 416 make_scoped_refptr(this))); |
| 416 } else { | 417 } else { |
| 417 CancelOnMessageLoopThread(); | 418 CancelOnMessageLoopThread(); |
| 418 } | 419 } |
| 419 } | 420 } |
| 420 | 421 |
| 421 void FilePathWatcherImpl::CancelOnMessageLoopThread() { | 422 void FilePathWatcherImpl::CancelOnMessageLoopThread() { |
| 422 if (!is_cancelled()) | 423 if (!is_cancelled()) |
| 423 set_cancelled(); | 424 set_cancelled(); |
| 424 | 425 |
| 425 if (delegate_) { | 426 if (delegate_) { |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 492 } | 493 } |
| 493 | 494 |
| 494 } // namespace | 495 } // namespace |
| 495 | 496 |
| 496 FilePathWatcher::FilePathWatcher() { | 497 FilePathWatcher::FilePathWatcher() { |
| 497 impl_ = new FilePathWatcherImpl(); | 498 impl_ = new FilePathWatcherImpl(); |
| 498 } | 499 } |
| 499 | 500 |
| 500 } // namespace files | 501 } // namespace files |
| 501 } // namespace base | 502 } // namespace base |
| OLD | NEW |