diff options
-rw-r--r-- | base/at_exit.cc | 14 | ||||
-rw-r--r-- | base/at_exit.h | 17 |
2 files changed, 16 insertions, 15 deletions
diff --git a/base/at_exit.cc b/base/at_exit.cc index 734de74..62efcc8 100644 --- a/base/at_exit.cc +++ b/base/at_exit.cc @@ -30,13 +30,13 @@ #include "base/at_exit.h" #include "base/logging.h" +namespace base { + // Keep a stack of registered AtExitManagers. We always operate on the most // recent, and we should never have more than one outside of testing, when we // use the shadow version of the constructor. We don't protect this for // thread-safe access, since it will only be modified in testing. -static std::stack<base::AtExitManager*> g_managers; - -namespace base { +static std::stack<AtExitManager*> g_managers; AtExitManager::AtExitManager() { DCHECK(g_managers.empty()); @@ -50,7 +50,7 @@ AtExitManager::AtExitManager(bool shadow) { AtExitManager::~AtExitManager() { if (g_managers.empty()) { - NOTREACHED() << "Tried to ~AtExitManager without a AtExitManager"; + NOTREACHED() << "Tried to ~AtExitManager without an AtExitManager"; return; } DCHECK(g_managers.top() == this); @@ -62,7 +62,7 @@ AtExitManager::~AtExitManager() { // static void AtExitManager::RegisterCallback(AtExitCallbackType func) { if (g_managers.empty()) { - NOTREACHED() << "Tried to RegisterCallback without a AtExitManager"; + NOTREACHED() << "Tried to RegisterCallback without an AtExitManager"; return; } @@ -74,7 +74,7 @@ void AtExitManager::RegisterCallback(AtExitCallbackType func) { // static void AtExitManager::ProcessCallbacksNow() { if (g_managers.empty()) { - NOTREACHED() << "Tried to RegisterCallback without a AtExitManager"; + NOTREACHED() << "Tried to ProcessCallbacksNow without an AtExitManager"; return; } @@ -82,7 +82,7 @@ void AtExitManager::ProcessCallbacksNow() { AutoLock lock(manager->lock_); while (!manager->stack_.empty()) { - base::AtExitCallbackType func = manager->stack_.top(); + AtExitCallbackType func = manager->stack_.top(); manager->stack_.pop(); if (func) func(); diff --git a/base/at_exit.h b/base/at_exit.h index 123935d..38e7b54 100644 --- a/base/at_exit.h +++ b/base/at_exit.h @@ -27,8 +27,8 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#ifndef BASE_AT_EXIT_H__ -#define BASE_AT_EXIT_H__ +#ifndef BASE_AT_EXIT_H_ +#define BASE_AT_EXIT_H_ #include <stack> @@ -37,8 +37,6 @@ namespace base { -typedef void (*AtExitCallbackType)(); - // This class provides a facility similar to the CRT atexit(), except that // we control when the callbacks are executed. Under Windows for a DLL they // happen at a really bad time and under the loader lock. This facility is @@ -56,11 +54,14 @@ typedef void (*AtExitCallbackType)(); class AtExitManager { protected: // This constructor will allow this instance of AtExitManager to be created - // even if on already exists. This should only be used for testing! + // even if one already exists. This should only be used for testing! // AtExitManagers are kept on a global stack, and it will be removed during // destruction. This allows you to shadow another AtExitManager. AtExitManager(bool shadow); + public: + typedef void (*AtExitCallbackType)(); + AtExitManager(); // The dtor calls all the registered callbacks. Do not try to register more @@ -77,10 +78,10 @@ class AtExitManager { private: Lock lock_; - std::stack<base::AtExitCallbackType> stack_; - DISALLOW_EVIL_CONSTRUCTORS(AtExitManager); + std::stack<AtExitCallbackType> stack_; + DISALLOW_COPY_AND_ASSIGN(AtExitManager); }; } // namespace base -#endif // BASE_AT_EXIT_H__ +#endif // BASE_AT_EXIT_H_ |