OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #include "components/leveldb_proto/leveldb_database.h" | 5 #include "components/leveldb_proto/leveldb_database.h" |
6 | 6 |
7 #include <inttypes.h> | 7 #include <inttypes.h> |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 if (!db_) | 180 if (!db_) |
181 return false; | 181 return false; |
182 | 182 |
183 std::string value; | 183 std::string value; |
184 uint64_t size; | 184 uint64_t size; |
185 bool res = db_->GetProperty("leveldb.approximate-memory-usage", &value); | 185 bool res = db_->GetProperty("leveldb.approximate-memory-usage", &value); |
186 DCHECK(res); | 186 DCHECK(res); |
187 res = base::StringToUint64(value, &size); | 187 res = base::StringToUint64(value, &size); |
188 DCHECK(res); | 188 DCHECK(res); |
189 | 189 |
190 std::string dump_name = "leveldb/leveldb_proto"; | |
191 if (!client_name_.empty()) | |
192 dump_name += "/" + client_name_; | |
193 base::trace_event::MemoryAllocatorDump* dump = pmd->CreateAllocatorDump( | 190 base::trace_event::MemoryAllocatorDump* dump = pmd->CreateAllocatorDump( |
194 base::StringPrintf("%s/0x%" PRIXPTR, dump_name.c_str(), | 191 base::StringPrintf("leveldb/leveldb_proto/0x%" PRIXPTR, |
195 reinterpret_cast<uintptr_t>(db_.get()))); | 192 reinterpret_cast<uintptr_t>(db_.get()))); |
196 dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize, | 193 dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize, |
197 base::trace_event::MemoryAllocatorDump::kUnitsBytes, size); | 194 base::trace_event::MemoryAllocatorDump::kUnitsBytes, size); |
| 195 if (!client_name_.empty() && |
| 196 dump_args.level_of_detail != |
| 197 base::trace_event::MemoryDumpLevelOfDetail::BACKGROUND) { |
| 198 dump->AddString("client_name", "", client_name_); |
| 199 } |
198 | 200 |
199 // Memory is allocated from system allocator (malloc). | 201 // Memory is allocated from system allocator (malloc). |
200 const char* system_allocator_pool_name = | 202 const char* system_allocator_pool_name = |
201 base::trace_event::MemoryDumpManager::GetInstance() | 203 base::trace_event::MemoryDumpManager::GetInstance() |
202 ->system_allocator_pool_name(); | 204 ->system_allocator_pool_name(); |
203 if (system_allocator_pool_name) | 205 if (system_allocator_pool_name) |
204 pmd->AddSuballocation(dump->guid(), system_allocator_pool_name); | 206 pmd->AddSuballocation(dump->guid(), system_allocator_pool_name); |
205 | 207 |
206 return true; | 208 return true; |
207 } | 209 } |
208 | 210 |
209 } // namespace leveldb_proto | 211 } // namespace leveldb_proto |
OLD | NEW |