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

Side by Side Diff: base/at_exit.h

Issue 1805: Add a void* parameter to the AtExitManager callbacks. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 12 years, 3 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | base/at_exit.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 #ifndef BASE_AT_EXIT_H_ 5 #ifndef BASE_AT_EXIT_H_
6 #define BASE_AT_EXIT_H_ 6 #define BASE_AT_EXIT_H_
7 7
8 #include <stack> 8 #include <stack>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 17 matching lines...) Expand all
28 28
29 class AtExitManager { 29 class AtExitManager {
30 protected: 30 protected:
31 // This constructor will allow this instance of AtExitManager to be created 31 // This constructor will allow this instance of AtExitManager to be created
32 // even if one already exists. This should only be used for testing! 32 // even if one already exists. This should only be used for testing!
33 // AtExitManagers are kept on a global stack, and it will be removed during 33 // AtExitManagers are kept on a global stack, and it will be removed during
34 // destruction. This allows you to shadow another AtExitManager. 34 // destruction. This allows you to shadow another AtExitManager.
35 AtExitManager(bool shadow); 35 AtExitManager(bool shadow);
36 36
37 public: 37 public:
38 typedef void (*AtExitCallbackType)(); 38 typedef void (*AtExitCallbackType)(void*);
39 39
40 AtExitManager(); 40 AtExitManager();
41 41
42 // The dtor calls all the registered callbacks. Do not try to register more 42 // The dtor calls all the registered callbacks. Do not try to register more
43 // callbacks after this point. 43 // callbacks after this point.
44 ~AtExitManager(); 44 ~AtExitManager();
45 45
46 // Registers the specified function to be called at exit. The prototype of 46 // Registers the specified function to be called at exit. The prototype of
47 // the callback function is void func(). 47 // the callback function is void func().
48 static void RegisterCallback(AtExitCallbackType func); 48 static void RegisterCallback(AtExitCallbackType func, void* param);
49 49
50 // Calls the functions registered with RegisterCallback in LIFO order. It 50 // Calls the functions registered with RegisterCallback in LIFO order. It
51 // is possible to register new callbacks after calling this function. 51 // is possible to register new callbacks after calling this function.
52 static void ProcessCallbacksNow(); 52 static void ProcessCallbacksNow();
53 53
54 private: 54 private:
55 struct CallbackAndParam {
56 CallbackAndParam(AtExitCallbackType func, void* param)
57 : func_(func), param_(param) { }
58 AtExitCallbackType func_;
59 void* param_;
60 };
61
55 Lock lock_; 62 Lock lock_;
56 std::stack<AtExitCallbackType> stack_; 63 std::stack<CallbackAndParam> stack_;
57 AtExitManager* next_manager_; // Stack of managers to allow shadowing. 64 AtExitManager* next_manager_; // Stack of managers to allow shadowing.
58 65
59 DISALLOW_COPY_AND_ASSIGN(AtExitManager); 66 DISALLOW_COPY_AND_ASSIGN(AtExitManager);
60 }; 67 };
61 68
62 } // namespace base 69 } // namespace base
63 70
64 #endif // BASE_AT_EXIT_H_ 71 #endif // BASE_AT_EXIT_H_
65
OLDNEW
« no previous file with comments | « no previous file | base/at_exit.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698