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 |