| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/at_exit.h" | 5 #include "base/at_exit.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <ostream> | 8 #include <ostream> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 DCHECK(!g_top_manager); | 26 DCHECK(!g_top_manager); |
| 27 #endif | 27 #endif |
| 28 g_top_manager = this; | 28 g_top_manager = this; |
| 29 } | 29 } |
| 30 | 30 |
| 31 AtExitManager::~AtExitManager() { | 31 AtExitManager::~AtExitManager() { |
| 32 if (!g_top_manager) { | 32 if (!g_top_manager) { |
| 33 NOTREACHED() << "Tried to ~AtExitManager without an AtExitManager"; | 33 NOTREACHED() << "Tried to ~AtExitManager without an AtExitManager"; |
| 34 return; | 34 return; |
| 35 } | 35 } |
| 36 DCHECK(g_top_manager == this); | 36 DCHECK_EQ(this, g_top_manager); |
| 37 | 37 |
| 38 ProcessCallbacksNow(); | 38 ProcessCallbacksNow(); |
| 39 g_top_manager = next_manager_; | 39 g_top_manager = next_manager_; |
| 40 } | 40 } |
| 41 | 41 |
| 42 // static | 42 // static |
| 43 void AtExitManager::RegisterCallback(AtExitCallbackType func, void* param) { | 43 void AtExitManager::RegisterCallback(AtExitCallbackType func, void* param) { |
| 44 if (!g_top_manager) { | 44 if (!g_top_manager) { |
| 45 NOTREACHED() << "Tried to RegisterCallback without an AtExitManager"; | 45 NOTREACHED() << "Tried to RegisterCallback without an AtExitManager"; |
| 46 return; | 46 return; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 68 callback_and_param.func_(callback_and_param.param_); | 68 callback_and_param.func_(callback_and_param.param_); |
| 69 } | 69 } |
| 70 } | 70 } |
| 71 | 71 |
| 72 AtExitManager::AtExitManager(bool shadow) : next_manager_(g_top_manager) { | 72 AtExitManager::AtExitManager(bool shadow) : next_manager_(g_top_manager) { |
| 73 DCHECK(shadow || !g_top_manager); | 73 DCHECK(shadow || !g_top_manager); |
| 74 g_top_manager = this; | 74 g_top_manager = this; |
| 75 } | 75 } |
| 76 | 76 |
| 77 } // namespace base | 77 } // namespace base |
| OLD | NEW |