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 <map> | 8 #include <map> |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <set> | 10 #include <set> |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 74 MemoryDumpProvider* mdp, | 74 MemoryDumpProvider* mdp, |
| 75 const char* name, | 75 const char* name, |
| 76 const scoped_refptr<SingleThreadTaskRunner>& task_runner); | 76 const scoped_refptr<SingleThreadTaskRunner>& task_runner); |
| 77 void RegisterDumpProvider( | 77 void RegisterDumpProvider( |
| 78 MemoryDumpProvider* mdp, | 78 MemoryDumpProvider* mdp, |
| 79 const char* name, | 79 const char* name, |
| 80 const scoped_refptr<SingleThreadTaskRunner>& task_runner, | 80 const scoped_refptr<SingleThreadTaskRunner>& task_runner, |
| 81 const MemoryDumpProvider::Options& options); | 81 const MemoryDumpProvider::Options& options); |
| 82 void UnregisterDumpProvider(MemoryDumpProvider* mdp); | 82 void UnregisterDumpProvider(MemoryDumpProvider* mdp); |
| 83 | 83 |
| 84 // Unregisters an unbound dump provider and takes care about its deletion | |
| 85 // asynchronously. Can be used only for for dump providers with no | |
| 86 // task-runner affinity. | |
| 87 // This method takes ownership of the dump provider and guarantees that: | |
| 88 // - The |mdp| will be deleted at some point in the near future. | |
| 89 // - Its deletion will not happen concurrently with the OnMemoryDump() call. | |
| 90 // Note that OnMemoryDump() calls can still happen after this method returns. | |
| 91 void UnregisterAndDeleteDumpProviderAsync(scoped_ptr<MemoryDumpProvider> mdp); | |
| 92 | |
| 84 // Requests a memory dump. The dump might happen or not depending on the | 93 // Requests a memory dump. The dump might happen or not depending on the |
| 85 // filters and categories specified when enabling tracing. | 94 // filters and categories specified when enabling tracing. |
| 86 // The optional |callback| is executed asynchronously, on an arbitrary thread, | 95 // The optional |callback| is executed asynchronously, on an arbitrary thread, |
| 87 // to notify about the completion of the global dump (i.e. after all the | 96 // to notify about the completion of the global dump (i.e. after all the |
| 88 // processes have dumped) and its success (true iff all the dumps were | 97 // processes have dumped) and its success (true iff all the dumps were |
| 89 // successful). | 98 // successful). |
| 90 void RequestGlobalDump(MemoryDumpType dump_type, | 99 void RequestGlobalDump(MemoryDumpType dump_type, |
| 91 MemoryDumpLevelOfDetail level_of_detail, | 100 MemoryDumpLevelOfDetail level_of_detail, |
| 92 const MemoryDumpCallback& callback); | 101 const MemoryDumpCallback& callback); |
| 93 | 102 |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 158 std::set<scoped_refptr<MemoryDumpProviderInfo>, Comparator>; | 167 std::set<scoped_refptr<MemoryDumpProviderInfo>, Comparator>; |
| 159 | 168 |
| 160 MemoryDumpProviderInfo( | 169 MemoryDumpProviderInfo( |
| 161 MemoryDumpProvider* dump_provider, | 170 MemoryDumpProvider* dump_provider, |
| 162 const char* name, | 171 const char* name, |
| 163 const scoped_refptr<SingleThreadTaskRunner>& task_runner, | 172 const scoped_refptr<SingleThreadTaskRunner>& task_runner, |
| 164 const MemoryDumpProvider::Options& options); | 173 const MemoryDumpProvider::Options& options); |
| 165 | 174 |
| 166 MemoryDumpProvider* const dump_provider; | 175 MemoryDumpProvider* const dump_provider; |
| 167 | 176 |
| 177 // Used to transfer ownership for UnregisterAndDeleteDumpProviderAsync(). | |
| 178 // Typically nullptr in nominal conditions. | |
|
Ruud van Asseldonk
2015/12/29 11:32:46
/s/nominal/normal/?
Primiano Tucci (use gerrit)
2016/01/04 14:44:38
Done.
| |
| 179 scoped_ptr<MemoryDumpProvider> owned_dump_provider; | |
| 180 | |
| 168 // Human readable name, for debugging and testing. Not necessarily unique. | 181 // Human readable name, for debugging and testing. Not necessarily unique. |
| 169 const char* const name; | 182 const char* const name; |
| 170 | 183 |
| 171 // The task_runner affinity. Can be nullptr, in which case the dump provider | 184 // The task_runner affinity. Can be nullptr, in which case the dump provider |
| 172 // will be invoked on |dump_thread_|. | 185 // will be invoked on |dump_thread_|. |
| 173 const scoped_refptr<SingleThreadTaskRunner> task_runner; | 186 const scoped_refptr<SingleThreadTaskRunner> task_runner; |
| 174 | 187 |
| 175 // The |options| arg passed to RegisterDumpProvider(). | 188 // The |options| arg passed to RegisterDumpProvider(). |
| 176 const MemoryDumpProvider::Options options; | 189 const MemoryDumpProvider::Options options; |
| 177 | 190 |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 254 // |callback| will be invoked asynchronously upon completion on the same | 267 // |callback| will be invoked asynchronously upon completion on the same |
| 255 // thread on which CreateProcessDump() was called. | 268 // thread on which CreateProcessDump() was called. |
| 256 void CreateProcessDump(const MemoryDumpRequestArgs& args, | 269 void CreateProcessDump(const MemoryDumpRequestArgs& args, |
| 257 const MemoryDumpCallback& callback); | 270 const MemoryDumpCallback& callback); |
| 258 | 271 |
| 259 // Continues the ProcessMemoryDump started by CreateProcessDump(), hopping | 272 // Continues the ProcessMemoryDump started by CreateProcessDump(), hopping |
| 260 // across threads as needed as specified by MDPs in RegisterDumpProvider(). | 273 // across threads as needed as specified by MDPs in RegisterDumpProvider(). |
| 261 void ContinueAsyncProcessDump( | 274 void ContinueAsyncProcessDump( |
| 262 ProcessMemoryDumpAsyncState* owned_pmd_async_state); | 275 ProcessMemoryDumpAsyncState* owned_pmd_async_state); |
| 263 | 276 |
| 277 // Helper for the public UnregisterDumpProvider* functions. | |
| 278 void UnregisterDumpProviderInternal(MemoryDumpProvider* mdp, | |
| 279 bool take_mdp_ownership_and_delete_async); | |
| 280 | |
| 264 // An ordererd set of registered MemoryDumpProviderInfo(s), sorted by thread | 281 // An ordererd set of registered MemoryDumpProviderInfo(s), sorted by thread |
| 265 // affinity (MDPs belonging to the same thread are adjacent). | 282 // affinity (MDPs belonging to the same thread are adjacent). |
| 266 MemoryDumpProviderInfo::OrderedSet dump_providers_; | 283 MemoryDumpProviderInfo::OrderedSet dump_providers_; |
| 267 | 284 |
| 268 // Shared among all the PMDs to keep state scoped to the tracing session. | 285 // Shared among all the PMDs to keep state scoped to the tracing session. |
| 269 scoped_refptr<MemoryDumpSessionState> session_state_; | 286 scoped_refptr<MemoryDumpSessionState> session_state_; |
| 270 | 287 |
| 271 MemoryDumpManagerDelegate* delegate_; // Not owned. | 288 MemoryDumpManagerDelegate* delegate_; // Not owned. |
| 272 | 289 |
| 273 // When true, this instance is in charge of coordinating periodic dumps. | 290 // When true, this instance is in charge of coordinating periodic dumps. |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 321 } | 338 } |
| 322 | 339 |
| 323 private: | 340 private: |
| 324 DISALLOW_COPY_AND_ASSIGN(MemoryDumpManagerDelegate); | 341 DISALLOW_COPY_AND_ASSIGN(MemoryDumpManagerDelegate); |
| 325 }; | 342 }; |
| 326 | 343 |
| 327 } // namespace trace_event | 344 } // namespace trace_event |
| 328 } // namespace base | 345 } // namespace base |
| 329 | 346 |
| 330 #endif // BASE_TRACE_EVENT_MEMORY_DUMP_MANAGER_H_ | 347 #endif // BASE_TRACE_EVENT_MEMORY_DUMP_MANAGER_H_ |
| OLD | NEW |