Chromium Code Reviews| Index: chrome/common/file_path_watcher/file_path_watcher_win.cc |
| diff --git a/chrome/browser/file_path_watcher/file_path_watcher_win.cc b/chrome/common/file_path_watcher/file_path_watcher_win.cc |
| similarity index 93% |
| rename from chrome/browser/file_path_watcher/file_path_watcher_win.cc |
| rename to chrome/common/file_path_watcher/file_path_watcher_win.cc |
| index c2f49b937ca55a352853e9b79e44a2ffcad28e2e..4d4ff65f1ee307a40bade1613417f473ec883b11 100644 |
| --- a/chrome/browser/file_path_watcher/file_path_watcher_win.cc |
| +++ b/chrome/common/file_path_watcher/file_path_watcher_win.cc |
| @@ -2,11 +2,12 @@ |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| -#include "chrome/browser/file_path_watcher/file_path_watcher.h" |
| +#include "chrome/common/file_path_watcher/file_path_watcher.h" |
| #include "base/file_path.h" |
| #include "base/file_util.h" |
| #include "base/logging.h" |
| +#include "base/message_loop_proxy.h" |
| #include "base/ref_counted.h" |
| #include "base/time.h" |
| #include "base/win/object_watcher.h" |
| @@ -18,8 +19,11 @@ class FilePathWatcherImpl : public FilePathWatcher::PlatformDelegate, |
| public: |
| FilePathWatcherImpl() : delegate_(NULL), handle_(INVALID_HANDLE_VALUE) {} |
| - virtual bool Watch(const FilePath& path, FilePathWatcher::Delegate* delegate); |
| - virtual void Cancel(); |
| + // FilePathWatcher::PlatformDelegate overrides. |
| + virtual bool Watch(const FilePath& path, |
| + FilePathWatcher::Delegate* delegate, |
| + scoped_refptr<base::MessageLoopProxy> loop) OVERRIDE; |
| + virtual void Cancel() OVERRIDE; |
| // Callback from MessageLoopForIO. |
| virtual void OnObjectSignaled(HANDLE object); |
| @@ -63,7 +67,8 @@ class FilePathWatcherImpl : public FilePathWatcher::PlatformDelegate, |
| }; |
| bool FilePathWatcherImpl::Watch(const FilePath& path, |
| - FilePathWatcher::Delegate* delegate) { |
| + FilePathWatcher::Delegate* delegate, |
| + scoped_refptr<base::MessageLoopProxy>) { |
| DCHECK(target_.value().empty()); // Can only watch one path. |
| delegate_ = delegate; |
| target_ = path; |
| @@ -78,8 +83,9 @@ bool FilePathWatcherImpl::Watch(const FilePath& path, |
| void FilePathWatcherImpl::Cancel() { |
| // Switch to the file thread if necessary so we can stop |watcher_|. |
| - if (!BrowserThread::CurrentlyOn(BrowserThread::FILE)) { |
| - BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, |
| + if (message_loop().get() && |
|
Mattias Nissler (ping if slow)
2011/03/17 10:37:56
Same comment as for Mac.
dmac
2011/03/17 17:16:48
Done.
|
| + !message_loop()->BelongsToCurrentThread()) { |
| + message_loop()->PostTask(FROM_HERE, |
| NewRunnableMethod(this, &FilePathWatcherImpl::Cancel)); |
| return; |
| } |