Benjamin Lerman | 507bb1a | 2015-02-26 13:15:17 +0100 | [diff] [blame] | 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 |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef BASE_TRACE_EVENT_PROCESS_MEMORY_MAPS_H_ |
| 6 | #define BASE_TRACE_EVENT_PROCESS_MEMORY_MAPS_H_ |
| 7 | |
| 8 | #include <string> |
| 9 | #include <vector> |
| 10 | |
| 11 | #include "base/base_export.h" |
| 12 | #include "base/basictypes.h" |
| 13 | |
| 14 | namespace base { |
| 15 | namespace trace_event { |
| 16 | |
| 17 | class TracedValue; |
| 18 | |
| 19 | // Data model for process-wide memory stats. |
| 20 | class BASE_EXPORT ProcessMemoryMaps { |
| 21 | public: |
Viet-Trung Luu | 235cf3d | 2015-06-11 10:01:25 -0700 | [diff] [blame] | 22 | struct BASE_EXPORT VMRegion { |
Benjamin Lerman | 507bb1a | 2015-02-26 13:15:17 +0100 | [diff] [blame] | 23 | static const uint32 kProtectionFlagsRead; |
| 24 | static const uint32 kProtectionFlagsWrite; |
| 25 | static const uint32 kProtectionFlagsExec; |
| 26 | |
Viet-Trung Luu | 235cf3d | 2015-06-11 10:01:25 -0700 | [diff] [blame] | 27 | VMRegion(); |
| 28 | |
Benjamin Lerman | 507bb1a | 2015-02-26 13:15:17 +0100 | [diff] [blame] | 29 | uint64 start_address; |
| 30 | uint64 size_in_bytes; |
| 31 | uint32 protection_flags; |
| 32 | std::string mapped_file; |
Alhaad Gokhale | 4f51307 | 2015-03-24 10:49:34 -0700 | [diff] [blame] | 33 | |
Viet-Trung Luu | 235cf3d | 2015-06-11 10:01:25 -0700 | [diff] [blame] | 34 | // private_dirty_resident + private_clean_resident + shared_dirty_resident + |
| 35 | // shared_clean_resident = resident set size. |
| 36 | uint64 byte_stats_private_dirty_resident; |
| 37 | uint64 byte_stats_private_clean_resident; |
| 38 | uint64 byte_stats_shared_dirty_resident; |
| 39 | uint64 byte_stats_shared_clean_resident; |
| 40 | |
| 41 | uint64 byte_stats_swapped; |
Alhaad Gokhale | 4f51307 | 2015-03-24 10:49:34 -0700 | [diff] [blame] | 42 | |
| 43 | // For multiprocess accounting. |
| 44 | uint64 byte_stats_proportional_resident; |
Benjamin Lerman | 507bb1a | 2015-02-26 13:15:17 +0100 | [diff] [blame] | 45 | }; |
| 46 | |
| 47 | ProcessMemoryMaps(); |
| 48 | ~ProcessMemoryMaps(); |
| 49 | |
| 50 | void AddVMRegion(const VMRegion& region) { vm_regions_.push_back(region); } |
| 51 | const std::vector<VMRegion>& vm_regions() const { return vm_regions_; } |
| 52 | |
| 53 | // Called at trace generation time to populate the TracedValue. |
| 54 | void AsValueInto(TracedValue* value) const; |
| 55 | |
Viet-Trung Luu | 235cf3d | 2015-06-11 10:01:25 -0700 | [diff] [blame] | 56 | // Clears up all the VMRegion(s) stored. |
| 57 | void Clear(); |
| 58 | |
Benjamin Lerman | 507bb1a | 2015-02-26 13:15:17 +0100 | [diff] [blame] | 59 | private: |
| 60 | std::vector<VMRegion> vm_regions_; |
| 61 | |
| 62 | DISALLOW_COPY_AND_ASSIGN(ProcessMemoryMaps); |
| 63 | }; |
| 64 | |
| 65 | } // namespace trace_event |
| 66 | } // namespace base |
| 67 | |
| 68 | #endif // BASE_TRACE_EVENT_PROCESS_MEMORY_MAPS_H_ |