OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_TRACE_EVENT_MEMORY_DUMP_MANAGER_H_ | 5 #ifndef BASE_TRACE_EVENT_MEMORY_DUMP_MANAGER_H_ |
6 #define BASE_TRACE_EVENT_MEMORY_DUMP_MANAGER_H_ | 6 #define BASE_TRACE_EVENT_MEMORY_DUMP_MANAGER_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/atomicops.h" | 10 #include "base/atomicops.h" |
(...skipping 25 matching lines...) Expand all Loading... |
36 // Invoked once per process to register the TraceLog observer. | 36 // Invoked once per process to register the TraceLog observer. |
37 void Initialize(); | 37 void Initialize(); |
38 | 38 |
39 // MemoryDumpManager does NOT take memory ownership of |mdp|, which is | 39 // MemoryDumpManager does NOT take memory ownership of |mdp|, which is |
40 // expected to be a singleton. | 40 // expected to be a singleton. |
41 void RegisterDumpProvider(MemoryDumpProvider* mdp); | 41 void RegisterDumpProvider(MemoryDumpProvider* mdp); |
42 void UnregisterDumpProvider(MemoryDumpProvider* mdp); | 42 void UnregisterDumpProvider(MemoryDumpProvider* mdp); |
43 | 43 |
44 // Requests a memory dump. The dump might happen or not depending on the | 44 // Requests a memory dump. The dump might happen or not depending on the |
45 // filters and categories specified when enabling tracing. | 45 // filters and categories specified when enabling tracing. |
46 void RequestDumpPoint(DumpPointType type); | 46 void RequestDumpPoint(DumpPointType dump_point_type); |
47 | 47 |
48 // TraceLog::EnabledStateObserver implementation. | 48 // TraceLog::EnabledStateObserver implementation. |
49 void OnTraceLogEnabled() override; | 49 void OnTraceLogEnabled() override; |
50 void OnTraceLogDisabled() override; | 50 void OnTraceLogDisabled() override; |
51 | 51 |
52 private: | 52 private: |
53 friend struct DefaultDeleter<MemoryDumpManager>; // For the testing instance. | 53 friend struct DefaultDeleter<MemoryDumpManager>; // For the testing instance. |
54 friend struct DefaultSingletonTraits<MemoryDumpManager>; | 54 friend struct DefaultSingletonTraits<MemoryDumpManager>; |
55 friend class MemoryDumpManagerTest; | 55 friend class MemoryDumpManagerTest; |
56 | 56 |
57 static const char kTraceCategory[]; | 57 static const char kTraceCategory[]; |
58 | 58 |
59 static void SetInstanceForTesting(MemoryDumpManager* instance); | 59 static void SetInstanceForTesting(MemoryDumpManager* instance); |
60 | 60 |
61 MemoryDumpManager(); | 61 MemoryDumpManager(); |
62 virtual ~MemoryDumpManager(); | 62 virtual ~MemoryDumpManager(); |
63 | 63 |
64 // Broadcasts the dump requests to the other processes. | 64 // Broadcasts the dump requests to the other processes. |
65 void BroadcastDumpRequest(); | 65 void BroadcastDumpRequest(); |
66 | 66 |
67 // Creates a dump point for the current process and appends it to the trace. | 67 // Creates a dump point for the current process and appends it to the trace. |
68 void CreateLocalDumpPoint(); | 68 void CreateLocalDumpPoint(DumpPointType dump_point_type, uint64 guid); |
69 | 69 |
70 std::vector<MemoryDumpProvider*> dump_providers_registered_; // Not owned. | 70 std::vector<MemoryDumpProvider*> dump_providers_registered_; // Not owned. |
71 std::vector<MemoryDumpProvider*> dump_providers_enabled_; // Not owned. | 71 std::vector<MemoryDumpProvider*> dump_providers_enabled_; // Not owned. |
72 | 72 |
73 // Protects from concurrent accesses to the |dump_providers_*|, e.g., tearing | 73 // Protects from concurrent accesses to the |dump_providers_*|, e.g., tearing |
74 // down logging while creating a dump point on another thread. | 74 // down logging while creating a dump point on another thread. |
75 Lock lock_; | 75 Lock lock_; |
76 | 76 |
77 // Optimization to avoid attempting any dump point (i.e. to not walk an empty | 77 // Optimization to avoid attempting any dump point (i.e. to not walk an empty |
78 // dump_providers_enabled_ list) when tracing is not enabled. | 78 // dump_providers_enabled_ list) when tracing is not enabled. |
79 subtle::AtomicWord memory_tracing_enabled_; | 79 subtle::AtomicWord memory_tracing_enabled_; |
80 | 80 |
81 DISALLOW_COPY_AND_ASSIGN(MemoryDumpManager); | 81 DISALLOW_COPY_AND_ASSIGN(MemoryDumpManager); |
82 }; | 82 }; |
83 | 83 |
84 } // namespace trace_event | 84 } // namespace trace_event |
85 } // namespace base | 85 } // namespace base |
86 | 86 |
87 #endif // BASE_TRACE_EVENT_MEMORY_DUMP_MANAGER_H_ | 87 #endif // BASE_TRACE_EVENT_MEMORY_DUMP_MANAGER_H_ |
OLD | NEW |