RefCounted types should not have public destructors, base/ edition
BUG=123295
TEST=none
Review URL: http://codereview.chromium.org/10065037
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@133825 0039d316-1c4b-4281-b951-d872f2087c98
CrOS-Libchrome-Original-Commit: a9aaa9d16ba4bfc0a1e765d349cae8470301749e
diff --git a/base/files/file_path_watcher.h b/base/files/file_path_watcher.h
index 3174a9e..3140628 100644
--- a/base/files/file_path_watcher.h
+++ b/base/files/file_path_watcher.h
@@ -33,11 +33,14 @@
// corresponding FileWatcher object to prevent a reference cycle.
class Delegate : public base::RefCountedThreadSafe<Delegate> {
public:
- virtual ~Delegate() {}
virtual void OnFilePathChanged(const FilePath& path) = 0;
// Called when platform specific code detected an error. The watcher will
// not call OnFilePathChanged for future changes.
virtual void OnFilePathError(const FilePath& path) {}
+
+ protected:
+ friend class base::RefCountedThreadSafe<Delegate>;
+ virtual ~Delegate() {}
};
// Used internally to encapsulate different members on different platforms.
@@ -57,6 +60,7 @@
virtual void Cancel() = 0;
protected:
+ friend class base::RefCountedThreadSafe<PlatformDelegate>;
friend class FilePathWatcher;
virtual ~PlatformDelegate();
@@ -84,8 +88,6 @@
}
private:
- friend class base::RefCountedThreadSafe<PlatformDelegate>;
-
scoped_refptr<base::MessageLoopProxy> message_loop_;
bool cancelled_;
};
diff --git a/base/files/file_path_watcher_browsertest.cc b/base/files/file_path_watcher_browsertest.cc
index 495f4d3..7886df8 100644
--- a/base/files/file_path_watcher_browsertest.cc
+++ b/base/files/file_path_watcher_browsertest.cc
@@ -65,6 +65,9 @@
}
private:
+ friend class base::RefCountedThreadSafe<NotificationCollector>;
+ ~NotificationCollector() {}
+
void RecordChange(TestDelegate* delegate) {
ASSERT_TRUE(loop_->BelongsToCurrentThread());
ASSERT_TRUE(delegates_.count(delegate));
@@ -107,6 +110,9 @@
ADD_FAILURE() << "Error " << path.value();
}
+ protected:
+ virtual ~TestDelegate() {}
+
private:
scoped_refptr<NotificationCollector> collector_;
@@ -249,6 +255,9 @@
scoped_ptr<FilePathWatcher> watcher_;
MessageLoop* loop_;
+
+ private:
+ virtual ~Deleter() {}
};
// Verify that deleting a watcher during the callback doesn't crash.
diff --git a/base/files/file_path_watcher_kqueue.cc b/base/files/file_path_watcher_kqueue.cc
index d4ddb7d..29c104a 100644
--- a/base/files/file_path_watcher_kqueue.cc
+++ b/base/files/file_path_watcher_kqueue.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -54,7 +54,6 @@
public MessageLoop::DestructionObserver {
public:
FilePathWatcherImpl() : kqueue_(-1) {}
- virtual ~FilePathWatcherImpl() {}
// MessageLoopForIO::Watcher overrides.
virtual void OnFileCanReadWithoutBlocking(int fd) OVERRIDE;
@@ -68,6 +67,9 @@
FilePathWatcher::Delegate* delegate) OVERRIDE;
virtual void Cancel() OVERRIDE;
+ protected:
+ virtual ~FilePathWatcherImpl() {}
+
private:
class EventData {
public:
diff --git a/base/files/file_path_watcher_linux.cc b/base/files/file_path_watcher_linux.cc
index 72c8610..4bdfe74 100644
--- a/base/files/file_path_watcher_linux.cc
+++ b/base/files/file_path_watcher_linux.cc
@@ -110,9 +110,10 @@
// cleanup thread, in case it quits before Cancel() is called.
virtual void WillDestroyCurrentMessageLoop() OVERRIDE;
- private:
+ protected:
virtual ~FilePathWatcherImpl() {}
+ private:
// Cleans up and stops observing the |message_loop_| thread.
void CancelOnMessageLoopThread() OVERRIDE;
diff --git a/base/files/file_path_watcher_stub.cc b/base/files/file_path_watcher_stub.cc
index 6c49101..d91c1a7 100644
--- a/base/files/file_path_watcher_stub.cc
+++ b/base/files/file_path_watcher_stub.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -22,6 +22,9 @@
virtual void Cancel() OVERRIDE {}
virtual void CancelOnMessageLoopThread() OVERRIDE {}
+
+ protected:
+ virtual ~FilePathWatcherImpl() {}
};
} // namespace