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

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: fix up linux clang issue, and clean up bad commented block 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
« no previous file with comments | « content/common/file_path_watcher/file_path_watcher_stub.cc ('k') | content/content_common.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 91%
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..b6b4333bf32c2befc3d2bc3bda109132807a1405 100644
--- a/chrome/browser/file_path_watcher/file_path_watcher_win.cc
+++ b/content/common/file_path_watcher/file_path_watcher_win.cc
@@ -1,12 +1,13 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 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.
-#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,
+ base::MessageLoopProxy* loop) OVERRIDE;
+ virtual void Cancel() OVERRIDE;
// Callback from MessageLoopForIO.
virtual void OnObjectSignaled(HANDLE object);
@@ -63,8 +67,11 @@ class FilePathWatcherImpl : public FilePathWatcher::PlatformDelegate,
};
bool FilePathWatcherImpl::Watch(const FilePath& path,
- FilePathWatcher::Delegate* delegate) {
+ FilePathWatcher::Delegate* delegate,
+ base::MessageLoopProxy*) {
DCHECK(target_.value().empty()); // Can only watch one path.
+
+ set_message_loop(base::MessageLoopProxy::CreateForCurrentThread());
delegate_ = delegate;
target_ = path;
@@ -77,9 +84,14 @@ bool FilePathWatcherImpl::Watch(const FilePath& path,
}
void FilePathWatcherImpl::Cancel() {
+ if (!message_loop().get()) {
+ // Watch was never called, so exit.
+ return;
+ }
+
// 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()->BelongsToCurrentThread()) {
+ message_loop()->PostTask(FROM_HERE,
NewRunnableMethod(this, &FilePathWatcherImpl::Cancel));
return;
}
« no previous file with comments | « content/common/file_path_watcher/file_path_watcher_stub.cc ('k') | content/content_common.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698