Index: chrome/common/file_path_watcher/file_path_watcher.cc |
diff --git a/chrome/common/file_path_watcher/file_path_watcher.cc b/chrome/common/file_path_watcher/file_path_watcher.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..5ebffe44d97c8ac0d5f2de65ed7266a56e29d914 |
--- /dev/null |
+++ b/chrome/common/file_path_watcher/file_path_watcher.cc |
@@ -0,0 +1,43 @@ |
+// Copyright (c) 2010 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+// Cross platform methods for FilePathWatcher. See the various platform |
+// specific implementation files, too. |
+ |
+#include "chrome/common/file_path_watcher/file_path_watcher.h" |
+ |
+#include "base/logging.h" |
+#include "base/message_loop.h" |
+ |
+FilePathWatcher::~FilePathWatcher() { |
+ impl_->Cancel(); |
+} |
+ |
+bool FilePathWatcher::Watch(const FilePath& path, |
+ Delegate* delegate, |
+ scoped_refptr<base::MessageLoopProxy> loop) { |
+ DCHECK(path.IsAbsolute()); |
+ impl_->set_message_loop(base::MessageLoopProxy::CreateForCurrentThread()); |
Mattias Nissler (ping if slow)
2011/03/17 10:37:56
This effectively allows you to instantiate a watch
dmac
2011/03/17 17:16:48
Down in the implementations we check to make sure
|
+ return impl_->Watch(path, delegate, loop); |
+} |
+ |
+FilePathWatcher::PlatformDelegate::~PlatformDelegate() { |
+} |
+ |
+void FilePathWatcher::PlatformDelegate::set_message_loop( |
+ scoped_refptr<base::MessageLoopProxy> loop) { |
+ CHECK(!message_loop_.get()); |
+ message_loop_ = loop; |
+} |
+ |
+void FilePathWatcher::DeletePlatformDelegate::Destruct( |
+ const PlatformDelegate* delegate) { |
+ scoped_refptr<base::MessageLoopProxy> loop = delegate->message_loop(); |
+ if (loop.get() == NULL || loop->BelongsToCurrentThread()) { |
+ delete delegate; |
+ } else { |
+ loop->PostNonNestableTask(FROM_HERE, |
+ new DeleteTask<PlatformDelegate>(delegate)); |
+ } |
+} |