OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "sql/mojo/mojo_vfs.h" | 5 #include "sql/mojo/mojo_vfs.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/rand_util.h" | 8 #include "base/rand_util.h" |
9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
10 #include "components/filesystem/public/interfaces/file.mojom.h" | 10 #include "components/filesystem/public/interfaces/file.mojom.h" |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 filesystem::FilePtr file_ptr; | 54 filesystem::FilePtr file_ptr; |
55 }; | 55 }; |
56 | 56 |
57 filesystem::FilePtr& GetFSFile(sqlite3_file* vfs_file) { | 57 filesystem::FilePtr& GetFSFile(sqlite3_file* vfs_file) { |
58 return reinterpret_cast<MojoVFSFile*>(vfs_file)->file_ptr; | 58 return reinterpret_cast<MojoVFSFile*>(vfs_file)->file_ptr; |
59 } | 59 } |
60 | 60 |
61 int MojoVFSClose(sqlite3_file* file) { | 61 int MojoVFSClose(sqlite3_file* file) { |
62 DVLOG(1) << "MojoVFSClose(*)"; | 62 DVLOG(1) << "MojoVFSClose(*)"; |
63 using filesystem::FilePtr; | 63 using filesystem::FilePtr; |
| 64 filesystem::FileError error = filesystem::FILE_ERROR_FAILED; |
| 65 // Must call File::Close explicitly instead of just deleting the file, since |
| 66 // otherwise we wouldn't have an object to wait on. |
| 67 GetFSFile(file)->Close(mojo::Capture(&error)); |
| 68 GetFSFile(file).WaitForIncomingResponse(); |
64 GetFSFile(file).~FilePtr(); | 69 GetFSFile(file).~FilePtr(); |
65 return SQLITE_OK; | 70 return SQLITE_OK; |
66 } | 71 } |
67 | 72 |
68 int MojoVFSRead(sqlite3_file* sql_file, | 73 int MojoVFSRead(sqlite3_file* sql_file, |
69 void* buffer, | 74 void* buffer, |
70 int size, | 75 int size, |
71 sqlite3_int64 offset) { | 76 sqlite3_int64 offset) { |
72 DVLOG(1) << "MojoVFSRead (" << size << " @ " << offset << ")"; | 77 DVLOG(1) << "MojoVFSRead (" << size << " @ " << offset << ")"; |
73 filesystem::FileError error = filesystem::FILE_ERROR_FAILED; | 78 filesystem::FileError error = filesystem::FILE_ERROR_FAILED; |
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
421 | 426 |
422 CHECK(sqlite3_vfs_register(parent_, 1) == SQLITE_OK); | 427 CHECK(sqlite3_vfs_register(parent_, 1) == SQLITE_OK); |
423 CHECK(sqlite3_vfs_unregister(&mojo_vfs) == SQLITE_OK); | 428 CHECK(sqlite3_vfs_unregister(&mojo_vfs) == SQLITE_OK); |
424 } | 429 } |
425 | 430 |
426 filesystem::DirectoryPtr& ScopedMojoFilesystemVFS::GetDirectory() { | 431 filesystem::DirectoryPtr& ScopedMojoFilesystemVFS::GetDirectory() { |
427 return root_directory_; | 432 return root_directory_; |
428 } | 433 } |
429 | 434 |
430 } // namespace sql | 435 } // namespace sql |
OLD | NEW |