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

Side by Side Diff: Source/modules/webdatabase/sqlite/SQLiteFileSystemWin.cpp

Issue 454353002: Cleanup namespace usage in modules/. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 4 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 | Annotate | Revision Log
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 17 matching lines...) Expand all
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #include "config.h" 31 #include "config.h"
32 #include "modules/webdatabase/sqlite/SQLiteFileSystem.h" 32 #include "modules/webdatabase/sqlite/SQLiteFileSystem.h"
33 33
34 #include <windows.h> 34 #include <windows.h>
35 #include <sqlite3.h> 35 #include <sqlite3.h>
36 #include "public/platform/Platform.h" 36 #include "public/platform/Platform.h"
37 37
38 using namespace blink;
39
40 // Defined in Chromium's codebase in third_party/sqlite/src/os_win.c 38 // Defined in Chromium's codebase in third_party/sqlite/src/os_win.c
41 extern "C" { 39 extern "C" {
42 int chromium_sqlite3_initialize_win_sqlite3_file(sqlite3_file* file, HANDLE hand le); 40 int chromium_sqlite3_initialize_win_sqlite3_file(sqlite3_file* file, HANDLE hand le);
43 } 41 }
44 42
43 namespace blink {
44
45 // Chromium's Windows implementation of SQLite VFS 45 // Chromium's Windows implementation of SQLite VFS
46 namespace { 46 namespace {
47 47
48 // Opens a file. 48 // Opens a file.
49 // 49 //
50 // vfs - pointer to the sqlite3_vfs object. 50 // vfs - pointer to the sqlite3_vfs object.
51 // fileName - the name of the file. 51 // fileName - the name of the file.
52 // id - the structure that will manipulate the newly opened file. 52 // id - the structure that will manipulate the newly opened file.
53 // desiredFlags - the desired open mode flags. 53 // desiredFlags - the desired open mode flags.
54 // usedFlags - the actual open mode flags that were used. 54 // usedFlags - the actual open mode flags that were used.
55 int chromiumOpen(sqlite3_vfs*, const char* fileName, 55 int chromiumOpen(sqlite3_vfs*, const char* fileName,
56 sqlite3_file* id, int desiredFlags, int* usedFlags) 56 sqlite3_file* id, int desiredFlags, int* usedFlags)
57 { 57 {
58 HANDLE h = blink::Platform::current()->databaseOpenFile(String(fileName), de siredFlags); 58 HANDLE h = Platform::current()->databaseOpenFile(String(fileName), desiredFl ags);
59 if (h == INVALID_HANDLE_VALUE) { 59 if (h == INVALID_HANDLE_VALUE) {
60 if (desiredFlags & SQLITE_OPEN_READWRITE) { 60 if (desiredFlags & SQLITE_OPEN_READWRITE) {
61 int newFlags = (desiredFlags | SQLITE_OPEN_READONLY) & ~SQLITE_OPEN_ READWRITE; 61 int newFlags = (desiredFlags | SQLITE_OPEN_READONLY) & ~SQLITE_OPEN_ READWRITE;
62 return chromiumOpen(0, fileName, id, newFlags, usedFlags); 62 return chromiumOpen(0, fileName, id, newFlags, usedFlags);
63 } else 63 } else
64 return SQLITE_CANTOPEN; 64 return SQLITE_CANTOPEN;
65 } 65 }
66 if (usedFlags) { 66 if (usedFlags) {
67 if (desiredFlags & SQLITE_OPEN_READWRITE) 67 if (desiredFlags & SQLITE_OPEN_READWRITE)
68 *usedFlags = SQLITE_OPEN_READWRITE; 68 *usedFlags = SQLITE_OPEN_READWRITE;
69 else 69 else
70 *usedFlags = SQLITE_OPEN_READONLY; 70 *usedFlags = SQLITE_OPEN_READONLY;
71 } 71 }
72 72
73 chromium_sqlite3_initialize_win_sqlite3_file(id, h); 73 chromium_sqlite3_initialize_win_sqlite3_file(id, h);
74 return SQLITE_OK; 74 return SQLITE_OK;
75 } 75 }
76 76
77 // Deletes the given file. 77 // Deletes the given file.
78 // 78 //
79 // vfs - pointer to the sqlite3_vfs object. 79 // vfs - pointer to the sqlite3_vfs object.
80 // fileName - the name of the file. 80 // fileName - the name of the file.
81 // syncDir - determines if the directory to which this file belongs 81 // syncDir - determines if the directory to which this file belongs
82 // should be synched after the file is deleted. 82 // should be synched after the file is deleted.
83 int chromiumDelete(sqlite3_vfs*, const char* fileName, int) 83 int chromiumDelete(sqlite3_vfs*, const char* fileName, int)
84 { 84 {
85 return blink::Platform::current()->databaseDeleteFile(String(fileName), fals e); 85 return Platform::current()->databaseDeleteFile(String(fileName), false);
86 } 86 }
87 87
88 // Check the existance and status of the given file. 88 // Check the existance and status of the given file.
89 // 89 //
90 // vfs - pointer to the sqlite3_vfs object. 90 // vfs - pointer to the sqlite3_vfs object.
91 // fileName - the name of the file. 91 // fileName - the name of the file.
92 // flag - the type of test to make on this file. 92 // flag - the type of test to make on this file.
93 // res - the result. 93 // res - the result.
94 int chromiumAccess(sqlite3_vfs*, const char* fileName, int flag, int* res) 94 int chromiumAccess(sqlite3_vfs*, const char* fileName, int flag, int* res)
95 { 95 {
96 DWORD attr = blink::Platform::current()->databaseGetFileAttributes(String(fi leName)); 96 DWORD attr = Platform::current()->databaseGetFileAttributes(String(fileName) );
97 switch (flag) { 97 switch (flag) {
98 case SQLITE_ACCESS_READ: 98 case SQLITE_ACCESS_READ:
99 case SQLITE_ACCESS_EXISTS: 99 case SQLITE_ACCESS_EXISTS:
100 *res = (attr != INVALID_FILE_ATTRIBUTES); 100 *res = (attr != INVALID_FILE_ATTRIBUTES);
101 break; 101 break;
102 case SQLITE_ACCESS_READWRITE: 102 case SQLITE_ACCESS_READWRITE:
103 *res = ((attr & FILE_ATTRIBUTE_READONLY) == 0); 103 *res = ((attr & FILE_ATTRIBUTE_READONLY) == 0);
104 break; 104 break;
105 default: 105 default:
106 return SQLITE_ERROR; 106 return SQLITE_ERROR;
(...skipping 24 matching lines...) Expand all
131 void* chromiumDlOpen(sqlite3_vfs*, const char*) 131 void* chromiumDlOpen(sqlite3_vfs*, const char*)
132 { 132 {
133 return 0; 133 return 0;
134 } 134 }
135 #else 135 #else
136 #define chromiumDlOpen 0 136 #define chromiumDlOpen 0
137 #endif // SQLITE_OMIT_LOAD_EXTENSION 137 #endif // SQLITE_OMIT_LOAD_EXTENSION
138 138
139 } // namespace 139 } // namespace
140 140
141 namespace blink {
142
143 void SQLiteFileSystem::registerSQLiteVFS() 141 void SQLiteFileSystem::registerSQLiteVFS()
144 { 142 {
145 sqlite3_vfs* win32_vfs = sqlite3_vfs_find("win32"); 143 sqlite3_vfs* win32_vfs = sqlite3_vfs_find("win32");
146 static sqlite3_vfs chromium_vfs = { 144 static sqlite3_vfs chromium_vfs = {
147 1, 145 1,
148 win32_vfs->szOsFile, 146 win32_vfs->szOsFile,
149 win32_vfs->mxPathname, 147 win32_vfs->mxPathname,
150 0, 148 0,
151 "chromium_vfs", 149 "chromium_vfs",
152 win32_vfs->pAppData, 150 win32_vfs->pAppData,
153 chromiumOpen, 151 chromiumOpen,
154 chromiumDelete, 152 chromiumDelete,
155 chromiumAccess, 153 chromiumAccess,
156 chromiumFullPathname, 154 chromiumFullPathname,
157 chromiumDlOpen, 155 chromiumDlOpen,
158 win32_vfs->xDlError, 156 win32_vfs->xDlError,
159 win32_vfs->xDlSym, 157 win32_vfs->xDlSym,
160 win32_vfs->xDlClose, 158 win32_vfs->xDlClose,
161 win32_vfs->xRandomness, 159 win32_vfs->xRandomness,
162 win32_vfs->xSleep, 160 win32_vfs->xSleep,
163 win32_vfs->xCurrentTime, 161 win32_vfs->xCurrentTime,
164 win32_vfs->xGetLastError 162 win32_vfs->xGetLastError
165 }; 163 };
166 sqlite3_vfs_register(&chromium_vfs, 0); 164 sqlite3_vfs_register(&chromium_vfs, 0);
167 } 165 }
168 166
169 } // namespace blink 167 } // namespace blink
OLDNEW
« no previous file with comments | « Source/modules/webdatabase/sqlite/SQLiteFileSystemPosix.cpp ('k') | Source/modules/websockets/WebSocketDeflaterTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698