| Index: chrome/common/file_path_watcher/file_path_watcher.h
|
| diff --git a/chrome/browser/file_path_watcher/file_path_watcher.h b/chrome/common/file_path_watcher/file_path_watcher.h
|
| similarity index 54%
|
| rename from chrome/browser/file_path_watcher/file_path_watcher.h
|
| rename to chrome/common/file_path_watcher/file_path_watcher.h
|
| index 530962e3e8ee6da239d8a8d3e762b833b4f1f731..8c3551d3fa51cb68aa330f42ab6c5ba126b0dbef 100644
|
| --- a/chrome/browser/file_path_watcher/file_path_watcher.h
|
| +++ b/chrome/common/file_path_watcher/file_path_watcher.h
|
| @@ -4,14 +4,14 @@
|
|
|
| // This module provides a way to monitor a file or directory for changes.
|
|
|
| -#ifndef CHROME_BROWSER_FILE_PATH_WATCHER_FILE_PATH_WATCHER_H_
|
| -#define CHROME_BROWSER_FILE_PATH_WATCHER_FILE_PATH_WATCHER_H_
|
| +#ifndef CHROME_COMMON_FILE_PATH_WATCHER_FILE_PATH_WATCHER_H_
|
| +#define CHROME_COMMON_FILE_PATH_WATCHER_FILE_PATH_WATCHER_H_
|
| #pragma once
|
|
|
| #include "base/basictypes.h"
|
| #include "base/file_path.h"
|
| +#include "base/message_loop_proxy.h"
|
| #include "base/ref_counted.h"
|
| -#include "content/browser/browser_thread.h"
|
|
|
| // This class lets you register interest in changes on a FilePath.
|
| // The delegate will get called whenever the file or directory referenced by the
|
| @@ -36,27 +36,53 @@ class FilePathWatcher {
|
| ~FilePathWatcher();
|
|
|
| // Register interest in any changes on |path|. OnPathChanged will be called
|
| - // back for each change. Returns true on success.
|
| - bool Watch(const FilePath& path, Delegate* delegate) WARN_UNUSED_RESULT;
|
| + // back for each change. Returns true on success. |loop| is only used
|
| + // by the Mac implementation right now, and must be backed by a CFRunLoop
|
| + // based MessagePump. This is usually going to be a MessageLoop of type
|
| + // TYPE_UI.
|
| + bool Watch(const FilePath& path,
|
| + Delegate* delegate,
|
| + scoped_refptr<base::MessageLoopProxy> loop) WARN_UNUSED_RESULT;
|
| +
|
| + class PlatformDelegate;
|
| +
|
| + // Traits for PlatformDelegate, which must delete itself on the IO message
|
| + // loop that Watch was called from.
|
| + struct DeletePlatformDelegate {
|
| + static void Destruct(const PlatformDelegate* delegate);
|
| + };
|
|
|
| // Used internally to encapsulate different members on different platforms.
|
| class PlatformDelegate
|
| : public base::RefCountedThreadSafe<PlatformDelegate,
|
| - BrowserThread::DeleteOnFileThread> {
|
| + DeletePlatformDelegate> {
|
| public:
|
| // Start watching for the given |path| and notify |delegate| about changes.
|
| - virtual bool Watch(const FilePath& path, Delegate* delegate)
|
| - WARN_UNUSED_RESULT = 0;
|
| + // |loop| is only used by the Mac implementation right now, and must be
|
| + // backed by a CFRunLoop based MessagePump. This is usually going to be a
|
| + // MessageLoop of type TYPE_UI.
|
| + virtual bool Watch(
|
| + const FilePath& path,
|
| + Delegate* delegate,
|
| + scoped_refptr<base::MessageLoopProxy> loop) WARN_UNUSED_RESULT = 0;
|
|
|
| // Stop watching. This is called from FilePathWatcher's dtor in order to
|
| // allow to shut down properly while the object is still alive.
|
| - virtual void Cancel() {}
|
| + virtual void Cancel() = 0;
|
| +
|
| + scoped_refptr<base::MessageLoopProxy> message_loop() const {
|
| + return message_loop_;
|
| + }
|
| + void set_message_loop(scoped_refptr<base::MessageLoopProxy> loop);
|
|
|
| protected:
|
| - friend struct BrowserThread::DeleteOnThread<BrowserThread::FILE>;
|
| friend class DeleteTask<PlatformDelegate>;
|
| + friend struct DeletePlatformDelegate;
|
| + virtual ~PlatformDelegate();
|
|
|
| - virtual ~PlatformDelegate() {}
|
| + private:
|
| + // IO Message Loop.
|
| + scoped_refptr<base::MessageLoopProxy> message_loop_;
|
| };
|
|
|
| private:
|
| @@ -65,4 +91,4 @@ class FilePathWatcher {
|
| DISALLOW_COPY_AND_ASSIGN(FilePathWatcher);
|
| };
|
|
|
| -#endif // CHROME_BROWSER_FILE_PATH_WATCHER_FILE_PATH_WATCHER_H_
|
| +#endif // CHROME_COMMON_FILE_PATH_WATCHER_FILE_PATH_WATCHER_H_
|
|
|