Chromium Code Reviews| 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 BASE_MEMORY_SHARED_MEMORY_TRACKER_H_ | 5 #ifndef BASE_MEMORY_SHARED_MEMORY_TRACKER_H_ |
| 6 #define BASE_MEMORY_SHARED_MEMORY_TRACKER_H_ | 6 #define BASE_MEMORY_SHARED_MEMORY_TRACKER_H_ |
| 7 | 7 |
| 8 #include <unordered_map> | 8 #include <unordered_map> |
| 9 | 9 |
| 10 #include "base/memory/shared_memory.h" | 10 #include "base/memory/shared_memory.h" |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 24 // Returns a singleton instance. | 24 // Returns a singleton instance. |
| 25 static SharedMemoryTracker* GetInstance(); | 25 static SharedMemoryTracker* GetInstance(); |
| 26 | 26 |
| 27 // Records shared memory usage on mapping. | 27 // Records shared memory usage on mapping. |
| 28 void IncrementMemoryUsage(const SharedMemory& shared_memory); | 28 void IncrementMemoryUsage(const SharedMemory& shared_memory); |
| 29 | 29 |
| 30 // Records shared memory usage on unmapping. | 30 // Records shared memory usage on unmapping. |
| 31 void DecrementMemoryUsage(const SharedMemory& shared_memory); | 31 void DecrementMemoryUsage(const SharedMemory& shared_memory); |
| 32 | 32 |
| 33 private: | 33 private: |
| 34 struct Usage { | |
| 35 Usage(); | |
| 36 Usage(const Usage& rhs); | |
| 37 ~Usage(); | |
| 38 SharedMemory::UniqueId unique_id; | |
| 39 size_t size; | |
| 40 }; | |
| 41 | |
| 42 SharedMemoryTracker(); | 34 SharedMemoryTracker(); |
| 43 ~SharedMemoryTracker() override; | 35 ~SharedMemoryTracker() override; |
| 44 | 36 |
| 45 // base::trace_event::MemoryDumpProvider implementation. | 37 // base::trace_event::MemoryDumpProvider implementation. |
| 46 bool OnMemoryDump(const base::trace_event::MemoryDumpArgs& args, | 38 bool OnMemoryDump(const base::trace_event::MemoryDumpArgs& args, |
| 47 base::trace_event::ProcessMemoryDump* pmd) override; | 39 base::trace_event::ProcessMemoryDump* pmd) override; |
| 48 | 40 |
| 49 // Used to lock when |usages_| is modified or read. | 41 // Used to lock when |usages_| is modified or read. |
| 50 Lock usages_lock_; | 42 Lock usages_lock_; |
| 51 std::unordered_map<const SharedMemory*, Usage> usages_; | 43 std::unordered_map<const SharedMemory*, std::size_t> usages_; |
|
danakj
2017/05/09 14:54:18
just size_t, no std::
hajimehoshi
2017/05/10 05:55:22
Done.
| |
| 52 | 44 |
| 53 DISALLOW_COPY_AND_ASSIGN(SharedMemoryTracker); | 45 DISALLOW_COPY_AND_ASSIGN(SharedMemoryTracker); |
| 54 }; | 46 }; |
| 55 | 47 |
| 56 } // namespace base | 48 } // namespace base |
| 57 | 49 |
| 58 #endif // BASE_MEMORY_SHARED_MEMORY_TRACKER_H_ | 50 #endif // BASE_MEMORY_SHARED_MEMORY_TRACKER_H_ |
| OLD | NEW |