| 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 <inttypes.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <cerrno> | 10 #include <cerrno> |
| (...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 474 std::string value; | 474 std::string value; |
| 475 uint64_t size; | 475 uint64_t size; |
| 476 bool res = db_->GetProperty("leveldb.approximate-memory-usage", &value); | 476 bool res = db_->GetProperty("leveldb.approximate-memory-usage", &value); |
| 477 DCHECK(res); | 477 DCHECK(res); |
| 478 base::StringToUint64(value, &size); | 478 base::StringToUint64(value, &size); |
| 479 | 479 |
| 480 auto* dump = pmd->CreateAllocatorDump(base::StringPrintf( | 480 auto* dump = pmd->CreateAllocatorDump(base::StringPrintf( |
| 481 "leveldb/index_db/0x%" PRIXPTR, reinterpret_cast<uintptr_t>(db_.get()))); | 481 "leveldb/index_db/0x%" PRIXPTR, reinterpret_cast<uintptr_t>(db_.get()))); |
| 482 dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize, | 482 dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize, |
| 483 base::trace_event::MemoryAllocatorDump::kUnitsBytes, size); | 483 base::trace_event::MemoryAllocatorDump::kUnitsBytes, size); |
| 484 |
| 485 // Dumps in BACKGROUND mode cannot have strings or edges in order to minimize |
| 486 // trace size and instrumentation overhead. |
| 487 if (args.level_of_detail == |
| 488 base::trace_event::MemoryDumpLevelOfDetail::BACKGROUND) { |
| 489 return true; |
| 490 } |
| 491 |
| 484 dump->AddString("file_name", "", file_name_for_tracing); | 492 dump->AddString("file_name", "", file_name_for_tracing); |
| 485 | 493 |
| 486 // Memory is allocated from system allocator (malloc). | 494 // Memory is allocated from system allocator (malloc). |
| 487 pmd->AddSuballocation(dump->guid(), | 495 pmd->AddSuballocation(dump->guid(), |
| 488 base::trace_event::MemoryDumpManager::GetInstance() | 496 base::trace_event::MemoryDumpManager::GetInstance() |
| 489 ->system_allocator_pool_name()); | 497 ->system_allocator_pool_name()); |
| 490 return true; | 498 return true; |
| 491 } | 499 } |
| 492 | 500 |
| 493 std::unique_ptr<leveldb::Iterator> LevelDBDatabase::CreateLevelDBIterator( | 501 std::unique_ptr<leveldb::Iterator> LevelDBDatabase::CreateLevelDBIterator( |
| (...skipping 20 matching lines...) Expand all Loading... |
| 514 void LevelDBDatabase::OnIteratorDestroyed(LevelDBIterator* iter) { | 522 void LevelDBDatabase::OnIteratorDestroyed(LevelDBIterator* iter) { |
| 515 DCHECK_GT(num_iterators_, 0u); | 523 DCHECK_GT(num_iterators_, 0u); |
| 516 --num_iterators_; | 524 --num_iterators_; |
| 517 auto it = iterator_lru_.Peek(iter); | 525 auto it = iterator_lru_.Peek(iter); |
| 518 if (it == iterator_lru_.end()) | 526 if (it == iterator_lru_.end()) |
| 519 return; | 527 return; |
| 520 iterator_lru_.Erase(it); | 528 iterator_lru_.Erase(it); |
| 521 } | 529 } |
| 522 | 530 |
| 523 } // namespace content | 531 } // namespace content |
| OLD | NEW |