craig.schlenter@chromium.org | b2d581e | 2011-04-15 01:56:01 +0900 | [diff] [blame] | 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 |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | // Cross platform methods for FilePathWatcher. See the various platform |
| 6 | // specific implementation files, too. |
| 7 | |
| 8 | #include "base/files/file_path_watcher.h" |
| 9 | |
| 10 | #include "base/logging.h" |
| 11 | #include "base/message_loop.h" |
| 12 | |
| 13 | namespace base { |
craig.schlenter@chromium.org | b2d581e | 2011-04-15 01:56:01 +0900 | [diff] [blame] | 14 | |
| 15 | FilePathWatcher::~FilePathWatcher() { |
| 16 | impl_->Cancel(); |
| 17 | } |
| 18 | |
jhawkins@chromium.org | fce1f41 | 2011-11-24 05:44:00 +0900 | [diff] [blame] | 19 | // static |
| 20 | void FilePathWatcher::CancelWatch( |
| 21 | const scoped_refptr<PlatformDelegate>& delegate) { |
| 22 | delegate->CancelOnMessageLoopThread(); |
| 23 | } |
| 24 | |
craig.schlenter@chromium.org | b2d581e | 2011-04-15 01:56:01 +0900 | [diff] [blame] | 25 | FilePathWatcher::PlatformDelegate::PlatformDelegate(): cancelled_(false) { |
| 26 | } |
| 27 | |
| 28 | FilePathWatcher::PlatformDelegate::~PlatformDelegate() { |
| 29 | DCHECK(is_cancelled()); |
| 30 | } |
| 31 | |
kmadhusu@chromium.org | c9126e5 | 2012-12-05 09:36:39 +0900 | [diff] [blame] | 32 | bool FilePathWatcher::Watch(const FilePath& path, |
| 33 | bool recursive, |
| 34 | const Callback& callback) { |
| 35 | DCHECK(path.IsAbsolute()); |
darin@chromium.org | 9498d47 | 2013-01-15 09:37:47 +0900 | [diff] [blame] | 36 | return impl_->Watch(path, recursive, callback); |
joaodasilva@chromium.org | 5e57506 | 2012-06-04 23:21:27 +0900 | [diff] [blame] | 37 | } |
| 38 | |
craig.schlenter@chromium.org | b2d581e | 2011-04-15 01:56:01 +0900 | [diff] [blame] | 39 | } // namespace base |