| Differences between
and this patch
- WebCore/ChangeLog +43 lines
Lines 1-3 WebCore/ChangeLog_sec1
1
2009-06-26  Dumitru Daniliuc  <dumi@chromium.org>
2
3
        Reviewed by NOBODY (OOPS!).
4
5
        Adds an abstraction layer between the DB classes and the file
6
        system, which allows us to add our own logic for storing, opening,
7
        deleting, etc. databases.
8
9
        https://bugs.webkit.org/show_bug.cgi?id=26054
10
11
        * GNUmakefile.am:
12
        * WebCore.pro:
13
        * WebCore.vcproj/WebCore.vcproj:
14
        * platform/sql/SQLiteDatabase.cpp:
15
        (WebCore::SQLiteDatabase::open):
16
        * platform/sql/SQLiteFileSystem.cpp: Added.
17
        (WebCore::SQLiteFileSystem::SQLiteFileSystem):
18
        (WebCore::SQLiteFileSystem::registerSQLiteVFS):
19
        (WebCore::SQLiteFileSystem::openDatabase):
20
        (WebCore::SQLiteFileSystem::getFileNameForNewDatabase):
21
        (WebCore::SQLiteFileSystem::appendDatabaseFileNameToPath):
22
        (WebCore::SQLiteFileSystem::ensureDatabaseDirectoryExists):
23
        (WebCore::SQLiteFileSystem::ensureDatabaseFileExists):
24
        (WebCore::SQLiteFileSystem::deleteEmptyDatabaseDirectory):
25
        (WebCore::SQLiteFileSystem::deleteDatabaseFile):
26
        (WebCore::SQLiteFileSystem::getDatabaseFileSize):
27
        * platform/sql/SQLiteFileSystem.h: Added.
28
        * platform/win/FileSystemWin.cpp:
29
        (WebCore::directoryName):
30
        * storage/Database.cpp:
31
        (WebCore::Database::databaseSize):
32
        * storage/DatabaseTracker.cpp:
33
        (WebCore::DatabaseTracker::DatabaseTracker):
34
        (WebCore::DatabaseTracker::trackerDatabasePath):
35
        (WebCore::DatabaseTracker::openTrackerDatabase):
36
        (WebCore::DatabaseTracker::originPath):
37
        (WebCore::DatabaseTracker::fullPathForDatabase):
38
        (WebCore::DatabaseTracker::usageForDatabase):
39
        (WebCore::DatabaseTracker::deleteOrigin):
40
        (WebCore::DatabaseTracker::deleteDatabaseFile):
41
        * storage/OriginUsageRecord.cpp:
42
        (WebCore::OriginUsageRecord::diskUsage):
43
1
2009-06-26  Simon Fraser  <simon.fraser@apple.com>
44
2009-06-26  Simon Fraser  <simon.fraser@apple.com>
2
45
3
        Rubber-stamped by Dave Levin
46
        Rubber-stamped by Dave Levin
- WebCore/GNUmakefile.am +2 lines
Lines 2028-2033 webcore_sources += \ WebCore/GNUmakefile.am_sec1
2028
	WebCore/platform/sql/SQLiteAuthorizer.cpp \
2028
	WebCore/platform/sql/SQLiteAuthorizer.cpp \
2029
	WebCore/platform/sql/SQLiteDatabase.cpp \
2029
	WebCore/platform/sql/SQLiteDatabase.cpp \
2030
	WebCore/platform/sql/SQLiteDatabase.h \
2030
	WebCore/platform/sql/SQLiteDatabase.h \
2031
	WebCore/platform/sql/SQLiteFileSystem.cpp \
2032
	WebCore/platform/sql/SQLiteFileSystem.h \
2031
	WebCore/platform/sql/SQLiteStatement.cpp \
2033
	WebCore/platform/sql/SQLiteStatement.cpp \
2032
	WebCore/platform/sql/SQLiteStatement.h \
2034
	WebCore/platform/sql/SQLiteStatement.h \
2033
	WebCore/platform/sql/SQLiteTransaction.cpp \
2035
	WebCore/platform/sql/SQLiteTransaction.cpp \
- WebCore/WebCore.pro +1 lines
Lines 1322-1327 contains(DEFINES, ENABLE_SQLITE=1) { WebCore/WebCore.pro_sec1
1322
    SOURCES += \
1322
    SOURCES += \
1323
        platform/sql/SQLiteAuthorizer.cpp \
1323
        platform/sql/SQLiteAuthorizer.cpp \
1324
        platform/sql/SQLiteDatabase.cpp \
1324
        platform/sql/SQLiteDatabase.cpp \
1325
        platform/sql/SQLiteFileSystem.cpp \
1325
        platform/sql/SQLiteStatement.cpp \
1326
        platform/sql/SQLiteStatement.cpp \
1326
        platform/sql/SQLiteTransaction.cpp \
1327
        platform/sql/SQLiteTransaction.cpp \
1327
        platform/sql/SQLValue.cpp \
1328
        platform/sql/SQLValue.cpp \
- WebCore/WebCore.vcproj/WebCore.vcproj +8 lines
Lines 20140-20145 WebCore/WebCore.vcproj/WebCore.vcproj_sec1
20140
					>
20140
					>
20141
				</File>
20141
				</File>
20142
				<File
20142
				<File
20143
					RelativePath="..\platform\sql\SQLiteFileSystem.cpp"
20144
					>
20145
				</File>
20146
				<File
20147
					RelativePath="..\platform\sql\SQLiteFileSystem.h"
20148
					>
20149
				</File>
20150
				<File
20143
					RelativePath="..\platform\sql\SQLiteStatement.cpp"
20151
					RelativePath="..\platform\sql\SQLiteStatement.cpp"
20144
					>
20152
					>
20145
				</File>
20153
				</File>
- WebCore/platform/sql/SQLiteDatabase.cpp -3 / +2 lines
Lines 29-34 WebCore/platform/sql/SQLiteDatabase.cpp_sec1
29
29
30
#include "DatabaseAuthorizer.h"
30
#include "DatabaseAuthorizer.h"
31
#include "Logging.h"
31
#include "Logging.h"
32
#include "SQLiteFileSystem.h"
32
#include "SQLiteStatement.h"
33
#include "SQLiteStatement.h"
33
34
34
#include <sqlite3.h>
35
#include <sqlite3.h>
Lines 60-68 bool SQLiteDatabase::open(const String& WebCore/platform/sql/SQLiteDatabase.cpp_sec2
60
{
61
{
61
    close();
62
    close();
62
    
63
    
63
    // SQLite expects a null terminator on its UTF-16 strings.
64
    m_lastError = SQLiteFileSystem::openDatabase(filename, &m_db);
64
    String path = filename;
65
    m_lastError = sqlite3_open16(path.charactersWithNullTermination(), &m_db);
66
    if (m_lastError != SQLITE_OK) {
65
    if (m_lastError != SQLITE_OK) {
67
        LOG_ERROR("SQLite database failed to load from %s\nCause - %s", filename.ascii().data(),
66
        LOG_ERROR("SQLite database failed to load from %s\nCause - %s", filename.ascii().data(),
68
            sqlite3_errmsg(m_db));
67
            sqlite3_errmsg(m_db));
- WebCore/platform/sql/SQLiteFileSystem.cpp +123 lines
Line 0 WebCore/platform/sql/SQLiteFileSystem.cpp_sec1
1
/*
2
 * Copyright (C) 2009 Google Inc. All rights reserved.
3
 *
4
 * Redistribution and use in source and binary forms, with or without
5
 * modification, are permitted provided that the following conditions are
6
 * met:
7
 *
8
 *     * Redistributions of source code must retain the above copyright
9
 * notice, this list of conditions and the following disclaimer.
10
 *     * Redistributions in binary form must reproduce the above
11
 * copyright notice, this list of conditions and the following disclaimer
12
 * in the documentation and/or other materials provided with the
13
 * distribution.
14
 *     * Neither the name of Google Inc. nor the names of its
15
 * contributors may be used to endorse or promote products derived from
16
 * this software without specific prior written permission.
17
 *
18
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
 */
30
31
#include "config.h"
32
#include "SQLiteFileSystem.h"
33
34
#include "FileSystem.h"
35
#include "SQLiteDatabase.h"
36
#include "SQLiteStatement.h"
37
#include <sqlite3.h>
38
39
namespace WebCore {
40
41
SQLiteFileSystem::SQLiteFileSystem()
42
{
43
}
44
45
void SQLiteFileSystem::registerSQLiteVFS()
46
{
47
}
48
49
int SQLiteFileSystem::openDatabase(const String& fileName, sqlite3** database)
50
{
51
    // SQLite expects a null terminator on its UTF-16 strings.
52
    String path = fileName;
53
    return sqlite3_open16(path.charactersWithNullTermination(), database);
54
}
55
56
String SQLiteFileSystem::getFileNameForNewDatabase(const String& dbDir, const String& dbName,
57
						   const String& originIdentifier, SQLiteDatabase* db)
58
{
59
    // try to get the next sequence number from the given database
60
    // if we can't get a number, return an empty string
61
    SQLiteStatement sequenceStatement(*db, "SELECT seq FROM sqlite_sequence WHERE name='Databases';");
62
    if (sequenceStatement.prepare() != SQLResultOk)
63
        return String();
64
    int result = sequenceStatement.step();
65
    int64_t seq = 0;
66
    if (result == SQLResultRow)
67
        seq = sequenceStatement.getColumnInt64(0);
68
    else if (result != SQLResultDone)
69
        return String();
70
    sequenceStatement.finalize();
71
72
    // increment the number until we can use it to form a file name that doesn't exist
73
    String fileName;
74
    do {
75
        ++seq;
76
        fileName = pathByAppendingComponent(dbDir, String::format("%016llx.db", seq));
77
    } while (fileExists(fileName));
78
79
    return fileName;
80
}
81
82
String SQLiteFileSystem::appendDatabaseFileNameToPath(const String& path, const String& fileName)
83
{
84
    return pathByAppendingComponent(path, fileName);
85
}
86
87
bool SQLiteFileSystem::ensureDatabaseDirectoryExists(const String& path)
88
{
89
    if (path.isEmpty())
90
        return false;
91
    return makeAllDirectories(path);
92
}
93
94
bool SQLiteFileSystem::ensureDatabaseFileExists(const String& fileName, bool checkPathOnly)
95
{
96
    if (fileName.isEmpty())
97
        return false;
98
99
    if (checkPathOnly) {
100
        String dir = directoryName(fileName);
101
        return ensureDatabaseDirectoryExists(dir);
102
    }
103
104
    return fileExists(fileName);
105
}
106
107
bool SQLiteFileSystem::deleteEmptyDatabaseDirectory(const String& path)
108
{
109
    return deleteEmptyDirectory(path);
110
}
111
112
bool SQLiteFileSystem::deleteDatabaseFile(const String& fileName)
113
{
114
    return deleteFile(fileName);
115
}
116
117
long long SQLiteFileSystem::getDatabaseFileSize(const String& fileName)
118
{        
119
    long long size;
120
    return getFileSize(fileName, size) ? size : 0;
121
}
122
123
} // namespace WebCore
- WebCore/platform/sql/SQLiteFileSystem.h +114 lines
Line 0 WebCore/platform/sql/SQLiteFileSystem.h_sec1
1
/*
2
 * Copyright (C) 2009 Google Inc. All rights reserved.
3
 *
4
 * Redistribution and use in source and binary forms, with or without
5
 * modification, are permitted provided that the following conditions are
6
 * met:
7
 *
8
 *     * Redistributions of source code must retain the above copyright
9
 * notice, this list of conditions and the following disclaimer.
10
 *     * Redistributions in binary form must reproduce the above
11
 * copyright notice, this list of conditions and the following disclaimer
12
 * in the documentation and/or other materials provided with the
13
 * distribution.
14
 *     * Neither the name of Google Inc. nor the names of its
15
 * contributors may be used to endorse or promote products derived from
16
 * this software without specific prior written permission.
17
 *
18
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
 */
30
31
#ifndef SQLiteFileSystem_h
32
#define SQLiteFileSystem_h
33
34
#include "PlatformString.h"
35
#include <wtf/Threading.h>
36
37
struct sqlite3;
38
39
namespace WebCore {
40
41
class SQLiteDatabase;
42
43
// A class that abstracts the file system related operations required
44
// by the WebKit database code.
45
class SQLiteFileSystem {
46
public:
47
    // Registers a user-defined SQLite VFS.
48
    static void registerSQLiteVFS();
49
50
    // Opens a database file.
51
    //
52
    // fileName - The name of the database file.
53
    // database - The SQLite structure that represents the database stored
54
    //            in the given file.
55
    static int openDatabase(const String& fileName, sqlite3** database);
56
57
    // Returns the file name for a database.
58
    //
59
    // dbDir - The directory where all databases are stored.
60
    // dbName - The name of the database.
61
    // originIdentifier - The origin that wants to use this database.
62
    // db - A database with a number generator used to create unique file names.
63
    static String getFileNameForNewDatabase(const String& dbDir, const String& dbName,
64
                                            const String& originIdentifier, SQLiteDatabase* db);
65
66
    // Creates an absolute file path given a directory and a file name.
67
    //
68
    // path - The directory.
69
    // fileName - The file name.
70
    static String appendDatabaseFileNameToPath(const String& path, const String& fileName);
71
72
    // Makes sure the given directory exists, by creating all missing directories
73
    // on the given path.
74
    //
75
    // path - The directory.
76
    static bool ensureDatabaseDirectoryExists(const String& path);
77
78
    // If 'checkPathOnly' is false, then this method only checks if the given file exists.
79
    // If 'checkPathOnly' is true, then this method makes sure all directories on the
80
    // given path exist by creating the missing ones, and does not check if the file
81
    // itself exists.
82
    //
83
    // Sometimes we expect a DB file to exist; other times, we're OK with creating a new
84
    // DB file, but we want to make sure that the directory in which we want to put the
85
    // new DB file exists. This method covers both cases.
86
    //
87
    // fileName - The file name.
88
    // checkPathOnly - If true, we only make sure that the given directory exists.
89
    //                 If false, we only check if the file exists.
90
    static bool ensureDatabaseFileExists(const String& fileName, bool checkPathOnly);
91
92
    // Deletes an empty database directory.
93
    //
94
    // path - The directory.
95
    static bool deleteEmptyDatabaseDirectory(const String& path);
96
97
    // Deletes a database file.
98
    //
99
    // fileName - The file name.
100
    static bool deleteDatabaseFile(const String& fileName);
101
102
    // Returns the size of the database file.
103
    //
104
    // fileName - The file name.
105
    static long long getDatabaseFileSize(const String& fileName);
106
107
private:
108
    // do not instantiate this class
109
    SQLiteFileSystem();
110
}; // class SQLiteFileSystem
111
112
} // namespace WebCore
113
114
#endif
- WebCore/platform/win/FileSystemWin.cpp -2 / +4 lines
Lines 133-140 String pathGetFileName(const String& pat WebCore/platform/win/FileSystemWin.cpp_sec1
133
133
134
String directoryName(const String& path)
134
String directoryName(const String& path)
135
{
135
{
136
    notImplemented();
136
  String fileName = pathGetFileName(path);
137
    return String();
137
  String dirName = String(path);
138
  dirName.truncate(dirName.length() - pathGetFileName(path).length());
139
  return dirName;
138
}
140
}
139
141
140
static String bundleName()
142
static String bundleName()
- WebCore/storage/Database.cpp -5 / +2 lines
Lines 40-46 WebCore/storage/Database.cpp_sec1
40
#include "DatabaseTracker.h"
40
#include "DatabaseTracker.h"
41
#include "Document.h"
41
#include "Document.h"
42
#include "ExceptionCode.h"
42
#include "ExceptionCode.h"
43
#include "FileSystem.h"
44
#include "Frame.h"
43
#include "Frame.h"
45
#include "InspectorController.h"
44
#include "InspectorController.h"
46
#include "Logging.h"
45
#include "Logging.h"
Lines 48-53 WebCore/storage/Database.cpp_sec2
48
#include "Page.h"
47
#include "Page.h"
49
#include "OriginQuotaManager.h"
48
#include "OriginQuotaManager.h"
50
#include "SQLiteDatabase.h"
49
#include "SQLiteDatabase.h"
50
#include "SQLiteFileSystem.h"
51
#include "SQLiteStatement.h"
51
#include "SQLiteStatement.h"
52
#include "SQLResultSet.h"
52
#include "SQLResultSet.h"
53
#include <wtf/MainThread.h>
53
#include <wtf/MainThread.h>
Lines 338-347 void Database::stop() WebCore/storage/Database.cpp_sec3
338
338
339
unsigned long long Database::databaseSize() const
339
unsigned long long Database::databaseSize() const
340
{
340
{
341
    long long size;
341
    return SQLiteFileSystem::getDatabaseFileSize(m_filename);
342
    if (!getFileSize(m_filename, size))
343
        size = 0;
344
    return size;
345
}
342
}
346
343
347
unsigned long long Database::maximumSize() const
344
unsigned long long Database::maximumSize() const
- WebCore/storage/DatabaseTracker.cpp -38 / +16 lines
Lines 35-46 WebCore/storage/DatabaseTracker.cpp_sec1
35
#include "Database.h"
35
#include "Database.h"
36
#include "DatabaseTrackerClient.h"
36
#include "DatabaseTrackerClient.h"
37
#include "Document.h"
37
#include "Document.h"
38
#include "FileSystem.h"
39
#include "Logging.h"
38
#include "Logging.h"
40
#include "OriginQuotaManager.h"
39
#include "OriginQuotaManager.h"
41
#include "Page.h"
40
#include "Page.h"
42
#include "SecurityOrigin.h"
41
#include "SecurityOrigin.h"
43
#include "SecurityOriginHash.h"
42
#include "SecurityOriginHash.h"
43
#include "SQLiteFileSystem.h"
44
#include "SQLiteStatement.h"
44
#include "SQLiteStatement.h"
45
#include <wtf/MainThread.h>
45
#include <wtf/MainThread.h>
46
#include <wtf/StdLibExtras.h>
46
#include <wtf/StdLibExtras.h>
Lines 69-74 DatabaseTracker::DatabaseTracker() WebCore/storage/DatabaseTracker.cpp_sec2
69
    , m_thread(currentThread())
69
    , m_thread(currentThread())
70
#endif
70
#endif
71
{
71
{
72
  SQLiteFileSystem::registerSQLiteVFS();
72
}
73
}
73
74
74
void DatabaseTracker::setDatabaseDirectoryPath(const String& path)
75
void DatabaseTracker::setDatabaseDirectoryPath(const String& path)
Lines 87-95 const String& DatabaseTracker::databaseD WebCore/storage/DatabaseTracker.cpp_sec3
87
String DatabaseTracker::trackerDatabasePath() const
88
String DatabaseTracker::trackerDatabasePath() const
88
{
89
{
89
    ASSERT(currentThread() == m_thread);
90
    ASSERT(currentThread() == m_thread);
90
    if (m_databaseDirectoryPath.isEmpty())
91
    return SQLiteFileSystem::appendDatabaseFileNameToPath(m_databaseDirectoryPath, "Databases.db");
91
        return String();
92
    return pathByAppendingComponent(m_databaseDirectoryPath, "Databases.db");
93
}
92
}
94
93
95
void DatabaseTracker::openTrackerDatabase(bool createIfDoesNotExist)
94
void DatabaseTracker::openTrackerDatabase(bool createIfDoesNotExist)
Lines 100-112 void DatabaseTracker::openTrackerDatabas WebCore/storage/DatabaseTracker.cpp_sec4
100
        return;
99
        return;
101
100
102
    String databasePath = trackerDatabasePath();
101
    String databasePath = trackerDatabasePath();
103
    if (databasePath.isEmpty())
102
    if (!SQLiteFileSystem::ensureDatabaseFileExists(databasePath, createIfDoesNotExist))
104
        return;
105
106
    if (!createIfDoesNotExist && !fileExists(databasePath))
107
        return;
103
        return;
108
104
109
    makeAllDirectories(m_databaseDirectoryPath);
110
    if (!m_database.open(databasePath)) {
105
    if (!m_database.open(databasePath)) {
111
        // FIXME: What do do here?
106
        // FIXME: What do do here?
112
        return;
107
        return;
Lines 190-198 bool DatabaseTracker::hasEntryForDatabas WebCore/storage/DatabaseTracker.cpp_sec5
190
String DatabaseTracker::originPath(SecurityOrigin* origin) const
185
String DatabaseTracker::originPath(SecurityOrigin* origin) const
191
{
186
{
192
    ASSERT(currentThread() == m_thread);
187
    ASSERT(currentThread() == m_thread);
193
    if (m_databaseDirectoryPath.isEmpty())
188
    return SQLiteFileSystem::appendDatabaseFileNameToPath(m_databaseDirectoryPath, origin->databaseIdentifier());
194
        return String();
195
    return pathByAppendingComponent(m_databaseDirectoryPath, origin->databaseIdentifier());
196
}
189
}
197
190
198
String DatabaseTracker::fullPathForDatabase(SecurityOrigin* origin, const String& name, bool createIfNotExists)
191
String DatabaseTracker::fullPathForDatabase(SecurityOrigin* origin, const String& name, bool createIfNotExists)
Lines 206-212 String DatabaseTracker::fullPathForDatab WebCore/storage/DatabaseTracker.cpp_sec6
206
    String originPath = this->originPath(origin);
199
    String originPath = this->originPath(origin);
207
    
200
    
208
    // Make sure the path for this SecurityOrigin exists
201
    // Make sure the path for this SecurityOrigin exists
209
    if (createIfNotExists && !makeAllDirectories(originPath))
202
    if (createIfNotExists && !SQLiteFileSystem::ensureDatabaseDirectoryExists(originPath))
210
        return String();
203
        return String();
211
    
204
    
212
    // See if we have a path for this database yet
205
    // See if we have a path for this database yet
Lines 224-230 String DatabaseTracker::fullPathForDatab WebCore/storage/DatabaseTracker.cpp_sec7
224
    int result = statement.step();
217
    int result = statement.step();
225
218
226
    if (result == SQLResultRow)
219
    if (result == SQLResultRow)
227
        return pathByAppendingComponent(originPath, statement.getColumnText(0));
220
        return SQLiteFileSystem::appendDatabaseFileNameToPath(originPath, statement.getColumnText(0));
228
    if (!createIfNotExists)
221
    if (!createIfNotExists)
229
        return String();
222
        return String();
230
        
223
        
Lines 241-262 String DatabaseTracker::fullPathForDatab WebCore/storage/DatabaseTracker.cpp_sec8
241
        return String();
234
        return String();
242
    result = sequenceStatement.step();
235
    result = sequenceStatement.step();
243
236
244
    // This has a range of 2^63 and starts at 0 for every time a user resets Safari -
237
    String fileName = SQLiteFileSystem::getFileNameForNewDatabase(originPath, origin->databaseIdentifier(), name, &m_database);
245
    // I can't imagine it'd over overflow
238
    if (!addDatabase(origin, name, fileName))
246
    int64_t seq = 0;
247
    if (result == SQLResultRow) {
248
        seq = sequenceStatement.getColumnInt64(0);
249
    } else if (result != SQLResultDone)
250
        return String();
251
    sequenceStatement.finalize();
252
253
    String filename;
254
    do {
255
        ++seq;
256
        filename = pathByAppendingComponent(originPath, String::format("%016llx.db", seq));
257
    } while (fileExists(filename));
258
259
    if (!addDatabase(origin, name, String::format("%016llx.db", seq)))
260
        return String();
239
        return String();
261
240
262
    // If this origin's quota is being tracked (open handle to a database in this origin), add this new database
241
    // If this origin's quota is being tracked (open handle to a database in this origin), add this new database
Lines 264-273 String DatabaseTracker::fullPathForDatab WebCore/storage/DatabaseTracker.cpp_sec9
264
    {
243
    {
265
        Locker<OriginQuotaManager> locker(originQuotaManager());
244
        Locker<OriginQuotaManager> locker(originQuotaManager());
266
        if (originQuotaManager().tracksOrigin(origin))
245
        if (originQuotaManager().tracksOrigin(origin))
267
            originQuotaManager().addDatabase(origin, name, filename);
246
            originQuotaManager().addDatabase(origin, name, fileName);
268
    }
247
    }
269
    
248
    
270
    return filename;
249
    return fileName;
271
}
250
}
272
251
273
void DatabaseTracker::populateOrigins()
252
void DatabaseTracker::populateOrigins()
Lines 423-430 unsigned long long DatabaseTracker::usag WebCore/storage/DatabaseTracker.cpp_sec10
423
    if (path.isEmpty())
402
    if (path.isEmpty())
424
        return 0;
403
        return 0;
425
        
404
        
426
    long long size;
405
    return SQLiteFileSystem::getDatabaseFileSize(path);
427
    return getFileSize(path, size) ? size : 0;
428
}
406
}
429
407
430
void DatabaseTracker::addOpenDatabase(Database* database)
408
void DatabaseTracker::addOpenDatabase(Database* database)
Lines 665-671 void DatabaseTracker::deleteOrigin(Secur WebCore/storage/DatabaseTracker.cpp_sec11
665
        return;
643
        return;
666
    }
644
    }
667
645
668
    deleteEmptyDirectory(originPath(origin));
646
    SQLiteFileSystem::deleteEmptyDatabaseDirectory(originPath(origin));
669
647
670
    RefPtr<SecurityOrigin> originPossiblyLastReference = origin;
648
    RefPtr<SecurityOrigin> originPossiblyLastReference = origin;
671
    {
649
    {
Lines 679-686 void DatabaseTracker::deleteOrigin(Secur WebCore/storage/DatabaseTracker.cpp_sec12
679
        if (m_quotaMap->isEmpty()) {
657
        if (m_quotaMap->isEmpty()) {
680
            if (m_database.isOpen())
658
            if (m_database.isOpen())
681
                m_database.close();
659
                m_database.close();
682
            deleteFile(trackerDatabasePath());
660
	    SQLiteFileSystem::deleteDatabaseFile(trackerDatabasePath());
683
            deleteEmptyDirectory(m_databaseDirectoryPath);
661
	    SQLiteFileSystem::deleteEmptyDatabaseDirectory(m_databaseDirectoryPath);
684
        }
662
        }
685
    }
663
    }
686
664
Lines 763-769 bool DatabaseTracker::deleteDatabaseFile WebCore/storage/DatabaseTracker.cpp_sec13
763
    for (unsigned i = 0; i < deletedDatabases.size(); ++i)
741
    for (unsigned i = 0; i < deletedDatabases.size(); ++i)
764
        deletedDatabases[i]->markAsDeletedAndClose();
742
        deletedDatabases[i]->markAsDeletedAndClose();
765
743
766
    return deleteFile(fullPath);
744
    return SQLiteFileSystem::deleteDatabaseFile(fullPath);
767
}
745
}
768
746
769
void DatabaseTracker::setClient(DatabaseTrackerClient* client)
747
void DatabaseTracker::setClient(DatabaseTrackerClient* client)
- WebCore/storage/OriginUsageRecord.cpp -3 / +3 lines
Lines 30-36 WebCore/storage/OriginUsageRecord.cpp_sec1
30
30
31
#if ENABLE(DATABASE)
31
#if ENABLE(DATABASE)
32
32
33
#include "FileSystem.h"
33
#include "SQLiteFileSystem.h"
34
34
35
namespace WebCore {
35
namespace WebCore {
36
36
Lines 82-89 unsigned long long OriginUsageRecord::di WebCore/storage/OriginUsageRecord.cpp_sec2
82
        const String& path = m_databaseMap.get(*iUnknown).filename;
82
        const String& path = m_databaseMap.get(*iUnknown).filename;
83
        ASSERT(!path.isEmpty());
83
        ASSERT(!path.isEmpty());
84
                
84
                
85
        long long size;
85
        long long size = SQLiteFileSystem::getDatabaseFileSize(path);
86
        if (getFileSize(path, size))
86
        if (size > 0)
87
            m_databaseMap.set(*iUnknown, DatabaseEntry(path, size));
87
            m_databaseMap.set(*iUnknown, DatabaseEntry(path, size));
88
        else {
88
        else {
89
            // When we can't determine the file size, we'll just have to assume the file is missing/inaccessible.
89
            // When we can't determine the file size, we'll just have to assume the file is missing/inaccessible.
- WebKit/win/WebKitDLL.cpp -1 lines
Lines 32-38 WebKit/win/WebKitDLL.cpp_sec1
32
#include "WebKitClassFactory.h"
32
#include "WebKitClassFactory.h"
33
#include <WebCore/COMPtr.h>
33
#include <WebCore/COMPtr.h>
34
#include <WebCore/IconDatabase.h>
34
#include <WebCore/IconDatabase.h>
35
#include <WebCore/LocalStorage.h>
36
#include <WebCore/Page.h>
35
#include <WebCore/Page.h>
37
#include <WebCore/PageGroup.h>
36
#include <WebCore/PageGroup.h>
38
#include <WebCore/RenderThemeWin.h>
37
#include <WebCore/RenderThemeWin.h>

Return to Bug 26054