| OLD | NEW |
| 1 // Copyright (c) 2011 The LevelDB Authors. All rights reserved. | 1 // Copyright (c) 2011 The LevelDB 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. See the AUTHORS file for names of contributors. | 3 // found in the LICENSE file. See the AUTHORS file for names of contributors. |
| 4 | 4 |
| 5 #include "third_party/leveldatabase/env_chromium.h" | 5 #include "third_party/leveldatabase/env_chromium.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #if defined(OS_POSIX) | 9 #if defined(OS_POSIX) |
| 10 #include <dirent.h> | 10 #include <dirent.h> |
| (...skipping 1175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1186 // 0x7FE70F530D80 188.4 KiB /Users/.../Sync Data/LevelDB | 1186 // 0x7FE70F530D80 188.4 KiB /Users/.../Sync Data/LevelDB |
| 1187 // 0x7FE71442F270 4.0 KiB /Users/.../Sync App Settings/... | 1187 // 0x7FE71442F270 4.0 KiB /Users/.../Sync App Settings/... |
| 1188 // 0x7FE71471EC50 8.0 KiB /Users/.../Extension State | 1188 // 0x7FE71471EC50 8.0 KiB /Users/.../Extension State |
| 1189 // | 1189 // |
| 1190 class DBTracker::MemoryDumpProvider | 1190 class DBTracker::MemoryDumpProvider |
| 1191 : public base::trace_event::MemoryDumpProvider { | 1191 : public base::trace_event::MemoryDumpProvider { |
| 1192 public: | 1192 public: |
| 1193 bool OnMemoryDump(const base::trace_event::MemoryDumpArgs& args, | 1193 bool OnMemoryDump(const base::trace_event::MemoryDumpArgs& args, |
| 1194 base::trace_event::ProcessMemoryDump* pmd) override { | 1194 base::trace_event::ProcessMemoryDump* pmd) override { |
| 1195 auto db_visitor = [&](TrackedDB* db) { | 1195 auto db_visitor = [&](TrackedDB* db) { |
| 1196 std::string db_dump_name = base::StringPrintf( | 1196 std::string db_dump_name = DBTracker::GetMemoryDumpName(db); |
| 1197 "leveldatabase/0x%" PRIXPTR, reinterpret_cast<uintptr_t>(db)); | |
| 1198 auto* db_dump = pmd->CreateAllocatorDump(db_dump_name.c_str()); | 1197 auto* db_dump = pmd->CreateAllocatorDump(db_dump_name.c_str()); |
| 1199 | 1198 |
| 1200 uint64_t db_memory_usage = 0; | 1199 uint64_t db_memory_usage = 0; |
| 1201 { | 1200 { |
| 1202 std::string usage_string; | 1201 std::string usage_string; |
| 1203 bool success = db->GetProperty("leveldb.approximate-memory-usage", | 1202 bool success = db->GetProperty("leveldb.approximate-memory-usage", |
| 1204 &usage_string) && | 1203 &usage_string) && |
| 1205 base::StringToUint64(usage_string, &db_memory_usage); | 1204 base::StringToUint64(usage_string, &db_memory_usage); |
| 1206 DCHECK(success); | 1205 DCHECK(success); |
| 1207 } | 1206 } |
| (...skipping 26 matching lines...) Expand all Loading... |
| 1234 | 1233 |
| 1235 DBTracker::~DBTracker() { | 1234 DBTracker::~DBTracker() { |
| 1236 NOTREACHED(); // DBTracker is a singleton | 1235 NOTREACHED(); // DBTracker is a singleton |
| 1237 } | 1236 } |
| 1238 | 1237 |
| 1239 DBTracker* DBTracker::GetInstance() { | 1238 DBTracker* DBTracker::GetInstance() { |
| 1240 static DBTracker* instance = new DBTracker(); | 1239 static DBTracker* instance = new DBTracker(); |
| 1241 return instance; | 1240 return instance; |
| 1242 } | 1241 } |
| 1243 | 1242 |
| 1243 std::string DBTracker::GetMemoryDumpName(leveldb::DB* db) { |
| 1244 return base::StringPrintf("leveldatabase/0x%" PRIXPTR, |
| 1245 reinterpret_cast<uintptr_t>(db)); |
| 1246 } |
| 1247 |
| 1244 leveldb::Status DBTracker::OpenDatabase(const leveldb::Options& options, | 1248 leveldb::Status DBTracker::OpenDatabase(const leveldb::Options& options, |
| 1245 const std::string& name, | 1249 const std::string& name, |
| 1246 TrackedDB** dbptr) { | 1250 TrackedDB** dbptr) { |
| 1247 leveldb::DB* db = nullptr; | 1251 leveldb::DB* db = nullptr; |
| 1248 auto status = leveldb::DB::Open(options, name, &db); | 1252 auto status = leveldb::DB::Open(options, name, &db); |
| 1249 if (status.ok()) { | 1253 if (status.ok()) { |
| 1250 // TrackedDBImpl ctor adds the instance to the tracker. | 1254 // TrackedDBImpl ctor adds the instance to the tracker. |
| 1251 *dbptr = new TrackedDBImpl(GetInstance(), name, db); | 1255 *dbptr = new TrackedDBImpl(GetInstance(), name, db); |
| 1252 } | 1256 } |
| 1253 return status; | 1257 return status; |
| (...skipping 30 matching lines...) Expand all Loading... |
| 1284 | 1288 |
| 1285 } // namespace leveldb_env | 1289 } // namespace leveldb_env |
| 1286 | 1290 |
| 1287 namespace leveldb { | 1291 namespace leveldb { |
| 1288 | 1292 |
| 1289 Env* Env::Default() { | 1293 Env* Env::Default() { |
| 1290 return leveldb_env::default_env.Pointer(); | 1294 return leveldb_env::default_env.Pointer(); |
| 1291 } | 1295 } |
| 1292 | 1296 |
| 1293 } // namespace leveldb | 1297 } // namespace leveldb |
| OLD | NEW |