Chromium Code Reviews| Index: base/at_exit.cc |
| diff --git a/base/at_exit.cc b/base/at_exit.cc |
| index cfe4cf9a587cc3da54e0ec3bc693e860beec425c..06203e8cf9944acad01e7259722ffa8fbc98b8ca 100644 |
| --- a/base/at_exit.cc |
| +++ b/base/at_exit.cc |
| @@ -22,6 +22,8 @@ namespace base { |
| // this for thread-safe access, since it will only be modified in testing. |
| static AtExitManager* g_top_manager = NULL; |
| +static bool g_disable_managers = false; |
| + |
| AtExitManager::AtExitManager() |
| : processing_callbacks_(false), next_manager_(g_top_manager) { |
| // If multiple modules instantiate AtExitManagers they'll end up living in this |
| @@ -80,7 +82,8 @@ void AtExitManager::ProcessCallbacksNow() { |
| while (!tasks.empty()) { |
| base::Closure task = tasks.top(); |
| - task.Run(); |
| + if (!g_disable_managers) |
|
dcheng
2017/01/12 02:22:38
Is it important to pop the tasks like this? I wond
haraken
2017/01/12 02:44:02
Fixed.
|
| + task.Run(); |
| tasks.pop(); |
| } |
| @@ -88,6 +91,11 @@ void AtExitManager::ProcessCallbacksNow() { |
| DCHECK(g_top_manager->stack_.empty()); |
| } |
| +void AtExitManager::DisableAllAtExitManagers() { |
| + AutoLock lock(g_top_manager->lock_); |
| + g_disable_managers = true; |
| +} |
| + |
| AtExitManager::AtExitManager(bool shadow) |
| : processing_callbacks_(false), next_manager_(g_top_manager) { |
| DCHECK(shadow || !g_top_manager); |