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

Unified Diff: base/files/file_path_watcher.h

Issue 2596273003: Remove ref-counting from FilePathWatcher. (Closed)
Patch Set: self-review Created 4 years 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 | « no previous file | base/files/file_path_watcher_fsevents.h » ('j') | base/files/file_path_watcher_fsevents.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/files/file_path_watcher.h
diff --git a/base/files/file_path_watcher.h b/base/files/file_path_watcher.h
index b9ddb0d5c19943ca5fc5ca988b99deaf6022a964..9e29d0a9d5375ccd7f09fd939867e67b58ac78bb 100644
--- a/base/files/file_path_watcher.h
+++ b/base/files/file_path_watcher.h
@@ -7,6 +7,8 @@
#ifndef BASE_FILES_FILE_PATH_WATCHER_H_
#define BASE_FILES_FILE_PATH_WATCHER_H_
+#include <memory>
+
#include "base/base_export.h"
#include "base/callback.h"
#include "base/files/file_path.h"
@@ -36,9 +38,10 @@ class BASE_EXPORT FilePathWatcher {
typedef base::Callback<void(const FilePath& path, bool error)> Callback;
// Used internally to encapsulate different members on different platforms.
- class PlatformDelegate : public base::RefCountedThreadSafe<PlatformDelegate> {
+ class PlatformDelegate {
public:
PlatformDelegate();
+ virtual ~PlatformDelegate();
// Start watching for the given |path| and notify |delegate| about changes.
virtual bool Watch(const FilePath& path,
@@ -50,11 +53,8 @@ class BASE_EXPORT FilePathWatcher {
virtual void Cancel() = 0;
protected:
- friend class base::RefCountedThreadSafe<PlatformDelegate>;
friend class FilePathWatcher;
- virtual ~PlatformDelegate();
-
scoped_refptr<SequencedTaskRunner> task_runner() const {
return task_runner_;
}
@@ -75,16 +75,13 @@ class BASE_EXPORT FilePathWatcher {
private:
scoped_refptr<SequencedTaskRunner> task_runner_;
bool cancelled_;
+
+ DISALLOW_COPY_AND_ASSIGN(PlatformDelegate);
};
FilePathWatcher();
~FilePathWatcher();
- // A callback that always cleans up the PlatformDelegate, either when executed
- // or when deleted without having been executed at all, as can happen during
- // shutdown.
- static void CancelWatch(const scoped_refptr<PlatformDelegate>& delegate);
-
// Returns true if the platform and OS version support recursive watches.
static bool RecursiveWatchAvailable();
@@ -101,7 +98,7 @@ class BASE_EXPORT FilePathWatcher {
bool Watch(const FilePath& path, bool recursive, const Callback& callback);
private:
- scoped_refptr<PlatformDelegate> impl_;
+ std::unique_ptr<PlatformDelegate> impl_;
SequenceChecker sequence_checker_;
« no previous file with comments | « no previous file | base/files/file_path_watcher_fsevents.h » ('j') | base/files/file_path_watcher_fsevents.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698