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_REQUEST_ARGS_H_ | 5 #ifndef BASE_TRACE_EVENT_MEMORY_DUMP_REQUEST_ARGS_H_ |
| 6 #define BASE_TRACE_EVENT_MEMORY_DUMP_REQUEST_ARGS_H_ | 6 #define BASE_TRACE_EVENT_MEMORY_DUMP_REQUEST_ARGS_H_ |
| 7 | 7 |
| 8 // This file defines the types and structs used to issue memory dump requests. | 8 // This file defines the types and structs used to issue memory dump requests. |
| 9 // These are also used in the IPCs for coordinating inter-process memory dumps. | 9 // These are also used in the IPCs for coordinating inter-process memory dumps. |
| 10 | 10 |
| 11 #include <stdint.h> | 11 #include <stdint.h> |
| 12 #include <map> | 12 #include <map> |
| 13 #include <string> | 13 #include <string> |
| 14 | 14 |
| 15 #include "base/base_export.h" | 15 #include "base/base_export.h" |
| 16 #include "base/callback.h" | 16 #include "base/callback.h" |
| 17 #include "base/optional.h" | |
| 17 #include "base/process/process_handle.h" | 18 #include "base/process/process_handle.h" |
| 18 | 19 |
| 19 namespace base { | 20 namespace base { |
| 20 namespace trace_event { | 21 namespace trace_event { |
| 21 | 22 |
| 22 // Captures the reason why a memory dump is being requested. This is to allow | 23 // Captures the reason why a memory dump is being requested. This is to allow |
| 23 // selective enabling of dumps, filtering and post-processing. Important: this | 24 // selective enabling of dumps, filtering and post-processing. Important: this |
| 24 // must be kept consistent with | 25 // must be kept consistent with |
| 25 // services/resource_coordinator/public/cpp/memory/memory_infra_traits.cc. | 26 // services/resource_coordinator/public/cpp/memory/memory_infra_traits.cc. |
| 26 enum class MemoryDumpType { | 27 enum class MemoryDumpType { |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 71 // providers. Dump providers are expected to read the args for creating dumps. | 72 // providers. Dump providers are expected to read the args for creating dumps. |
| 72 struct MemoryDumpArgs { | 73 struct MemoryDumpArgs { |
| 73 // Specifies how detailed the dumps should be. | 74 // Specifies how detailed the dumps should be. |
| 74 MemoryDumpLevelOfDetail level_of_detail; | 75 MemoryDumpLevelOfDetail level_of_detail; |
| 75 }; | 76 }; |
| 76 | 77 |
| 77 // TODO(hjd): Not used yet, see crbug.com/703184 | 78 // TODO(hjd): Not used yet, see crbug.com/703184 |
| 78 // Summarises information about memory use as seen by a single process. | 79 // Summarises information about memory use as seen by a single process. |
| 79 // This information will eventually be passed to a service to be colated | 80 // This information will eventually be passed to a service to be colated |
| 80 // and reported. | 81 // and reported. |
| 81 struct MemoryDumpCallbackResult { | 82 struct MemoryDumpCallbackResult { |
|
Primiano Tucci (use gerrit)
2017/04/07 15:31:36
I think you now need BASE_EXPORT here.
The bots a
fmeawad
2017/04/10 20:20:19
Done.
| |
| 82 struct OSMemDump { | 83 struct OSMemDump { |
| 83 uint32_t resident_set_kb = 0; | 84 uint32_t resident_set_kb = 0; |
| 84 }; | 85 }; |
| 85 struct ChromeMemDump { | 86 struct ChromeMemDump { |
| 86 uint32_t malloc_total_kb = 0; | 87 uint32_t malloc_total_kb = 0; |
| 87 uint32_t partition_alloc_total_kb = 0; | 88 uint32_t partition_alloc_total_kb = 0; |
| 88 uint32_t blink_gc_total_kb = 0; | 89 uint32_t blink_gc_total_kb = 0; |
| 89 uint32_t v8_total_kb = 0; | 90 uint32_t v8_total_kb = 0; |
| 90 }; | 91 }; |
| 91 | 92 |
| 92 // These are for the current process. | 93 // These are for the current process. |
| 93 OSMemDump os_dump; | 94 OSMemDump os_dump; |
| 94 ChromeMemDump chrome_dump; | 95 ChromeMemDump chrome_dump; |
| 95 | 96 |
| 96 // In some cases, OS stats can only be dumped from a privileged process to | 97 // In some cases, OS stats can only be dumped from a privileged process to |
| 97 // get around to sandboxing/selinux restrictions (see crbug.com/461788). | 98 // get around to sandboxing/selinux restrictions (see crbug.com/461788). |
| 98 std::map<ProcessId, OSMemDump> extra_processes_dump; | 99 std::map<ProcessId, OSMemDump> extra_processes_dump; |
| 99 | 100 |
| 100 MemoryDumpCallbackResult(); | 101 MemoryDumpCallbackResult(); |
| 102 MemoryDumpCallbackResult(const MemoryDumpCallbackResult&); | |
| 101 ~MemoryDumpCallbackResult(); | 103 ~MemoryDumpCallbackResult(); |
| 102 }; | 104 }; |
| 103 | 105 |
| 104 using MemoryDumpCallback = Callback<void(uint64_t dump_guid, bool success)>; | 106 using GlobalMemoryDumpCallback = |
| 107 Callback<void(uint64_t dump_guid, bool success)>; | |
| 108 | |
| 109 using ProcessMemoryDumpCallback = | |
| 110 Callback<void(uint64_t dump_guid, | |
| 111 bool success, | |
| 112 const base::Optional<MemoryDumpCallbackResult>& result)>; | |
|
Primiano Tucci (use gerrit)
2017/04/07 15:31:36
nit: no need for base:: this is already in "namesp
fmeawad
2017/04/10 20:20:19
Done.
| |
| 105 | 113 |
| 106 BASE_EXPORT const char* MemoryDumpTypeToString(const MemoryDumpType& dump_type); | 114 BASE_EXPORT const char* MemoryDumpTypeToString(const MemoryDumpType& dump_type); |
| 107 | 115 |
| 108 BASE_EXPORT MemoryDumpType StringToMemoryDumpType(const std::string& str); | 116 BASE_EXPORT MemoryDumpType StringToMemoryDumpType(const std::string& str); |
| 109 | 117 |
| 110 BASE_EXPORT const char* MemoryDumpLevelOfDetailToString( | 118 BASE_EXPORT const char* MemoryDumpLevelOfDetailToString( |
| 111 const MemoryDumpLevelOfDetail& level_of_detail); | 119 const MemoryDumpLevelOfDetail& level_of_detail); |
| 112 | 120 |
| 113 BASE_EXPORT MemoryDumpLevelOfDetail | 121 BASE_EXPORT MemoryDumpLevelOfDetail |
| 114 StringToMemoryDumpLevelOfDetail(const std::string& str); | 122 StringToMemoryDumpLevelOfDetail(const std::string& str); |
| 115 | 123 |
| 116 } // namespace trace_event | 124 } // namespace trace_event |
| 117 } // namespace base | 125 } // namespace base |
| 118 | 126 |
| 119 #endif // BASE_TRACE_EVENT_MEMORY_DUMP_REQUEST_ARGS_H_ | 127 #endif // BASE_TRACE_EVENT_MEMORY_DUMP_REQUEST_ARGS_H_ |
| OLD | NEW |