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

Unified Diff: base/files/file_path_watcher_mac.cc

Issue 2596273003: Remove ref-counting from FilePathWatcher. (Closed)
Patch Set: fix mac build error Created 3 years, 11 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
« no previous file with comments | « base/files/file_path_watcher_linux.cc ('k') | base/files/file_path_watcher_stub.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/files/file_path_watcher_mac.cc
diff --git a/base/files/file_path_watcher_mac.cc b/base/files/file_path_watcher_mac.cc
index d59ca2156beb79705fa0f76c6817702d70f4dd62..2520b9288ae9e2dfcf3371cf117584e954010df9 100644
--- a/base/files/file_path_watcher_mac.cc
+++ b/base/files/file_path_watcher_mac.cc
@@ -2,8 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include <memory>
+
#include "base/files/file_path_watcher.h"
#include "base/files/file_path_watcher_kqueue.h"
+#include "base/macros.h"
+#include "base/memory/ptr_util.h"
#include "build/build_config.h"
#if !defined(OS_IOS)
@@ -16,6 +20,9 @@ namespace {
class FilePathWatcherImpl : public FilePathWatcher::PlatformDelegate {
public:
+ FilePathWatcherImpl() = default;
+ ~FilePathWatcherImpl() override = default;
+
bool Watch(const FilePath& path,
bool recursive,
const FilePathWatcher::Callback& callback) override {
@@ -25,10 +32,10 @@ class FilePathWatcherImpl : public FilePathWatcher::PlatformDelegate {
if (!FilePathWatcher::RecursiveWatchAvailable())
return false;
#if !defined(OS_IOS)
- impl_ = new FilePathWatcherFSEvents();
+ impl_ = MakeUnique<FilePathWatcherFSEvents>();
#endif // OS_IOS
} else {
- impl_ = new FilePathWatcherKQueue();
+ impl_ = MakeUnique<FilePathWatcherKQueue>();
}
DCHECK(impl_.get());
return impl_->Watch(path, recursive, callback);
@@ -40,17 +47,17 @@ class FilePathWatcherImpl : public FilePathWatcher::PlatformDelegate {
set_cancelled();
}
- protected:
- ~FilePathWatcherImpl() override {}
+ private:
+ std::unique_ptr<PlatformDelegate> impl_;
- scoped_refptr<PlatformDelegate> impl_;
+ DISALLOW_COPY_AND_ASSIGN(FilePathWatcherImpl);
};
} // namespace
FilePathWatcher::FilePathWatcher() {
sequence_checker_.DetachFromSequence();
- impl_ = new FilePathWatcherImpl();
+ impl_ = MakeUnique<FilePathWatcherImpl>();
}
} // namespace base
« no previous file with comments | « base/files/file_path_watcher_linux.cc ('k') | base/files/file_path_watcher_stub.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698