summaryrefslogtreecommitdiffstats
path: root/base/at_exit.h
diff options
context:
space:
mode:
authorapatrick@chromium.org <apatrick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-06 23:14:47 +0000
committerapatrick@chromium.org <apatrick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-06 23:14:47 +0000
commit762de919a02b352bc684b3a49175d6aa5234b0c1 (patch)
treeb02d9c4a95f97add41cfc2d537a43680934ee6b6 /base/at_exit.h
parentd3a250fc8802f10bc22d9f04475867821fa45f57 (diff)
downloadchromium_src-762de919a02b352bc684b3a49175d6aa5234b0c1.zip
chromium_src-762de919a02b352bc684b3a49175d6aa5234b0c1.tar.gz
chromium_src-762de919a02b352bc684b3a49175d6aa5234b0c1.tar.bz2
Support for registering arbitrary Tasks with AtExitManager.
Previously it was limitted to functions taling a single void* argument. Review URL: http://codereview.chromium.org/7831021 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@99856 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/at_exit.h')
-rw-r--r--base/at_exit.h15
1 files changed, 6 insertions, 9 deletions
diff --git a/base/at_exit.h b/base/at_exit.h
index 9e75a3f..613c9fe 100644
--- a/base/at_exit.h
+++ b/base/at_exit.h
@@ -10,6 +10,7 @@
#include "base/base_export.h"
#include "base/basictypes.h"
+#include "base/callback.h"
#include "base/synchronization/lock.h"
namespace base {
@@ -39,9 +40,12 @@ class BASE_EXPORT AtExitManager {
~AtExitManager();
// Registers the specified function to be called at exit. The prototype of
- // the callback function is void func().
+ // the callback function is void func(void*).
static void RegisterCallback(AtExitCallbackType func, void* param);
+ // Registers the specified task to be called at exit.
+ static void RegisterTask(base::Closure task);
+
// Calls the functions registered with RegisterCallback in LIFO order. It
// is possible to register new callbacks after calling this function.
static void ProcessCallbacksNow();
@@ -54,15 +58,8 @@ class BASE_EXPORT AtExitManager {
explicit AtExitManager(bool shadow);
private:
- struct CallbackAndParam {
- CallbackAndParam(AtExitCallbackType func, void* param)
- : func_(func), param_(param) { }
- AtExitCallbackType func_;
- void* param_;
- };
-
base::Lock lock_;
- std::stack<CallbackAndParam> stack_;
+ std::stack<base::Closure> stack_;
AtExitManager* next_manager_; // Stack of managers to allow shadowing.
DISALLOW_COPY_AND_ASSIGN(AtExitManager);