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

Unified Diff: sql/mojo/mojo_vfs.h

Issue 1176653002: mandoline filesystem: add a sqlite3 vfs to proxy filesystem usage. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix win 8 Created 5 years, 6 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 | « sql/mojo/DEPS ('k') | sql/mojo/mojo_vfs.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sql/mojo/mojo_vfs.h
diff --git a/sql/mojo/mojo_vfs.h b/sql/mojo/mojo_vfs.h
new file mode 100644
index 0000000000000000000000000000000000000000..dc835938eff9b07e617e644a8fd0bc7bcd3e2856
--- /dev/null
+++ b/sql/mojo/mojo_vfs.h
@@ -0,0 +1,45 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef SQL_MOJO_MOJO_VFS_H_
+#define SQL_MOJO_MOJO_VFS_H_
+
+#include "base/macros.h"
+#include "components/filesystem/public/interfaces/directory.mojom.h"
+
+typedef struct sqlite3_vfs sqlite3_vfs;
+
+namespace sql {
+
+// Changes the default sqlite3 vfs to a vfs that uses proxies calls to the
+// mojo:filesystem service. Instantiating this object transparently changes how
+// the entire //sql/ subsystem works in the process of the caller; all paths
+// are treated as relative to |directory|.
+class ScopedMojoFilesystemVFS {
+ public:
+ explicit ScopedMojoFilesystemVFS(filesystem::DirectoryPtr directory);
+ ~ScopedMojoFilesystemVFS();
+
+ // Returns the directory of the current VFS.
+ filesystem::DirectoryPtr& GetDirectory();
+
+ private:
+ friend sqlite3_vfs* GetParentVFS(sqlite3_vfs* mojo_vfs);
+ friend filesystem::DirectoryPtr& GetRootDirectory(sqlite3_vfs* mojo_vfs);
+
+ // The default vfs at the time MojoVFS was installed. We use the to pass
+ // through things like randomness requests and per-platform sleep calls.
+ sqlite3_vfs* parent_;
+
+ // When we initialize the subsystem, we are given a filesystem::Directory
+ // object, which is the root directory of a mojo:filesystem. All access to
+ // various files are specified from this root directory.
+ filesystem::DirectoryPtr root_directory_;
+
+ DISALLOW_COPY_AND_ASSIGN(ScopedMojoFilesystemVFS);
+};
+
+} // namespace sql
+
+#endif // SQL_MOJO_MOJO_VFS_H_
« no previous file with comments | « sql/mojo/DEPS ('k') | sql/mojo/mojo_vfs.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698