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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 dump_point_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 // Returns the MemoryDumpProvider which is currently being dumping into a |
| 53 // ProcessMemoryDump via DumpInto(...) if any, nullptr otherwise. |
| 54 MemoryDumpProvider* dump_provider_currently_active() const { |
| 55 return dump_provider_currently_active_; |
| 56 } |
| 57 |
52 private: | 58 private: |
53 friend struct DefaultDeleter<MemoryDumpManager>; // For the testing instance. | 59 friend struct DefaultDeleter<MemoryDumpManager>; // For the testing instance. |
54 friend struct DefaultSingletonTraits<MemoryDumpManager>; | 60 friend struct DefaultSingletonTraits<MemoryDumpManager>; |
55 friend class MemoryDumpManagerTest; | 61 friend class MemoryDumpManagerTest; |
56 | 62 |
57 static const char kTraceCategory[]; | 63 static const char kTraceCategory[]; |
58 | 64 |
59 static void SetInstanceForTesting(MemoryDumpManager* instance); | 65 static void SetInstanceForTesting(MemoryDumpManager* instance); |
60 | 66 |
61 MemoryDumpManager(); | 67 MemoryDumpManager(); |
62 virtual ~MemoryDumpManager(); | 68 virtual ~MemoryDumpManager(); |
63 | 69 |
64 // Broadcasts the dump requests to the other processes. | 70 // Broadcasts the dump requests to the other processes. |
65 void BroadcastDumpRequest(); | 71 void BroadcastDumpRequest(); |
66 | 72 |
67 // Creates a dump point for the current process and appends it to the trace. | 73 // Creates a dump point for the current process and appends it to the trace. |
68 void CreateLocalDumpPoint(DumpPointType dump_point_type, uint64 guid); | 74 void CreateLocalDumpPoint(DumpPointType dump_point_type, uint64 guid); |
69 | 75 |
70 std::vector<MemoryDumpProvider*> dump_providers_registered_; // Not owned. | 76 std::vector<MemoryDumpProvider*> dump_providers_registered_; // Not owned. |
71 std::vector<MemoryDumpProvider*> dump_providers_enabled_; // Not owned. | 77 std::vector<MemoryDumpProvider*> dump_providers_enabled_; // Not owned. |
72 | 78 |
| 79 // TODO(primiano): this is required only until crbug.com/466121 gets fixed. |
| 80 MemoryDumpProvider* dump_provider_currently_active_; // Now owned. |
| 81 |
73 // Protects from concurrent accesses to the |dump_providers_*|, e.g., tearing | 82 // Protects from concurrent accesses to the |dump_providers_*|, e.g., tearing |
74 // down logging while creating a dump point on another thread. | 83 // down logging while creating a dump point on another thread. |
75 Lock lock_; | 84 Lock lock_; |
76 | 85 |
77 // Optimization to avoid attempting any dump point (i.e. to not walk an empty | 86 // Optimization to avoid attempting any dump point (i.e. to not walk an empty |
78 // dump_providers_enabled_ list) when tracing is not enabled. | 87 // dump_providers_enabled_ list) when tracing is not enabled. |
79 subtle::AtomicWord memory_tracing_enabled_; | 88 subtle::AtomicWord memory_tracing_enabled_; |
80 | 89 |
81 DISALLOW_COPY_AND_ASSIGN(MemoryDumpManager); | 90 DISALLOW_COPY_AND_ASSIGN(MemoryDumpManager); |
82 }; | 91 }; |
83 | 92 |
84 } // namespace trace_event | 93 } // namespace trace_event |
85 } // namespace base | 94 } // namespace base |
86 | 95 |
87 #endif // BASE_TRACE_EVENT_MEMORY_DUMP_MANAGER_H_ | 96 #endif // BASE_TRACE_EVENT_MEMORY_DUMP_MANAGER_H_ |
OLD | NEW |