From c56428f24b67efa6a2eff77a709b7b6489403617 Mon Sep 17 00:00:00 2001
From: "ajwong@chromium.org"
 <ajwong@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>
Date: Wed, 16 Jun 2010 02:17:23 +0000
Subject: Add DISABLE_RUNNABLE_METHOD_REFCOUNT to make disabling refcounts in
 RunnableMethods easier.

BUG=none
TEST=none

Review URL: http://codereview.chromium.org/2830006

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@49887 0039d316-1c4b-4281-b951-d872f2087c98
---
 chrome/browser/browser_process_impl.cc                            | 6 +-----
 chrome/browser/browsing_data_remover.cc                           | 6 +-----
 chrome/browser/chrome_plugin_host.cc                              | 6 +-----
 chrome/browser/chromeos/cros/language_library.cc                  | 6 +-----
 chrome/browser/chromeos/cros/mount_library.cc                     | 6 +-----
 chrome/browser/chromeos/cros/network_library.cc                   | 6 +-----
 chrome/browser/chromeos/cros/power_library.cc                     | 6 +-----
 chrome/browser/chromeos/cros/screen_lock_library.cc               | 6 +-----
 chrome/browser/crash_handler_host_linux.cc                        | 5 +----
 chrome/browser/dom_ui/chrome_url_data_manager.h                   | 5 +----
 chrome/browser/dom_ui/mediaplayer_ui.cc                           | 6 +-----
 chrome/browser/extensions/extension_error_reporter.cc             | 5 +----
 chrome/browser/gears_integration.cc                               | 6 +-----
 chrome/browser/history/history_unittest.cc                        | 6 +-----
 chrome/browser/io_thread.cc                                       | 6 +-----
 chrome/browser/sync/engine/syncapi.cc                             | 6 +-----
 chrome/browser/web_applications/web_app.cc                        | 6 +-----
 chrome/common/net/fake_network_change_notifier_thread.cc          | 8 ++------
 chrome/common/net/fake_network_change_notifier_thread_unittest.cc | 6 +-----
 chrome/common/net/notifier/listener/mediator_thread_impl.cc       | 6 +-----
 chrome/common/net/thread_blocker.cc                               | 6 +-----
 chrome/common/net/thread_blocker_unittest.cc                      | 6 +-----
 22 files changed, 23 insertions(+), 108 deletions(-)

(limited to 'chrome')

diff --git a/chrome/browser/browser_process_impl.cc b/chrome/browser/browser_process_impl.cc
index a9cda45..a74f5ab 100644
--- a/chrome/browser/browser_process_impl.cc
+++ b/chrome/browser/browser_process_impl.cc
@@ -463,11 +463,7 @@ void BrowserProcessImpl::CreateStatusTrayManager() {
 
 // The BrowserProcess object must outlive the file thread so we use traits
 // which don't do any management.
-template <>
-struct RunnableMethodTraits<BrowserProcessImpl> {
-  void RetainCallee(BrowserProcessImpl* process) {}
-  void ReleaseCallee(BrowserProcessImpl* process) {}
-};
+DISABLE_RUNNABLE_METHOD_REFCOUNT(BrowserProcessImpl);
 
 void BrowserProcessImpl::CheckForInspectorFiles() {
   file_thread()->message_loop()->PostTask
diff --git a/chrome/browser/browsing_data_remover.cc b/chrome/browser/browsing_data_remover.cc
index dac2404..61a1cb6 100644
--- a/chrome/browser/browsing_data_remover.cc
+++ b/chrome/browser/browsing_data_remover.cc
@@ -31,11 +31,7 @@
 
 // Done so that we can use PostTask on BrowsingDataRemovers and not have
 // BrowsingDataRemover implement RefCounted.
-template <>
-struct RunnableMethodTraits<BrowsingDataRemover> {
-  void RetainCallee(BrowsingDataRemover* remover) {}
-  void ReleaseCallee(BrowsingDataRemover* remover) {}
-};
+DISABLE_RUNNABLE_METHOD_REFCOUNT(BrowsingDataRemover);
 
 bool BrowsingDataRemover::removing_ = false;
 
diff --git a/chrome/browser/chrome_plugin_host.cc b/chrome/browser/chrome_plugin_host.cc
index 4d45f93..dc06c09 100644
--- a/chrome/browser/chrome_plugin_host.cc
+++ b/chrome/browser/chrome_plugin_host.cc
@@ -369,11 +369,7 @@ class ModelessHtmlDialogDelegate : public HtmlDialogUIDelegate {
 
 // Allows InvokeLater without adding refcounting.  The object is only deleted
 // when its last InvokeLater is run anyway.
-template <>
-struct RunnableMethodTraits<ModelessHtmlDialogDelegate> {
-  void RetainCallee(ModelessHtmlDialogDelegate* delegate) {}
-  void ReleaseCallee(ModelessHtmlDialogDelegate* delegate) {}
-};
+DISABLE_RUNNABLE_METHOD_REFCOUNT(ModelessHtmlDialogDelegate);
 
 namespace {
 
diff --git a/chrome/browser/chromeos/cros/language_library.cc b/chrome/browser/chromeos/cros/language_library.cc
index f7346bc..022d58c 100644
--- a/chrome/browser/chromeos/cros/language_library.cc
+++ b/chrome/browser/chromeos/cros/language_library.cc
@@ -15,11 +15,7 @@
 
 // Allows InvokeLater without adding refcounting. This class is a Singleton and
 // won't be deleted until it's last InvokeLater is run.
-template <>
-struct RunnableMethodTraits<chromeos::LanguageLibraryImpl> {
-  void RetainCallee(chromeos::LanguageLibraryImpl* obj) {}
-  void ReleaseCallee(chromeos::LanguageLibraryImpl* obj) {}
-};
+DISABLE_RUNNABLE_METHOD_REFCOUNT(chromeos::LanguageLibraryImpl);
 
 namespace {
 
diff --git a/chrome/browser/chromeos/cros/mount_library.cc b/chrome/browser/chromeos/cros/mount_library.cc
index 74de250..894bccf8 100644
--- a/chrome/browser/chromeos/cros/mount_library.cc
+++ b/chrome/browser/chromeos/cros/mount_library.cc
@@ -11,11 +11,7 @@
 
 // Allows InvokeLater without adding refcounting. This class is a Singleton and
 // won't be deleted until it's last InvokeLater is run.
-template <>
-struct RunnableMethodTraits<chromeos::MountLibraryImpl> {
-  void RetainCallee(chromeos::MountLibraryImpl* obj) {}
-  void ReleaseCallee(chromeos::MountLibraryImpl* obj) {}
-};
+DISABLE_RUNNABLE_METHOD_REFCOUNT(chromeos::MountLibraryImpl);
 
 namespace chromeos {
 
diff --git a/chrome/browser/chromeos/cros/network_library.cc b/chrome/browser/chromeos/cros/network_library.cc
index 9af0847..28a4364 100644
--- a/chrome/browser/chromeos/cros/network_library.cc
+++ b/chrome/browser/chromeos/cros/network_library.cc
@@ -14,11 +14,7 @@
 
 // Allows InvokeLater without adding refcounting. This class is a Singleton and
 // won't be deleted until it's last InvokeLater is run.
-template <>
-struct RunnableMethodTraits<chromeos::NetworkLibraryImpl> {
-  void RetainCallee(chromeos::NetworkLibraryImpl* obj) {}
-  void ReleaseCallee(chromeos::NetworkLibraryImpl* obj) {}
-};
+DISABLE_RUNNABLE_METHOD_REFCOUNT(chromeos::NetworkLibraryImpl);
 
 namespace chromeos {
 
diff --git a/chrome/browser/chromeos/cros/power_library.cc b/chrome/browser/chromeos/cros/power_library.cc
index 112f43c..42978aa 100644
--- a/chrome/browser/chromeos/cros/power_library.cc
+++ b/chrome/browser/chromeos/cros/power_library.cc
@@ -11,11 +11,7 @@
 
 // Allows InvokeLater without adding refcounting. This class is a Singleton and
 // won't be deleted until it's last InvokeLater is run.
-template <>
-struct RunnableMethodTraits<chromeos::PowerLibraryImpl> {
-  void RetainCallee(chromeos::PowerLibraryImpl* obj) {}
-  void ReleaseCallee(chromeos::PowerLibraryImpl* obj) {}
-};
+DISABLE_RUNNABLE_METHOD_REFCOUNT(chromeos::PowerLibraryImpl);
 
 namespace chromeos {
 
diff --git a/chrome/browser/chromeos/cros/screen_lock_library.cc b/chrome/browser/chromeos/cros/screen_lock_library.cc
index 5786c6c..d9fca88 100644
--- a/chrome/browser/chromeos/cros/screen_lock_library.cc
+++ b/chrome/browser/chromeos/cros/screen_lock_library.cc
@@ -11,11 +11,7 @@
 
 // Allows InvokeLater without adding refcounting. This class is a Singleton and
 // won't be deleted until it's last InvokeLater is run.
-template <>
-struct RunnableMethodTraits<chromeos::ScreenLockLibraryImpl> {
-  void RetainCallee(chromeos::ScreenLockLibraryImpl* obj) {}
-  void ReleaseCallee(chromeos::ScreenLockLibraryImpl* obj) {}
-};
+DISABLE_RUNNABLE_METHOD_REFCOUNT(chromeos::ScreenLockLibraryImpl);
 
 namespace chromeos {
 
diff --git a/chrome/browser/crash_handler_host_linux.cc b/chrome/browser/crash_handler_host_linux.cc
index 34166d6..b23b7ea 100644
--- a/chrome/browser/crash_handler_host_linux.cc
+++ b/chrome/browser/crash_handler_host_linux.cc
@@ -30,10 +30,7 @@
 // Since classes derived from CrashHandlerHostLinux are singletons, it's only
 // destroyed at the end of the processes lifetime, which is greater in span than
 // the lifetime of the IO message loop.
-template<> struct RunnableMethodTraits<CrashHandlerHostLinux> {
-  void RetainCallee(CrashHandlerHostLinux*) { }
-  void ReleaseCallee(CrashHandlerHostLinux*) { }
-};
+DISABLE_RUNNABLE_METHOD_REFCOUNT(CrashHandlerHostLinux);
 
 CrashHandlerHostLinux::CrashHandlerHostLinux()
     : process_socket_(-1),
diff --git a/chrome/browser/dom_ui/chrome_url_data_manager.h b/chrome/browser/dom_ui/chrome_url_data_manager.h
index 0247a2b..f08daaf 100644
--- a/chrome/browser/dom_ui/chrome_url_data_manager.h
+++ b/chrome/browser/dom_ui/chrome_url_data_manager.h
@@ -159,10 +159,7 @@ class ChromeURLDataManager {
 
 // Since we have a single global ChromeURLDataManager, we don't need to
 // grab a reference to it when creating Tasks involving it.
-template <> struct RunnableMethodTraits<ChromeURLDataManager> {
-  void RetainCallee(ChromeURLDataManager* manager) {}
-  void ReleaseCallee(ChromeURLDataManager* manager) {}
-};
+DISABLE_RUNNABLE_METHOD_REFCOUNT(ChromeURLDataManager);
 
 // Register our special URL handler under our special URL scheme.
 // Must be done once at startup.
diff --git a/chrome/browser/dom_ui/mediaplayer_ui.cc b/chrome/browser/dom_ui/mediaplayer_ui.cc
index a3e8bcd..e35df55 100644
--- a/chrome/browser/dom_ui/mediaplayer_ui.cc
+++ b/chrome/browser/dom_ui/mediaplayer_ui.cc
@@ -345,11 +345,7 @@ void MediaplayerHandler::HandleTogglePlaylist(const Value* value) {
 
 // Allows InvokeLater without adding refcounting. This class is a Singleton and
 // won't be deleted until it's last InvokeLater is run.
-template <>
-struct RunnableMethodTraits<MediaPlayer> {
-  void RetainCallee(MediaPlayer* obj) {}
-  void ReleaseCallee(MediaPlayer* obj) {}
-};
+DISABLE_RUNNABLE_METHOD_REFCOUNT(MediaPlayer);
 
 void MediaPlayer::EnqueueMediaURL(const GURL& url, Browser* creator) {
   if (handler_ == NULL) {
diff --git a/chrome/browser/extensions/extension_error_reporter.cc b/chrome/browser/extensions/extension_error_reporter.cc
index 92f854e..00ffb85 100644
--- a/chrome/browser/extensions/extension_error_reporter.cc
+++ b/chrome/browser/extensions/extension_error_reporter.cc
@@ -14,10 +14,7 @@
 // No AddRef required when using ExtensionErrorReporter with RunnableMethod.
 // This is okay since the ExtensionErrorReporter is a singleton that lives until
 // the end of the process.
-template <> struct RunnableMethodTraits<ExtensionErrorReporter> {
-  void RetainCallee(ExtensionErrorReporter*) {}
-  void ReleaseCallee(ExtensionErrorReporter*) {}
-};
+DISABLE_RUNNABLE_METHOD_REFCOUNT(ExtensionErrorReporter);
 
 ExtensionErrorReporter* ExtensionErrorReporter::instance_ = NULL;
 
diff --git a/chrome/browser/gears_integration.cc b/chrome/browser/gears_integration.cc
index e29f224..5cfad85 100644
--- a/chrome/browser/gears_integration.cc
+++ b/chrome/browser/gears_integration.cc
@@ -228,11 +228,7 @@ class CreateShortcutCommand : public CPCommandInterface {
 
 // Allows InvokeLater without adding refcounting.  The object is only deleted
 // when its last InvokeLater is run anyway.
-template <>
-struct RunnableMethodTraits<CreateShortcutCommand> {
-  void RetainCallee(CreateShortcutCommand* command) {}
-  void ReleaseCallee(CreateShortcutCommand* command) {}
-};
+DISABLE_RUNNABLE_METHOD_REFCOUNT(CreateShortcutCommand);
 
 void GearsCreateShortcut(
     const webkit_glue::WebApplicationInfo& app_info,
diff --git a/chrome/browser/history/history_unittest.cc b/chrome/browser/history/history_unittest.cc
index 1886cdc..be0cd0a 100644
--- a/chrome/browser/history/history_unittest.cc
+++ b/chrome/browser/history/history_unittest.cc
@@ -58,11 +58,7 @@ class HistoryTest;
 // Specialize RunnableMethodTraits for HistoryTest so we can create callbacks.
 // None of these callbacks can outlast the test, so there is not need to retain
 // the HistoryTest object.
-template <>
-struct RunnableMethodTraits<history::HistoryTest> {
-  void RetainCallee(history::HistoryTest* obj) { }
-  void ReleaseCallee(history::HistoryTest* obj) { }
-};
+DISABLE_RUNNABLE_METHOD_REFCOUNT(history::HistoryTest);
 
 namespace history {
 
diff --git a/chrome/browser/io_thread.cc b/chrome/browser/io_thread.cc
index 5dfd284..5fcdb3d 100644
--- a/chrome/browser/io_thread.cc
+++ b/chrome/browser/io_thread.cc
@@ -81,11 +81,7 @@ net::HostResolver* CreateGlobalHostResolver(
 
 // The IOThread object must outlive any tasks posted to the IO thread before the
 // Quit task.
-template <>
-struct RunnableMethodTraits<IOThread> {
-  void RetainCallee(IOThread* /* io_thread */) {}
-  void ReleaseCallee(IOThread* /* io_thread */) {}
-};
+DISABLE_RUNNABLE_METHOD_REFCOUNT(IOThread);
 
 IOThread::IOThread()
     : BrowserProcessSubThread(ChromeThread::IO),
diff --git a/chrome/browser/sync/engine/syncapi.cc b/chrome/browser/sync/engine/syncapi.cc
index 754ddae..452e584 100644
--- a/chrome/browser/sync/engine/syncapi.cc
+++ b/chrome/browser/sync/engine/syncapi.cc
@@ -85,11 +85,7 @@ static const int kThreadExitTimeoutMsec = 60000;
 static const int kSSLPort = 443;
 
 // We manage the lifetime of sync_api::SyncManager::SyncInternal ourselves.
-template <>
-struct RunnableMethodTraits<sync_api::SyncManager::SyncInternal> {
-  void RetainCallee(sync_api::SyncManager::SyncInternal*) {}
-  void ReleaseCallee(sync_api::SyncManager::SyncInternal*) {}
-};
+DISABLE_RUNNABLE_METHOD_REFCOUNT(sync_api::SyncManager::SyncInternal);
 
 namespace sync_api {
 
diff --git a/chrome/browser/web_applications/web_app.cc b/chrome/browser/web_applications/web_app.cc
index e1dc105..fce3da3 100644
--- a/chrome/browser/web_applications/web_app.cc
+++ b/chrome/browser/web_applications/web_app.cc
@@ -678,11 +678,7 @@ void UpdateShortcutWorker::DeleteMeOnUIThread() {
 #if defined(OS_WIN)
 // Allows UpdateShortcutWorker without adding refcounting. UpdateShortcutWorker
 // manages its own life time and will delete itself when it's done.
-template <>
-struct RunnableMethodTraits<UpdateShortcutWorker> {
-  void RetainCallee(UpdateShortcutWorker* worker) {}
-  void ReleaseCallee(UpdateShortcutWorker* worker) {}
-};
+DISABLE_RUNNABLE_METHOD_REFCOUNT(UpdateShortcutWorker);
 #endif  // defined(OS_WIN)
 
 namespace web_app {
diff --git a/chrome/common/net/fake_network_change_notifier_thread.cc b/chrome/common/net/fake_network_change_notifier_thread.cc
index 6c22d48..b8059ab 100644
--- a/chrome/common/net/fake_network_change_notifier_thread.cc
+++ b/chrome/common/net/fake_network_change_notifier_thread.cc
@@ -11,12 +11,8 @@
 
 // We manage the lifetime of
 // chrome_common_net::FakeNetworkChangeNotifierThread ourselves.
-template <>
-struct RunnableMethodTraits<chrome_common_net::
-    FakeNetworkChangeNotifierThread> {
-  void RetainCallee(chrome_common_net::FakeNetworkChangeNotifierThread*) {}
-  void ReleaseCallee(chrome_common_net::FakeNetworkChangeNotifierThread*) {}
-};
+DISABLE_RUNNABLE_METHOD_REFCOUNT(
+    chrome_common_net::FakeNetworkChangeNotifierThread);
 
 namespace chrome_common_net {
 
diff --git a/chrome/common/net/fake_network_change_notifier_thread_unittest.cc b/chrome/common/net/fake_network_change_notifier_thread_unittest.cc
index 3902888..25eb1ec9 100644
--- a/chrome/common/net/fake_network_change_notifier_thread_unittest.cc
+++ b/chrome/common/net/fake_network_change_notifier_thread_unittest.cc
@@ -16,11 +16,7 @@ class FlagToggler;
 }  // namespace chrome_common_net
 
 // We manage the lifetime of chrome_common_net::FlagToggler ourselves.
-template <>
-struct RunnableMethodTraits<chrome_common_net::FlagToggler> {
-  void RetainCallee(chrome_common_net::FlagToggler*) {}
-  void ReleaseCallee(chrome_common_net::FlagToggler*) {}
-};
+DISABLE_RUNNABLE_METHOD_REFCOUNT(chrome_common_net::FlagToggler);
 
 namespace chrome_common_net {
 
diff --git a/chrome/common/net/notifier/listener/mediator_thread_impl.cc b/chrome/common/net/notifier/listener/mediator_thread_impl.cc
index ac88983..d15e2c8 100644
--- a/chrome/common/net/notifier/listener/mediator_thread_impl.cc
+++ b/chrome/common/net/notifier/listener/mediator_thread_impl.cc
@@ -23,11 +23,7 @@
 #include "talk/xmpp/xmppclientsettings.h"
 
 // We manage the lifetime of notifier::MediatorThreadImpl ourselves.
-template <>
-struct RunnableMethodTraits<notifier::MediatorThreadImpl> {
-  void RetainCallee(notifier::MediatorThreadImpl*) {}
-  void ReleaseCallee(notifier::MediatorThreadImpl*) {}
-};
+DISABLE_RUNNABLE_METHOD_REFCOUNT(notifier::MediatorThreadImpl);
 
 namespace notifier {
 
diff --git a/chrome/common/net/thread_blocker.cc b/chrome/common/net/thread_blocker.cc
index 4ecce8a..2291d33 100644
--- a/chrome/common/net/thread_blocker.cc
+++ b/chrome/common/net/thread_blocker.cc
@@ -12,11 +12,7 @@
 
 // Since a ThreadBlocker is outlived by its target thread, we don't
 // have to ref-count it.
-template <>
-struct RunnableMethodTraits<chrome_common_net::ThreadBlocker> {
-  void RetainCallee(chrome_common_net::ThreadBlocker*) {}
-  void ReleaseCallee(chrome_common_net::ThreadBlocker*) {}
-};
+DISABLE_RUNNABLE_METHOD_REFCOUNT(chrome_common_net::ThreadBlocker);
 
 namespace chrome_common_net {
 
diff --git a/chrome/common/net/thread_blocker_unittest.cc b/chrome/common/net/thread_blocker_unittest.cc
index 1f54482..7ce0668 100644
--- a/chrome/common/net/thread_blocker_unittest.cc
+++ b/chrome/common/net/thread_blocker_unittest.cc
@@ -18,11 +18,7 @@ class Flag;
 };  // namespace chrome_common_net
 
 // We manage the lifetime of chrome_common_net::Flag ourselves.
-template <>
-struct RunnableMethodTraits<chrome_common_net::Flag> {
-  void RetainCallee(chrome_common_net::Flag*) {}
-  void ReleaseCallee(chrome_common_net::Flag*) {}
-};
+DISABLE_RUNNABLE_METHOD_REFCOUNT(chrome_common_net::Flag);
 
 namespace chrome_common_net {
 
-- 
cgit v1.1