OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2010 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 "content/common/file_path_watcher/file_path_watcher.h" |
| 9 |
| 10 #include "base/logging.h" |
| 11 #include "base/message_loop.h" |
| 12 |
| 13 FilePathWatcher::~FilePathWatcher() { |
| 14 impl_->Cancel(); |
| 15 } |
| 16 |
| 17 bool FilePathWatcher::Watch(const FilePath& path, |
| 18 Delegate* delegate, |
| 19 scoped_refptr<base::MessageLoopProxy> loop) { |
| 20 DCHECK(path.IsAbsolute()); |
| 21 impl_->set_message_loop(base::MessageLoopProxy::CreateForCurrentThread()); |
| 22 return impl_->Watch(path, delegate, loop); |
| 23 } |
| 24 |
| 25 FilePathWatcher::PlatformDelegate::~PlatformDelegate() { |
| 26 } |
| 27 |
| 28 void FilePathWatcher::PlatformDelegate::set_message_loop( |
| 29 scoped_refptr<base::MessageLoopProxy> loop) { |
| 30 CHECK(!message_loop_.get()); |
| 31 message_loop_ = loop; |
| 32 } |
| 33 |
| 34 void FilePathWatcher::DeletePlatformDelegate::Destruct( |
| 35 const PlatformDelegate* delegate) { |
| 36 scoped_refptr<base::MessageLoopProxy> loop = delegate->message_loop(); |
| 37 if (loop.get() == NULL || loop->BelongsToCurrentThread()) { |
| 38 delete delegate; |
| 39 } else { |
| 40 loop->PostNonNestableTask(FROM_HERE, |
| 41 new DeleteTask<PlatformDelegate>(delegate)); |
| 42 } |
| 43 } |
OLD | NEW |