| 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_PROVIDER_H_ | 5 #ifndef BASE_TRACE_EVENT_MEMORY_DUMP_PROVIDER_H_ |
| 6 #define BASE_TRACE_EVENT_MEMORY_DUMP_PROVIDER_H_ | 6 #define BASE_TRACE_EVENT_MEMORY_DUMP_PROVIDER_H_ |
| 7 | 7 |
| 8 #include "base/base_export.h" | 8 #include "base/base_export.h" |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 | 10 |
| 11 namespace base { | 11 namespace base { |
| 12 namespace trace_event { | 12 namespace trace_event { |
| 13 | 13 |
| 14 class ProcessMemoryDump; | 14 class ProcessMemoryDump; |
| 15 | 15 |
| 16 // Contains information about the type of memory dump the MemoryDumpProvider | 16 // Contains information about the type of memory dump the MemoryDumpProvider |
| 17 // should generate on dump request. This is to control the size of dumps | 17 // should generate on dump request. This is to control the size of dumps |
| 18 // generated. | 18 // generated. |
| 19 struct MemoryDumpArgs { | 19 struct MemoryDumpArgs { |
| 20 enum class LevelOfDetail { | 20 enum class LevelOfDetail { |
| 21 LOW, | 21 LOW, |
| 22 HIGH, | 22 HIGH, |
| 23 LAST = HIGH // For IPC Macros. | 23 LAST = HIGH // For IPC Macros. |
| 24 }; | 24 }; |
| 25 | 25 |
| 26 bool operator==(const MemoryDumpArgs& other) const { |
| 27 return level_of_detail == other.level_of_detail; |
| 28 } |
| 29 |
| 26 LevelOfDetail level_of_detail; | 30 LevelOfDetail level_of_detail; |
| 27 }; | 31 }; |
| 28 | 32 |
| 29 // The contract interface that memory dump providers must implement. | 33 // The contract interface that memory dump providers must implement. |
| 30 class BASE_EXPORT MemoryDumpProvider { | 34 class BASE_EXPORT MemoryDumpProvider { |
| 31 public: | 35 public: |
| 32 // Called by the MemoryDumpManager when generating memory dumps. | 36 // Called by the MemoryDumpManager when generating memory dumps. |
| 33 // The |args| specify if the embedder should generate light/heavy dumps on | 37 // The |args| specify if the embedder should generate light/heavy dumps on |
| 34 // dump requests. The embedder should return true if the |pmd| was | 38 // dump requests. The embedder should return true if the |pmd| was |
| 35 // successfully populated, false if something went wrong and the dump should | 39 // successfully populated, false if something went wrong and the dump should |
| 36 // be considered invalid. | 40 // be considered invalid. |
| 37 // (Note, the MemoryDumpManager has a fail-safe logic which will disable the | 41 // (Note, the MemoryDumpManager has a fail-safe logic which will disable the |
| 38 // MemoryDumpProvider for the entire trace session if it fails consistently). | 42 // MemoryDumpProvider for the entire trace session if it fails consistently). |
| 39 virtual bool OnMemoryDump(const MemoryDumpArgs& args, | 43 virtual bool OnMemoryDump(const MemoryDumpArgs& args, |
| 40 ProcessMemoryDump* pmd) = 0; | 44 ProcessMemoryDump* pmd) = 0; |
| 41 | 45 |
| 42 protected: | 46 protected: |
| 43 MemoryDumpProvider() {} | 47 MemoryDumpProvider() {} |
| 44 virtual ~MemoryDumpProvider() {} | 48 virtual ~MemoryDumpProvider() {} |
| 45 | 49 |
| 46 DISALLOW_COPY_AND_ASSIGN(MemoryDumpProvider); | 50 DISALLOW_COPY_AND_ASSIGN(MemoryDumpProvider); |
| 47 }; | 51 }; |
| 48 | 52 |
| 49 } // namespace trace_event | 53 } // namespace trace_event |
| 50 } // namespace base | 54 } // namespace base |
| 51 | 55 |
| 52 #endif // BASE_TRACE_EVENT_MEMORY_DUMP_PROVIDER_H_ | 56 #endif // BASE_TRACE_EVENT_MEMORY_DUMP_PROVIDER_H_ |
| OLD | NEW |