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

Side by Side Diff: third_party/sqlite/patches/0006-Modify-default-VFS-to-support-WebDatabase.patch

Issue 885473002: [sql] Rewrite sqlite patching "system". (Closed) Base URL: http://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed typo in readme. Created 5 years, 10 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 unified diff | Download patch
OLDNEW
1 The WebDatabase implementation in the renderer users a custom vfs to 1 From 25f1f784320aa0e32b69f78098b652b30df40865 Mon Sep 17 00:00:00 2001
2 broker file open and other requests. This modifies the built-in vfs 2 From: dumi <dumi@chromium.org>
3 implementation to let that code share much of the implementation 3 Date: Mon, 20 Jul 2009 23:40:51 +0000
4 details. 4 Subject: [PATCH 06/23] Modify default VFS to support WebDatabase.
5 5
6 diff --git src/os_unix.c src/os_unix.c 6 The renderer WebDatabase implementation needs to broker certain requests
7 index ef04a72..e5e1509 100644 7 to the browser. This modifies SQLite to allow monkey-patching the VFS
8 --- src/os_unix.c 8 to support this.
9 +++ src/os_unix.c 9
10 @@ -3496,9 +3496,16 @@ typedef const sqlite3_io_methods *(*finder_type)(const ch ar*,unixFile*); 10 NOTE(shess): This patch relies on core SQLite implementation details
11 remaining unchanged. When importing a new version of SQLite, pay very
12 close attention to whether the change is still doing what is intended.
13
14 Original review URLs:
15 https://codereview.chromium.org/159044
16 https://codereview.chromium.org/384075
17 https://codereview.chromium.org/377039
18 [Possibly not a complete list.]
19 ---
20 third_party/sqlite/src/src/os_unix.c | 98 +++++++++++++++++++++++++++++-------
21 third_party/sqlite/src/src/os_win.c | 7 +++
22 2 files changed, 88 insertions(+), 17 deletions(-)
23
24 diff --git a/third_party/sqlite/src/src/os_unix.c b/third_party/sqlite/src/src/o s_unix.c
25 index 998e353..766b52a 100644
26 --- a/third_party/sqlite/src/src/os_unix.c
27 +++ b/third_party/sqlite/src/src/os_unix.c
28 @@ -4418,9 +4418,16 @@ typedef const sqlite3_io_methods *(*finder_type)(const ch ar*,unixFile*);
11 */ 29 */
12 30
13 /* 31 /*
14 +** Initializes a unixFile structure with zeros. 32 +** Initializes a unixFile structure with zeros.
15 +*/ 33 +*/
16 +void initUnixFile(sqlite3_file* file) { 34 +void initUnixFile(sqlite3_file* file) {
17 + memset(file, 0, sizeof(unixFile)); 35 + memset(file, 0, sizeof(unixFile));
18 +} 36 +}
19 + 37 +
20 +/* 38 +/*
21 ** Initialize the contents of the unixFile structure pointed to by pId. 39 ** Initialize the contents of the unixFile structure pointed to by pId.
22 */ 40 */
23 -static int fillInUnixFile( 41 -static int fillInUnixFile(
24 +int fillInUnixFile( 42 +int fillInUnixFile(
25 sqlite3_vfs *pVfs, /* Pointer to vfs object */ 43 sqlite3_vfs *pVfs, /* Pointer to vfs object */
26 int h, /* Open file descriptor of file being opened */ 44 int h, /* Open file descriptor of file being opened */
27 int dirfd, /* Directory file descriptor */ 45 int dirfd, /* Directory file descriptor */
28 @@ -3812,6 +3819,73 @@ static UnixUnusedFd *findReusableFd(const char *zPath, in t flags){ 46 @@ -4834,6 +4841,73 @@ static int findCreateFileMode(
29 } 47 }
30 48
31 /* 49 /*
32 +** Initializes a unixFile structure with zeros. 50 +** Initializes a unixFile structure with zeros.
33 +*/ 51 +*/
34 +void chromium_sqlite3_initialize_unix_sqlite3_file(sqlite3_file* file) { 52 +void chromium_sqlite3_initialize_unix_sqlite3_file(sqlite3_file* file) {
35 + memset(file, 0, sizeof(unixFile)); 53 + memset(file, 0, sizeof(unixFile));
36 +} 54 +}
37 + 55 +
38 +int chromium_sqlite3_fill_in_unix_sqlite3_file(sqlite3_vfs* vfs, 56 +int chromium_sqlite3_fill_in_unix_sqlite3_file(sqlite3_vfs* vfs,
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 +*/ 110 +*/
93 +void chromium_sqlite3_destroy_reusable_file_handle(sqlite3_file* file) { 111 +void chromium_sqlite3_destroy_reusable_file_handle(sqlite3_file* file) {
94 + unixFile* unixSQLite3File = (unixFile*)file; 112 + unixFile* unixSQLite3File = (unixFile*)file;
95 + sqlite3_free(unixSQLite3File->pUnused); 113 + sqlite3_free(unixSQLite3File->pUnused);
96 +} 114 +}
97 + 115 +
98 +/* 116 +/*
99 ** Open the file zPath. 117 ** Open the file zPath.
100 ** 118 **
101 ** Previously, the SQLite OS layer used three functions in place of this 119 ** Previously, the SQLite OS layer used three functions in place of this
102 @@ -3893,20 +3967,13 @@ static int unixOpen( 120 @@ -4921,20 +4995,13 @@ static int unixOpen(
103 || eType==SQLITE_OPEN_TRANSIENT_DB 121 || eType==SQLITE_OPEN_TRANSIENT_DB || eType==SQLITE_OPEN_WAL
104 ); 122 );
105 123
106 - memset(p, 0, sizeof(unixFile)); 124 - memset(p, 0, sizeof(unixFile));
107 + chromium_sqlite3_initialize_unix_sqlite3_file(pFile); 125 + chromium_sqlite3_initialize_unix_sqlite3_file(pFile);
108 126
109 if( eType==SQLITE_OPEN_MAIN_DB ){ 127 if( eType==SQLITE_OPEN_MAIN_DB ){
110 - UnixUnusedFd *pUnused; 128 - UnixUnusedFd *pUnused;
111 - pUnused = findReusableFd(zName, flags); 129 - pUnused = findReusableFd(zName, flags);
112 - if( pUnused ){ 130 - if( pUnused ){
113 - fd = pUnused->fd; 131 - fd = pUnused->fd;
114 - }else{ 132 - }else{
115 - pUnused = sqlite3_malloc(sizeof(*pUnused)); 133 - pUnused = sqlite3_malloc(sizeof(*pUnused));
116 - if( !pUnused ){ 134 - if( !pUnused ){
117 - return SQLITE_NOMEM; 135 - return SQLITE_NOMEM;
118 - } 136 - }
119 + rc = chromium_sqlite3_get_reusable_file_handle(pFile, zName, flags, &fd); 137 + rc = chromium_sqlite3_get_reusable_file_handle(pFile, zName, flags, &fd);
120 + if( rc!=SQLITE_OK ){ 138 + if( rc!=SQLITE_OK ){
121 + return rc; 139 + return rc;
122 } 140 }
123 - p->pUnused = pUnused; 141 - p->pUnused = pUnused;
124 }else if( !zName ){ 142 }else if( !zName ){
125 /* If zName is NULL, the upper layer is requesting a temp file. */ 143 /* If zName is NULL, the upper layer is requesting a temp file. */
126 assert(isDelete && !isOpenDirectory); 144 assert(isDelete && !isOpenDirectory);
127 @@ -3949,10 +4016,7 @@ static int unixOpen( 145 @@ -4984,10 +5051,7 @@ static int unixOpen(
128 *pOutFlags = flags; 146 *pOutFlags = flags;
129 } 147 }
130 148
131 - if( p->pUnused ){ 149 - if( p->pUnused ){
132 - p->pUnused->fd = fd; 150 - p->pUnused->fd = fd;
133 - p->pUnused->flags = flags; 151 - p->pUnused->flags = flags;
134 - } 152 - }
135 + chromium_sqlite3_update_reusable_file_handle(pFile, fd, flags); 153 + chromium_sqlite3_update_reusable_file_handle(pFile, fd, flags);
136 154
137 if( isDelete ){ 155 if( isDelete ){
138 #if OS_VXWORKS 156 #if OS_VXWORKS
139 @@ -4028,7 +4092,7 @@ static int unixOpen( 157 @@ -5090,7 +5154,7 @@ static int unixOpen(
140 rc = fillInUnixFile(pVfs, fd, dirfd, pFile, zPath, noLock, isDelete); 158 isDelete, isReadonly);
141 open_finished: 159 open_finished:
142 if( rc!=SQLITE_OK ){ 160 if( rc!=SQLITE_OK ){
143 - sqlite3_free(p->pUnused); 161 - sqlite3_free(p->pUnused);
144 + chromium_sqlite3_destroy_reusable_file_handle(pFile); 162 + chromium_sqlite3_destroy_reusable_file_handle(pFile);
145 } 163 }
146 return rc; 164 return rc;
147 } 165 }
148 diff --git src/os_win.c src/os_win.c 166 diff --git a/third_party/sqlite/src/src/os_win.c b/third_party/sqlite/src/src/os _win.c
149 index bc03a4b..06539d7 100644 167 index c876833..78e58b5 100644
150 --- src/os_win.c 168 --- a/third_party/sqlite/src/src/os_win.c
151 +++ src/os_win.c 169 +++ b/third_party/sqlite/src/src/os_win.c
152 @@ -1890,4 +1890,11 @@ int sqlite3_os_end(void){ 170 @@ -2784,4 +2784,11 @@ int sqlite3_os_end(void){
153 return SQLITE_OK; 171 return SQLITE_OK;
154 } 172 }
155 173
156 +void chromium_sqlite3_initialize_win_sqlite3_file(sqlite3_file* file, HANDLE ha ndle) { 174 +void chromium_sqlite3_initialize_win_sqlite3_file(sqlite3_file* file, HANDLE ha ndle) {
157 + winFile* winSQLite3File = (winFile*)file; 175 + winFile* winSQLite3File = (winFile*)file;
158 + memset(file, 0, sizeof(*file)); 176 + memset(file, 0, sizeof(*file));
159 + winSQLite3File->pMethod = &winIoMethod; 177 + winSQLite3File->pMethod = &winIoMethod;
160 + winSQLite3File->h = handle; 178 + winSQLite3File->h = handle;
161 +} 179 +}
162 + 180 +
163 #endif /* SQLITE_OS_WIN */ 181 #endif /* SQLITE_OS_WIN */
182 --
183 2.2.1
184
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698