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