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

Unified Diff: base/at_exit.cc

Issue 7831021: Support for registering arbitrary Tasks with AtExitManager. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 4 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/at_exit.h ('k') | base/at_exit_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/at_exit.cc
===================================================================
--- base/at_exit.cc (revision 99168)
+++ base/at_exit.cc (working copy)
@@ -7,7 +7,9 @@
#include <stddef.h>
#include <ostream>
+#include "base/bind.h"
#include "base/logging.h"
+#include "base/task.h"
namespace base {
@@ -41,15 +43,19 @@
// static
void AtExitManager::RegisterCallback(AtExitCallbackType func, void* param) {
+ DCHECK(func);
+ RegisterTask(base::Bind(func, param));
+}
+
+// static
+void AtExitManager::RegisterTask(base::Closure task) {
if (!g_top_manager) {
NOTREACHED() << "Tried to RegisterCallback without an AtExitManager";
return;
}
- DCHECK(func);
-
AutoLock lock(g_top_manager->lock_);
- g_top_manager->stack_.push(CallbackAndParam(func, param));
+ g_top_manager->stack_.push(task);
}
// static
@@ -62,10 +68,9 @@
AutoLock lock(g_top_manager->lock_);
while (!g_top_manager->stack_.empty()) {
- CallbackAndParam callback_and_param = g_top_manager->stack_.top();
+ base::Closure task = g_top_manager->stack_.top();
+ task.Run();
g_top_manager->stack_.pop();
-
- callback_and_param.func_(callback_and_param.param_);
}
}
« no previous file with comments | « base/at_exit.h ('k') | base/at_exit_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698