Chromium Code Reviews| Index: sql/mojo/mojo_vfs.cc |
| diff --git a/sql/mojo/mojo_vfs.cc b/sql/mojo/mojo_vfs.cc |
| index 6e38af9704032a15b0cf1bbd329e6c4da212c560..111bd62c5c83e0033b2359dd8bf7ba7cab695ed2 100644 |
| --- a/sql/mojo/mojo_vfs.cc |
| +++ b/sql/mojo/mojo_vfs.cc |
| @@ -6,6 +6,7 @@ |
| #include "base/logging.h" |
| #include "base/rand_util.h" |
| +#include "base/strings/stringprintf.h" |
| #include "components/filesystem/public/interfaces/file.mojom.h" |
| #include "components/filesystem/public/interfaces/file_system.mojom.h" |
| #include "components/filesystem/public/interfaces/types.mojom.h" |
| @@ -203,7 +204,8 @@ int MojoVFSSectorSize(sqlite3_file* pFile) { |
| int MojoVFSDeviceCharacteristics(sqlite3_file* pFile) { |
| DVLOG(1) << "MojoVFSDeviceCharacteristics(*)"; |
| - NOTIMPLEMENTED(); |
| + // TODO(erg): Figure out what to return here. (This function is super spammy, |
| + // so not leaving a NOTIMPLEMENTED().) |
|
Scott Hess - ex-Googler
2015/07/21 21:55:24
I think "return 0;" is a fine implementation of th
|
| return 0; |
| } |
| @@ -245,10 +247,25 @@ int MojoVFSOpen(sqlite3_vfs* mojo_vfs, |
| if (flags & SQLITE_OPEN_DELETEONCLOSE) |
| open_flags |= filesystem::kDeleteOnClose; |
| + mojo::String mojo_name; |
| + if (name) { |
| + // Don't let callers open the pattern of our temporary databases. When we |
| + // open with a null name and SQLITE_OPEN_DELETEONCLOSE, we unlink the |
| + // database after we open it. If we create a database here, close it |
| + // normally, and then open the same file through the other path, we could |
| + // delete the database. |
| + CHECK(strncmp("Temp_", name, 5) != 0); |
| + mojo_name = name; |
| + } else { |
| + DCHECK(flags & SQLITE_OPEN_DELETEONCLOSE); |
| + static int temp_number = 0; |
| + mojo_name = base::StringPrintf("Temp_%d.db", temp_number++); |
| + } |
| + |
| // Grab the incoming file |
| filesystem::FilePtr file_ptr; |
| filesystem::FileError error = filesystem::FILE_ERROR_FAILED; |
| - GetRootDirectory(mojo_vfs)->OpenFile(mojo::String(name), GetProxy(&file_ptr), |
| + GetRootDirectory(mojo_vfs)->OpenFile(mojo_name, GetProxy(&file_ptr), |
| open_flags, Capture(&error)); |
| GetRootDirectory(mojo_vfs).WaitForIncomingResponse(); |
| if (error != filesystem::FILE_ERROR_OK) { |