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

Unified Diff: base/files/file_path_watcher_win.cc

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
Index: base/files/file_path_watcher_win.cc
diff --git a/base/files/file_path_watcher_win.cc b/base/files/file_path_watcher_win.cc
index 65c13dae74abf1194da34ca80d7278d235e60339..3557514f66e03ed951ed9f999583ca6ec9eb0d9c 100644
--- a/base/files/file_path_watcher_win.cc
+++ b/base/files/file_path_watcher_win.cc
@@ -10,6 +10,7 @@
#include "base/files/file_util.h"
#include "base/logging.h"
#include "base/macros.h"
+#include "base/memory/ptr_util.h"
#include "base/memory/ref_counted.h"
#include "base/threading/sequenced_task_runner_handle.h"
#include "base/time/time.h"
@@ -25,6 +26,7 @@ class FilePathWatcherImpl : public FilePathWatcher::PlatformDelegate,
FilePathWatcherImpl()
: handle_(INVALID_HANDLE_VALUE),
recursive_watch_(false) {}
+ ~FilePathWatcherImpl() override;
// FilePathWatcher::PlatformDelegate:
bool Watch(const FilePath& path,
@@ -36,8 +38,6 @@ class FilePathWatcherImpl : public FilePathWatcher::PlatformDelegate,
void OnObjectSignaled(HANDLE object) override;
private:
- ~FilePathWatcherImpl() override {}
-
// Setup a watch handle for directory |dir|. Set |recursive| to true to watch
// the directory sub trees. Returns true if no fatal error occurs. |handle|
// will receive the handle value if |dir| is watchable, otherwise
@@ -78,6 +78,10 @@ class FilePathWatcherImpl : public FilePathWatcher::PlatformDelegate,
DISALLOW_COPY_AND_ASSIGN(FilePathWatcherImpl);
};
+FilePathWatcherImpl::~FilePathWatcherImpl() {
+ DCHECK(!task_runner() || task_runner()->RunsTasksOnCurrentThread());
+}
+
bool FilePathWatcherImpl::Watch(const FilePath& path,
bool recursive,
const FilePathWatcher::Callback& callback) {
@@ -269,7 +273,7 @@ void FilePathWatcherImpl::DestroyWatch() {
FilePathWatcher::FilePathWatcher() {
sequence_checker_.DetachFromSequence();
- impl_ = new FilePathWatcherImpl();
+ impl_ = MakeUnique<FilePathWatcherImpl>();
}
} // namespace base
« base/files/file_path_watcher_stub.cc ('K') | « base/files/file_path_watcher_stub.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698