Changeset 29698 in webkit
- Timestamp:
- Jan 21, 2008 2:23:28 PM (16 years ago)
- Location:
- trunk
- Files:
-
- 53 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r29696 r29698 1 2008-01-21 Darin Adler <darin@apple.com> 2 3 Reviewed by John Sullivan. 4 5 - fix <rdar://problem/5644324> Delegate-less WebKit clients should have no databases 6 7 - remove the default database quota setting 8 9 - simplify the quota-related client calls by merging the one for a new database with 10 the one for an existing database, adding a feature where you can get details about 11 a database being created using the same functions that work on the other databases, 12 and removing the parameters and return values, instead having clients use a function 13 to set the quota 14 15 - fix unsafe multi-thread access to the database tracker's quota map 16 - fix bug in deleteAllDatabases where it would iterate a HashMap while modifying it 17 18 The tracker database is now only created when we set the quota for a database origin. 19 Thus asking for info about databases won't cause anything to be written to disk. 20 21 * WebCore.base.exp: Updated. 22 23 * bindings/js/GCController.cpp: Added an #if to get rid of an unused function warning. 24 25 * page/Chrome.cpp: Removed database-related functions. There's no problem having the 26 code deal directly with the client. 27 * page/Chrome.h: Ditto. Also made Chrome inherit from Noncopyable. 28 29 * page/ChromeClient.h: Replaced the two quota-related functions with a single one. 30 The details about the state of databases in the origin are now available by asking 31 for database details. There's also no need to pass the security origin, since 32 it's easy to get that from the frame's document. 33 34 * page/Settings.cpp: Removed the default quota setting. 35 * page/Settings.h: Ditto. 36 37 * platform/FileSystem.h: Added deleteEmptyDirectory. 38 * platform/gtk/FileSystemGtk.cpp: 39 (WebCore::deleteEmptyDirectory): Added. 40 * platform/posix/FileSystemPOSIX.cpp: 41 (WebCore::deleteEmptyDirectory): Added. 42 * platform/qt/FileSystemQt.cpp: 43 (WebCore::deleteEmptyDirectory): Added. 44 * platform/win/FileSystemWin.cpp: 45 (WebCore::deleteEmptyDirectory): Added. 46 * platform/wx/FileSystemWx.cpp: 47 (WebCore::deleteEmptyDirectory): Added placeholder. 48 49 * storage/DatabaseDetails.h: Removed the isValid() function since its name is 50 confusing -- we removed our other isValid() functions. For the few callers that 51 need this, it's fine to just check name().isEmpty(). Made the member functions 52 all const. 53 54 * storage/DatabaseTracker.cpp: 55 (WebCore::DatabaseTracker::DatabaseTracker): Removed m_defaultQuota initialization. 56 Added m_proposedDatabase and m_thread. 57 (WebCore::DatabaseTracker::setDatabaseDirectoryPath): Got rid of code that would 58 open the tracker database here. This might slightly speed up launch time, since 59 we won't do the I/O until we have to, and before we were actually creating an SQL 60 database in this code that's run when we go to the first webpage. 61 (WebCore::DatabaseTracker::trackerDatabasePath): Added. 62 (WebCore::DatabaseTracker::openTrackerDatabase): Added a boolean parameter telling 63 this function whether to create the database. Made this function safe to call if 64 the database is already open. Also made the function fail quietly if the path has 65 not been set yet. 66 (WebCore::DatabaseTracker::canEstablishDatabase): Got rid of the call to the 67 establishEntryForOrigin function. The origin is now put in the tracker database 68 when the quota is set to a non-zero value. When judging if there's enough space 69 for the new database, require at least one byte even if estimatedSize is 0, and 70 check for overflow. Also added code here to populate the origins map, which 71 guarantees it will be ready when the database uses it on another thread later. 72 Also changed this to call the new ChromeClient function. 73 (WebCore::DatabaseTracker::hasEntryForDatabase): Added code to open the 74 tracker database, since that's no longer done by setDatabaseDirectoryPath. 75 (WebCore::DatabaseTracker::originPath): Added. 76 (WebCore::DatabaseTracker::fullPathForDatabase): Added code so that this will 77 return a null string for the proposed database if called from within the 78 ChromeClient function. Also switched from empty string to null string for the 79 error cases. 80 (WebCore::DatabaseTracker::populateOrigins): Added code to open the tracker 81 database. 82 (WebCore::DatabaseTracker::databaseNamesForOrigin): Ditto. 83 (WebCore::DatabaseTracker::detailsForNameAndOrigin): Ditto. Also added code that 84 will return the details of the proposed database if called from within the 85 ChromeClient function. This is how the client can learn of the display name and 86 the estimated size of the new database. 87 (WebCore::DatabaseTracker::setDatabaseDetails): Added code to open the tracker 88 database. 89 (WebCore::DatabaseTracker::quotaForOrigin): Made this code OK to call on a non-main 90 thread by using m_quotaMapGuard to guard access to the map. Other code runs on the 91 main thread only, and only functions that write to the map use the lock. 92 (WebCore::DatabaseTracker::setQuota): Changed this function so it can insert the 93 initial quota as well as updating an existing quota. Added locking since this 94 function modifies the quota map. Added code to open the tracker database. Added 95 an early exit if the quota is already correct, which is guarantees that if you 96 set a quota to 0 it won't trigger creation of a tracker database. 97 (WebCore::DatabaseTracker::addDatabase): Added code to open the tracker database. 98 (WebCore::DatabaseTracker::deleteAllDatabases): Made a copy of the quota map before 99 iterating it to find all the origins. This fixes a problem with the old code where 100 it would modify the map while iterating it, which gives assertions in debug builds 101 and unpredictable results. 102 (WebCore::DatabaseTracker::deleteOrigin): Replaced deleteDatabasesWithOrigin with 103 this function. Added code to open the tracker database if needed. Added code to 104 delete the origin from the tracker database, and to close the tracker database 105 and delete files and directories as needed if we are deleting the final origin. 106 (WebCore::DatabaseTracker::deleteDatabase): Added code to open the tracker database 107 if needed. 108 109 * storage/DatabaseTracker.h: Renamed databasePath to databaseDirectoryPath for 110 clarity, including the data member, and the getter and setter functions. 111 Replaced deleteDatabasesWithOrigin with deleteOrigin. Removed the functions 112 dealing with default origin quota. There is no default any more; origins start 113 with no quota and the client must set a quota. Added trackerDatabasePath and 114 originPath helper functions. Added a boolean parameter to openTrackerDatabase 115 to tell it whether to create the database or not. Removed the 116 establishEntryForOrigin function. Renamed m_originQuotaMap to just m_quotaMap, 117 and added m_quotaMapGuard. Added a QuotaMap typedef. Added m_proposedDatabase, 118 which holds the origin and details for the current proposed database during 119 the client callback function that must decide whether to grant quota. Added a 120 m_thread data member for debugging use to assert if functions that can only 121 be called on a single thread are misused. 122 123 * storage/SQLTransaction.cpp: 124 (WebCore::SQLTransaction::deliverQuotaIncreaseCallback): Changed to call the 125 new exceededDatabaseQuota function instead of the old one. 126 127 * svg/graphics/SVGImageEmptyClients.h: Updated for the change to ChromeClient. 128 1 129 2008-01-21 David Hyatt <hyatt@apple.com> 2 130 -
trunk/WebCore/WebCore.base.exp
r29593 r29698 295 295 __ZN7WebCore15BackForwardListD1Ev 296 296 __ZN7WebCore15ContextMenuItem26releasePlatformDescriptionEv 297 __ZN7WebCore15DatabaseTracker12deleteOriginEPNS_14SecurityOriginE 297 298 __ZN7WebCore15DatabaseTracker14deleteDatabaseEPNS_14SecurityOriginERKNS_6StringE 298 299 __ZN7WebCore15DatabaseTracker14quotaForOriginEPNS_14SecurityOriginE 299 300 __ZN7WebCore15DatabaseTracker14usageForOriginEPNS_14SecurityOriginE 300 __ZN7WebCore15DatabaseTracker15setDatabasePathERKNS_6StringE301 301 __ZN7WebCore15DatabaseTracker18deleteAllDatabasesEv 302 302 __ZN7WebCore15DatabaseTracker22databaseNamesForOriginEPNS_14SecurityOriginERN3WTF6VectorINS_6StringELm0EEE 303 303 __ZN7WebCore15DatabaseTracker23detailsForNameAndOriginERKNS_6StringEPNS_14SecurityOriginE 304 __ZN7WebCore15DatabaseTracker2 5deleteDatabasesWithOriginEPNS_14SecurityOriginE304 __ZN7WebCore15DatabaseTracker24setDatabaseDirectoryPathERKNS_6StringE 305 305 __ZN7WebCore15DatabaseTracker7originsERN3WTF6VectorINS1_6RefPtrINS_14SecurityOriginEEELm0EEE 306 306 __ZN7WebCore15DatabaseTracker7trackerEv … … 492 492 __ZN7WebCore8Settings28setForceFTPDirectoryListingsEb 493 493 __ZN7WebCore8Settings29setAuthorAndUserStylesEnabledEb 494 __ZN7WebCore8Settings29setDefaultDatabaseOriginQuotaEy495 494 __ZN7WebCore8Settings31setShrinksStandaloneImagesToFitEb 496 495 __ZN7WebCore8Settings32setNeedsAdobeFrameReloadingQuirkEb -
trunk/WebCore/bindings/js/GCController.cpp
r29663 r29698 38 38 namespace WebCore { 39 39 40 #if USE(PTHREADS) 41 40 42 static void* collect(void*) 41 43 { … … 44 46 return 0; 45 47 } 48 49 #endif 46 50 47 51 GCController& gcController() -
trunk/WebCore/page/Chrome.cpp
r29663 r29698 344 344 } 345 345 346 unsigned long long Chrome::requestQuotaIncreaseForNewDatabase(Frame* frame, SecurityOrigin* origin, const String& databaseDisplayName, unsigned long long estimatedSize)347 {348 return m_client->requestQuotaIncreaseForNewDatabase(frame, origin, databaseDisplayName, estimatedSize);349 }350 351 unsigned long long Chrome::requestQuotaIncreaseForDatabaseOperation(Frame* frame, SecurityOrigin* origin, const String& databaseIdentifier, unsigned long long proposedNewQuota)352 {353 return m_client->requestQuotaIncreaseForDatabaseOperation(frame, origin, databaseIdentifier, proposedNewQuota);354 }355 356 346 PageGroupLoadDeferrer::PageGroupLoadDeferrer(Page* page, bool deferSelf) 357 347 { -
trunk/WebCore/page/Chrome.h
r29663 r29698 1 1 // -*- mode: c++; c-basic-offset: 4 -*- 2 2 /* 3 * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.3 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved. 4 4 * 5 5 * This library is free software; you can redistribute it and/or … … 24 24 #include "FocusDirection.h" 25 25 #include <wtf/Forward.h> 26 #include <wtf/Noncopyable.h> 26 27 #include <wtf/RefPtr.h> 27 28 … … 41 42 class IntRect; 42 43 class Page; 43 class SecurityOrigin;44 44 class String; 45 45 … … 62 62 }; 63 63 64 class Chrome {64 class Chrome : Noncopyable { 65 65 public: 66 66 Chrome(Page*, ChromeClient*); … … 126 126 127 127 void print(Frame*); 128 129 unsigned long long requestQuotaIncreaseForNewDatabase(Frame*, SecurityOrigin*, const String& databaseDisplayName, unsigned long long estimatedSize);130 unsigned long long requestQuotaIncreaseForDatabaseOperation(Frame*, SecurityOrigin* origin, const String& databaseIdentifier, unsigned long long proposedNewQuota);131 128 132 129 #if PLATFORM(MAC) -
trunk/WebCore/page/ChromeClient.h
r29663 r29698 1 1 // -*- mode: c++; c-basic-offset: 4 -*- 2 2 /* 3 * Copyright (C) 2006 -2007 Apple, Inc.3 * Copyright (C) 2006, 2007, 2008 Apple, Inc. All rights reserved. 4 4 * 5 5 * This library is free software; you can redistribute it and/or … … 31 31 class IntRect; 32 32 class Page; 33 class SecurityOrigin;34 33 class String; 35 34 … … 39 38 class ChromeClient { 40 39 public: 41 virtual ~ChromeClient() { }42 40 virtual void chromeDestroyed() = 0; 43 41 … … 105 103 virtual void print(Frame*) = 0; 106 104 107 virtual unsigned long long requestQuotaIncreaseForNewDatabase(Frame*, SecurityOrigin* origin, const String& databaseDisplayName, unsigned long long estimatedSize) = 0; 108 virtual unsigned long long requestQuotaIncreaseForDatabaseOperation(Frame*, SecurityOrigin* origin, const String& databaseIdentifier, unsigned long long proposedNewQuota) = 0; 109 }; 105 virtual void exceededDatabaseQuota(Frame*, const String& databaseName) = 0; 106 107 protected: 108 virtual ~ChromeClient() { } 109 }; 110 110 111 111 } -
trunk/WebCore/page/Settings.cpp
r29663 r29698 302 302 } 303 303 304 void Settings::setDefaultDatabaseOriginQuota(unsigned long long quota)305 {306 #if ENABLE(DATABASE)307 DatabaseTracker::tracker().setDefaultOriginQuota(quota);308 #endif309 }310 311 unsigned long long Settings::defaultDatabaseOriginQuota() const312 {313 #if ENABLE(DATABASE)314 return DatabaseTracker::tracker().defaultOriginQuota();315 #else316 return 0;317 #endif318 }319 320 304 void Settings::setFontRenderingMode(FontRenderingMode mode) 321 305 { -
trunk/WebCore/page/Settings.h
r28869 r29698 145 145 bool authorAndUserStylesEnabled() const { return m_authorAndUserStylesEnabled; } 146 146 147 void setDefaultDatabaseOriginQuota(unsigned long long);148 unsigned long long defaultDatabaseOriginQuota() const;149 150 147 void setFontRenderingMode(FontRenderingMode mode); 151 148 FontRenderingMode fontRenderingMode() const; -
trunk/WebCore/platform/FileSystem.h
r29663 r29698 1 1 /* 2 * Copyright (C) 2007 Apple Inc. All rights reserved.2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. 3 3 * Copyright (C) 2008 Collabora, Ltd. All rights reserved. 4 4 * … … 32 32 33 33 #include <wtf/Platform.h> 34 #include <wtf/Vector.h>35 34 36 35 typedef const struct __CFData* CFDataRef; … … 51 50 bool fileExists(const String&); 52 51 bool deleteFile(const String&); 52 bool deleteEmptyDirectory(const String&); 53 53 bool fileSize(const String&, long long& result); 54 54 String pathByAppendingComponent(const String& path, const String& component); … … 60 60 inline bool isHandleValid(const PlatformFileHandle& handle) { return handle != invalidPlatformFileHandle; } 61 61 62 / * Prefix is what the filename should be prefixed with, not the full path */62 // Prefix is what the filename should be prefixed with, not the full path. 63 63 CString openTemporaryFile(const char* prefix, PlatformFileHandle&); 64 64 void closeFile(PlatformFileHandle&); -
trunk/WebCore/platform/gtk/FileSystemGtk.cpp
r29663 r29698 2 2 * Copyright (C) 2007 Holger Hans Peter Freyther 3 3 * Copyright (C) 2008 Collabora, Ltd. 4 * Copyright (C) 2008 Apple Inc. All rights reserved. 4 5 * 5 6 * This library is free software; you can redistribute it and/or … … 51 52 if (filename) { 52 53 result = g_remove(filename) == 0; 54 g_free(filename); 55 } 56 57 return result; 58 } 59 60 bool deleteEmptyDirectory(const String& path) 61 { 62 bool result = false; 63 gchar* filename = g_filename_from_utf8(path.utf8().data(), -1, 0, 0, 0); 64 65 if (filename) { 66 result = g_rmdir(filename) == 0; 53 67 g_free(filename); 54 68 } -
trunk/WebCore/platform/posix/FileSystemPOSIX.cpp
r29663 r29698 1 1 /* 2 * Copyright (C) 2007 Apple Inc. All rights reserved.2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 26 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 27 */ 28 28 29 #include "config.h" 29 30 #include "FileSystem.h" … … 62 63 // unlink(...) returns 0 on successful deletion of the path and non-zero in any other case (including invalid permissions or non-existent file) 63 64 return !unlink(fsRep.data()); 65 } 66 67 bool deleteEmptyDirectory(const String& path) 68 { 69 CString fsRep = fileSystemRepresentation(path); 70 71 if (!fsRep.data() || fsRep.data()[0] == '\0') 72 return false; 73 74 // rmdir(...) returns 0 on successful deletion of the path and non-zero in any other case (including invalid permissions or non-existent file) 75 return !rmdir(fsRep.data()); 64 76 } 65 77 -
trunk/WebCore/platform/qt/FileSystemQt.cpp
r29663 r29698 2 2 * Copyright (C) 2007 Staikos Computing Services Inc. 3 3 * Copyright (C) 2007 Holger Hans Peter Freyther 4 * Copyright (C) 2008 Apple, Inc. All rights reserved. 4 5 * 5 6 * Redistribution and use in source and binary forms, with or without … … 46 47 } 47 48 49 bool deleteEmptyDirectory(const String& path) 50 { 51 return QDir::rmdir(path); 52 } 53 48 54 bool fileSize(const String& path, long long& result) 49 55 { -
trunk/WebCore/platform/win/FileSystemWin.cpp
r29631 r29698 1 1 /* 2 * Copyright (C) 2007 Apple Inc. All rights reserved.2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. 3 3 * Copyright (C) 2008 Collabora, Ltd. All rights reserved. 4 4 * … … 66 66 } 67 67 68 bool deleteEmptyDirectory(const String& path) 69 { 70 String filename = path; 71 return !!RemoveDirectoryW(filename.charactersWithNullTermination()); 72 } 73 68 74 String pathByAppendingComponent(const String& path, const String& component) 69 75 { -
trunk/WebCore/platform/wx/FileSystemWx.cpp
r29663 r29698 46 46 } 47 47 48 bool deleteEmptyDirectory(const String& path) 49 { 50 notImplemented(); 51 return false; 52 } 53 48 54 bool fileSize(const String& path, long long& resultSize) 49 55 { -
trunk/WebCore/storage/DatabaseDetails.h
r29663 r29698 1 1 /* 2 * Copyright (C) 2007 Apple Inc. All rights reserved.2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 26 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 27 */ 28 28 29 #ifndef DatabaseDetails_h 29 30 #define DatabaseDetails_h … … 38 39 : m_expectedUsage(0) 39 40 , m_currentUsage(0) 40 { } 41 41 { 42 } 43 42 44 DatabaseDetails(const String& databaseName, const String& displayName, unsigned long long expectedUsage, unsigned long long currentUsage) 43 45 : m_name(databaseName) … … 45 47 , m_expectedUsage(expectedUsage) 46 48 , m_currentUsage(currentUsage) 47 { } 48 49 bool isValid() const { return !(m_name.isEmpty() && m_displayName.isEmpty() && !m_expectedUsage && !m_currentUsage); } 50 51 const String& name() { return m_name; } 52 const String& displayName() { return m_displayName; } 53 unsigned long long expectedUsage() { return m_expectedUsage; } 54 unsigned long long currentUsage() { return m_currentUsage; } 55 49 { 50 } 51 52 const String& name() const { return m_name; } 53 const String& displayName() const { return m_displayName; } 54 unsigned long long expectedUsage() const { return m_expectedUsage; } 55 unsigned long long currentUsage() const { return m_currentUsage; } 56 56 57 private: 57 58 String m_name; -
trunk/WebCore/storage/DatabaseTracker.cpp
r29663 r29698 1 1 /* 2 * Copyright (C) 2007 Apple Inc. All rights reserved.2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 26 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 27 */ 28 28 29 #include "config.h" 29 30 #include "DatabaseTracker.h" 30 31 32 #include "ChromeClient.h" 31 33 #include "Database.h" 32 34 #include "DatabaseTrackerClient.h" … … 37 39 #include "SQLiteStatement.h" 38 40 41 using namespace std; 42 39 43 namespace WebCore { 40 41 // HTML5 SQL Storage spec suggests 5MB as the default quota per origin42 static const unsigned DefaultOriginQuota = 5242880;43 44 44 45 struct SecurityOriginHash { … … 82 83 { 83 84 static DatabaseTracker tracker; 84 85 85 return tracker; 86 86 } 87 87 88 88 DatabaseTracker::DatabaseTracker() 89 : m_defaultQuota(DefaultOriginQuota) 90 , m_client(0) 91 { 92 } 93 94 void DatabaseTracker::setDatabasePath(const String& path) 95 { 96 m_databasePath = path; 97 openTrackerDatabase(); 98 } 99 100 const String& DatabaseTracker::databasePath() 101 { 102 return m_databasePath; 103 } 104 105 void DatabaseTracker::openTrackerDatabase() 106 { 89 : m_client(0) 90 , m_proposedDatabase(0) 91 #ifndef NDEBUG 92 , m_thread(currentThread()) 93 #endif 94 { 95 } 96 97 void DatabaseTracker::setDatabaseDirectoryPath(const String& path) 98 { 99 ASSERT(currentThread() == m_thread); 107 100 ASSERT(!m_database.isOpen()); 108 109 makeAllDirectories(m_databasePath); 110 String databasePath = pathByAppendingComponent(m_databasePath, "Databases.db"); 111 101 m_databaseDirectoryPath = path; 102 } 103 104 const String& DatabaseTracker::databaseDirectoryPath() const 105 { 106 ASSERT(currentThread() == m_thread); 107 return m_databaseDirectoryPath; 108 } 109 110 String DatabaseTracker::trackerDatabasePath() const 111 { 112 ASSERT(currentThread() == m_thread); 113 if (m_databaseDirectoryPath.isEmpty()) 114 return String(); 115 return pathByAppendingComponent(m_databaseDirectoryPath, "Databases.db"); 116 } 117 118 void DatabaseTracker::openTrackerDatabase(bool createIfDoesNotExist) 119 { 120 ASSERT(currentThread() == m_thread); 121 122 if (m_database.isOpen()) 123 return; 124 125 String databasePath = trackerDatabasePath(); 126 if (databasePath.isEmpty()) 127 return; 128 129 if (!createIfDoesNotExist && !fileExists(databasePath)) 130 return; 131 132 makeAllDirectories(m_databaseDirectoryPath); 112 133 if (!m_database.open(databasePath)) { 113 134 // FIXME: What do do here? … … 119 140 } 120 141 } 121 122 142 if (!m_database.tableExists("Databases")) { 123 143 if (!m_database.executeCommand("CREATE TABLE Databases (guid INTEGER PRIMARY KEY AUTOINCREMENT, origin TEXT, name TEXT, displayName TEXT, estimatedSize INTEGER, path TEXT);")) { … … 129 149 bool DatabaseTracker::canEstablishDatabase(Document* document, const String& name, const String& displayName, unsigned long estimatedSize) 130 150 { 151 ASSERT(currentThread() == m_thread); 152 153 // Populate the origins before we establish a database; this guarantees that quotaForOrigin 154 // can run on the database thread later. 155 populateOrigins(); 156 157 // If a database already exists, ignore the passed-in estimated size and say it's OK. 131 158 SecurityOrigin* origin = document->securityOrigin(); 132 133 // If this origin has no databases yet, establish an entry in the tracker database with the default quota134 if (!hasEntryForOrigin(origin))135 establishEntryForOrigin(origin);136 137 // If a database already exists, you can always establish a handle to it138 159 if (hasEntryForDatabase(origin, name)) 139 160 return true; 140 141 // If the new database will fit as-is, allow its creation161 162 // If the database will fit, allow its creation. 142 163 unsigned long long usage = usageForOrigin(origin); 143 if (usage + estimatedSize < quotaForOrigin(origin)) 164 unsigned long long requirement = usage + max(1UL, estimatedSize); 165 if (requirement < usage) 166 return false; // If the estimated size is so big it causes an overflow, don't allow creation. 167 if (requirement <= quotaForOrigin(origin)) 144 168 return true; 145 146 // Otherwise, ask the UI Delegate for a new quota 147 Page* page; 148 if (!(page = document->page())) 149 return false; 150 151 // If no displayName was specified, pass the standard (required) name instead 152 unsigned long long newQuota = page->chrome()->requestQuotaIncreaseForNewDatabase(document->frame(), origin, displayName.length() > 0 ? displayName : name, estimatedSize); 153 setQuota(origin, newQuota); 154 155 return usage + estimatedSize <= newQuota; 169 170 // Give the chrome client a chance to increase the quota. 171 // Temporarily make the details of the proposed database available, so the client can get at them. 172 Page* page = document->page(); 173 if (!page) 174 return false; 175 pair<SecurityOrigin*, DatabaseDetails> details(origin, DatabaseDetails(name, displayName, estimatedSize, 0)); 176 m_proposedDatabase = &details; 177 page->chrome()->client()->exceededDatabaseQuota(document->frame(), name); 178 m_proposedDatabase = 0; 179 180 // If the database will fit now, allow its creation. 181 return requirement <= quotaForOrigin(origin); 156 182 } 157 183 158 184 bool DatabaseTracker::hasEntryForOrigin(SecurityOrigin* origin) 159 185 { 186 ASSERT(currentThread() == m_thread); 160 187 populateOrigins(); 161 return m_ originQuotaMap->contains(origin);188 return m_quotaMap->contains(origin); 162 189 } 163 190 164 191 bool DatabaseTracker::hasEntryForDatabase(SecurityOrigin* origin, const String& databaseIdentifier) 165 192 { 193 ASSERT(currentThread() == m_thread); 194 openTrackerDatabase(false); 195 if (!m_database.isOpen()) 196 return false; 166 197 SQLiteStatement statement(m_database, "SELECT guid FROM Databases WHERE origin=? AND name=?;"); 167 198 … … 175 206 } 176 207 177 void DatabaseTracker::establishEntryForOrigin(SecurityOrigin* origin) 178 { 179 ASSERT(!hasEntryForOrigin(origin)); 180 181 SQLiteStatement statement(m_database, "INSERT INTO Origins VALUES (?, ?)"); 182 if (statement.prepare() != SQLResultOk) { 183 LOG_ERROR("Unable to establish origin %s in the tracker", origin->stringIdentifier().ascii().data()); 184 return; 185 } 186 187 statement.bindText(1, origin->stringIdentifier()); 188 statement.bindInt64(2, m_defaultQuota); 189 190 if (statement.step() != SQLResultDone) { 191 LOG_ERROR("Unable to establish origin %s in the tracker", origin->stringIdentifier().ascii().data()); 192 return; 193 } 194 195 populateOrigins(); 196 m_originQuotaMap->set(origin, m_defaultQuota); 197 198 if (m_client) 199 m_client->dispatchDidModifyOrigin(origin); 208 String DatabaseTracker::originPath(SecurityOrigin* origin) const 209 { 210 ASSERT(currentThread() == m_thread); 211 if (m_databaseDirectoryPath.isEmpty()) 212 return String(); 213 return pathByAppendingComponent(m_databaseDirectoryPath, origin->stringIdentifier()); 200 214 } 201 215 202 216 String DatabaseTracker::fullPathForDatabase(SecurityOrigin* origin, const String& name, bool createIfNotExists) 203 217 { 218 ASSERT(currentThread() == m_thread); 219 220 if (m_proposedDatabase && m_proposedDatabase->first == origin && m_proposedDatabase->second.name() == name) 221 return String(); 222 204 223 String originIdentifier = origin->stringIdentifier(); 205 String originPath = pathByAppendingComponent(m_databasePath, originIdentifier);224 String originPath = this->originPath(origin); 206 225 207 226 // Make sure the path for this SecurityOrigin exists 208 227 if (createIfNotExists && !makeAllDirectories(originPath)) 209 return "";228 return String(); 210 229 211 230 // See if we have a path for this database yet 231 openTrackerDatabase(false); 232 if (!m_database.isOpen()) 233 return String(); 212 234 SQLiteStatement statement(m_database, "SELECT path FROM Databases WHERE origin=? AND name=?;"); 213 235 214 236 if (statement.prepare() != SQLResultOk) 215 return "";237 return String(); 216 238 217 239 statement.bindText(1, originIdentifier); … … 223 245 return pathByAppendingComponent(originPath, statement.getColumnText16(0)); 224 246 if (!createIfNotExists) 225 return "";247 return String(); 226 248 227 249 if (result != SQLResultDone) { 228 250 LOG_ERROR("Failed to retrieve filename from Database Tracker for origin %s, name %s", origin->stringIdentifier().ascii().data(), name.ascii().data()); 229 return "";251 return String(); 230 252 } 231 253 statement.finalize(); … … 235 257 // FIXME: More informative error handling here, even though these steps should never fail 236 258 if (sequenceStatement.prepare() != SQLResultOk) 237 return "";259 return String(); 238 260 result = sequenceStatement.step(); 239 261 … … 244 266 seq = sequenceStatement.getColumnInt64(0); 245 267 } else if (result != SQLResultDone) 246 return "";268 return String(); 247 269 sequenceStatement.finalize(); 248 270 … … 254 276 255 277 if (!addDatabase(origin, name, String::format("%016llx.db", seq))) 256 return "";278 return String(); 257 279 258 280 return filename; … … 261 283 void DatabaseTracker::populateOrigins() 262 284 { 263 if (m_originQuotaMap) 264 return; 265 266 m_originQuotaMap.set(new HashMap<RefPtr<SecurityOrigin>, unsigned long long, SecurityOriginHash, SecurityOriginTraits>); 267 285 if (m_quotaMap) 286 return; 287 288 ASSERT(currentThread() == m_thread); 289 290 m_quotaMap.set(new QuotaMap); 291 292 openTrackerDatabase(false); 268 293 if (!m_database.isOpen()) 269 294 return; … … 277 302 while ((result = statement.step()) == SQLResultRow) { 278 303 RefPtr<SecurityOrigin> origin = SecurityOrigin::createFromIdentifier(statement.getColumnText16(0)); 279 m_ originQuotaMap->set(origin.get(), statement.getColumnInt64(1));304 m_quotaMap->set(origin.get(), statement.getColumnInt64(1)); 280 305 } 281 306 282 307 if (result != SQLResultDone) 283 308 LOG_ERROR("Failed to read in all origins from the database"); 284 285 return;286 309 } 287 310 288 311 void DatabaseTracker::origins(Vector<RefPtr<SecurityOrigin> >& result) 289 312 { 290 if (!m_originQuotaMap) 291 populateOrigins(); 292 293 copyKeysToVector(*(m_originQuotaMap.get()), result); 313 ASSERT(currentThread() == m_thread); 314 populateOrigins(); 315 copyKeysToVector(*m_quotaMap, result); 294 316 } 295 317 296 318 bool DatabaseTracker::databaseNamesForOrigin(SecurityOrigin* origin, Vector<String>& resultVector) 297 319 { 320 ASSERT(currentThread() == m_thread); 321 openTrackerDatabase(false); 298 322 if (!m_database.isOpen()) 299 323 return false; … … 320 344 DatabaseDetails DatabaseTracker::detailsForNameAndOrigin(const String& name, SecurityOrigin* origin) 321 345 { 346 ASSERT(currentThread() == m_thread); 347 348 if (m_proposedDatabase && m_proposedDatabase->first == origin && m_proposedDatabase->second.name() == name) 349 return m_proposedDatabase->second; 350 322 351 String originIdentifier = origin->stringIdentifier(); 323 352 353 openTrackerDatabase(false); 354 if (!m_database.isOpen()) 355 return DatabaseDetails(); 324 356 SQLiteStatement statement(m_database, "SELECT displayName, estimatedSize FROM Databases WHERE origin=? AND name=?"); 325 357 if (statement.prepare() != SQLResultOk) … … 343 375 void DatabaseTracker::setDatabaseDetails(SecurityOrigin* origin, const String& name, const String& displayName, unsigned long estimatedSize) 344 376 { 377 ASSERT(currentThread() == m_thread); 378 345 379 String originIdentifier = origin->stringIdentifier(); 346 380 int64_t guid = 0; 347 381 382 openTrackerDatabase(true); 383 if (!m_database.isOpen()) 384 return; 348 385 SQLiteStatement statement(m_database, "SELECT guid FROM Databases WHERE origin=? AND name=?"); 349 386 if (statement.prepare() != SQLResultOk) … … 390 427 unsigned long long DatabaseTracker::usageForDatabase(const String& name, SecurityOrigin* origin) 391 428 { 429 ASSERT(currentThread() == m_thread); 392 430 String path = fullPathForDatabase(origin, name, false); 393 431 if (path.isEmpty()) … … 400 438 unsigned long long DatabaseTracker::usageForOrigin(SecurityOrigin* origin) 401 439 { 440 ASSERT(currentThread() == m_thread); 402 441 Vector<String> names; 403 442 databaseNamesForOrigin(origin, names); … … 412 451 unsigned long long DatabaseTracker::quotaForOrigin(SecurityOrigin* origin) 413 452 { 453 ASSERT(currentThread() == m_thread || m_quotaMap); 414 454 populateOrigins(); 415 return m_originQuotaMap->get(origin); 455 MutexLocker lockQuotaMap(m_quotaMapGuard); 456 return m_quotaMap->get(origin); 416 457 } 417 458 418 459 void DatabaseTracker::setQuota(SecurityOrigin* origin, unsigned long long quota) 419 460 { 420 populateOrigins(); 421 if (!m_originQuotaMap->contains(origin)) 422 establishEntryForOrigin(origin); 423 424 m_originQuotaMap->set(origin, quota); 425 426 SQLiteStatement statement(m_database, "UPDATE Origins SET quota=? WHERE origin=?"); 427 428 bool error = statement.prepare() != SQLResultOk; 429 if (!error) { 430 statement.bindInt64(1, quota); 431 statement.bindText(2, origin->stringIdentifier()); 432 433 error = !statement.executeCommand(); 434 } 435 436 if (error) 437 LOG_ERROR("Failed to set quota %llu in tracker database for origin %s", quota, origin->stringIdentifier().ascii().data()); 461 ASSERT(currentThread() == m_thread); 462 if (quotaForOrigin(origin) == quota) 463 return; 464 465 openTrackerDatabase(true); 466 if (!m_database.isOpen()) 467 return; 468 if (!m_quotaMap->contains(origin)) { 469 SQLiteStatement statement(m_database, "INSERT INTO Origins VALUES (?, ?)"); 470 if (statement.prepare() != SQLResultOk) { 471 LOG_ERROR("Unable to establish origin %s in the tracker", origin->stringIdentifier().ascii().data()); 472 } else { 473 statement.bindText(1, origin->stringIdentifier()); 474 statement.bindInt64(2, quota); 475 476 if (statement.step() != SQLResultDone) 477 LOG_ERROR("Unable to establish origin %s in the tracker", origin->stringIdentifier().ascii().data()); 478 } 479 } else { 480 SQLiteStatement statement(m_database, "UPDATE Origins SET quota=? WHERE origin=?"); 481 bool error = statement.prepare() != SQLResultOk; 482 if (!error) { 483 statement.bindInt64(1, quota); 484 statement.bindText(2, origin->stringIdentifier()); 485 486 error = !statement.executeCommand(); 487 } 488 if (error) 489 LOG_ERROR("Failed to set quota %llu in tracker database for origin %s", quota, origin->stringIdentifier().ascii().data()); 490 } 491 // FIXME: Is it really OK to update the quota in memory if we failed to update it on disk? 492 493 { 494 MutexLocker lockQuotaMap(m_quotaMapGuard); 495 m_quotaMap->set(origin, quota); 496 } 438 497 439 498 if (m_client) … … 443 502 bool DatabaseTracker::addDatabase(SecurityOrigin* origin, const String& name, const String& path) 444 503 { 504 ASSERT(currentThread() == m_thread); 505 openTrackerDatabase(true); 445 506 if (!m_database.isOpen()) 446 507 return false; … … 471 532 void DatabaseTracker::deleteAllDatabases() 472 533 { 534 ASSERT(currentThread() == m_thread); 473 535 populateOrigins(); 474 536 475 HashMap<RefPtr<SecurityOrigin>, unsigned long long, SecurityOriginHash, SecurityOriginTraits>::const_iterator iter = m_originQuotaMap->begin(); 476 HashMap<RefPtr<SecurityOrigin>, unsigned long long, SecurityOriginHash, SecurityOriginTraits>::const_iterator end = m_originQuotaMap->end(); 477 478 for (; iter != end; ++iter) 479 deleteDatabasesWithOrigin(iter->first.get()); 480 } 481 482 void DatabaseTracker::deleteDatabasesWithOrigin(SecurityOrigin* origin) 483 { 537 QuotaMap quotaMapCopy = *m_quotaMap; 538 QuotaMap::const_iterator end = quotaMapCopy.end(); 539 for (QuotaMap::const_iterator iter = quotaMapCopy.begin(); iter != end; ++iter) 540 deleteOrigin(iter->first.get()); 541 } 542 543 void DatabaseTracker::deleteOrigin(SecurityOrigin* origin) 544 { 545 ASSERT(currentThread() == m_thread); 546 openTrackerDatabase(false); 547 if (!m_database.isOpen()) 548 return; 549 484 550 Vector<String> databaseNames; 485 551 if (!databaseNamesForOrigin(origin, databaseNames)) { … … 508 574 } 509 575 576 SQLiteStatement originStatement(m_database, "DELETE FROM Origins WHERE origin=?"); 577 if (originStatement.prepare() != SQLResultOk) { 578 LOG_ERROR("Unable to prepare deletion of origin %s from tracker", origin->stringIdentifier().ascii().data()); 579 return; 580 } 581 582 originStatement.bindText(1, origin->stringIdentifier()); 583 584 if (!originStatement.executeCommand()) { 585 LOG_ERROR("Unable to execute deletion of databases from origin %s from tracker", origin->stringIdentifier().ascii().data()); 586 return; 587 } 588 589 deleteEmptyDirectory(originPath(origin)); 590 591 RefPtr<SecurityOrigin> originPossiblyLastReference = origin; 592 { 593 MutexLocker lockQuotaMap(m_quotaMapGuard); 594 m_quotaMap->remove(origin); 595 } 596 597 // If we removed the last origin, do some additional deletion. 598 if (m_quotaMap->isEmpty()) { 599 if (m_database.isOpen()) 600 m_database.close(); 601 deleteFile(trackerDatabasePath()); 602 deleteEmptyDirectory(m_databaseDirectoryPath); 603 } 604 510 605 if (m_client) { 511 606 m_client->dispatchDidModifyOrigin(origin); … … 517 612 void DatabaseTracker::deleteDatabase(SecurityOrigin* origin, const String& name) 518 613 { 614 ASSERT(currentThread() == m_thread); 615 openTrackerDatabase(false); 616 if (!m_database.isOpen()) 617 return; 618 519 619 if (!deleteDatabaseFile(origin, name)) { 520 620 LOG_ERROR("Unable to delete file for database %s in origin %s", name.ascii().data(), origin->stringIdentifier().ascii().data()); … … 544 644 bool DatabaseTracker::deleteDatabaseFile(SecurityOrigin* origin, const String& name) 545 645 { 646 ASSERT(currentThread() == m_thread); 546 647 String fullPath = fullPathForDatabase(origin, name, false); 547 648 if (fullPath.isEmpty()) … … 553 654 void DatabaseTracker::setClient(DatabaseTrackerClient* client) 554 655 { 656 ASSERT(currentThread() == m_thread); 555 657 m_client = client; 556 }557 558 void DatabaseTracker::setDefaultOriginQuota(unsigned long long quota)559 {560 m_defaultQuota = quota;561 }562 563 unsigned long long DatabaseTracker::defaultOriginQuota() const564 {565 return m_defaultQuota;566 658 } 567 659 … … 600 692 void DatabaseTracker::notifyDatabasesChanged() 601 693 { 602 // Note that if DatabaseTracker ever becomes non-singleton, we'll have to am mend this notification603 // mechanism to inclu e which tracker the notification goes out on, as well694 // Note that if DatabaseTracker ever becomes non-singleton, we'll have to amend this notification 695 // mechanism to include which tracker the notification goes out on as well. 604 696 DatabaseTracker& theTracker(tracker()); 605 697 -
trunk/WebCore/storage/DatabaseTracker.h
r29663 r29698 1 1 /* 2 * Copyright (C) 2007 Apple Inc. All rights reserved.2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 26 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 27 */ 28 28 29 #ifndef DatabaseTracker_h 29 30 #define DatabaseTracker_h … … 47 48 class DatabaseTracker { 48 49 public: 49 void setDatabase Path(const String&);50 const String& database Path();50 void setDatabaseDirectoryPath(const String&); 51 const String& databaseDirectoryPath() const; 51 52 52 53 bool canEstablishDatabase(Document*, const String& name, const String& displayName, unsigned long estimatedSize); 53 54 void setDatabaseDetails(SecurityOrigin*, const String& name, const String& displayName, unsigned long estimatedSize); 54 String fullPathForDatabase(SecurityOrigin*, const String& name, bool createIf NotExists= true);55 String fullPathForDatabase(SecurityOrigin*, const String& name, bool createIfDoesNotExist = true); 55 56 56 57 void origins(Vector<RefPtr<SecurityOrigin> >& result); … … 65 66 66 67 void deleteAllDatabases(); 67 void delete DatabasesWithOrigin(SecurityOrigin*);68 void deleteOrigin(SecurityOrigin*); 68 69 void deleteDatabase(SecurityOrigin*, const String& name); 69 70 70 71 void setClient(DatabaseTrackerClient*); 71 72 void setDefaultOriginQuota(unsigned long long);73 unsigned long long defaultOriginQuota() const;74 72 75 73 // From a secondary thread, must be thread safe with its data … … 77 75 78 76 static DatabaseTracker& tracker(); 77 79 78 private: 80 79 DatabaseTracker(); 81 80 82 void openTrackerDatabase(); 81 String trackerDatabasePath() const; 82 void openTrackerDatabase(bool createIfDoesNotExist); 83 84 String originPath(SecurityOrigin*) const; 83 85 84 86 bool hasEntryForOrigin(SecurityOrigin*); 85 87 bool hasEntryForDatabase(SecurityOrigin*, const String& databaseIdentifier); 86 void establishEntryForOrigin(SecurityOrigin*);87 88 88 89 bool addDatabase(SecurityOrigin*, const String& name, const String& path); … … 92 93 93 94 SQLiteDatabase m_database; 94 mutable OwnPtr<HashMap<RefPtr<SecurityOrigin>, unsigned long long, SecurityOriginHash, SecurityOriginTraits> > m_originQuotaMap;95 95 96 String m_databasePath; 96 typedef HashMap<RefPtr<SecurityOrigin>, unsigned long long, SecurityOriginHash, SecurityOriginTraits> QuotaMap; 97 Mutex m_quotaMapGuard; 98 mutable OwnPtr<QuotaMap> m_quotaMap; 99 100 String m_databaseDirectoryPath; 97 101 98 unsigned long long m_defaultQuota;99 102 DatabaseTrackerClient* m_client; 103 104 std::pair<SecurityOrigin*, DatabaseDetails>* m_proposedDatabase; 105 106 #ifndef NDEBUG 107 ThreadIdentifier m_thread; 108 #endif 100 109 101 110 static void scheduleForNotification(); -
trunk/WebCore/storage/SQLTransaction.cpp
r29663 r29698 1 1 /* 2 * Copyright (C) 2007 Apple Inc. All rights reserved.2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 26 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 27 */ 28 28 29 #include "config.h" 29 30 #include "SQLTransaction.h" 30 31 32 #include "ChromeClient.h" 31 33 #include "Database.h" 32 34 #include "DatabaseAuthorizer.h" 35 #include "DatabaseDetails.h" 33 36 #include "DatabaseTracker.h" 34 37 #include "Document.h" … … 295 298 296 299 unsigned long long currentQuota = DatabaseTracker::tracker().quotaForOrigin(origin.get()); 297 unsigned long long newQuota = page->chrome()->requestQuotaIncreaseForDatabaseOperation(m_database->document()->frame(), origin.get(), m_database->stringIdentifier(), currentQuota + DefaultQuotaSizeIncrease); 298 299 DatabaseTracker::tracker().setQuota(origin.get(), newQuota); 300 page->chrome()->client()->exceededDatabaseQuota(m_database->document()->frame(), m_database->stringIdentifier()); 301 unsigned long long newQuota = DatabaseTracker::tracker().quotaForOrigin(origin.get()); 300 302 301 303 // If the new quota ended up being larger than the old quota, we will retry the statement. -
trunk/WebCore/svg/graphics/SVGImageEmptyClients.h
r29663 r29698 117 117 virtual void print(Frame*) { } 118 118 119 virtual unsigned long long requestQuotaIncreaseForNewDatabase(Frame*, SecurityOrigin*, const String&, unsigned long long) { return 0; } 120 virtual unsigned long long requestQuotaIncreaseForDatabaseOperation(Frame*, SecurityOrigin*, const String&, unsigned long long) { return 0; } 119 virtual void exceededDatabaseQuota(Frame*, const String&) { } 121 120 }; 122 121 -
trunk/WebKit/gtk/ChangeLog
r29683 r29698 1 2008-01-21 Darin Adler <darin@apple.com> 2 3 Reviewed by John Sullivan. 4 5 - updated for changes to database functions 6 7 * WebCoreSupport/ChromeClientGtk.cpp: 8 (WebKit::ChromeClient::exceededDatabaseQuota): 9 * WebCoreSupport/ChromeClientGtk.h: 10 * WebView/webkitprivate.cpp: 11 (webkit_init): 12 1 13 2008-01-20 Alp Toker <alp@atoker.com> 2 14 -
trunk/WebKit/gtk/WebCoreSupport/ChromeClientGtk.cpp
r29669 r29698 309 309 } 310 310 311 unsigned long long ChromeClient::requestQuotaIncreaseForNewDatabase(Frame*, SecurityOrigin*, const String&, unsigned long long) 312 { 313 notImplemented(); 314 return 0; 315 } 316 317 unsigned long long ChromeClient::requestQuotaIncreaseForDatabaseOperation(Frame*, SecurityOrigin*, const String&, unsigned long long) 318 { 319 notImplemented(); 320 return 0; 321 } 322 323 } 311 void ChromeClient::exceededDatabaseQuota(Frame*, const String&) 312 { 313 notImplemented(); 314 } 315 316 } -
trunk/WebKit/gtk/WebCoreSupport/ChromeClientGtk.h
r29663 r29698 94 94 virtual void print(WebCore::Frame*); 95 95 96 virtual unsigned long long requestQuotaIncreaseForNewDatabase(WebCore::Frame*, WebCore::SecurityOrigin*, const WebCore::String&, unsigned long long); 97 virtual unsigned long long requestQuotaIncreaseForDatabaseOperation(WebCore::Frame*, WebCore::SecurityOrigin*, const WebCore::String&, unsigned long long); 96 virtual void exceededDatabaseQuota(Frame*, const String&); 98 97 99 98 private: -
trunk/WebKit/gtk/WebView/webkitprivate.cpp
r29663 r29698 106 106 // FIXME: It should be possible for client applications to override this default location 107 107 gchar* databaseDirectory = g_build_filename(g_get_user_data_dir(), "webkit", "databases", NULL); 108 WebCore::DatabaseTracker::tracker().setDatabase Path(databaseDirectory);108 WebCore::DatabaseTracker::tracker().setDatabaseDirectoryPath(databaseDirectory); 109 109 g_free(databaseDirectory); 110 110 #endif -
trunk/WebKit/mac/ChangeLog
r29682 r29698 1 2008-01-21 Darin Adler <darin@apple.com> 2 3 Reviewed by John Sullivan. 4 5 - fix <rdar://problem/5644324> Delegate-less WebKit clients should have no databases 6 - add a missing export of WebDatabaseExpectedSizeKey 7 - implement deleteOrigin: and remove deleteDatabasesWithOrigin: 8 9 * Storage/WebDatabaseManager.mm: 10 (-[WebDatabaseManager detailsForDatabase:withOrigin:]): Updated to check for a null 11 name instead of calling isValid(). 12 (-[WebDatabaseManager deleteOrigin:]): Implemented. 13 (WebKitInitializeDatabasesIfNecessary): Updated for name change. 14 15 * Storage/WebDatabaseManagerPrivate.h: Removed deleteDatabasesWithOrigin:. 16 17 * WebCoreSupport/WebChromeClient.h: Updated for changes to ChromeClient. 18 * WebCoreSupport/WebChromeClient.mm: 19 (WebChromeClient::exceededDatabaseQuota): Replaced the two different client functions 20 we had before with a single one. 21 22 * WebKit.exp: Added missing export for WebDatabaseExpectedSizeKey. 23 24 * WebView/WebPreferenceKeysPrivate.h: Removed WebKitDefaultDatabaseQuotaKey. 25 * WebView/WebPreferences.m: 26 (+[WebPreferences initialize]): Removed the default for WebKitDefaultDatabaseQuotaKey. 27 * WebView/WebPreferencesPrivate.h: Removed defaultDatabaseQuota and 28 setDefaultDatabaseQuota:. 29 30 * WebView/WebUIDelegatePrivate.h: Replaced the two different database quota delegate 31 methods we had before with a single one. 32 33 * WebView/WebView.mm: 34 (-[WebView _preferencesChangedNotification:]): Removed the code to set the 35 default database origin quota in WebCore::Settings based on WebPreferences. 36 37 * WebView/WebViewInternal.h: Removed delegate method dispatch functions for unusual 38 types of parameters that the database UI delegate methods had before. 39 1 40 2008-01-20 Mark Rowe <mrowe@apple.com> 2 41 -
trunk/WebKit/mac/Storage/WebDatabaseManager.mm
r29663 r29698 1 1 /* 2 * Copyright (C) 2007 Apple Inc.All rights reserved.2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 91 91 92 92 DatabaseDetails details = DatabaseTracker::tracker().detailsForNameAndOrigin(databaseIdentifier, [origin _core]); 93 if ( !details.isValid())93 if (details.name().isNull()) 94 94 return nil; 95 95 … … 109 109 - (void)deleteOrigin:(WebSecurityOrigin *)origin 110 110 { 111 // FIXME: this needs to delete the origin as well as the databases therein 112 [self deleteDatabasesWithOrigin:origin]; 113 } 114 115 - (void)deleteDatabasesWithOrigin:(WebSecurityOrigin *)origin 116 { 117 DatabaseTracker::tracker().deleteDatabasesWithOrigin([origin _core]); 111 DatabaseTracker::tracker().deleteOrigin([origin _core]); 118 112 } 119 113 … … 138 132 databasesDirectory = @"~/Library/WebKit/Databases"; 139 133 140 DatabaseTracker::tracker().setDatabase Path([databasesDirectory stringByStandardizingPath]);134 DatabaseTracker::tracker().setDatabaseDirectoryPath([databasesDirectory stringByStandardizingPath]); 141 135 142 136 // Set the DatabaseTrackerClient -
trunk/WebKit/mac/Storage/WebDatabaseManagerPrivate.h
r29663 r29698 1 1 /* 2 * Copyright (C) 2007 Apple Inc.All rights reserved.2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 46 46 47 47 @interface WebDatabaseManager : NSObject 48 {49 }50 48 51 + (WebDatabaseManager *) 49 + (WebDatabaseManager *)sharedWebDatabaseManager; 52 50 53 // Will return an array of WebSecurityOrigin s51 // Will return an array of WebSecurityOrigin objects. 54 52 - (NSArray *)origins; 55 53 56 // Will return an array of strings, the names of each database in the given origin54 // Will return an array of strings, the identifiers of each database in the given origin. 57 55 - (NSArray *)databasesWithOrigin:(WebSecurityOrigin *)origin; 58 56 59 // Will return the dictionary describing everything about the database for the passed origin and name57 // Will return the dictionary describing everything about the database for the passed identifier and origin. 60 58 - (NSDictionary *)detailsForDatabase:(NSString *)databaseIdentifier withOrigin:(WebSecurityOrigin *)origin; 61 59 62 - (void)deleteAllDatabases; 60 - (void)deleteAllDatabases; // Deletes all databases and all origins. 63 61 - (void)deleteOrigin:(WebSecurityOrigin *)origin; 64 - (void)deleteDatabasesWithOrigin:(WebSecurityOrigin *)origin;65 62 - (void)deleteDatabase:(NSString *)databaseIdentifier withOrigin:(WebSecurityOrigin *)origin; 66 63 -
trunk/WebKit/mac/WebCoreSupport/WebChromeClient.h
r29663 r29698 1 1 /* 2 * Copyright (C) 2006 Apple Computer, Inc.All rights reserved.2 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved. 3 3 * Copyright (C) 2007 Trolltech ASA 4 4 * … … 101 101 virtual void print(WebCore::Frame*); 102 102 103 virtual unsigned long long requestQuotaIncreaseForNewDatabase(WebCore::Frame*, WebCore::SecurityOrigin* origin, const WebCore::String& databaseDisplayName, unsigned long long estimatedSize); 104 virtual unsigned long long requestQuotaIncreaseForDatabaseOperation(WebCore::Frame*, WebCore::SecurityOrigin* origin, const WebCore::String& databaseIdentifier, unsigned long long proposedNewQuota); 103 virtual void exceededDatabaseQuota(WebCore::Frame*, const WebCore::String& databaseName); 105 104 106 105 private: -
trunk/WebKit/mac/WebCoreSupport/WebChromeClient.mm
r29663 r29698 1 1 /* 2 * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.2 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved. 3 3 * Copyright (C) 2007 Trolltech ASA 4 4 * … … 45 45 #import <WebCore/BlockExceptions.h> 46 46 #import <WebCore/FloatRect.h> 47 #import <WebCore/Frame.h> 47 48 #import <WebCore/FrameLoadRequest.h> 48 49 #import <WebCore/HitTestResult.h> … … 364 365 } 365 366 366 void WebChromeClient::setStatusbarText(const WebCore::String& status)367 void WebChromeClient::setStatusbarText(const String& status) 367 368 { 368 369 // We want the temporaries allocated here to be released even before returning to the … … 413 414 } 414 415 415 unsigned long long WebChromeClient::requestQuotaIncreaseForNewDatabase(WebCore::Frame* frame, WebCore::SecurityOrigin* origin, const WebCore::String& databaseDisplayName, unsigned long long estimatedSize)416 { 417 WebSecurityOrigin *webOrigin = [[WebSecurityOrigin alloc] _initWithWebCoreSecurityOrigin: origin];418 unsigned long long result = CallUIDelegateReturningUnsignedLongLong(m_webView, @selector(webView:frame:quotaForSecurityOrigin:toCreateDatabase:withEstimatedSize:), kit(frame), webOrigin, (NSString *)databaseDisplayName, estimatedSize);416 void WebChromeClient::exceededDatabaseQuota(Frame* frame, const String& databaseName) 417 { 418 WebSecurityOrigin *webOrigin = [[WebSecurityOrigin alloc] _initWithWebCoreSecurityOrigin:frame->document()->securityOrigin()]; 419 CallUIDelegate(m_webView, @selector(webView:frame:exceededDatabaseQuotaForSecurityOrigin:database:), kit(frame), webOrigin, (NSString *)databaseName); 419 420 [webOrigin release]; 420 return result;421 }422 423 unsigned long long WebChromeClient::requestQuotaIncreaseForDatabaseOperation(WebCore::Frame* frame, WebCore::SecurityOrigin* origin, const WebCore::String& databaseIdentifier, unsigned long long proposedNewQuota)424 {425 WebSecurityOrigin *webOrigin = [[WebSecurityOrigin alloc] _initWithWebCoreSecurityOrigin:origin];426 unsigned long long result = CallUIDelegateReturningUnsignedLongLong(m_webView, @selector(webView:frame:quotaForSecurityOrigin:fromProposedQuota:database:), kit(frame), webOrigin, proposedNewQuota, (NSString *)databaseIdentifier);427 [webOrigin release];428 return result;429 421 } 430 422 -
trunk/WebKit/mac/WebKit.exp
r28441 r29698 45 45 _WebDatabaseDirectoryDefaultsKey 46 46 _WebDatabaseDisplayNameKey 47 _WebDatabaseExpectedSizeKey 47 48 _WebDatabaseIdentifierKey 48 49 _WebDatabaseUsageKey -
trunk/WebKit/mac/WebView/WebPreferenceKeysPrivate.h
r28202 r29698 75 75 #define WebKitEditableLinkBehaviorPreferenceKey @"WebKitEditableLinkBehavior" 76 76 #define WebKitCacheModelPreferenceKey @"WebKitCacheModelPreferenceKey" 77 #define WebKitDefaultDatabaseQuotaKey @"WebKitDefaultDatabaseQuota"78 77 79 78 // CoreGraphics deferred updates are disabled if WebKitEnableCoalescedUpdatesPreferenceKey is set -
trunk/WebKit/mac/WebView/WebPreferences.m
r28314 r29698 333 333 [NSNumber numberWithBool:NO], WebKitDeveloperExtrasEnabledPreferenceKey, 334 334 [NSNumber numberWithBool:YES], WebKitAuthorAndUserStylesEnabledPreferenceKey, 335 [NSNumber numberWithUnsignedLongLong:5242880], WebKitDefaultDatabaseQuotaKey,336 335 nil]; 337 336 … … 978 977 } 979 978 980 - (unsigned long long)defaultDatabaseQuota981 {982 return [self _unsignedLongLongValueForKey:WebKitDefaultDatabaseQuotaKey];983 }984 985 - (void)setDefaultDatabaseQuota:(unsigned long long)quota986 {987 [self _setUnsignedLongLongValue:quota forKey:WebKitDefaultDatabaseQuotaKey];988 }989 990 979 @end 991 980 -
trunk/WebKit/mac/WebView/WebPreferencesPrivate.h
r28071 r29698 106 106 - (void)didRemoveFromWebView; 107 107 108 - (unsigned long long)defaultDatabaseQuota;109 - (void)setDefaultDatabaseQuota:(unsigned long long)quota;110 108 @end -
trunk/WebKit/mac/WebView/WebUIDelegatePrivate.h
r28597 r29698 1 1 /* 2 * Copyright (C) 2005, 2006, 2007 Apple Inc.All rights reserved.2 * Copyright (C) 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 88 88 89 89 /*! 90 @method webView: quotaForSecurityOrigin:toCreateDatabase:withEstimatedSize:91 @param sender The WebView sending the delegate method 90 @method webView:frame:exceededDatabaseQuotaForSecurityOrigin:database: 91 @param sender The WebView sending the delegate method. 92 92 @param frame The WebFrame whose JavaScript initiated this call. 93 @param origin The security origin of the database that needs a larger quota to create a database 94 @param newDatabaseName The display name of the new database 95 @param estimatedSize The estimated maximum usage of the new database 96 @result The new quota, in bytes 97 @discussion If the new quota is less than or equal to the current usage for the given security origin, the new database will not be created. 98 Otherwise the database will created, even if the new quota doesn't allow for the entire estimated size. 93 @param origin The security origin that needs a larger quota. 94 @param databaseIdentifier The identifier of the database involved. 99 95 */ 100 - (unsigned long long)webView:(WebView *)sender frame:(WebFrame *)frame quotaForSecurityOrigin:(WebSecurityOrigin *)origin toCreateDatabase:(NSString *)newDatabaseName withEstimatedSize:(unsigned long long)estimatedSize; 101 102 /*! 103 @method webView:quotaForSecurityOrigin:fromProposedQuota:database: 104 @param sender The WebView sending the delegate method 105 @param frame The WebFrame whose JavaScript initiated this call. 106 @param origin The security origin of the database that has reached its size limit 107 @param proposedNewQuota WebKit's best guess as to the required new quota 108 @param databaseIdentifier The string identifier of the database 109 @result The new quota, in bytes 110 @discussion If the new quota is less than the proposedNewQuota, the current database operation will fail. 111 If the new quota is equal to or greater than the proposedNewQuota, the current database operation will continue, 112 possibly calling this delegate method again to request even more space 113 */ 114 - (unsigned long long)webView:(WebView *)sender frame:(WebFrame *)frame quotaForSecurityOrigin:(WebSecurityOrigin *)origin fromProposedQuota:(unsigned long long)proposedNewQuota database:(NSString *)databaseIdentifier; 96 - (void)webView:(WebView *)sender frame:(WebFrame *)frame exceededDatabaseQuotaForSecurityOrigin:(WebSecurityOrigin *)origin database:(NSString *)databaseIdentifier; 115 97 116 98 - (WebView *)webView:(WebView *)sender createWebViewWithRequest:(NSURLRequest *)request windowFeatures:(NSDictionary *)features; -
trunk/WebKit/mac/WebView/WebView.mm
r29682 r29698 1 1 /* 2 * Copyright (C) 2005, 2006, 2007 Apple Inc. All rights reserved.2 * Copyright (C) 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. 3 3 * Copyright (C) 2006 David Smith (catfish.man@gmail.com) 4 4 * … … 977 977 settings->setNeedsAdobeFrameReloadingQuirk([self _needsAdobeFrameReloadingQuirk]); 978 978 settings->setNeedsKeyboardEventDisambiguationQuirks([self _needsKeyboardEventDisambiguationQuirks]); 979 settings->setDefaultDatabaseOriginQuota([preferences defaultDatabaseQuota]);980 979 } 981 980 … … 4287 4286 } 4288 4287 4289 typedef unsigned long long (*ObjCMsgSendULLRet)(id, SEL, ...);4290 static const ObjCMsgSendULLRet objc_msgSend_ullret = reinterpret_cast<ObjCMsgSendULLRet>(objc_msgSend);4291 4292 static inline unsigned long long CallDelegateReturningUnsignedLongLong(WebView *self, id delegate, SEL selector, id object1, id object2, id object3, unsigned long long integer)4293 {4294 if (!delegate || ![delegate respondsToSelector:selector])4295 return 0;4296 if (!self->_private->catchesDelegateExceptions)4297 return objc_msgSend_ullret(delegate, selector, self, object1, object2, object3, integer);4298 @try {4299 return objc_msgSend_ullret(delegate, selector, self, object1, object2, object3, integer);4300 } @catch(id exception) {4301 ReportDiscardedDelegateException(selector, exception);4302 }4303 return 0;4304 }4305 4306 static inline unsigned long long CallDelegateReturningUnsignedLongLong(WebView *self, id delegate, SEL selector, id object1, id object2, unsigned long long integer, id object3)4307 {4308 if (!delegate || ![delegate respondsToSelector:selector])4309 return 0;4310 if (!self->_private->catchesDelegateExceptions)4311 return objc_msgSend_ullret(delegate, selector, self, object1, object2, integer, object3);4312 @try {4313 return objc_msgSend_ullret(delegate, selector, self, object1, object2, integer, object3);4314 } @catch(id exception) {4315 ReportDiscardedDelegateException(selector, exception);4316 }4317 return 0;4318 }4319 4320 4288 static inline BOOL CallDelegateReturningBoolean(BOOL result, WebView *self, id delegate, SEL selector) 4321 4289 { … … 4524 4492 { 4525 4493 return CallDelegateReturningFloat(self, self->_private->UIDelegate, selector); 4526 }4527 4528 unsigned long long CallUIDelegateReturningUnsignedLongLong(WebView *self, SEL selector, id object1, id object2, id object3, unsigned long long integer)4529 {4530 return CallDelegateReturningUnsignedLongLong(self, self->_private->UIDelegate, selector, object1, object2, object3, integer);4531 }4532 4533 unsigned long long CallUIDelegateReturningUnsignedLongLong(WebView *self, SEL selector, id object1, id object2, unsigned long long integer, id object3)4534 {4535 return CallDelegateReturningUnsignedLongLong(self, self->_private->UIDelegate, selector, object1, object2, integer, object3);4536 4494 } 4537 4495 -
trunk/WebKit/mac/WebView/WebViewInternal.h
r29496 r29698 170 170 id CallUIDelegate(WebView *, SEL, id, NSUInteger); 171 171 float CallUIDelegateReturningFloat(WebView *, SEL); 172 unsigned long long CallUIDelegateReturningUnsignedLongLong(WebView *, SEL, id, id, id, unsigned long long);173 unsigned long long CallUIDelegateReturningUnsignedLongLong(WebView *, SEL, id, id, unsigned long long, id);174 172 BOOL CallUIDelegateReturningBoolean(BOOL, WebView *, SEL); 175 173 BOOL CallUIDelegateReturningBoolean(BOOL, WebView *, SEL, id); -
trunk/WebKit/qt/ChangeLog
r29693 r29698 1 2008-01-21 Darin Adler <darin@apple.com> 2 3 Reviewed by John Sullivan. 4 5 - updated for changes to ChromeClient database functions 6 7 * WebCoreSupport/ChromeClientQt.cpp: 8 (WebCore::ChromeClientQt::exceededDatabaseQuota): 9 * WebCoreSupport/ChromeClientQt.h: 10 1 11 2008-01-21 Benjamin Meyer <bmeyer@trolltech.com> 2 12 -
trunk/WebKit/qt/WebCoreSupport/ChromeClientQt.cpp
r29689 r29698 331 331 } 332 332 333 unsigned long long ChromeClientQt::requestQuotaIncreaseForNewDatabase(Frame*, SecurityOrigin*, const String&, unsigned long long) 334 { 335 notImplemented(); 336 return 0; 337 } 338 339 unsigned long long ChromeClientQt::requestQuotaIncreaseForDatabaseOperation(Frame*, SecurityOrigin*, const String&, unsigned long long) 340 { 341 notImplemented(); 342 return 0; 343 } 344 345 } 346 347 333 void ChromeClientQt::exceededDatabaseQuota(Frame*, const String&) 334 { 335 notImplemented(); 336 } 337 338 } 339 340 -
trunk/WebKit/qt/WebCoreSupport/ChromeClientQt.h
r29663 r29698 108 108 virtual void print(Frame*); 109 109 110 virtual unsigned long long requestQuotaIncreaseForNewDatabase(Frame*, SecurityOrigin*, const String&, unsigned long long); 111 virtual unsigned long long requestQuotaIncreaseForDatabaseOperation(Frame*, SecurityOrigin*, const String&, unsigned long long); 110 virtual void exceededDatabaseQuota(Frame*, const String&); 112 111 113 112 QWebPage* m_webPage; -
trunk/WebKit/win/ChangeLog
r29671 r29698 1 2008-01-21 Darin Adler <darin@apple.com> 2 3 Reviewed by John Sullivan. 4 5 - fix <rdar://problem/5644324> Delegate-less WebKit clients should have no databases 6 - fix incorrect value for WebDatabaseDisplayNameKey in header 7 8 * Interfaces/IWebDatabaseManager.idl: Renamed detailsForDatabaseWithOrigin to 9 detailsForDatabase. Replaced deleteDatabasesWithOrigin with deleteOrigin. 10 Renamed deleteDatabaseWithOrigin to deleteDatabase. Fixed incorrect value for 11 WebDatabaseDisplayNameKey. 12 * Interfaces/IWebPreferencesPrivate.idl: Removed defaultDatabaseQuota and 13 setDefaultDatabaseQuota. 14 * Interfaces/IWebUIDelegatePrivate.idl: Replaced the two database quota functions 15 with a single one. 16 17 * WebChromeClient.cpp: 18 (WebChromeClient::exceededDatabaseQuota): Replaced the two database quota functions 19 with a single one. 20 * WebChromeClient.h: Ditto. 21 22 * WebDatabaseManager.cpp: 23 (WebDatabaseManager::detailsForDatabase): Changed to check for a name of null to 24 detect a nonexistent database rather than using isValid. 25 (WebDatabaseManager::deleteOrigin): Updated for name change (actually a semantic 26 change too, but both have the same name). 27 (WebDatabaseManager::deleteDatabase): Updated for name change. 28 (WebKitSetWebDatabasesPathIfNecessary): Ditto. 29 30 * WebDatabaseManager.h: Updated for name changes. 31 32 * WebPreferenceKeysPrivate.h: Removed WebKitDefaultDatabaseQuotaKey. 33 * WebPreferences.cpp: 34 (WebPreferences::initializeDefaultSettings): Removed the default for 35 WebKitDefaultDatabaseQuotaKey. 36 * WebPreferences.h: Removed defaultDatabaseQuota and setDefaultDatabaseQuota. 37 * WebView.cpp: 38 (WebView::notifyPreferencesChanged): Removed the code to set the 39 default database origin quota in WebCore::Settings based on IWebPreferencesPrivate. 40 1 41 2008-01-19 Mark Rowe <mrowe@apple.com> 2 42 -
trunk/WebKit/win/Interfaces/IWebDatabaseManager.idl
r29671 r29698 25 25 26 26 cpp_quote("/*") 27 cpp_quote(" * Copyright (C) 2007 Apple Inc.All rights reserved.")27 cpp_quote(" * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.") 28 28 cpp_quote(" *") 29 29 cpp_quote(" * Redistribution and use in source and binary forms, with or without") … … 52 52 import "ocidl.idl"; 53 53 54 cpp_quote("#define WebDatabaseDisplayNameKey TEXT(\"WebDatabase ExpectedSizeKey\")")54 cpp_quote("#define WebDatabaseDisplayNameKey TEXT(\"WebDatabaseDisplayNameKey\")") 55 55 cpp_quote("#define WebDatabaseExpectedSizeKey TEXT(\"WebDatabaseExpectedSizeKey\")") 56 56 cpp_quote("#define WebDatabaseUsageKey TEXT(\"WebDatabaseUsageKey\")") … … 74 74 HRESULT origins([out, retval] IEnumVARIANT** result); 75 75 HRESULT databasesWithOrigin([in] IWebSecurityOrigin* origin, [out, retval] IEnumVARIANT** result); 76 HRESULT detailsForDatabase WithOrigin([in] BSTR databaseName, [in] IWebSecurityOrigin* origin, [out, retval] IPropertyBag **result);76 HRESULT detailsForDatabase([in] BSTR databaseName, [in] IWebSecurityOrigin* origin, [out, retval] IPropertyBag **result); 77 77 78 78 HRESULT deleteAllDatabases(); 79 HRESULT delete DatabasesWithOrigin([in] IWebSecurityOrigin* origin);80 HRESULT deleteDatabase WithOrigin([in] BSTR databaseName, [in] IWebSecurityOrigin* origin);79 HRESULT deleteOrigin([in] IWebSecurityOrigin* origin); 80 HRESULT deleteDatabase([in] BSTR databaseName, [in] IWebSecurityOrigin* origin); 81 81 } -
trunk/WebKit/win/Interfaces/IWebPreferencesPrivate.idl
r29671 r29698 1 1 /* 2 * Copyright (C) 2007 Apple Inc.All rights reserved.2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 28 28 29 29 cpp_quote("/*") 30 cpp_quote(" * Copyright (C) 2007 Apple Inc.All rights reserved.")30 cpp_quote(" * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.") 31 31 cpp_quote(" *") 32 32 cpp_quote(" * Redistribution and use in source and binary forms, with or without") … … 75 75 HRESULT setAuthorAndUserStylesEnabled([in] BOOL enabled); 76 76 HRESULT authorAndUserStylesEnabled([out, retval] BOOL* enabled); 77 78 HRESULT defaultDatabaseQuota([out, retval] unsigned long long* quota);79 HRESULT setDefaultDatabaseQuota([in] unsigned long long quota);80 77 } -
trunk/WebKit/win/Interfaces/IWebUIDelegatePrivate.idl
r28632 r29698 1 1 /* 2 * Copyright (C) 2006, 2007 Apple Inc.All rights reserved.2 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 25 25 26 26 cpp_quote("/*") 27 cpp_quote(" * Copyright (C) 2006, 2007 Apple Inc.All rights reserved.")27 cpp_quote(" * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.") 28 28 cpp_quote(" *") 29 29 cpp_quote(" * Redistribution and use in source and binary forms, with or without") … … 87 87 } 88 88 89 90 89 [ 91 90 object, … … 96 95 interface IWebUIDelegatePrivate3 : IWebUIDelegatePrivate2 97 96 { 98 /*! 99 @method webView:quotaForSecurityOrigin:toCreateDatabase:withEstimatedSize: 100 @param sender The WebView sending the delegate method 101 @param origin The security origin of the database that needs a larger quota to create a database 102 @param newDatabaseName The display name of the new database 103 @param estimatedSize The estimated maximum usage of the new database 104 @result The new quota, in bytes 105 @discussion If the new quota is less than or equal to the current usage for the given security origin, the new database will not be created. 106 Otherwise the database will created, even if the new quota doesn't allow for the entire estimated size. 107 108 - (unsigned long long)webView:(WebView *)sender quotaForSecurityOrigin:(WebSecurityOrigin *)origin toCreateDatabase:(NSString *)newDatabaseName withEstimatedSize:(unsigned long long)estimatedSize; 109 */ 110 HRESULT quotaForSecurityOriginForNewDatabase([in] IWebView* sender, [in] IWebFrame* frame, [in] IWebSecurityOrigin* origin, [in] BSTR newDatabaseName, [in] unsigned long long estimatedSize, [out, retval] unsigned long long* newQuota); 111 112 /*! 113 @method webView:quotaForSecurityOrigin:fromProposedQuota:database: 114 @param sender The WebView sending the delegate method 115 @param origin The security origin of the database that has reached its size limit 116 @param proposedNewQuota WebKit's best guess as to the required new quota 117 @param databaseIdentifier The string identifier of the database 118 @result The new quota, in bytes 119 @discussion If the new quota is less than the proposedNewQuota, the current database operation will fail. 120 If the new quota is equal to or greater than the proposedNewQuota, the current database operation will continue, 121 possibly calling this delegate method again to request even more space 122 123 - (unsigned long long)webView:(WebView *)sender quotaForSecurityOrigin:(WebSecurityOrigin *)origin fromProposedQuota:(unsigned long long)proposedNewQuota database:(NSString *)databaseIdentifier; 124 */ 125 HRESULT quotaForSecurityOriginForDatabaseOperation([in] IWebView* sender, [in] IWebFrame* frame, [in] IWebSecurityOrigin* origin, [in] unsigned long long proposedNewQuota, [in] BSTR databaseIdentifier, [out, retval] unsigned long long* newQuota); 97 HRESULT exceededDatabaseQuota([in] IWebView* sender, [in] IWebFrame* frame, [in] IWebSecurityOrigin* origin, [in] BSTR databaseIdentifier); 126 98 } -
trunk/WebKit/win/WebChromeClient.cpp
r29498 r29698 460 460 } 461 461 462 unsigned long long WebChromeClient::requestQuotaIncreaseForNewDatabase(Frame* frame, SecurityOrigin* origin, const String& databaseDisplayName, unsigned long long estimatedSize) 463 { 464 COMPtr<WebSecurityOrigin> webOrigin(AdoptCOM, WebSecurityOrigin::createInstance(origin)); 465 unsigned long long result = 0; 462 void WebChromeClient::exceededDatabaseQuota(Frame* frame, const String& databaseIdentifier) 463 { 464 COMPtr<WebSecurityOrigin> origin(AdoptCOM, WebSecurityOrigin::createInstance(frame->document()->securityOrigin())); 466 465 COMPtr<IWebUIDelegate> uiDelegate; 467 466 if (SUCCEEDED(m_webView->uiDelegate(&uiDelegate))) { 468 467 COMPtr<IWebUIDelegatePrivate3> uiDelegatePrivate3(Query, uiDelegate); 469 if (uiDelegatePrivate3 && 470 SUCCEEDED(uiDelegatePrivate3->quotaForSecurityOriginForNewDatabase(m_webView, kit(frame), webOrigin.get(), BString(databaseDisplayName), estimatedSize, &result))) 471 return result; 472 } 473 // an error happened - just return the current quota 474 webOrigin->quota(&result); 475 return result; 476 } 477 478 unsigned long long WebChromeClient::requestQuotaIncreaseForDatabaseOperation(Frame* frame, SecurityOrigin* origin, const String& databaseIdentifier, unsigned long long proposedNewQuota) 479 { 480 COMPtr<WebSecurityOrigin> webOrigin(AdoptCOM, WebSecurityOrigin::createInstance(origin)); 481 unsigned long long result = 0; 482 COMPtr<IWebUIDelegate> uiDelegate; 483 if (SUCCEEDED(m_webView->uiDelegate(&uiDelegate))) { 484 COMPtr<IWebUIDelegatePrivate3> uiDelegatePrivate3(Query, uiDelegate); 485 if (uiDelegatePrivate3 && 486 SUCCEEDED(uiDelegatePrivate3->quotaForSecurityOriginForDatabaseOperation(m_webView, kit(frame), webOrigin.get(), proposedNewQuota, BString(databaseIdentifier), &result))) 487 return result; 488 } 489 // an error happened - just return the current quota 490 webOrigin->quota(&result); 491 return result; 468 uiDelegatePrivate3->exceededDatabaseQuota(m_webView, kit(frame), origin.get(), BString(databaseIdentifier)); 469 } 492 470 } 493 471 -
trunk/WebKit/win/WebChromeClient.h
r29386 r29698 99 99 virtual void print(WebCore::Frame*); 100 100 101 virtual unsigned long long requestQuotaIncreaseForNewDatabase(WebCore::Frame*, WebCore::SecurityOrigin*, const WebCore::String&, unsigned long long); 102 virtual unsigned long long requestQuotaIncreaseForDatabaseOperation(WebCore::Frame*, WebCore::SecurityOrigin*, const WebCore::String&, unsigned long long); 101 virtual void exceededDatabaseQuota(WebCore::Frame*, const WebCore::String&); 103 102 104 103 virtual WebView* webView() const { return m_webView; } -
trunk/WebKit/win/WebDatabaseManager.cpp
r29663 r29698 1 1 /* 2 * Copyright (C) 2007 Apple Inc. All rights reserved.2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 26 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 27 */ 28 28 29 #include "config.h" 29 30 #include "WebDatabaseManager.h" … … 246 247 } 247 248 248 HRESULT STDMETHODCALLTYPE WebDatabaseManager::detailsForDatabase WithOrigin(249 HRESULT STDMETHODCALLTYPE WebDatabaseManager::detailsForDatabase( 249 250 /* [in] */ BSTR databaseName, 250 251 /* [in] */ IWebSecurityOrigin* origin, … … 266 267 webSecurityOrigin->securityOrigin()); 267 268 268 if ( !details.isValid())269 if (details.name().isNull()) 269 270 return E_INVALIDARG; 270 271 … … 283 284 } 284 285 285 HRESULT STDMETHODCALLTYPE WebDatabaseManager::delete DatabasesWithOrigin(286 HRESULT STDMETHODCALLTYPE WebDatabaseManager::deleteOrigin( 286 287 /* [in] */ IWebSecurityOrigin* origin) 287 288 { … … 296 297 return E_FAIL; 297 298 298 DatabaseTracker::tracker().delete DatabasesWithOrigin(webSecurityOrigin->securityOrigin());299 DatabaseTracker::tracker().deleteOrigin(webSecurityOrigin->securityOrigin()); 299 300 300 301 return S_OK; 301 302 } 302 303 303 HRESULT STDMETHODCALLTYPE WebDatabaseManager::deleteDatabase WithOrigin(304 HRESULT STDMETHODCALLTYPE WebDatabaseManager::deleteDatabase( 304 305 /* [in] */ BSTR databaseName, 305 306 /* [in] */ IWebSecurityOrigin* origin) … … 358 359 359 360 WebCore::String databasesDirectory = WebCore::pathByAppendingComponent(WebCore::localUserSpecificStorageDirectory(), "Databases"); 360 WebCore::DatabaseTracker::tracker().setDatabase Path(databasesDirectory);361 WebCore::DatabaseTracker::tracker().setDatabaseDirectoryPath(databasesDirectory); 361 362 362 363 pathSet = true; 363 364 } 364 -
trunk/WebKit/win/WebDatabaseManager.h
r29663 r29698 1 1 /* 2 * Copyright (C) 2007 Apple Inc. All rights reserved.2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 26 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 27 */ 28 28 29 #ifndef WebDatabaseManager_h 29 30 #define WebDatabaseManager_h … … 57 58 /* [retval][out] */ IEnumVARIANT** result); 58 59 59 virtual HRESULT STDMETHODCALLTYPE detailsForDatabase WithOrigin(60 virtual HRESULT STDMETHODCALLTYPE detailsForDatabase( 60 61 /* [in] */ BSTR databaseName, 61 62 /* [in] */ IWebSecurityOrigin* origin, … … 64 65 virtual HRESULT STDMETHODCALLTYPE deleteAllDatabases(); 65 66 66 virtual HRESULT STDMETHODCALLTYPE delete DatabasesWithOrigin(67 virtual HRESULT STDMETHODCALLTYPE deleteOrigin( 67 68 /* [in] */ IWebSecurityOrigin* origin); 68 69 69 virtual HRESULT STDMETHODCALLTYPE deleteDatabase WithOrigin(70 virtual HRESULT STDMETHODCALLTYPE deleteDatabase( 70 71 /* [in] */ BSTR databaseName, 71 72 /* [in] */ IWebSecurityOrigin* origin); -
trunk/WebKit/win/WebPreferenceKeysPrivate.h
r28866 r29698 68 68 #define WebKitPDFScaleFactorPreferenceKey "WebKitPDFScaleFactor" 69 69 #define WebKitEditableLinkBehaviorPreferenceKey "WebKitEditableLinkBehavior" 70 #define WebKitDefaultDatabaseQuotaKey "WebKitDefaultDatabaseQuota"71 70 72 71 // Window display is throttled to 60 frames per second if WebKitThrottleWindowDisplayPreferenceKey -
trunk/WebKit/win/WebPreferences.cpp
r28866 r29698 192 192 RetainPtr<CFStringRef> cacheModelRef(AdoptCF, CFStringCreateWithFormat(0, 0, CFSTR("%d"), WebCacheModelDocumentViewer)); 193 193 CFDictionaryAddValue(defaults, CFSTR(WebKitCacheModelPreferenceKey), cacheModelRef.get()); 194 CFDictionaryAddValue(defaults, CFSTR(WebKitDefaultDatabaseQuotaKey), CFSTR("5242880")); // 5 MB195 194 196 195 CFDictionaryAddValue(defaults, CFSTR(WebKitAuthorAndUserStylesEnabledPreferenceKey), kCFBooleanTrue); … … 1134 1133 } 1135 1134 1136 HRESULT STDMETHODCALLTYPE WebPreferences::defaultDatabaseQuota(unsigned long long* quota)1137 {1138 if (!quota)1139 return E_POINTER;1140 1141 long long value = longlongValueForKey(CFSTR(WebKitDefaultDatabaseQuotaKey));1142 if (value < 0 || value > LLONG_MAX) {1143 value = 0;1144 setDefaultDatabaseQuota(0);1145 }1146 *quota = value;1147 return S_OK;1148 }1149 1150 HRESULT STDMETHODCALLTYPE WebPreferences::setDefaultDatabaseQuota(unsigned long long quota)1151 {1152 if (quota > LLONG_MAX)1153 quota = 0;1154 setLongLongValue(CFSTR(WebKitDefaultDatabaseQuotaKey), quota);1155 return S_OK;1156 }1157 1158 1135 HRESULT STDMETHODCALLTYPE WebPreferences::setAuthorAndUserStylesEnabled(BOOL enabled) 1159 1136 { -
trunk/WebKit/win/WebPreferences.h
r28422 r29698 289 289 /* [out, retval] */ BOOL* automaticallyDetectsCacheModel); 290 290 291 virtual HRESULT STDMETHODCALLTYPE defaultDatabaseQuota(292 /* [retval][out] */ unsigned long long *quota);293 294 virtual HRESULT STDMETHODCALLTYPE setDefaultDatabaseQuota(295 /* [in] */ unsigned long long quota);296 297 291 virtual HRESULT STDMETHODCALLTYPE setAuthorAndUserStylesEnabled(BOOL); 298 292 virtual HRESULT STDMETHODCALLTYPE authorAndUserStylesEnabled(BOOL*); -
trunk/WebKit/win/WebView.cpp
r29627 r29698 3915 3915 COMPtr<IWebPreferencesPrivate> prefsPrivate(Query, preferences); 3916 3916 if (prefsPrivate) { 3917 unsigned long long defaultQuota = 0;3918 hr = prefsPrivate->defaultDatabaseQuota(&defaultQuota);3919 if (FAILED(hr))3920 return hr;3921 settings->setDefaultDatabaseOriginQuota(defaultQuota);3922 3923 3917 hr = prefsPrivate->authorAndUserStylesEnabled(&enabled); 3924 3918 if (FAILED(hr)) -
trunk/WebKit/wx/ChangeLog
r29663 r29698 1 2008-01-21 Darin Adler <darin@apple.com> 2 3 Reviewed by John Sullivan. 4 5 - updated for changes to ChromeClient database functions 6 7 * WebKitSupport/ChromeClientWx.cpp: 8 (WebCore::ChromeClientWx::exceededDatabaseQuota): 9 * WebKitSupport/ChromeClientWx.h: 10 1 11 2008-01-16 Adam Roben <aroben@apple.com> 2 12 -
trunk/WebKit/wx/WebKitSupport/ChromeClientWx.cpp
r29663 r29698 309 309 notImplemented(); 310 310 } 311 311 312 void ChromeClientWx::print(Frame*) 312 313 { … … 314 315 } 315 316 316 unsigned long long ChromeClientWx::requestQuotaIncreaseForNewDatabase(Frame*, SecurityOrigin*, const String&, unsigned long long) 317 { 318 notImplemented(); 319 return 0; 320 } 321 322 unsigned long long ChromeClientWx::requestQuotaIncreaseForDatabaseOperation(Frame*, SecurityOrigin*, const String&, unsigned long long) 323 { 324 notImplemented(); 325 return 0; 326 } 327 328 } 317 void ChromeClientWx::exceededDatabaseQuota(Frame*, const String&) 318 { 319 notImplemented(); 320 } 321 322 } -
trunk/WebKit/wx/WebKitSupport/ChromeClientWx.h
r29663 r29698 105 105 virtual void print(Frame*); 106 106 107 virtual unsigned long long requestQuotaIncreaseForNewDatabase(Frame*, SecurityOrigin*, const String&, unsigned long long); 108 virtual unsigned long long requestQuotaIncreaseForDatabaseOperation(Frame*, SecurityOrigin*, const String&, unsigned long long); 107 virtual void exceededDatabaseQuota(Frame*, const String&); 109 108 110 109 private:
Note: See TracChangeset
for help on using the changeset viewer.