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

Side by Side Diff: third_party/WebKit/Source/modules/webdatabase/sqlite/SQLiteFileSystemPosix.cpp

Issue 2395473002: reflow comments in modules/webdatabase (Closed)
Patch Set: Created 4 years, 2 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 /* 1 /*
2 * Copyright (C) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2009 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 fd = Platform::current()->databaseOpenFile(String(fileName), desiredFlags); 171 fd = Platform::current()->databaseOpenFile(String(fileName), desiredFlags);
172 } 172 }
173 if (fd < 0) 173 if (fd < 0)
174 return SQLITE_CANTOPEN; 174 return SQLITE_CANTOPEN;
175 175
176 if (usedFlags) 176 if (usedFlags)
177 *usedFlags = desiredFlags; 177 *usedFlags = desiredFlags;
178 178
179 fcntl(fd, F_SETFD, fcntl(fd, F_GETFD) | FD_CLOEXEC); 179 fcntl(fd, F_SETFD, fcntl(fd, F_GETFD) | FD_CLOEXEC);
180 180
181 // The mask 0x00007F00 gives us the 7 bits that determine the type of the file SQLite is trying to open. 181 // The mask 0x00007F00 gives us the 7 bits that determine the type of the file
182 // SQLite is trying to open.
182 int fileType = desiredFlags & 0x00007F00; 183 int fileType = desiredFlags & 0x00007F00;
183 int noLock = (fileType != SQLITE_OPEN_MAIN_DB); 184 int noLock = (fileType != SQLITE_OPEN_MAIN_DB);
184 sqlite3_vfs* wrappedVfs = static_cast<sqlite3_vfs*>(vfs->pAppData); 185 sqlite3_vfs* wrappedVfs = static_cast<sqlite3_vfs*>(vfs->pAppData);
185 return chromium_sqlite3_fill_in_unix_sqlite3_file( 186 return chromium_sqlite3_fill_in_unix_sqlite3_file(
186 wrappedVfs, fd, id, fileName, noLock, desiredFlags); 187 wrappedVfs, fd, id, fileName, noLock, desiredFlags);
187 } 188 }
188 189
189 int chromiumOpen(sqlite3_vfs* vfs, 190 int chromiumOpen(sqlite3_vfs* vfs,
190 const char* fileName, 191 const char* fileName,
191 sqlite3_file* id, 192 sqlite3_file* id,
192 int desiredFlags, 193 int desiredFlags,
193 int* usedFlags) { 194 int* usedFlags) {
194 sqlite3_vfs* wrappedVfs = static_cast<sqlite3_vfs*>(vfs->pAppData); 195 sqlite3_vfs* wrappedVfs = static_cast<sqlite3_vfs*>(vfs->pAppData);
195 sqlite3_file* wrappedFile = 196 sqlite3_file* wrappedFile =
196 static_cast<sqlite3_file*>(sqlite3_malloc(wrappedVfs->szOsFile)); 197 static_cast<sqlite3_file*>(sqlite3_malloc(wrappedVfs->szOsFile));
197 if (!wrappedFile) 198 if (!wrappedFile)
198 return SQLITE_NOMEM; 199 return SQLITE_NOMEM;
199 200
200 // Make a local copy of the file name. SQLite's os_unix.c appears to be writt en to allow caching the pointer passed 201 // Make a local copy of the file name. SQLite's os_unix.c appears to be
201 // in to this function, but that seems brittle. 202 // written to allow caching the pointer passed in to this function, but that
203 // seems brittle.
202 char* wrappedFileName = sqlite3_mprintf("%s", fileName); 204 char* wrappedFileName = sqlite3_mprintf("%s", fileName);
203 if (!wrappedFileName) { 205 if (!wrappedFileName) {
204 sqlite3_free(wrappedFile); 206 sqlite3_free(wrappedFile);
205 return SQLITE_NOMEM; 207 return SQLITE_NOMEM;
206 } 208 }
207 209
208 // SQLite's unixOpen() makes assumptions about the structure of |fileName|. O ur local copy may not answer those 210 // SQLite's unixOpen() makes assumptions about the structure of |fileName|.
209 // assumptions correctly. 211 // Our local copy may not answer those assumptions correctly.
210 int rc = 212 int rc =
211 chromiumOpenInternal(vfs, fileName, wrappedFile, desiredFlags, usedFlags); 213 chromiumOpenInternal(vfs, fileName, wrappedFile, desiredFlags, usedFlags);
212 if (rc != SQLITE_OK) { 214 if (rc != SQLITE_OK) {
213 sqlite3_free(wrappedFileName); 215 sqlite3_free(wrappedFileName);
214 sqlite3_free(wrappedFile); 216 sqlite3_free(wrappedFile);
215 return rc; 217 return rc;
216 } 218 }
217 219
218 static sqlite3_io_methods chromiumIoMethods = { 220 static sqlite3_io_methods chromiumIoMethods = {
219 1, 221 1,
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 sqlite3_vfs* wrappedVfs = static_cast<sqlite3_vfs*>(vfs->pAppData); 320 sqlite3_vfs* wrappedVfs = static_cast<sqlite3_vfs*>(vfs->pAppData);
319 return wrappedVfs->xSleep(wrappedVfs, microseconds); 321 return wrappedVfs->xSleep(wrappedVfs, microseconds);
320 } 322 }
321 323
322 int chromiumCurrentTime(sqlite3_vfs* vfs, double* prNow) { 324 int chromiumCurrentTime(sqlite3_vfs* vfs, double* prNow) {
323 sqlite3_vfs* wrappedVfs = static_cast<sqlite3_vfs*>(vfs->pAppData); 325 sqlite3_vfs* wrappedVfs = static_cast<sqlite3_vfs*>(vfs->pAppData);
324 return wrappedVfs->xCurrentTime(wrappedVfs, prNow); 326 return wrappedVfs->xCurrentTime(wrappedVfs, prNow);
325 } 327 }
326 328
327 int chromiumGetLastError(sqlite3_vfs* vfs, int e, char* s) { 329 int chromiumGetLastError(sqlite3_vfs* vfs, int e, char* s) {
328 // xGetLastError() has never been used by SQLite. The implementation in os_wi n.c indicates this is a reasonable implementation. 330 // xGetLastError() has never been used by SQLite. The implementation in
331 // os_win.c indicates this is a reasonable implementation.
329 *s = '\0'; 332 *s = '\0';
330 return 0; 333 return 0;
331 } 334 }
332 335
333 } // namespace 336 } // namespace
334 337
335 void SQLiteFileSystem::registerSQLiteVFS() { 338 void SQLiteFileSystem::registerSQLiteVFS() {
336 sqlite3_vfs* wrappedVfs = sqlite3_vfs_find("unix"); 339 sqlite3_vfs* wrappedVfs = sqlite3_vfs_find("unix");
337 340
338 // These are implemented by delegating to |wrappedVfs|. 341 // These are implemented by delegating to |wrappedVfs|.
(...skipping 17 matching lines...) Expand all
356 chromiumDlSym, 359 chromiumDlSym,
357 chromiumDlClose, 360 chromiumDlClose,
358 chromiumRandomness, 361 chromiumRandomness,
359 chromiumSleep, 362 chromiumSleep,
360 chromiumCurrentTime, 363 chromiumCurrentTime,
361 chromiumGetLastError}; 364 chromiumGetLastError};
362 sqlite3_vfs_register(&chromium_vfs, 0); 365 sqlite3_vfs_register(&chromium_vfs, 0);
363 } 366 }
364 367
365 } // namespace blink 368 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698