Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(318)

Unified Diff: components/leveldb/env_mojo.h

Issue 2722293002: Fix lifetime of leveldb::MojoEnv instances. (Closed)
Patch Set: minor cleanups Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | components/leveldb/env_mojo.cc » ('j') | components/leveldb/env_mojo.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/leveldb/env_mojo.h
diff --git a/components/leveldb/env_mojo.h b/components/leveldb/env_mojo.h
index d784803324321735652be12bd77c44540a4ae91b..80d7ff0290a323561bad19e4e565f81568e3a10b 100644
--- a/components/leveldb/env_mojo.h
+++ b/components/leveldb/env_mojo.h
@@ -5,6 +5,7 @@
#ifndef COMPONENTS_LEVELDB_ENV_MOJO_H_
#define COMPONENTS_LEVELDB_ENV_MOJO_H_
+#include "base/id_map.h"
#include "components/filesystem/public/interfaces/directory.mojom.h"
#include "components/leveldb/leveldb_mojo_proxy.h"
#include "third_party/leveldatabase/env_chromium.h"
@@ -19,10 +20,13 @@ namespace leveldb {
// existence.
class MojoEnv : public leveldb_env::ChromiumEnv {
public:
- MojoEnv(const std::string& name,
- scoped_refptr<LevelDBMojoProxy> file_thread,
- LevelDBMojoProxy::OpaqueDir* dir);
- ~MojoEnv() override;
+ static MojoEnv* Get(
+ scoped_refptr<base::SingleThreadTaskRunner> file_task_runner);
+
+ // Registers a |directory| with the leveldb environment, returning a string
+ // that should be used as prefix to indicate files in that directory.
+ std::string RegisterDirectory(filesystem::mojom::DirectoryPtr directory);
+ void UnregisterDirectory(base::StringPiece prefix);
// Overridden from leveldb_env::EnvChromium:
Status NewSequentialFile(const std::string& fname,
@@ -50,8 +54,15 @@ class MojoEnv : public leveldb_env::ChromiumEnv {
// NowMicros() or SleepForMicroseconds() and use the EnvChromium versions.
private:
+ MojoEnv(scoped_refptr<base::SingleThreadTaskRunner> file_task_runner);
+ ~MojoEnv() override;
+
+ void ParsePath(const std::string& path,
+ LevelDBMojoProxy::OpaqueDir** out_dir,
+ std::string* out_path);
+
scoped_refptr<LevelDBMojoProxy> thread_;
- LevelDBMojoProxy::OpaqueDir* dir_;
+ IDMap<LevelDBMojoProxy::OpaqueDir*> dirs_;
DISALLOW_COPY_AND_ASSIGN(MojoEnv);
};
« no previous file with comments | « no previous file | components/leveldb/env_mojo.cc » ('j') | components/leveldb/env_mojo.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698