| 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_TRACE_EVENT_MEMORY_OVERHEAD_H_ | 5 #ifndef BASE_TRACE_EVENT_TRACE_EVENT_MEMORY_OVERHEAD_H_ |
| 6 #define BASE_TRACE_EVENT_TRACE_EVENT_MEMORY_OVERHEAD_H_ | 6 #define BASE_TRACE_EVENT_TRACE_EVENT_MEMORY_OVERHEAD_H_ |
| 7 | 7 |
| 8 #include "base/base_export.h" | 8 #include "base/base_export.h" |
| 9 #include "base/containers/hash_tables.h" | 9 #include "base/containers/hash_tables.h" |
| 10 #include "base/containers/small_map.h" | 10 #include "base/containers/small_map.h" |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 | 36 |
| 37 // Specialized profiling functions for commonly used object types. | 37 // Specialized profiling functions for commonly used object types. |
| 38 void AddString(const std::string& str); | 38 void AddString(const std::string& str); |
| 39 void AddValue(const Value& value); | 39 void AddValue(const Value& value); |
| 40 void AddRefCountedString(const RefCountedString& str); | 40 void AddRefCountedString(const RefCountedString& str); |
| 41 | 41 |
| 42 // Call this after all the Add* methods above to account the memory used by | 42 // Call this after all the Add* methods above to account the memory used by |
| 43 // this TraceEventMemoryOverhead instance itself. | 43 // this TraceEventMemoryOverhead instance itself. |
| 44 void AddSelf(); | 44 void AddSelf(); |
| 45 | 45 |
| 46 // Retrieves the count, that is, the count of Add*(|object_type|, ...) calls. | |
| 47 size_t GetCount(const char* object_type) const; | |
| 48 | |
| 49 // Adds up and merges all the values from |other| to this instance. | 46 // Adds up and merges all the values from |other| to this instance. |
| 50 void Update(const TraceEventMemoryOverhead& other); | 47 void Update(const TraceEventMemoryOverhead& other); |
| 51 | 48 |
| 52 void DumpInto(const char* base_name, ProcessMemoryDump* pmd) const; | 49 void DumpInto(const char* base_name, ProcessMemoryDump* pmd) const; |
| 53 | 50 |
| 54 private: | 51 private: |
| 55 struct ObjectCountAndSize { | 52 struct ObjectCountAndSize { |
| 56 size_t count; | 53 size_t count; |
| 57 size_t allocated_size_in_bytes; | 54 size_t allocated_size_in_bytes; |
| 58 size_t resident_size_in_bytes; | 55 size_t resident_size_in_bytes; |
| 59 }; | 56 }; |
| 60 using map_type = SmallMap<hash_map<const char*, ObjectCountAndSize>, 16>; | 57 using map_type = SmallMap<hash_map<const char*, ObjectCountAndSize>, 16>; |
| 61 map_type allocated_objects_; | 58 map_type allocated_objects_; |
| 62 | 59 |
| 63 void AddOrCreateInternal(const char* object_type, | 60 void AddOrCreateInternal(const char* object_type, |
| 64 size_t count, | 61 size_t count, |
| 65 size_t allocated_size_in_bytes, | 62 size_t allocated_size_in_bytes, |
| 66 size_t resident_size_in_bytes); | 63 size_t resident_size_in_bytes); |
| 67 | 64 |
| 68 DISALLOW_COPY_AND_ASSIGN(TraceEventMemoryOverhead); | 65 DISALLOW_COPY_AND_ASSIGN(TraceEventMemoryOverhead); |
| 69 }; | 66 }; |
| 70 | 67 |
| 71 } // namespace trace_event | 68 } // namespace trace_event |
| 72 } // namespace base | 69 } // namespace base |
| 73 | 70 |
| 74 #endif // BASE_TRACE_EVENT_TRACE_EVENT_MEMORY_OVERHEAD_H_ | 71 #endif // BASE_TRACE_EVENT_TRACE_EVENT_MEMORY_OVERHEAD_H_ |
| OLD | NEW |