| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "content/browser/indexed_db/leveldb/leveldb_database.h" | 5 #include "content/browser/indexed_db/leveldb/leveldb_database.h" |
| 6 | 6 |
| 7 #include <inttypes.h> |
| 7 #include <stdint.h> | 8 #include <stdint.h> |
| 8 | 9 |
| 9 #include <cerrno> | 10 #include <cerrno> |
| 10 #include <memory> | 11 #include <memory> |
| 11 #include <utility> | 12 #include <utility> |
| 12 | 13 |
| 13 #include "base/files/file.h" | 14 #include "base/files/file.h" |
| 14 #include "base/logging.h" | 15 #include "base/logging.h" |
| 15 #include "base/macros.h" | 16 #include "base/macros.h" |
| 16 #include "base/memory/ptr_util.h" | 17 #include "base/memory/ptr_util.h" |
| (...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 453 base::trace_event::ProcessMemoryDump* pmd) { | 454 base::trace_event::ProcessMemoryDump* pmd) { |
| 454 if (!db_) | 455 if (!db_) |
| 455 return false; | 456 return false; |
| 456 | 457 |
| 457 std::string value; | 458 std::string value; |
| 458 uint64_t size; | 459 uint64_t size; |
| 459 bool res = db_->GetProperty("leveldb.approximate-memory-usage", &value); | 460 bool res = db_->GetProperty("leveldb.approximate-memory-usage", &value); |
| 460 DCHECK(res); | 461 DCHECK(res); |
| 461 base::StringToUint64(value, &size); | 462 base::StringToUint64(value, &size); |
| 462 | 463 |
| 463 auto dump = pmd->CreateAllocatorDump( | 464 auto dump = pmd->CreateAllocatorDump(base::StringPrintf( |
| 464 base::StringPrintf("leveldb/index_db/%p", db_.get())); | 465 "leveldb/index_db/0x%" PRIXPTR, reinterpret_cast<uintptr_t>(db_.get()))); |
| 465 dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize, | 466 dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize, |
| 466 base::trace_event::MemoryAllocatorDump::kUnitsBytes, size); | 467 base::trace_event::MemoryAllocatorDump::kUnitsBytes, size); |
| 467 dump->AddString("file_name", "", file_name_for_tracing); | 468 dump->AddString("file_name", "", file_name_for_tracing); |
| 468 | 469 |
| 469 // Memory is allocated from system allocator (malloc). | 470 // Memory is allocated from system allocator (malloc). |
| 470 pmd->AddSuballocation(dump->guid(), | 471 pmd->AddSuballocation(dump->guid(), |
| 471 base::trace_event::MemoryDumpManager::GetInstance() | 472 base::trace_event::MemoryDumpManager::GetInstance() |
| 472 ->system_allocator_pool_name()); | 473 ->system_allocator_pool_name()); |
| 473 return true; | 474 return true; |
| 474 } | 475 } |
| 475 | 476 |
| 476 } // namespace content | 477 } // namespace content |
| OLD | NEW |