Chromium Code Reviews| 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> |
|
pwnall
2017/07/06 00:49:08
Do we still need <functional> now that we don't us
| |
| 10 #include <memory> | 10 #include <memory> |
| 11 #include <set> | 11 #include <set> |
| 12 #include <string> | 12 #include <string> |
| 13 #include <vector> | 13 #include <vector> |
| 14 | 14 |
| 15 #include "base/callback.h" | |
| 15 #include "base/containers/linked_list.h" | 16 #include "base/containers/linked_list.h" |
| 16 #include "base/files/file.h" | 17 #include "base/files/file.h" |
| 17 #include "base/files/file_path.h" | 18 #include "base/files/file_path.h" |
| 18 #include "base/macros.h" | 19 #include "base/macros.h" |
| 19 #include "base/metrics/histogram.h" | 20 #include "base/metrics/histogram.h" |
| 20 #include "leveldb/db.h" | 21 #include "leveldb/db.h" |
| 21 #include "leveldb/env.h" | 22 #include "leveldb/env.h" |
| 22 #include "port/port_chromium.h" | 23 #include "port/port_chromium.h" |
| 23 #include "util/mutexlock.h" | 24 #include "util/mutexlock.h" |
| 24 | 25 |
| (...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 249 virtual const std::string& name() const = 0; | 250 virtual const std::string& name() const = 0; |
| 250 }; | 251 }; |
| 251 | 252 |
| 252 // Opens a database and starts tracking it. As long as the opened database | 253 // 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 | 254 // is alive (i.e. its instance is not destroyed) the database is exposed to |
| 254 // memory-infra and is enumerated by VisitDatabases() method. | 255 // memory-infra and is enumerated by VisitDatabases() method. |
| 255 leveldb::Status OpenDatabase(const leveldb::Options& options, | 256 leveldb::Status OpenDatabase(const leveldb::Options& options, |
| 256 const std::string& name, | 257 const std::string& name, |
| 257 TrackedDB** dbptr); | 258 TrackedDB** dbptr); |
| 258 | 259 |
| 259 using DatabaseVisitor = std::function<void(TrackedDB*)>; | 260 using DatabaseVisitor = base::RepeatingCallback<void(TrackedDB*)>; |
| 260 | 261 |
| 261 // Calls |visitor| for each live database. The database is live from the | 262 // Calls |visitor| for each live database. The database is live from the |
| 262 // point it was returned from OpenDatabase() and up until its instance is | 263 // point it was returned from OpenDatabase() and up until its instance is |
| 263 // destroyed. | 264 // destroyed. |
| 264 // The databases may be visited in an arbitrary order. | 265 // The databases may be visited in an arbitrary order. |
| 265 // This function takes a lock, preventing any database from being opened or | 266 // This function takes a lock, preventing any database from being opened or |
| 266 // destroyed (but doesn't lock the databases themselves). | 267 // destroyed (but doesn't lock the databases themselves). |
| 267 void VisitDatabases(const DatabaseVisitor& visitor); | 268 void VisitDatabases(const DatabaseVisitor& visitor); |
| 268 | 269 |
| 269 private: | 270 private: |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 286 | 287 |
| 287 // Opens a database and exposes it to Chrome's tracing (see DBTracker for | 288 // Opens a database and exposes it to Chrome's tracing (see DBTracker for |
| 288 // details). Note that |dbptr| is touched only when function succeeds. | 289 // details). Note that |dbptr| is touched only when function succeeds. |
| 289 leveldb::Status OpenDB(const leveldb::Options& options, | 290 leveldb::Status OpenDB(const leveldb::Options& options, |
| 290 const std::string& name, | 291 const std::string& name, |
| 291 std::unique_ptr<leveldb::DB>* dbptr); | 292 std::unique_ptr<leveldb::DB>* dbptr); |
| 292 | 293 |
| 293 } // namespace leveldb_env | 294 } // namespace leveldb_env |
| 294 | 295 |
| 295 #endif // THIRD_PARTY_LEVELDATABASE_ENV_CHROMIUM_H_ | 296 #endif // THIRD_PARTY_LEVELDATABASE_ENV_CHROMIUM_H_ |
| OLD | NEW |