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

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
Index: base/at_exit.cc
===================================================================
--- base/at_exit.cc (revision 99168)
+++ base/at_exit.cc (working copy)
@@ -8,6 +8,7 @@
#include <ostream>
#include "base/logging.h"
+#include "base/task.h"
namespace base {
@@ -41,15 +42,21 @@
// static
void AtExitManager::RegisterCallback(AtExitCallbackType func, void* param) {
+ DCHECK(func);
+ RegisterTask(NewRunnableFunction(func, param));
+}
+
+// static
+void AtExitManager::RegisterTask(Task* task) {
if (!g_top_manager) {
NOTREACHED() << "Tried to RegisterCallback without an AtExitManager";
return;
}
- DCHECK(func);
+ DCHECK(task);
AutoLock lock(g_top_manager->lock_);
- g_top_manager->stack_.push(CallbackAndParam(func, param));
+ g_top_manager->stack_.push(linked_ptr<Task>(task));
}
// static
@@ -62,10 +69,9 @@
AutoLock lock(g_top_manager->lock_);
while (!g_top_manager->stack_.empty()) {
- CallbackAndParam callback_and_param = g_top_manager->stack_.top();
+ Task* task = g_top_manager->stack_.top().get();
+ task->Run();
g_top_manager->stack_.pop();
-
- callback_and_param.func_(callback_and_param.param_);
}
}
« base/at_exit.h ('K') | « 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