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

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: 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 fbe968c746d928b8372ea354229aef6772606336 Mon Sep 17 00:00:00 2001
2 broker file open and other requests. This modifies the built-in vfs 2 From: Scott Hess <shess@chromium.org>
3 implementation to let that code share much of the implementation 3 Date: Tue, 16 Dec 2014 13:03:36 -0800
4 details. 4 Subject: [PATCH 06/24] 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 third_party/sqlite/src/src/os_unix.c | 98 +++++++++++++++++++++++++++++-------
15 third_party/sqlite/src/src/os_win.c | 7 +++
16 2 files changed, 88 insertions(+), 17 deletions(-)
17
18 diff --git a/third_party/sqlite/src/src/os_unix.c b/third_party/sqlite/src/src/o s_unix.c
19 index 998e353..766b52a 100644
20 --- a/third_party/sqlite/src/src/os_unix.c
21 +++ b/third_party/sqlite/src/src/os_unix.c
22 @@ -4418,9 +4418,16 @@ typedef const sqlite3_io_methods *(*finder_type)(const ch ar*,unixFile*);
11 */ 23 */
12 24
13 /* 25 /*
14 +** Initializes a unixFile structure with zeros. 26 +** Initializes a unixFile structure with zeros.
15 +*/ 27 +*/
16 +void initUnixFile(sqlite3_file* file) { 28 +void initUnixFile(sqlite3_file* file) {
17 + memset(file, 0, sizeof(unixFile)); 29 + memset(file, 0, sizeof(unixFile));
18 +} 30 +}
19 + 31 +
20 +/* 32 +/*
21 ** Initialize the contents of the unixFile structure pointed to by pId. 33 ** Initialize the contents of the unixFile structure pointed to by pId.
22 */ 34 */
23 -static int fillInUnixFile( 35 -static int fillInUnixFile(
24 +int fillInUnixFile( 36 +int fillInUnixFile(
25 sqlite3_vfs *pVfs, /* Pointer to vfs object */ 37 sqlite3_vfs *pVfs, /* Pointer to vfs object */
26 int h, /* Open file descriptor of file being opened */ 38 int h, /* Open file descriptor of file being opened */
27 int dirfd, /* Directory file descriptor */ 39 int dirfd, /* Directory file descriptor */
28 @@ -3812,6 +3819,73 @@ static UnixUnusedFd *findReusableFd(const char *zPath, in t flags){ 40 @@ -4834,6 +4841,73 @@ static int findCreateFileMode(
29 } 41 }
30 42
31 /* 43 /*
32 +** Initializes a unixFile structure with zeros. 44 +** Initializes a unixFile structure with zeros.
33 +*/ 45 +*/
34 +void chromium_sqlite3_initialize_unix_sqlite3_file(sqlite3_file* file) { 46 +void chromium_sqlite3_initialize_unix_sqlite3_file(sqlite3_file* file) {
35 + memset(file, 0, sizeof(unixFile)); 47 + memset(file, 0, sizeof(unixFile));
36 +} 48 +}
37 + 49 +
38 +int chromium_sqlite3_fill_in_unix_sqlite3_file(sqlite3_vfs* vfs, 50 +int chromium_sqlite3_fill_in_unix_sqlite3_file(sqlite3_vfs* vfs,
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 +*/ 104 +*/
93 +void chromium_sqlite3_destroy_reusable_file_handle(sqlite3_file* file) { 105 +void chromium_sqlite3_destroy_reusable_file_handle(sqlite3_file* file) {
94 + unixFile* unixSQLite3File = (unixFile*)file; 106 + unixFile* unixSQLite3File = (unixFile*)file;
95 + sqlite3_free(unixSQLite3File->pUnused); 107 + sqlite3_free(unixSQLite3File->pUnused);
96 +} 108 +}
97 + 109 +
98 +/* 110 +/*
99 ** Open the file zPath. 111 ** Open the file zPath.
100 ** 112 **
101 ** Previously, the SQLite OS layer used three functions in place of this 113 ** Previously, the SQLite OS layer used three functions in place of this
102 @@ -3893,20 +3967,13 @@ static int unixOpen( 114 @@ -4921,20 +4995,13 @@ static int unixOpen(
103 || eType==SQLITE_OPEN_TRANSIENT_DB 115 || eType==SQLITE_OPEN_TRANSIENT_DB || eType==SQLITE_OPEN_WAL
104 ); 116 );
105 117
106 - memset(p, 0, sizeof(unixFile)); 118 - memset(p, 0, sizeof(unixFile));
107 + chromium_sqlite3_initialize_unix_sqlite3_file(pFile); 119 + chromium_sqlite3_initialize_unix_sqlite3_file(pFile);
108 120
109 if( eType==SQLITE_OPEN_MAIN_DB ){ 121 if( eType==SQLITE_OPEN_MAIN_DB ){
110 - UnixUnusedFd *pUnused; 122 - UnixUnusedFd *pUnused;
111 - pUnused = findReusableFd(zName, flags); 123 - pUnused = findReusableFd(zName, flags);
112 - if( pUnused ){ 124 - if( pUnused ){
113 - fd = pUnused->fd; 125 - fd = pUnused->fd;
114 - }else{ 126 - }else{
115 - pUnused = sqlite3_malloc(sizeof(*pUnused)); 127 - pUnused = sqlite3_malloc(sizeof(*pUnused));
116 - if( !pUnused ){ 128 - if( !pUnused ){
117 - return SQLITE_NOMEM; 129 - return SQLITE_NOMEM;
118 - } 130 - }
119 + rc = chromium_sqlite3_get_reusable_file_handle(pFile, zName, flags, &fd); 131 + rc = chromium_sqlite3_get_reusable_file_handle(pFile, zName, flags, &fd);
120 + if( rc!=SQLITE_OK ){ 132 + if( rc!=SQLITE_OK ){
121 + return rc; 133 + return rc;
122 } 134 }
123 - p->pUnused = pUnused; 135 - p->pUnused = pUnused;
124 }else if( !zName ){ 136 }else if( !zName ){
125 /* If zName is NULL, the upper layer is requesting a temp file. */ 137 /* If zName is NULL, the upper layer is requesting a temp file. */
126 assert(isDelete && !isOpenDirectory); 138 assert(isDelete && !isOpenDirectory);
127 @@ -3949,10 +4016,7 @@ static int unixOpen( 139 @@ -4984,10 +5051,7 @@ static int unixOpen(
128 *pOutFlags = flags; 140 *pOutFlags = flags;
129 } 141 }
130 142
131 - if( p->pUnused ){ 143 - if( p->pUnused ){
132 - p->pUnused->fd = fd; 144 - p->pUnused->fd = fd;
133 - p->pUnused->flags = flags; 145 - p->pUnused->flags = flags;
134 - } 146 - }
135 + chromium_sqlite3_update_reusable_file_handle(pFile, fd, flags); 147 + chromium_sqlite3_update_reusable_file_handle(pFile, fd, flags);
136 148
137 if( isDelete ){ 149 if( isDelete ){
138 #if OS_VXWORKS 150 #if OS_VXWORKS
139 @@ -4028,7 +4092,7 @@ static int unixOpen( 151 @@ -5090,7 +5154,7 @@ static int unixOpen(
140 rc = fillInUnixFile(pVfs, fd, dirfd, pFile, zPath, noLock, isDelete); 152 isDelete, isReadonly);
141 open_finished: 153 open_finished:
142 if( rc!=SQLITE_OK ){ 154 if( rc!=SQLITE_OK ){
143 - sqlite3_free(p->pUnused); 155 - sqlite3_free(p->pUnused);
144 + chromium_sqlite3_destroy_reusable_file_handle(pFile); 156 + chromium_sqlite3_destroy_reusable_file_handle(pFile);
145 } 157 }
146 return rc; 158 return rc;
147 } 159 }
148 diff --git src/os_win.c src/os_win.c 160 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 161 index c876833..78e58b5 100644
150 --- src/os_win.c 162 --- a/third_party/sqlite/src/src/os_win.c
151 +++ src/os_win.c 163 +++ b/third_party/sqlite/src/src/os_win.c
152 @@ -1890,4 +1890,11 @@ int sqlite3_os_end(void){ 164 @@ -2784,4 +2784,11 @@ int sqlite3_os_end(void){
153 return SQLITE_OK; 165 return SQLITE_OK;
154 } 166 }
155 167
156 +void chromium_sqlite3_initialize_win_sqlite3_file(sqlite3_file* file, HANDLE ha ndle) { 168 +void chromium_sqlite3_initialize_win_sqlite3_file(sqlite3_file* file, HANDLE ha ndle) {
157 + winFile* winSQLite3File = (winFile*)file; 169 + winFile* winSQLite3File = (winFile*)file;
158 + memset(file, 0, sizeof(*file)); 170 + memset(file, 0, sizeof(*file));
159 + winSQLite3File->pMethod = &winIoMethod; 171 + winSQLite3File->pMethod = &winIoMethod;
160 + winSQLite3File->h = handle; 172 + winSQLite3File->h = handle;
161 +} 173 +}
162 + 174 +
163 #endif /* SQLITE_OS_WIN */ 175 #endif /* SQLITE_OS_WIN */
176 --
177 2.2.1
178
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698