OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef SQL_MOJO_MOJO_VFS_H_ |
| 6 #define SQL_MOJO_MOJO_VFS_H_ |
| 7 |
| 8 #include "base/macros.h" |
| 9 #include "components/filesystem/public/interfaces/directory.mojom.h" |
| 10 |
| 11 typedef struct sqlite3_vfs sqlite3_vfs; |
| 12 |
| 13 namespace sql { |
| 14 |
| 15 // Changes the default sqlite3 vfs to a vfs that uses proxies calls to the |
| 16 // mojo:filesystem service. Instantiating this object transparently changes how |
| 17 // the entire //sql/ subsystem works in the process of the caller; all paths |
| 18 // are treated as relative to |directory|. |
| 19 class ScopedMojoFilesystemVFS { |
| 20 public: |
| 21 explicit ScopedMojoFilesystemVFS(filesystem::DirectoryPtr directory); |
| 22 ~ScopedMojoFilesystemVFS(); |
| 23 |
| 24 // Returns the directory of the current VFS. |
| 25 filesystem::DirectoryPtr& GetDirectory(); |
| 26 |
| 27 private: |
| 28 friend sqlite3_vfs* GetParentVFS(sqlite3_vfs* mojo_vfs); |
| 29 friend filesystem::DirectoryPtr& GetRootDirectory(sqlite3_vfs* mojo_vfs); |
| 30 |
| 31 // The default vfs at the time MojoVFS was installed. We use the to pass |
| 32 // through things like randomness requests and per-platform sleep calls. |
| 33 sqlite3_vfs* parent_; |
| 34 |
| 35 // When we initialize the subsystem, we are given a filesystem::Directory |
| 36 // object, which is the root directory of a mojo:filesystem. All access to |
| 37 // various files are specified from this root directory. |
| 38 filesystem::DirectoryPtr root_directory_; |
| 39 |
| 40 DISALLOW_COPY_AND_ASSIGN(ScopedMojoFilesystemVFS); |
| 41 }; |
| 42 |
| 43 } // namespace sql |
| 44 |
| 45 #endif // SQL_MOJO_MOJO_VFS_H_ |
OLD | NEW |