RESOLVED FIXED 26940
alias [Chromium] Add a SQLite VFS for Chromium
https://bugs.webkit.org/show_bug.cgi?id=26940
Summary [Chromium] Add a SQLite VFS for Chromium
Dumitru Daniliuc
Reported 2009-07-02 16:05:27 PDT
Because of sandboxed renderer processes, Chromium needs a special SQLite VFS implementation.
Attachments
win patch (27.03 KB, patch)
2009-07-02 16:29 PDT, Dumitru Daniliuc
no flags
win patch (10.31 KB, patch)
2009-07-02 16:31 PDT, Dumitru Daniliuc
dglazkov: review-
win patch (12.55 KB, patch)
2009-07-06 18:02 PDT, Dumitru Daniliuc
no flags
win patch (12.48 KB, patch)
2009-07-08 14:59 PDT, Dumitru Daniliuc
dglazkov: review-
win patch (12.49 KB, patch)
2009-07-08 16:00 PDT, Dumitru Daniliuc
dglazkov: review+
win patch (12.57 KB, patch)
2009-07-09 18:30 PDT, Dumitru Daniliuc
no flags
win patch (13.46 KB, patch)
2009-07-10 15:57 PDT, Dumitru Daniliuc
dglazkov: review+
win patch + mac/linux stubs (17.92 KB, patch)
2009-07-17 13:38 PDT, Dumitru Daniliuc
dglazkov: review+
win VFS + mac/linux stubs (17.92 KB, patch)
2009-07-17 15:24 PDT, Dumitru Daniliuc
no flags
same patch (18.01 KB, patch)
2009-07-17 15:42 PDT, Dumitru Daniliuc
dglazkov: review+
Dumitru Daniliuc
Comment 1 2009-07-02 16:29:16 PDT
Created attachment 32205 [details] win patch SQLite VFS: only the code that deals directly with files was slightly modified. FileSystem: openDatabase() uses "chromium_vfs" to open files, all other functions are either very simple or delegate to ChromiumBridge.
Dumitru Daniliuc
Comment 2 2009-07-02 16:31:58 PDT
Created attachment 32206 [details] win patch Attached the wrong patch...
Dumitru Daniliuc
Comment 3 2009-07-02 16:34:50 PDT
Comment on attachment 32206 [details] win patch > + } else { > + return SQLITE_CANTOPEN; > + } '}' is not aligned properly. i will fix that with the other comments you might have (don't want to upload another patch for this only).
Dimitri Glazkov (Google)
Comment 4 2009-07-06 12:41:25 PDT
Comment on attachment 32206 [details] win patch > Index: WebCore/platform/sql/chromium/SQLiteFileSystemChromium.cpp If this is a Windows-specific file, it should be SQLiteFileSystemChromiumWin.cpp > + if (desiredFlags & SQLITE_OPEN_READWRITE) { > + int newFlags = (desiredFlags | SQLITE_OPEN_READONLY) & ~SQLITE_OPEN_READWRITE; > + return chromiumOpen(0, fileName, id, newFlags, usedFlags); > + } else { > + return SQLITE_CANTOPEN; > + } Fix indentation, no need for brackets for one-liners. > +#ifndef SQLITE_OMIT_LOAD_EXTENSION > +// Returns NULL, thus disallowing loading libraries in the renderer process. > +// > +// vfs - pointer to the sqlite3_vfs object. > +// fileName - the name of the shared library file. > +void* chromiumDlOpen(sqlite3_vfs* vfs, const char* fileName) > +{ > + return NULL; return 0; > + static sqlite3_vfs chromium_vfs = { > + 1, > + win32_vfs->szOsFile, > + win32_vfs->mxPathname, > + 0, > + "chromium_vfs", > + 0, > + chromiumOpen, > + chromiumDelete, > + chromiumAccess, > + chromiumFullPathname, > + chromiumDlOpen, > + win32_vfs->xDlError, > + win32_vfs->xDlSym, > + win32_vfs->xDlClose, > + win32_vfs->xRandomness, > + win32_vfs->xSleep, > + win32_vfs->xCurrentTime, > + win32_vfs->xGetLastError 4 space indent. > + > +bool SQLiteFileSystem::ensureDatabaseDirectoryExists(const String& path) > +{ Should probably eliminate unused param for consistency. > +bool SQLiteFileSystem::ensureDatabaseFileExists(const String& fileName, bool checkPathOnly) > +{ Ditto. > +bool SQLiteFileSystem::deleteEmptyDatabaseDirectory(const String& path) > +{ Ditto.
Dimitri Glazkov (Google)
Comment 5 2009-07-06 12:48:41 PDT
Also, instead of including windows.h and having platform-specific #ifdef in ChromiumBridge, just use PlatformFileHandle from FileSystem.h.
Dumitru Daniliuc
Comment 6 2009-07-06 18:02:34 PDT
Created attachment 32338 [details] win patch
Dumitru Daniliuc
Comment 7 2009-07-06 18:10:41 PDT
(In reply to comment #4) > (From update of attachment 32206 [details]) > > Index: WebCore/platform/sql/chromium/SQLiteFileSystemChromium.cpp > > If this is a Windows-specific file, it should be > SQLiteFileSystemChromiumWin.cpp > > > + if (desiredFlags & SQLITE_OPEN_READWRITE) { > > + int newFlags = (desiredFlags | SQLITE_OPEN_READONLY) & ~SQLITE_OPEN_READWRITE; > > + return chromiumOpen(0, fileName, id, newFlags, usedFlags); > > + } else { > > + return SQLITE_CANTOPEN; > > + } > > Fix indentation, no need for brackets for one-liners. removed the brackets. > > +#ifndef SQLITE_OMIT_LOAD_EXTENSION > > +// Returns NULL, thus disallowing loading libraries in the renderer process. > > +// > > +// vfs - pointer to the sqlite3_vfs object. > > +// fileName - the name of the shared library file. > > +void* chromiumDlOpen(sqlite3_vfs* vfs, const char* fileName) > > +{ > > + return NULL; > > return 0; done. > > + static sqlite3_vfs chromium_vfs = { > > + 1, > > + win32_vfs->szOsFile, > > + win32_vfs->mxPathname, > > + 0, > > + "chromium_vfs", > > + 0, > > + chromiumOpen, > > + chromiumDelete, > > + chromiumAccess, > > + chromiumFullPathname, > > + chromiumDlOpen, > > + win32_vfs->xDlError, > > + win32_vfs->xDlSym, > > + win32_vfs->xDlClose, > > + win32_vfs->xRandomness, > > + win32_vfs->xSleep, > > + win32_vfs->xCurrentTime, > > + win32_vfs->xGetLastError > > 4 space indent. done. > > + > > +bool SQLiteFileSystem::ensureDatabaseDirectoryExists(const String& path) > > +{ > > Should probably eliminate unused param for consistency. fixed everywhere. > > +bool SQLiteFileSystem::ensureDatabaseFileExists(const String& fileName, bool checkPathOnly) > > +{ > > Ditto. done. > > +bool SQLiteFileSystem::deleteEmptyDatabaseDirectory(const String& path) > > +{ > > Ditto. done. > Also, instead of including windows.h and having platform-specific #ifdef in > ChromiumBridge, just use PlatformFileHandle from FileSystem.h. i didn't change this. from what i understand, webkit has only one chromium port: PLATFORM(CHROMIUM). it doesn't know how to differentiate between chromium compiled on windows and chromium compiled on linux/mac. so we can't use #defines in FileSystem.h. basically, if we define something in FileSystem.h for PLATFORM(CHROMIUM), we'd have to use those definitions for all OSes we're compiling chromium on, and it just doesn't work. i talked a bit to john about this and he said that separate, per-OS function signatures should be fine in this case. let me know what you think.
Dumitru Daniliuc
Comment 8 2009-07-07 18:16:42 PDT
After talking to Darin, it looks like we can use PLATFORM(WIN_OS) (instead of PLATFORM(WIN)) in WebKit to get some code in all ports when built on a Windows OS. Patch pending: https://bugs.webkit.org/show_bug.cgi?id=27013.
Dumitru Daniliuc
Comment 9 2009-07-08 14:59:25 PDT
Created attachment 32476 [details] win patch
Dimitri Glazkov (Google)
Comment 10 2009-07-08 15:05:57 PDT
Comment on attachment 32476 [details] win patch Looking much prettier -- two minor issues below: > +String SQLiteFileSystem::appendDatabaseFileNameToPath(const String& path, const String& fileName) > +{ > + if (path.isEmpty()) > + return fileName; > + else > + return path + "\\" + fileName; > +} Whoops. This is a Windows-ism. Can we use FileSystem.h magic here? > +int chromiumDelete(sqlite3_vfs* vfs, const char* fileName, int syncDir) unused param syncDir?
Dumitru Daniliuc
Comment 11 2009-07-08 16:00:13 PDT
Created attachment 32482 [details] win patch
Dimitri Glazkov (Google)
Comment 12 2009-07-08 19:13:26 PDT
Land tomorrow?
Dumitru Daniliuc
Comment 13 2009-07-09 18:30:34 PDT
Created attachment 32546 [details] win patch minor bug fix in appendDatabaseFileNameToPath() in SQLiteFileSystemChromium.cpp.
Dumitru Daniliuc
Comment 14 2009-07-10 15:57:53 PDT
Created attachment 32588 [details] win patch same patch + WebCore/WebCore.gypi changes.
Dimitri Glazkov (Google)
Comment 15 2009-07-15 11:39:09 PDT
Comment on attachment 32588 [details] win patch Please add WebCore.gypi changes and we'll be good to land.
Nate Chapin
Comment 16 2009-07-15 16:19:39 PDT
Landed as r45959.
Dumitru Daniliuc
Comment 17 2009-07-17 13:38:40 PDT
Created attachment 32967 [details] win patch + mac/linux stubs Same patch + stubs for Mac/Linux.
Dimitri Glazkov (Google)
Comment 18 2009-07-17 14:37:49 PDT
Comment on attachment 32967 [details] win patch + mac/linux stubs ok.
Dimitri Glazkov (Google)
Comment 19 2009-07-17 14:38:17 PDT
Eric, can you coordinate w/Dumi to land this?
Dumitru Daniliuc
Comment 20 2009-07-17 15:24:32 PDT
Created attachment 32980 [details] win VFS + mac/linux stubs Last patch for this bug hopefully...
Dumitru Daniliuc
Comment 21 2009-07-17 15:42:19 PDT
Created attachment 32983 [details] same patch
Dimitri Glazkov (Google)
Comment 22 2009-07-17 15:43:44 PDT
Comment on attachment 32983 [details] same patch good deal. Let's land this puppy.
Jeremy Orlow
Comment 23 2009-07-17 19:03:12 PDT
A note to any prospective committers: this patch is going to require special landing in conjunction with Chromium. Right now, we're just waiting for the tree to go green.
Eric Roman
Comment 24 2009-07-20 10:59:15 PDT
landed r46126.
zooz hada
Comment 25 2018-04-02 15:35:50 PDT
Comment on attachment 32206 [details] win patch 32206
zooz hada
Comment 26 2018-04-02 15:45:03 PDT
32206
John
Comment 27 2023-04-19 11:24:03 PDT
nice
Note You need to log in before you can comment on or make changes to this bug.