Chromium Code Reviews| 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 18 matching lines...) Expand all Loading... | |
| 29 class MemoryDumpManagerDelegate; | 29 class MemoryDumpManagerDelegate; |
| 30 class MemoryDumpProvider; | 30 class MemoryDumpProvider; |
| 31 class ProcessMemoryDump; | 31 class ProcessMemoryDump; |
| 32 class MemoryDumpSessionState; | 32 class MemoryDumpSessionState; |
| 33 | 33 |
| 34 // This is the interface exposed to the rest of the codebase to deal with | 34 // This is the interface exposed to the rest of the codebase to deal with |
| 35 // memory tracing. The main entry point for clients is represented by | 35 // memory tracing. The main entry point for clients is represented by |
| 36 // RequestDumpPoint(). The extension by Un(RegisterDumpProvider). | 36 // RequestDumpPoint(). The extension by Un(RegisterDumpProvider). |
| 37 class BASE_EXPORT MemoryDumpManager : public TraceLog::EnabledStateObserver { | 37 class BASE_EXPORT MemoryDumpManager : public TraceLog::EnabledStateObserver { |
| 38 public: | 38 public: |
| 39 static const int kInvalidTracingProcessId = -1; | |
| 39 static const char* const kTraceCategoryForTesting; | 40 static const char* const kTraceCategoryForTesting; |
| 40 | 41 |
| 41 static MemoryDumpManager* GetInstance(); | 42 static MemoryDumpManager* GetInstance(); |
| 42 | 43 |
| 43 // Invoked once per process to register the TraceLog observer. | 44 // Invoked once per process to register the TraceLog observer. |
| 44 void Initialize(); | 45 void Initialize(); |
| 45 | 46 |
| 46 // See the lifetime and thread-safety requirements on the delegate below in | 47 // See the lifetime and thread-safety requirements on the delegate below in |
| 47 // the |MemoryDumpManagerDelegate| docstring. | 48 // the |MemoryDumpManagerDelegate| docstring. |
| 48 void SetDelegate(MemoryDumpManagerDelegate* delegate); | 49 void SetDelegate(MemoryDumpManagerDelegate* delegate); |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 74 void OnTraceLogEnabled() override; | 75 void OnTraceLogEnabled() override; |
| 75 void OnTraceLogDisabled() override; | 76 void OnTraceLogDisabled() override; |
| 76 | 77 |
| 77 // Returns the MemoryDumpSessionState object, which is shared by all the | 78 // Returns the MemoryDumpSessionState object, which is shared by all the |
| 78 // ProcessMemoryDump and MemoryAllocatorDump instances through all the tracing | 79 // ProcessMemoryDump and MemoryAllocatorDump instances through all the tracing |
| 79 // session lifetime. | 80 // session lifetime. |
| 80 const scoped_refptr<MemoryDumpSessionState>& session_state() const { | 81 const scoped_refptr<MemoryDumpSessionState>& session_state() const { |
| 81 return session_state_; | 82 return session_state_; |
| 82 } | 83 } |
| 83 | 84 |
| 85 // Sets the unique hash value for identifying child process to create cross | |
|
Primiano Tucci (use gerrit)
2015/06/23 13:35:20
Don't expose the "hash" thing here. Just clarify t
ssid
2015/06/24 08:37:57
hm, base/ shouldn't really know about child proces
| |
| 86 // process unique guids. Pass kInvalidTracingProcessId for invalidating the | |
| 87 // id. | |
| 88 void set_tracing_process_id(int id) { | |
|
Primiano Tucci (use gerrit)
2015/06/23 13:35:20
Can you make the setter private and use the "frien
ssid
2015/06/24 08:37:57
Done.
| |
| 89 DCHECK(tracing_process_id_ == kInvalidTracingProcessId || | |
| 90 id == kInvalidTracingProcessId); | |
| 91 tracing_process_id_ = id; | |
| 92 } | |
| 93 | |
| 94 int tracing_process_id() { | |
|
Primiano Tucci (use gerrit)
2015/06/23 13:35:20
+const
ssid
2015/06/24 08:37:57
Done.
| |
| 95 DCHECK_NE(tracing_process_id_, kInvalidTracingProcessId); | |
|
Primiano Tucci (use gerrit)
2015/06/23 13:35:20
add a comment saying that if you are requesting th
ssid
2015/06/24 08:37:57
Done.
| |
| 96 return tracing_process_id_; | |
| 97 } | |
| 98 | |
| 84 private: | 99 private: |
| 85 // Descriptor struct used to hold information about registered MDPs. It is | 100 // Descriptor struct used to hold information about registered MDPs. It is |
| 86 // deliberately copyable, in order to allow to be used as hash_map value. | 101 // deliberately copyable, in order to allow to be used as hash_map value. |
| 87 struct MemoryDumpProviderInfo { | 102 struct MemoryDumpProviderInfo { |
| 88 MemoryDumpProviderInfo( | 103 MemoryDumpProviderInfo( |
| 89 const scoped_refptr<SingleThreadTaskRunner>& task_runner); | 104 const scoped_refptr<SingleThreadTaskRunner>& task_runner); |
| 90 ~MemoryDumpProviderInfo(); | 105 ~MemoryDumpProviderInfo(); |
| 91 | 106 |
| 92 scoped_refptr<SingleThreadTaskRunner> task_runner; // Optional. | 107 scoped_refptr<SingleThreadTaskRunner> task_runner; // Optional. |
| 93 int consecutive_failures; // Number of times the provider failed (to | 108 int consecutive_failures; // Number of times the provider failed (to |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 132 // to guard against disabling logging while dumping on another thread. | 147 // to guard against disabling logging while dumping on another thread. |
| 133 Lock lock_; | 148 Lock lock_; |
| 134 | 149 |
| 135 // Optimization to avoid attempting any memory dump (i.e. to not walk an empty | 150 // Optimization to avoid attempting any memory dump (i.e. to not walk an empty |
| 136 // dump_providers_enabled_ list) when tracing is not enabled. | 151 // dump_providers_enabled_ list) when tracing is not enabled. |
| 137 subtle::AtomicWord memory_tracing_enabled_; | 152 subtle::AtomicWord memory_tracing_enabled_; |
| 138 | 153 |
| 139 // For time-triggered periodic dumps. | 154 // For time-triggered periodic dumps. |
| 140 RepeatingTimer<MemoryDumpManager> periodic_dump_timer_; | 155 RepeatingTimer<MemoryDumpManager> periodic_dump_timer_; |
| 141 | 156 |
| 157 // The unique id of the child process for tracing. The value is expected to | |
|
Primiano Tucci (use gerrit)
2015/06/23 13:35:20
Can you clarify that this is neither the PID nor t
| |
| 158 // be valid only when tracing is enabled. | |
| 159 int tracing_process_id_; | |
| 160 | |
| 142 // Skips the auto-registration of the core dumpers during Initialize(). | 161 // Skips the auto-registration of the core dumpers during Initialize(). |
| 143 bool skip_core_dumpers_auto_registration_for_testing_; | 162 bool skip_core_dumpers_auto_registration_for_testing_; |
| 144 | 163 |
| 145 DISALLOW_COPY_AND_ASSIGN(MemoryDumpManager); | 164 DISALLOW_COPY_AND_ASSIGN(MemoryDumpManager); |
| 146 }; | 165 }; |
| 147 | 166 |
| 148 // The delegate is supposed to be long lived (read: a Singleton) and thread | 167 // The delegate is supposed to be long lived (read: a Singleton) and thread |
| 149 // safe (i.e. should expect calls from any thread and handle thread hopping). | 168 // safe (i.e. should expect calls from any thread and handle thread hopping). |
| 150 class BASE_EXPORT MemoryDumpManagerDelegate { | 169 class BASE_EXPORT MemoryDumpManagerDelegate { |
| 151 public: | 170 public: |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 166 } | 185 } |
| 167 | 186 |
| 168 private: | 187 private: |
| 169 DISALLOW_COPY_AND_ASSIGN(MemoryDumpManagerDelegate); | 188 DISALLOW_COPY_AND_ASSIGN(MemoryDumpManagerDelegate); |
| 170 }; | 189 }; |
| 171 | 190 |
| 172 } // namespace trace_event | 191 } // namespace trace_event |
| 173 } // namespace base | 192 } // namespace base |
| 174 | 193 |
| 175 #endif // BASE_TRACE_EVENT_MEMORY_DUMP_MANAGER_H_ | 194 #endif // BASE_TRACE_EVENT_MEMORY_DUMP_MANAGER_H_ |
| OLD | NEW |