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 { |
| 14 | namespace files { |
| 15 | |
| 16 | FilePathWatcher::~FilePathWatcher() { |
| 17 | impl_->Cancel(); |
| 18 | } |
| 19 | |
jhawkins@chromium.org | fce1f41 | 2011-11-24 05:44:00 +0900 | [diff] [blame^] | 20 | // static |
| 21 | void FilePathWatcher::CancelWatch( |
| 22 | const scoped_refptr<PlatformDelegate>& delegate) { |
| 23 | delegate->CancelOnMessageLoopThread(); |
| 24 | } |
| 25 | |
craig.schlenter@chromium.org | b2d581e | 2011-04-15 01:56:01 +0900 | [diff] [blame] | 26 | bool FilePathWatcher::Watch(const FilePath& path, Delegate* delegate) { |
| 27 | DCHECK(path.IsAbsolute()); |
| 28 | return impl_->Watch(path, delegate); |
| 29 | } |
| 30 | |
| 31 | FilePathWatcher::PlatformDelegate::PlatformDelegate(): cancelled_(false) { |
| 32 | } |
| 33 | |
| 34 | FilePathWatcher::PlatformDelegate::~PlatformDelegate() { |
| 35 | DCHECK(is_cancelled()); |
| 36 | } |
| 37 | |
| 38 | } // namespace files |
| 39 | } // namespace base |