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

Unified Diff: chrome/common/file_path_watcher/file_path_watcher.cc

Issue 6670081: Move FilePathWatcher class from browser/... to common/... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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: 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));
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698