| 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 "extensions/browser/value_store/leveldb_value_store.h" | 5 #include "extensions/browser/value_store/leveldb_value_store.h" |
| 6 | 6 |
| 7 #include <inttypes.h> | 7 #include <inttypes.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 245 if (!db()) | 245 if (!db()) |
| 246 return true; | 246 return true; |
| 247 | 247 |
| 248 std::string value; | 248 std::string value; |
| 249 uint64_t size; | 249 uint64_t size; |
| 250 bool res = db()->GetProperty("leveldb.approximate-memory-usage", &value); | 250 bool res = db()->GetProperty("leveldb.approximate-memory-usage", &value); |
| 251 DCHECK(res); | 251 DCHECK(res); |
| 252 res = base::StringToUint64(value, &size); | 252 res = base::StringToUint64(value, &size); |
| 253 DCHECK(res); | 253 DCHECK(res); |
| 254 | 254 |
| 255 auto dump = pmd->CreateAllocatorDump(base::StringPrintf( | 255 auto* dump = pmd->CreateAllocatorDump(base::StringPrintf( |
| 256 "leveldb/value_store/%s/0x%" PRIXPTR, open_histogram_name().c_str(), | 256 "leveldb/value_store/%s/0x%" PRIXPTR, open_histogram_name().c_str(), |
| 257 reinterpret_cast<uintptr_t>(this))); | 257 reinterpret_cast<uintptr_t>(this))); |
| 258 dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize, | 258 dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize, |
| 259 base::trace_event::MemoryAllocatorDump::kUnitsBytes, size); | 259 base::trace_event::MemoryAllocatorDump::kUnitsBytes, size); |
| 260 | 260 |
| 261 // Memory is allocated from system allocator (malloc). | 261 // Memory is allocated from system allocator (malloc). |
| 262 const char* system_allocator_name = | 262 const char* system_allocator_name = |
| 263 base::trace_event::MemoryDumpManager::GetInstance() | 263 base::trace_event::MemoryDumpManager::GetInstance() |
| 264 ->system_allocator_pool_name(); | 264 ->system_allocator_pool_name(); |
| 265 if (system_allocator_name) | 265 if (system_allocator_name) |
| (...skipping 29 matching lines...) Expand all Loading... |
| 295 return Status(OTHER_ERROR, kCannotSerialize); | 295 return Status(OTHER_ERROR, kCannotSerialize); |
| 296 batch->Put(key, value_as_json); | 296 batch->Put(key, value_as_json); |
| 297 } | 297 } |
| 298 | 298 |
| 299 return Status(); | 299 return Status(); |
| 300 } | 300 } |
| 301 | 301 |
| 302 ValueStore::Status LeveldbValueStore::WriteToDb(leveldb::WriteBatch* batch) { | 302 ValueStore::Status LeveldbValueStore::WriteToDb(leveldb::WriteBatch* batch) { |
| 303 return ToValueStoreError(db()->Write(write_options(), batch)); | 303 return ToValueStoreError(db()->Write(write_options(), batch)); |
| 304 } | 304 } |
| OLD | NEW |