| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 SERVICES_RESOURCE_COORDINATOR_PUBLIC_CPP_MEMORY_MEMORY_INSTRUMENTATION_S
TRUCT_TRAITS_H_ | 5 #ifndef SERVICES_RESOURCE_COORDINATOR_PUBLIC_CPP_MEMORY_MEMORY_INSTRUMENTATION_S
TRUCT_TRAITS_H_ |
| 6 #define SERVICES_RESOURCE_COORDINATOR_PUBLIC_CPP_MEMORY_MEMORY_INSTRUMENTATION_S
TRUCT_TRAITS_H_ | 6 #define SERVICES_RESOURCE_COORDINATOR_PUBLIC_CPP_MEMORY_MEMORY_INSTRUMENTATION_S
TRUCT_TRAITS_H_ |
| 7 | 7 |
| 8 #include "base/process/process_handle.h" | 8 #include "base/process/process_handle.h" |
| 9 #include "base/trace_event/memory_dump_request_args.h" | 9 #include "base/trace_event/memory_dump_request_args.h" |
| 10 #include "mojo/common/common_custom_types_struct_traits.h" | 10 #include "mojo/common/common_custom_types_struct_traits.h" |
| 11 #include "services/resource_coordinator/public/cpp/resource_coordinator_export.h
" | 11 #include "services/resource_coordinator/public/cpp/memory/memory_export.h" |
| 12 #include "services/resource_coordinator/public/interfaces/memory/memory_instrume
ntation.mojom.h" | 12 #include "services/resource_coordinator/public/interfaces/memory/memory_instrume
ntation.mojom.h" |
| 13 | 13 |
| 14 namespace mojo { | 14 namespace mojo { |
| 15 | 15 |
| 16 template <> | 16 template <> |
| 17 struct SERVICES_RESOURCE_COORDINATOR_PUBLIC_CPP_EXPORT | 17 struct SERVICES_RESOURCE_COORDINATOR_PUBLIC_CPP_MEMORY_EXPORT |
| 18 EnumTraits<memory_instrumentation::mojom::DumpType, | 18 EnumTraits<memory_instrumentation::mojom::DumpType, |
| 19 base::trace_event::MemoryDumpType> { | 19 base::trace_event::MemoryDumpType> { |
| 20 static memory_instrumentation::mojom::DumpType ToMojom( | 20 static memory_instrumentation::mojom::DumpType ToMojom( |
| 21 base::trace_event::MemoryDumpType type); | 21 base::trace_event::MemoryDumpType type); |
| 22 static bool FromMojom(memory_instrumentation::mojom::DumpType input, | 22 static bool FromMojom(memory_instrumentation::mojom::DumpType input, |
| 23 base::trace_event::MemoryDumpType* out); | 23 base::trace_event::MemoryDumpType* out); |
| 24 }; | 24 }; |
| 25 | 25 |
| 26 template <> | 26 template <> |
| 27 struct SERVICES_RESOURCE_COORDINATOR_PUBLIC_CPP_EXPORT | 27 struct SERVICES_RESOURCE_COORDINATOR_PUBLIC_CPP_MEMORY_EXPORT |
| 28 EnumTraits<memory_instrumentation::mojom::LevelOfDetail, | 28 EnumTraits<memory_instrumentation::mojom::LevelOfDetail, |
| 29 base::trace_event::MemoryDumpLevelOfDetail> { | 29 base::trace_event::MemoryDumpLevelOfDetail> { |
| 30 static memory_instrumentation::mojom::LevelOfDetail ToMojom( | 30 static memory_instrumentation::mojom::LevelOfDetail ToMojom( |
| 31 base::trace_event::MemoryDumpLevelOfDetail level_of_detail); | 31 base::trace_event::MemoryDumpLevelOfDetail level_of_detail); |
| 32 static bool FromMojom(memory_instrumentation::mojom::LevelOfDetail input, | 32 static bool FromMojom(memory_instrumentation::mojom::LevelOfDetail input, |
| 33 base::trace_event::MemoryDumpLevelOfDetail* out); | 33 base::trace_event::MemoryDumpLevelOfDetail* out); |
| 34 }; | 34 }; |
| 35 | 35 |
| 36 template <> | 36 template <> |
| 37 struct SERVICES_RESOURCE_COORDINATOR_PUBLIC_CPP_EXPORT | 37 struct SERVICES_RESOURCE_COORDINATOR_PUBLIC_CPP_MEMORY_EXPORT |
| 38 StructTraits<memory_instrumentation::mojom::RequestArgsDataView, | 38 StructTraits<memory_instrumentation::mojom::RequestArgsDataView, |
| 39 base::trace_event::MemoryDumpRequestArgs> { | 39 base::trace_event::MemoryDumpRequestArgs> { |
| 40 static uint64_t dump_guid( | 40 static uint64_t dump_guid( |
| 41 const base::trace_event::MemoryDumpRequestArgs& args) { | 41 const base::trace_event::MemoryDumpRequestArgs& args) { |
| 42 return args.dump_guid; | 42 return args.dump_guid; |
| 43 } | 43 } |
| 44 static base::trace_event::MemoryDumpType dump_type( | 44 static base::trace_event::MemoryDumpType dump_type( |
| 45 const base::trace_event::MemoryDumpRequestArgs& args) { | 45 const base::trace_event::MemoryDumpRequestArgs& args) { |
| 46 return args.dump_type; | 46 return args.dump_type; |
| 47 } | 47 } |
| 48 static base::trace_event::MemoryDumpLevelOfDetail level_of_detail( | 48 static base::trace_event::MemoryDumpLevelOfDetail level_of_detail( |
| 49 const base::trace_event::MemoryDumpRequestArgs& args) { | 49 const base::trace_event::MemoryDumpRequestArgs& args) { |
| 50 return args.level_of_detail; | 50 return args.level_of_detail; |
| 51 } | 51 } |
| 52 static bool Read(memory_instrumentation::mojom::RequestArgsDataView input, | 52 static bool Read(memory_instrumentation::mojom::RequestArgsDataView input, |
| 53 base::trace_event::MemoryDumpRequestArgs* out); | 53 base::trace_event::MemoryDumpRequestArgs* out); |
| 54 }; | 54 }; |
| 55 | 55 |
| 56 template <> | 56 template <> |
| 57 struct SERVICES_RESOURCE_COORDINATOR_PUBLIC_CPP_EXPORT | 57 struct SERVICES_RESOURCE_COORDINATOR_PUBLIC_CPP_MEMORY_EXPORT |
| 58 StructTraits<memory_instrumentation::mojom::ChromeMemDumpDataView, | 58 StructTraits<memory_instrumentation::mojom::ChromeMemDumpDataView, |
| 59 base::trace_event::MemoryDumpCallbackResult::ChromeMemDump> { | 59 base::trace_event::MemoryDumpCallbackResult::ChromeMemDump> { |
| 60 static uint32_t malloc_total_kb( | 60 static uint32_t malloc_total_kb( |
| 61 const base::trace_event::MemoryDumpCallbackResult::ChromeMemDump& args) { | 61 const base::trace_event::MemoryDumpCallbackResult::ChromeMemDump& args) { |
| 62 return args.malloc_total_kb; | 62 return args.malloc_total_kb; |
| 63 } | 63 } |
| 64 static uint32_t partition_alloc_total_kb( | 64 static uint32_t partition_alloc_total_kb( |
| 65 const base::trace_event::MemoryDumpCallbackResult::ChromeMemDump& args) { | 65 const base::trace_event::MemoryDumpCallbackResult::ChromeMemDump& args) { |
| 66 return args.partition_alloc_total_kb; | 66 return args.partition_alloc_total_kb; |
| 67 } | 67 } |
| 68 static uint32_t blink_gc_total_kb( | 68 static uint32_t blink_gc_total_kb( |
| 69 const base::trace_event::MemoryDumpCallbackResult::ChromeMemDump& args) { | 69 const base::trace_event::MemoryDumpCallbackResult::ChromeMemDump& args) { |
| 70 return args.blink_gc_total_kb; | 70 return args.blink_gc_total_kb; |
| 71 } | 71 } |
| 72 static uint32_t v8_total_kb( | 72 static uint32_t v8_total_kb( |
| 73 const base::trace_event::MemoryDumpCallbackResult::ChromeMemDump& args) { | 73 const base::trace_event::MemoryDumpCallbackResult::ChromeMemDump& args) { |
| 74 return args.v8_total_kb; | 74 return args.v8_total_kb; |
| 75 } | 75 } |
| 76 static bool Read( | 76 static bool Read( |
| 77 memory_instrumentation::mojom::ChromeMemDumpDataView input, | 77 memory_instrumentation::mojom::ChromeMemDumpDataView input, |
| 78 base::trace_event::MemoryDumpCallbackResult::ChromeMemDump* out); | 78 base::trace_event::MemoryDumpCallbackResult::ChromeMemDump* out); |
| 79 }; | 79 }; |
| 80 | 80 |
| 81 template <> | 81 template <> |
| 82 struct SERVICES_RESOURCE_COORDINATOR_PUBLIC_CPP_EXPORT | 82 struct SERVICES_RESOURCE_COORDINATOR_PUBLIC_CPP_MEMORY_EXPORT |
| 83 StructTraits<memory_instrumentation::mojom::OSMemDumpDataView, | 83 StructTraits<memory_instrumentation::mojom::OSMemDumpDataView, |
| 84 base::trace_event::MemoryDumpCallbackResult::OSMemDump> { | 84 base::trace_event::MemoryDumpCallbackResult::OSMemDump> { |
| 85 static uint32_t resident_set_kb( | 85 static uint32_t resident_set_kb( |
| 86 const base::trace_event::MemoryDumpCallbackResult::OSMemDump& args) { | 86 const base::trace_event::MemoryDumpCallbackResult::OSMemDump& args) { |
| 87 return args.resident_set_kb; | 87 return args.resident_set_kb; |
| 88 } | 88 } |
| 89 static bool Read(memory_instrumentation::mojom::OSMemDumpDataView input, | 89 static bool Read(memory_instrumentation::mojom::OSMemDumpDataView input, |
| 90 base::trace_event::MemoryDumpCallbackResult::OSMemDump* out); | 90 base::trace_event::MemoryDumpCallbackResult::OSMemDump* out); |
| 91 }; | 91 }; |
| 92 | 92 |
| 93 template <> | 93 template <> |
| 94 struct SERVICES_RESOURCE_COORDINATOR_PUBLIC_CPP_EXPORT StructTraits< | 94 struct SERVICES_RESOURCE_COORDINATOR_PUBLIC_CPP_MEMORY_EXPORT StructTraits< |
| 95 memory_instrumentation::mojom::MemoryDumpCallbackResultDataView, | 95 memory_instrumentation::mojom::MemoryDumpCallbackResultDataView, |
| 96 base::trace_event::MemoryDumpCallbackResult> { | 96 base::trace_event::MemoryDumpCallbackResult> { |
| 97 static base::trace_event::MemoryDumpCallbackResult::OSMemDump os_dump( | 97 static base::trace_event::MemoryDumpCallbackResult::OSMemDump os_dump( |
| 98 const base::trace_event::MemoryDumpCallbackResult& args) { | 98 const base::trace_event::MemoryDumpCallbackResult& args) { |
| 99 return args.os_dump; | 99 return args.os_dump; |
| 100 } | 100 } |
| 101 static base::trace_event::MemoryDumpCallbackResult::ChromeMemDump chrome_dump( | 101 static base::trace_event::MemoryDumpCallbackResult::ChromeMemDump chrome_dump( |
| 102 const base::trace_event::MemoryDumpCallbackResult& args) { | 102 const base::trace_event::MemoryDumpCallbackResult& args) { |
| 103 return args.chrome_dump; | 103 return args.chrome_dump; |
| 104 } | 104 } |
| 105 static const std::map<base::ProcessId, | 105 static const std::map<base::ProcessId, |
| 106 base::trace_event::MemoryDumpCallbackResult::OSMemDump>& | 106 base::trace_event::MemoryDumpCallbackResult::OSMemDump>& |
| 107 extra_processes_dump( | 107 extra_processes_dump( |
| 108 const base::trace_event::MemoryDumpCallbackResult& args) { | 108 const base::trace_event::MemoryDumpCallbackResult& args) { |
| 109 return args.extra_processes_dump; | 109 return args.extra_processes_dump; |
| 110 } | 110 } |
| 111 static bool Read( | 111 static bool Read( |
| 112 memory_instrumentation::mojom::MemoryDumpCallbackResultDataView input, | 112 memory_instrumentation::mojom::MemoryDumpCallbackResultDataView input, |
| 113 base::trace_event::MemoryDumpCallbackResult* out); | 113 base::trace_event::MemoryDumpCallbackResult* out); |
| 114 }; | 114 }; |
| 115 | 115 |
| 116 } // namespace mojo | 116 } // namespace mojo |
| 117 | 117 |
| 118 #endif // SERVICES_RESOURCE_COORDINATOR_PUBLIC_CPP_MEMORY_MEMORY_INSTRUMENTATIO
N_STRUCT_TRAITS_H_ | 118 #endif // SERVICES_RESOURCE_COORDINATOR_PUBLIC_CPP_MEMORY_MEMORY_INSTRUMENTATIO
N_STRUCT_TRAITS_H_ |
| OLD | NEW |