| OLD | NEW |
| 1 // Copyright (c) 2013 The LevelDB Authors. All rights reserved. | 1 // Copyright (c) 2013 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 #ifndef THIRD_PARTY_LEVELDATABASE_ENV_CHROMIUM_H_ | 5 #ifndef THIRD_PARTY_LEVELDATABASE_ENV_CHROMIUM_H_ |
| 6 #define THIRD_PARTY_LEVELDATABASE_ENV_CHROMIUM_H_ | 6 #define THIRD_PARTY_LEVELDATABASE_ENV_CHROMIUM_H_ |
| 7 | 7 |
| 8 #include <deque> | 8 #include <deque> |
| 9 #include <functional> | 9 #include <functional> |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 LockTable locks_; | 235 LockTable locks_; |
| 236 }; | 236 }; |
| 237 | 237 |
| 238 // Tracks databases open via OpenDatabase() method and exposes them to | 238 // Tracks databases open via OpenDatabase() method and exposes them to |
| 239 // memory-infra. The class is thread safe. | 239 // memory-infra. The class is thread safe. |
| 240 class DBTracker { | 240 class DBTracker { |
| 241 public: | 241 public: |
| 242 // DBTracker singleton instance. | 242 // DBTracker singleton instance. |
| 243 static DBTracker* GetInstance(); | 243 static DBTracker* GetInstance(); |
| 244 | 244 |
| 245 // Returns name of memory-infra dump for |db|. Can be used to attach |
| 246 // additional info to the database dump, or to properly attribute memory |
| 247 // usage in memory dump providers that also dump |db|. |
| 248 static std::string GetMemoryDumpName(leveldb::DB* db); |
| 249 |
| 245 // Provides extra information about a tracked database. | 250 // Provides extra information about a tracked database. |
| 246 class TrackedDB : public leveldb::DB { | 251 class TrackedDB : public leveldb::DB { |
| 247 public: | 252 public: |
| 248 // Name that OpenDatabase() was called with. | 253 // Name that OpenDatabase() was called with. |
| 249 virtual const std::string& name() const = 0; | 254 virtual const std::string& name() const = 0; |
| 250 }; | 255 }; |
| 251 | 256 |
| 252 // Opens a database and starts tracking it. As long as the opened database | 257 // Opens a database and starts tracking it. As long as the opened database |
| 253 // is alive (i.e. its instance is not destroyed) the database is exposed to | 258 // is alive (i.e. its instance is not destroyed) the database is exposed to |
| 254 // memory-infra and is enumerated by VisitDatabases() method. | 259 // memory-infra and is enumerated by VisitDatabases() method. |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 286 | 291 |
| 287 // Opens a database and exposes it to Chrome's tracing (see DBTracker for | 292 // Opens a database and exposes it to Chrome's tracing (see DBTracker for |
| 288 // details). Note that |dbptr| is touched only when function succeeds. | 293 // details). Note that |dbptr| is touched only when function succeeds. |
| 289 leveldb::Status OpenDB(const leveldb::Options& options, | 294 leveldb::Status OpenDB(const leveldb::Options& options, |
| 290 const std::string& name, | 295 const std::string& name, |
| 291 std::unique_ptr<leveldb::DB>* dbptr); | 296 std::unique_ptr<leveldb::DB>* dbptr); |
| 292 | 297 |
| 293 } // namespace leveldb_env | 298 } // namespace leveldb_env |
| 294 | 299 |
| 295 #endif // THIRD_PARTY_LEVELDATABASE_ENV_CHROMIUM_H_ | 300 #endif // THIRD_PARTY_LEVELDATABASE_ENV_CHROMIUM_H_ |
| OLD | NEW |