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 // Cross platform methods for FilePathWatcher. See the various platform | 5 // Cross platform methods for FilePathWatcher. See the various platform |
6 // specific implementation files, too. | 6 // specific implementation files, too. |
7 | 7 |
8 #include "content/common/file_path_watcher/file_path_watcher.h" | 8 #include "content/common/file_path_watcher/file_path_watcher.h" |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "base/message_loop.h" | 11 #include "base/message_loop.h" |
12 | 12 |
13 FilePathWatcher::~FilePathWatcher() { | 13 FilePathWatcher::~FilePathWatcher() { |
14 impl_->Cancel(); | 14 impl_->Cancel(); |
15 } | 15 } |
16 | 16 |
17 bool FilePathWatcher::Watch(const FilePath& path, | 17 bool FilePathWatcher::Watch(const FilePath& path, |
18 Delegate* delegate, | 18 Delegate* delegate, |
19 base::MessageLoopProxy* loop) { | 19 base::MessageLoopProxy* loop) { |
20 DCHECK(path.IsAbsolute()); | 20 DCHECK(path.IsAbsolute()); |
21 return impl_->Watch(path, delegate, loop); | 21 return impl_->Watch(path, delegate, loop); |
22 } | 22 } |
23 | 23 |
24 FilePathWatcher::PlatformDelegate::PlatformDelegate() { | 24 FilePathWatcher::PlatformDelegate::PlatformDelegate(): cancelled_(false) { |
25 } | 25 } |
26 | 26 |
27 FilePathWatcher::PlatformDelegate::~PlatformDelegate() { | 27 FilePathWatcher::PlatformDelegate::~PlatformDelegate() { |
| 28 DCHECK(is_cancelled()); |
28 } | 29 } |
29 | 30 |
30 void FilePathWatcher::DeletePlatformDelegate::Destruct( | |
31 const PlatformDelegate* delegate) { | |
32 scoped_refptr<base::MessageLoopProxy> loop = delegate->message_loop(); | |
33 if (loop.get() == NULL || loop->BelongsToCurrentThread()) { | |
34 delete delegate; | |
35 } else { | |
36 loop->PostNonNestableTask(FROM_HERE, | |
37 new DeleteTask<PlatformDelegate>(delegate)); | |
38 } | |
39 } | |
OLD | NEW |