| 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 #ifndef BASE_TRACKED_OBJECTS_H_ | 5 #ifndef BASE_TRACKED_OBJECTS_H_ |
| 6 #define BASE_TRACKED_OBJECTS_H_ | 6 #define BASE_TRACKED_OBJECTS_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <map> | 9 #include <map> |
| 10 #include <stack> | 10 #include <stack> |
| (...skipping 693 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 704 // If tracking is not compiled in, this function will return false. | 704 // If tracking is not compiled in, this function will return false. |
| 705 static bool InitializeAndSetTrackingStatus(bool status); | 705 static bool InitializeAndSetTrackingStatus(bool status); |
| 706 static bool tracking_status(); | 706 static bool tracking_status(); |
| 707 | 707 |
| 708 // Provide a time function that does nothing (runs fast) when we don't have | 708 // Provide a time function that does nothing (runs fast) when we don't have |
| 709 // the profiler enabled. It will generally be optimized away when it is | 709 // the profiler enabled. It will generally be optimized away when it is |
| 710 // ifdef'ed to be small enough (allowing the profiler to be "compiled out" of | 710 // ifdef'ed to be small enough (allowing the profiler to be "compiled out" of |
| 711 // the code). | 711 // the code). |
| 712 static TrackedTime Now(); | 712 static TrackedTime Now(); |
| 713 | 713 |
| 714 // WARNING: ONLY call this function when you are running single threaded | 714 // Cleans up data structures, and returns statics to near pristine (mostly |
| 715 // (again) and all message loops and threads have terminated. Until that | 715 // uninitialized) state. If there is any chance that other threads are still |
| 716 // point some threads may still attempt to write into our data structures. | 716 // using the data structures, then the |leak| argument should be passed in as |
| 717 // Delete recursively all data structures, starting with the list of | 717 // true, and the data structures (birth maps, death maps, ThreadData |
| 718 // insntances, etc.) will be leaked and not deleted. If you have joined all |
| 719 // threads since the time that InitializeAndSetTrackingStatus() was called, |
| 720 // then you can pass in a |leak| value of false, and this function will |
| 721 // delete recursively all data structures, starting with the list of |
| 718 // ThreadData instances. | 722 // ThreadData instances. |
| 719 static void ShutdownSingleThreadedCleanup(); | 723 static void ShutdownSingleThreadedCleanup(bool leak); |
| 720 | 724 |
| 721 private: | 725 private: |
| 722 typedef std::stack<const ThreadData*> ThreadDataPool; | 726 typedef std::stack<const ThreadData*> ThreadDataPool; |
| 723 | 727 |
| 724 // Worker thread construction creates a name since there is none. | 728 // Worker thread construction creates a name since there is none. |
| 725 ThreadData(); | 729 ThreadData(); |
| 726 // Message loop based construction should provide a name. | 730 // Message loop based construction should provide a name. |
| 727 explicit ThreadData(const std::string& suggested_name); | 731 explicit ThreadData(const std::string& suggested_name); |
| 728 | 732 |
| 729 ~ThreadData(); | 733 ~ThreadData(); |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 830 } | 834 } |
| 831 | 835 |
| 832 private: | 836 private: |
| 833 | 837 |
| 834 DISALLOW_COPY_AND_ASSIGN(AutoTracking); | 838 DISALLOW_COPY_AND_ASSIGN(AutoTracking); |
| 835 }; | 839 }; |
| 836 | 840 |
| 837 } // namespace tracked_objects | 841 } // namespace tracked_objects |
| 838 | 842 |
| 839 #endif // BASE_TRACKED_OBJECTS_H_ | 843 #endif // BASE_TRACKED_OBJECTS_H_ |
| OLD | NEW |