Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1162)

Unified Diff: content/common/file_path_watcher/file_path_watcher_win.cc

Issue 6670081: Move FilePathWatcher class from browser/... to common/... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed comments Created 9 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/common/file_path_watcher/file_path_watcher_win.cc
diff --git a/chrome/browser/file_path_watcher/file_path_watcher_win.cc b/content/common/file_path_watcher/file_path_watcher_win.cc
similarity index 92%
rename from chrome/browser/file_path_watcher/file_path_watcher_win.cc
rename to content/common/file_path_watcher/file_path_watcher_win.cc
index c2f49b937ca55a352853e9b79e44a2ffcad28e2e..cf0318dd71cbde3267bf75c57a8bcd56289f17c7 100644
--- a/chrome/browser/file_path_watcher/file_path_watcher_win.cc
+++ b/content/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 "content/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;
@@ -77,9 +82,13 @@ 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()) {
+ // Watch was never called, so exit.
+ return;
+ }
+ // Switch to the file thread if necessary so we can stop |watcher_|.
Mattias Nissler (ping if slow) 2011/03/17 18:14:27 indentation
+ if (!message_loop()->BelongsToCurrentThread()) {
+ message_loop()->PostTask(FROM_HERE,
NewRunnableMethod(this, &FilePathWatcherImpl::Cancel));
return;
}

Powered by Google App Engine
This is Rietveld 408576698