Commit 958fc87f authored by darin@apple.com's avatar darin@apple.com

WebCore:

        Reviewed by John Sullivan.

        - fix <rdar://problem/5644324> Delegate-less WebKit clients should have no databases

        - remove the default database quota setting

        - simplify the quota-related client calls by merging the one for a new database with
          the one for an existing database, adding a feature where you can get details about
          a database being created using the same functions that work on the other databases,
          and removing the parameters and return values, instead having clients use a function
          to set the quota

        - fix unsafe multi-thread access to the database tracker's quota map
        - fix bug in deleteAllDatabases where it would iterate a HashMap while modifying it

        The tracker database is now only created when we set the quota for a database origin.
        Thus asking for info about databases won't cause anything to be written to disk.

        * WebCore.base.exp: Updated.

        * bindings/js/GCController.cpp: Added an #if to get rid of an unused function warning.

        * page/Chrome.cpp: Removed database-related functions. There's no problem having the
        code deal directly with the client.
        * page/Chrome.h: Ditto. Also made Chrome inherit from Noncopyable.

        * page/ChromeClient.h: Replaced the two quota-related functions with a single one.
        The details about the state of databases in the origin are now available by asking
        for database details. There's also no need to pass the security origin, since
        it's easy to get that from the frame's document.

        * page/Settings.cpp: Removed the default quota setting.
        * page/Settings.h: Ditto.

        * platform/FileSystem.h: Added deleteEmptyDirectory.
        * platform/gtk/FileSystemGtk.cpp:
        (WebCore::deleteEmptyDirectory): Added.
        * platform/posix/FileSystemPOSIX.cpp:
        (WebCore::deleteEmptyDirectory): Added.
        * platform/qt/FileSystemQt.cpp:
        (WebCore::deleteEmptyDirectory): Added.
        * platform/win/FileSystemWin.cpp:
        (WebCore::deleteEmptyDirectory): Added.
        * platform/wx/FileSystemWx.cpp:
        (WebCore::deleteEmptyDirectory): Added placeholder.

        * storage/DatabaseDetails.h: Removed the isValid() function since its name is
        confusing -- we removed our other isValid() functions. For the few callers that
        need this, it's fine to just check name().isEmpty(). Made the member functions
        all const.

        * storage/DatabaseTracker.cpp:
        (WebCore::DatabaseTracker::DatabaseTracker): Removed m_defaultQuota initialization.
        Added m_proposedDatabase and m_thread.
        (WebCore::DatabaseTracker::setDatabaseDirectoryPath): Got rid of code that would
        open the tracker database here. This might slightly speed up launch time, since
        we won't do the I/O until we have to, and before we were actually creating an SQL
        database in this code that's run when we go to the first webpage.
        (WebCore::DatabaseTracker::trackerDatabasePath): Added.
        (WebCore::DatabaseTracker::openTrackerDatabase): Added a boolean parameter telling
        this function whether to create the database. Made this function safe to call if
        the database is already open. Also made the function fail quietly if the path has
        not been set yet.
        (WebCore::DatabaseTracker::canEstablishDatabase): Got rid of the call to the
        establishEntryForOrigin function. The origin is now put in the tracker database
        when the quota is set to a non-zero value. When judging if there's enough space
        for the new database, require at least one byte even if estimatedSize is 0, and
        check for overflow. Also added code here to populate the origins map, which
        guarantees it will be ready when the database uses it on another thread later.
        Also changed this to call the new ChromeClient function.
        (WebCore::DatabaseTracker::hasEntryForDatabase): Added code to open the
        tracker database, since that's no longer done by setDatabaseDirectoryPath.
        (WebCore::DatabaseTracker::originPath): Added.
        (WebCore::DatabaseTracker::fullPathForDatabase): Added code so that this will
        return a null string for the proposed database if called from within the
        ChromeClient function. Also switched from empty string to null string for the
        error cases.
        (WebCore::DatabaseTracker::populateOrigins): Added code to open the tracker
        database.
        (WebCore::DatabaseTracker::databaseNamesForOrigin): Ditto.
        (WebCore::DatabaseTracker::detailsForNameAndOrigin): Ditto. Also added code that
        will return the details of the proposed database if called from within the
        ChromeClient function. This is how the client can learn of the display name and
        the estimated size of the new database.
        (WebCore::DatabaseTracker::setDatabaseDetails): Added code to open the tracker
        database.
        (WebCore::DatabaseTracker::quotaForOrigin): Made this code OK to call on a non-main
        thread by using m_quotaMapGuard to guard access to the map. Other code runs on the
        main thread only, and only functions that write to the map use the lock.
        (WebCore::DatabaseTracker::setQuota): Changed this function so it can insert the
        initial quota as well as updating an existing quota. Added locking since this
        function modifies the quota map. Added code to open the tracker database. Added
        an early exit if the quota is already correct, which is guarantees that if you
        set a quota to 0 it won't trigger creation of a tracker database.
        (WebCore::DatabaseTracker::addDatabase): Added code to open the tracker database.
        (WebCore::DatabaseTracker::deleteAllDatabases): Made a copy of the quota map before
        iterating it to find all the origins. This fixes a problem with the old code where
        it would modify the map while iterating it, which gives assertions in debug builds
        and unpredictable results.
        (WebCore::DatabaseTracker::deleteOrigin): Replaced deleteDatabasesWithOrigin with
        this function. Added code to open the tracker database if needed. Added code to
        delete the origin from the tracker database, and to close the tracker database
        and delete files and directories as needed if we are deleting the final origin.
        (WebCore::DatabaseTracker::deleteDatabase): Added code to open the tracker database
        if needed.

        * storage/DatabaseTracker.h: Renamed databasePath to databaseDirectoryPath for
        clarity, including the data member, and the getter and setter functions.
        Replaced deleteDatabasesWithOrigin with deleteOrigin. Removed the functions
        dealing with default origin quota. There is no default any more; origins start
        with no quota and the client must set a quota. Added trackerDatabasePath and
        originPath helper functions. Added a boolean parameter to openTrackerDatabase
        to tell it whether to create the database or not. Removed the
        establishEntryForOrigin function. Renamed m_originQuotaMap to just m_quotaMap,
        and added m_quotaMapGuard. Added a QuotaMap typedef. Added m_proposedDatabase,
        which holds the origin and details for the current proposed database during
        the client callback function that must decide whether to grant quota. Added a
        m_thread data member for debugging use to assert if functions that can only
        be called on a single thread are misused.

        * storage/SQLTransaction.cpp:
        (WebCore::SQLTransaction::deliverQuotaIncreaseCallback): Changed to call the
        new exceededDatabaseQuota function instead of the old one.

        * svg/graphics/SVGImageEmptyClients.h: Updated for the change to ChromeClient.

WebKit/gtk:

        Reviewed by John Sullivan.

        - updated for changes to database functions

        * WebCoreSupport/ChromeClientGtk.cpp:
        (WebKit::ChromeClient::exceededDatabaseQuota):
        * WebCoreSupport/ChromeClientGtk.h:
        * WebView/webkitprivate.cpp:
        (webkit_init):

WebKit/mac:

        Reviewed by John Sullivan.

        - fix <rdar://problem/5644324> Delegate-less WebKit clients should have no databases
        - add a missing export of WebDatabaseExpectedSizeKey
        - implement deleteOrigin: and remove deleteDatabasesWithOrigin:

        * Storage/WebDatabaseManager.mm:
        (-[WebDatabaseManager detailsForDatabase:withOrigin:]): Updated to check for a null
        name instead of calling isValid().
        (-[WebDatabaseManager deleteOrigin:]): Implemented.
        (WebKitInitializeDatabasesIfNecessary): Updated for name change.

        * Storage/WebDatabaseManagerPrivate.h: Removed deleteDatabasesWithOrigin:.

        * WebCoreSupport/WebChromeClient.h: Updated for changes to ChromeClient.
        * WebCoreSupport/WebChromeClient.mm:
        (WebChromeClient::exceededDatabaseQuota): Replaced the two different client functions
        we had before with a single one.

        * WebKit.exp: Added missing export for WebDatabaseExpectedSizeKey.

        * WebView/WebPreferenceKeysPrivate.h: Removed WebKitDefaultDatabaseQuotaKey.
        * WebView/WebPreferences.m:
        (+[WebPreferences initialize]): Removed the default for WebKitDefaultDatabaseQuotaKey.
        * WebView/WebPreferencesPrivate.h: Removed defaultDatabaseQuota and
        setDefaultDatabaseQuota:.

        * WebView/WebUIDelegatePrivate.h: Replaced the two different database quota delegate
        methods we had before with a single one.

        * WebView/WebView.mm:
        (-[WebView _preferencesChangedNotification:]): Removed the code to set the
        default database origin quota in WebCore::Settings based on WebPreferences.

        * WebView/WebViewInternal.h: Removed delegate method dispatch functions for unusual
        types of parameters that the database UI delegate methods had before.

WebKit/qt:

        Reviewed by John Sullivan.

        - updated for changes to ChromeClient database functions

        * WebCoreSupport/ChromeClientQt.cpp:
        (WebCore::ChromeClientQt::exceededDatabaseQuota):
        * WebCoreSupport/ChromeClientQt.h:

WebKit/win:

        Reviewed by John Sullivan.

        - fix <rdar://problem/5644324> Delegate-less WebKit clients should have no databases
        - fix incorrect value for WebDatabaseDisplayNameKey in header
        
        * Interfaces/IWebDatabaseManager.idl: Renamed detailsForDatabaseWithOrigin to
        detailsForDatabase. Replaced deleteDatabasesWithOrigin with deleteOrigin.
        Renamed deleteDatabaseWithOrigin to deleteDatabase. Fixed incorrect value for
        WebDatabaseDisplayNameKey.
        * Interfaces/IWebPreferencesPrivate.idl: Removed defaultDatabaseQuota and
        setDefaultDatabaseQuota.
        * Interfaces/IWebUIDelegatePrivate.idl: Replaced the two database quota functions
        with a single one.

        * WebChromeClient.cpp:
        (WebChromeClient::exceededDatabaseQuota): Replaced the two database quota functions
        with a single one.
        * WebChromeClient.h: Ditto.

        * WebDatabaseManager.cpp:
        (WebDatabaseManager::detailsForDatabase): Changed to check for a name of null to
        detect a nonexistent database rather than using isValid.
        (WebDatabaseManager::deleteOrigin): Updated for name change (actually a semantic
        change too, but both have the same name).
        (WebDatabaseManager::deleteDatabase): Updated for name change.
        (WebKitSetWebDatabasesPathIfNecessary): Ditto.

        * WebDatabaseManager.h: Updated for name changes.

        * WebPreferenceKeysPrivate.h: Removed WebKitDefaultDatabaseQuotaKey.
        * WebPreferences.cpp:
        (WebPreferences::initializeDefaultSettings): Removed the default for
        WebKitDefaultDatabaseQuotaKey.
        * WebPreferences.h: Removed defaultDatabaseQuota and setDefaultDatabaseQuota.
        * WebView.cpp:
        (WebView::notifyPreferencesChanged): Removed the code to set the
        default database origin quota in WebCore::Settings based on IWebPreferencesPrivate.

WebKit/wx:

        Reviewed by John Sullivan.

        - updated for changes to ChromeClient database functions

        * WebKitSupport/ChromeClientWx.cpp:
        (WebCore::ChromeClientWx::exceededDatabaseQuota):
        * WebKitSupport/ChromeClientWx.h:



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@29698 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 58806b8d
2008-01-21 Darin Adler <darin@apple.com>
Reviewed by John Sullivan.
- fix <rdar://problem/5644324> Delegate-less WebKit clients should have no databases
- remove the default database quota setting
- simplify the quota-related client calls by merging the one for a new database with
the one for an existing database, adding a feature where you can get details about
a database being created using the same functions that work on the other databases,
and removing the parameters and return values, instead having clients use a function
to set the quota
- fix unsafe multi-thread access to the database tracker's quota map
- fix bug in deleteAllDatabases where it would iterate a HashMap while modifying it
The tracker database is now only created when we set the quota for a database origin.
Thus asking for info about databases won't cause anything to be written to disk.
* WebCore.base.exp: Updated.
* bindings/js/GCController.cpp: Added an #if to get rid of an unused function warning.
* page/Chrome.cpp: Removed database-related functions. There's no problem having the
code deal directly with the client.
* page/Chrome.h: Ditto. Also made Chrome inherit from Noncopyable.
* page/ChromeClient.h: Replaced the two quota-related functions with a single one.
The details about the state of databases in the origin are now available by asking
for database details. There's also no need to pass the security origin, since
it's easy to get that from the frame's document.
* page/Settings.cpp: Removed the default quota setting.
* page/Settings.h: Ditto.
* platform/FileSystem.h: Added deleteEmptyDirectory.
* platform/gtk/FileSystemGtk.cpp:
(WebCore::deleteEmptyDirectory): Added.
* platform/posix/FileSystemPOSIX.cpp:
(WebCore::deleteEmptyDirectory): Added.
* platform/qt/FileSystemQt.cpp:
(WebCore::deleteEmptyDirectory): Added.
* platform/win/FileSystemWin.cpp:
(WebCore::deleteEmptyDirectory): Added.
* platform/wx/FileSystemWx.cpp:
(WebCore::deleteEmptyDirectory): Added placeholder.
* storage/DatabaseDetails.h: Removed the isValid() function since its name is
confusing -- we removed our other isValid() functions. For the few callers that
need this, it's fine to just check name().isEmpty(). Made the member functions
all const.
* storage/DatabaseTracker.cpp:
(WebCore::DatabaseTracker::DatabaseTracker): Removed m_defaultQuota initialization.
Added m_proposedDatabase and m_thread.
(WebCore::DatabaseTracker::setDatabaseDirectoryPath): Got rid of code that would
open the tracker database here. This might slightly speed up launch time, since
we won't do the I/O until we have to, and before we were actually creating an SQL
database in this code that's run when we go to the first webpage.
(WebCore::DatabaseTracker::trackerDatabasePath): Added.
(WebCore::DatabaseTracker::openTrackerDatabase): Added a boolean parameter telling
this function whether to create the database. Made this function safe to call if
the database is already open. Also made the function fail quietly if the path has
not been set yet.
(WebCore::DatabaseTracker::canEstablishDatabase): Got rid of the call to the
establishEntryForOrigin function. The origin is now put in the tracker database
when the quota is set to a non-zero value. When judging if there's enough space
for the new database, require at least one byte even if estimatedSize is 0, and
check for overflow. Also added code here to populate the origins map, which
guarantees it will be ready when the database uses it on another thread later.
Also changed this to call the new ChromeClient function.
(WebCore::DatabaseTracker::hasEntryForDatabase): Added code to open the
tracker database, since that's no longer done by setDatabaseDirectoryPath.
(WebCore::DatabaseTracker::originPath): Added.
(WebCore::DatabaseTracker::fullPathForDatabase): Added code so that this will
return a null string for the proposed database if called from within the
ChromeClient function. Also switched from empty string to null string for the
error cases.
(WebCore::DatabaseTracker::populateOrigins): Added code to open the tracker
database.
(WebCore::DatabaseTracker::databaseNamesForOrigin): Ditto.
(WebCore::DatabaseTracker::detailsForNameAndOrigin): Ditto. Also added code that
will return the details of the proposed database if called from within the
ChromeClient function. This is how the client can learn of the display name and
the estimated size of the new database.
(WebCore::DatabaseTracker::setDatabaseDetails): Added code to open the tracker
database.
(WebCore::DatabaseTracker::quotaForOrigin): Made this code OK to call on a non-main
thread by using m_quotaMapGuard to guard access to the map. Other code runs on the
main thread only, and only functions that write to the map use the lock.
(WebCore::DatabaseTracker::setQuota): Changed this function so it can insert the
initial quota as well as updating an existing quota. Added locking since this
function modifies the quota map. Added code to open the tracker database. Added
an early exit if the quota is already correct, which is guarantees that if you
set a quota to 0 it won't trigger creation of a tracker database.
(WebCore::DatabaseTracker::addDatabase): Added code to open the tracker database.
(WebCore::DatabaseTracker::deleteAllDatabases): Made a copy of the quota map before
iterating it to find all the origins. This fixes a problem with the old code where
it would modify the map while iterating it, which gives assertions in debug builds
and unpredictable results.
(WebCore::DatabaseTracker::deleteOrigin): Replaced deleteDatabasesWithOrigin with
this function. Added code to open the tracker database if needed. Added code to
delete the origin from the tracker database, and to close the tracker database
and delete files and directories as needed if we are deleting the final origin.
(WebCore::DatabaseTracker::deleteDatabase): Added code to open the tracker database
if needed.
* storage/DatabaseTracker.h: Renamed databasePath to databaseDirectoryPath for
clarity, including the data member, and the getter and setter functions.
Replaced deleteDatabasesWithOrigin with deleteOrigin. Removed the functions
dealing with default origin quota. There is no default any more; origins start
with no quota and the client must set a quota. Added trackerDatabasePath and
originPath helper functions. Added a boolean parameter to openTrackerDatabase
to tell it whether to create the database or not. Removed the
establishEntryForOrigin function. Renamed m_originQuotaMap to just m_quotaMap,
and added m_quotaMapGuard. Added a QuotaMap typedef. Added m_proposedDatabase,
which holds the origin and details for the current proposed database during
the client callback function that must decide whether to grant quota. Added a
m_thread data member for debugging use to assert if functions that can only
be called on a single thread are misused.
* storage/SQLTransaction.cpp:
(WebCore::SQLTransaction::deliverQuotaIncreaseCallback): Changed to call the
new exceededDatabaseQuota function instead of the old one.
* svg/graphics/SVGImageEmptyClients.h: Updated for the change to ChromeClient.
2008-01-21 David Hyatt <hyatt@apple.com>
Fix for http://bugs.webkit.org/show_bug.cgi?id=16935
......@@ -294,14 +294,14 @@ __ZN7WebCore15BackForwardList9goForwardEv
__ZN7WebCore15BackForwardListC1EPNS_4PageE
__ZN7WebCore15BackForwardListD1Ev
__ZN7WebCore15ContextMenuItem26releasePlatformDescriptionEv
__ZN7WebCore15DatabaseTracker12deleteOriginEPNS_14SecurityOriginE
__ZN7WebCore15DatabaseTracker14deleteDatabaseEPNS_14SecurityOriginERKNS_6StringE
__ZN7WebCore15DatabaseTracker14quotaForOriginEPNS_14SecurityOriginE
__ZN7WebCore15DatabaseTracker14usageForOriginEPNS_14SecurityOriginE
__ZN7WebCore15DatabaseTracker15setDatabasePathERKNS_6StringE
__ZN7WebCore15DatabaseTracker18deleteAllDatabasesEv
__ZN7WebCore15DatabaseTracker22databaseNamesForOriginEPNS_14SecurityOriginERN3WTF6VectorINS_6StringELm0EEE
__ZN7WebCore15DatabaseTracker23detailsForNameAndOriginERKNS_6StringEPNS_14SecurityOriginE
__ZN7WebCore15DatabaseTracker25deleteDatabasesWithOriginEPNS_14SecurityOriginE
__ZN7WebCore15DatabaseTracker24setDatabaseDirectoryPathERKNS_6StringE
__ZN7WebCore15DatabaseTracker7originsERN3WTF6VectorINS1_6RefPtrINS_14SecurityOriginEEELm0EEE
__ZN7WebCore15DatabaseTracker7trackerEv
__ZN7WebCore15DatabaseTracker8setQuotaEPNS_14SecurityOriginEy
......@@ -491,7 +491,6 @@ __ZN7WebCore8Settings27setFTPDirectoryTemplatePathERKNS_6StringE
__ZN7WebCore8Settings27setLoadsImagesAutomaticallyEb
__ZN7WebCore8Settings28setForceFTPDirectoryListingsEb
__ZN7WebCore8Settings29setAuthorAndUserStylesEnabledEb
__ZN7WebCore8Settings29setDefaultDatabaseOriginQuotaEy
__ZN7WebCore8Settings31setShrinksStandaloneImagesToFitEb
__ZN7WebCore8Settings32setNeedsAdobeFrameReloadingQuirkEb
__ZN7WebCore8Settings40setJavaScriptCanOpenWindowsAutomaticallyEb
......
......@@ -37,6 +37,8 @@ using namespace KJS;
namespace WebCore {
#if USE(PTHREADS)
static void* collect(void*)
{
JSLock lock;
......@@ -44,6 +46,8 @@ static void* collect(void*)
return 0;
}
#endif
GCController& gcController()
{
static GCController staticGCController;
......
......@@ -343,16 +343,6 @@ void Chrome::print(Frame* frame)
m_client->print(frame);
}
unsigned long long Chrome::requestQuotaIncreaseForNewDatabase(Frame* frame, SecurityOrigin* origin, const String& databaseDisplayName, unsigned long long estimatedSize)
{
return m_client->requestQuotaIncreaseForNewDatabase(frame, origin, databaseDisplayName, estimatedSize);
}
unsigned long long Chrome::requestQuotaIncreaseForDatabaseOperation(Frame* frame, SecurityOrigin* origin, const String& databaseIdentifier, unsigned long long proposedNewQuota)
{
return m_client->requestQuotaIncreaseForDatabaseOperation(frame, origin, databaseIdentifier, proposedNewQuota);
}
PageGroupLoadDeferrer::PageGroupLoadDeferrer(Page* page, bool deferSelf)
{
const HashSet<Page*>* group = page->frameNamespace();
......
// -*- mode: c++; c-basic-offset: 4 -*-
/*
* Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
* Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
......@@ -23,6 +23,7 @@
#include "FocusDirection.h"
#include <wtf/Forward.h>
#include <wtf/Noncopyable.h>
#include <wtf/RefPtr.h>
#if PLATFORM(MAC)
......@@ -40,7 +41,6 @@ namespace WebCore {
class HitTestResult;
class IntRect;
class Page;
class SecurityOrigin;
class String;
struct FrameLoadRequest;
......@@ -61,7 +61,7 @@ namespace WebCore {
ErrorMessageLevel
};
class Chrome {
class Chrome : Noncopyable {
public:
Chrome(Page*, ChromeClient*);
~Chrome();
......@@ -125,9 +125,6 @@ namespace WebCore {
void setToolTip(const HitTestResult&);
void print(Frame*);
unsigned long long requestQuotaIncreaseForNewDatabase(Frame*, SecurityOrigin*, const String& databaseDisplayName, unsigned long long estimatedSize);
unsigned long long requestQuotaIncreaseForDatabaseOperation(Frame*, SecurityOrigin* origin, const String& databaseIdentifier, unsigned long long proposedNewQuota);
#if PLATFORM(MAC)
void focusNSView(NSView*);
......
// -*- mode: c++; c-basic-offset: 4 -*-
/*
* Copyright (C) 2006-2007 Apple, Inc.
* Copyright (C) 2006, 2007, 2008 Apple, Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
......@@ -30,7 +30,6 @@ namespace WebCore {
class HitTestResult;
class IntRect;
class Page;
class SecurityOrigin;
class String;
struct FrameLoadRequest;
......@@ -38,7 +37,6 @@ namespace WebCore {
class ChromeClient {
public:
virtual ~ChromeClient() { }
virtual void chromeDestroyed() = 0;
virtual void setWindowRect(const FloatRect&) = 0;
......@@ -104,9 +102,11 @@ namespace WebCore {
virtual void print(Frame*) = 0;
virtual unsigned long long requestQuotaIncreaseForNewDatabase(Frame*, SecurityOrigin* origin, const String& databaseDisplayName, unsigned long long estimatedSize) = 0;
virtual unsigned long long requestQuotaIncreaseForDatabaseOperation(Frame*, SecurityOrigin* origin, const String& databaseIdentifier, unsigned long long proposedNewQuota) = 0;
};
virtual void exceededDatabaseQuota(Frame*, const String& databaseName) = 0;
protected:
virtual ~ChromeClient() { }
};
}
......
......@@ -301,22 +301,6 @@ void Settings::setAuthorAndUserStylesEnabled(bool authorAndUserStylesEnabled)
setNeedsReapplyStylesInAllFrames(m_page);
}
void Settings::setDefaultDatabaseOriginQuota(unsigned long long quota)
{
#if ENABLE(DATABASE)
DatabaseTracker::tracker().setDefaultOriginQuota(quota);
#endif
}
unsigned long long Settings::defaultDatabaseOriginQuota() const
{
#if ENABLE(DATABASE)
return DatabaseTracker::tracker().defaultOriginQuota();
#else
return 0;
#endif
}
void Settings::setFontRenderingMode(FontRenderingMode mode)
{
if (fontRenderingMode() == mode)
......
......@@ -144,9 +144,6 @@ namespace WebCore {
void setAuthorAndUserStylesEnabled(bool);
bool authorAndUserStylesEnabled() const { return m_authorAndUserStylesEnabled; }
void setDefaultDatabaseOriginQuota(unsigned long long);
unsigned long long defaultDatabaseOriginQuota() const;
void setFontRenderingMode(FontRenderingMode mode);
FontRenderingMode fontRenderingMode() const;
......
/*
* Copyright (C) 2007 Apple Inc. All rights reserved.
* Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
* Copyright (C) 2008 Collabora, Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
......@@ -31,7 +31,6 @@
#define FileSystem_h
#include <wtf/Platform.h>
#include <wtf/Vector.h>
typedef const struct __CFData* CFDataRef;
......@@ -50,6 +49,7 @@ const PlatformFileHandle invalidPlatformFileHandle = -1;
bool fileExists(const String&);
bool deleteFile(const String&);
bool deleteEmptyDirectory(const String&);
bool fileSize(const String&, long long& result);
String pathByAppendingComponent(const String& path, const String& component);
bool makeAllDirectories(const String& path);
......@@ -59,7 +59,7 @@ CString fileSystemRepresentation(const String&);
inline bool isHandleValid(const PlatformFileHandle& handle) { return handle != invalidPlatformFileHandle; }
/* Prefix is what the filename should be prefixed with, not the full path */
// Prefix is what the filename should be prefixed with, not the full path.
CString openTemporaryFile(const char* prefix, PlatformFileHandle&);
void closeFile(PlatformFileHandle&);
int writeToFile(PlatformFileHandle, const char* data, int length);
......
/*
* Copyright (C) 2007 Holger Hans Peter Freyther
* Copyright (C) 2008 Collabora, Ltd.
* Copyright (C) 2008 Apple Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
......@@ -56,6 +57,19 @@ bool deleteFile(const String& path)
return result;
}
bool deleteEmptyDirectory(const String& path)
{
bool result = false;
gchar* filename = g_filename_from_utf8(path.utf8().data(), -1, 0, 0, 0);
if (filename) {
result = g_rmdir(filename) == 0;
g_free(filename);
}
return result;
}
bool fileSize(const String& path, long long& resultSize)
{
gchar* filename = g_filename_from_utf8(path.utf8().data(), -1, 0, 0, 0);
......
/*
* Copyright (C) 2007 Apple Inc. All rights reserved.
* Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
......@@ -25,6 +25,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "config.h"
#include "FileSystem.h"
......@@ -63,6 +64,17 @@ bool deleteFile(const String& path)
return !unlink(fsRep.data());
}
bool deleteEmptyDirectory(const String& path)
{
CString fsRep = fileSystemRepresentation(path);
if (!fsRep.data() || fsRep.data()[0] == '\0')
return false;
// rmdir(...) returns 0 on successful deletion of the path and non-zero in any other case (including invalid permissions or non-existent file)
return !rmdir(fsRep.data());
}
bool fileSize(const String& path, long long& result)
{
CString fsRep = fileSystemRepresentation(path);
......
/*
* Copyright (C) 2007 Staikos Computing Services Inc.
* Copyright (C) 2007 Holger Hans Peter Freyther
* Copyright (C) 2008 Apple, Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
......@@ -45,6 +46,11 @@ bool deleteFile(const String& path)
return QFile::remove(path);
}
bool deleteEmptyDirectory(const String& path)
{
return QDir::rmdir(path);
}
bool fileSize(const String& path, long long& result)
{
QFileInfo info(path);
......
/*
* Copyright (C) 2007 Apple Inc. All rights reserved.
* Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
* Copyright (C) 2008 Collabora, Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
......@@ -65,6 +65,12 @@ bool deleteFile(const String& path)
return !!DeleteFileW(filename.charactersWithNullTermination());
}
bool deleteEmptyDirectory(const String& path)
{
String filename = path;
return !!RemoveDirectoryW(filename.charactersWithNullTermination());
}
String pathByAppendingComponent(const String& path, const String& component)
{
Vector<UChar> buffer(MAX_PATH);
......
......@@ -45,6 +45,12 @@ bool deleteFile(const String& path)
return false;
}
bool deleteEmptyDirectory(const String& path)
{
notImplemented();
return false;
}
bool fileSize(const String& path, long long& resultSize)
{
notImplemented();
......
/*
* Copyright (C) 2007 Apple Inc. All rights reserved.
* Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
......@@ -25,6 +25,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef DatabaseDetails_h
#define DatabaseDetails_h
......@@ -37,22 +38,22 @@ public:
DatabaseDetails()
: m_expectedUsage(0)
, m_currentUsage(0)
{ }
{
}
DatabaseDetails(const String& databaseName, const String& displayName, unsigned long long expectedUsage, unsigned long long currentUsage)
: m_name(databaseName)
, m_displayName(displayName)
, m_expectedUsage(expectedUsage)
, m_currentUsage(currentUsage)
{ }
bool isValid() const { return !(m_name.isEmpty() && m_displayName.isEmpty() && !m_expectedUsage && !m_currentUsage); }
const String& name() { return m_name; }
const String& displayName() { return m_displayName; }
unsigned long long expectedUsage() { return m_expectedUsage; }
unsigned long long currentUsage() { return m_currentUsage; }
{
}
const String& name() const { return m_name; }
const String& displayName() const { return m_displayName; }
unsigned long long expectedUsage() const { return m_expectedUsage; }
unsigned long long currentUsage() const { return m_currentUsage; }
private:
String m_name;
String m_displayName;
......
This diff is collapsed.
/*
* Copyright (C) 2007 Apple Inc. All rights reserved.
* Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
......@@ -25,6 +25,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef DatabaseTracker_h
#define DatabaseTracker_h
......@@ -46,12 +47,12 @@ struct SecurityOriginTraits;
class DatabaseTracker {
public:
void setDatabasePath(const String&);
const String& databasePath();
void setDatabaseDirectoryPath(const String&);
const String& databaseDirectoryPath() const;
bool canEstablishDatabase(Document*, const String& name, const String& displayName, unsigned long estimatedSize);
void setDatabaseDetails(SecurityOrigin*, const String& name, const String& displayName, unsigned long estimatedSize);
String fullPathForDatabase(SecurityOrigin*, const String& name, bool createIfNotExists = true);
String fullPathForDatabase(SecurityOrigin*, const String& name, bool createIfDoesNotExist = true);
void origins(Vector<RefPtr<SecurityOrigin> >& result);
bool databaseNamesForOrigin(SecurityOrigin*, Vector<String>& result);
......@@ -64,26 +65,26 @@ public:
void setQuota(SecurityOrigin*, unsigned long long);
void deleteAllDatabases();
void deleteDatabasesWithOrigin(SecurityOrigin*);
void deleteOrigin(SecurityOrigin*);
void deleteDatabase(SecurityOrigin*, const String& name);
void setClient(DatabaseTrackerClient*);
void setDefaultOriginQuota(unsigned long long);
unsigned long long defaultOriginQuota() const;
// From a secondary thread, must be thread safe with its data
void scheduleNotifyDatabaseChanged(SecurityOrigin*, const String& name);
static DatabaseTracker& tracker();
private:
DatabaseTracker();
void openTrackerDatabase();
String trackerDatabasePath() const;
void openTrackerDatabase(bool createIfDoesNotExist);
String originPath(SecurityOrigin*) const;
bool hasEntryForOrigin(SecurityOrigin*);
bool hasEntryForDatabase(SecurityOrigin*, const String& databaseIdentifier);
void establishEntryForOrigin(SecurityOrigin*);
bool addDatabase(SecurityOrigin*, const String& name, const String& path);
void populateOrigins();
......@@ -91,13 +92,21 @@ private:
bool deleteDatabaseFile(SecurityOrigin*, const String& name);
SQLiteDatabase m_database;
mutable OwnPtr<HashMap<RefPtr<SecurityOrigin>, unsigned long long, SecurityOriginHash, SecurityOriginTraits> > m_originQuotaMap;
String m_databasePath;
typedef HashMap<RefPtr<SecurityOrigin>, unsigned long long, SecurityOriginHash, SecurityOriginTraits> QuotaMap;
Mutex m_quotaMapGuard;
mutable OwnPtr<QuotaMap> m_quotaMap;
String m_databaseDirectoryPath;
unsigned long long m_defaultQuota;
DatabaseTrackerClient* m_client;
std::pair<SecurityOrigin*, DatabaseDetails>* m_proposedDatabase;
#ifndef NDEBUG
ThreadIdentifier m_thread;
#endif
static void scheduleForNotification();
static void notifyDatabasesChanged();
};
......
/*
* Copyright (C) 2007 Apple Inc. All rights reserved.
* Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
......@@ -25,11 +25,14 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "config.h"
#include "SQLTransaction.h"
#include "ChromeClient.h"
#include "Database.h"
#include "DatabaseAuthorizer.h"
#include "DatabaseDetails.h"
#include "DatabaseTracker.h"
#include "Document.h"
#include "ExceptionCode.h"
......@@ -294,9 +297,8 @@ void SQLTransaction::deliverQuotaIncreaseCallback()
RefPtr<SecurityOrigin> origin = m_database->securityOriginCopy();
unsigned long long currentQuota = DatabaseTracker::tracker().quotaForOrigin(origin.get());
unsigned long long newQuota = page->chrome()->requestQuotaIncreaseForDatabaseOperation(m_database->document()->frame(), origin.get(), m_database->stringIdentifier(), currentQuota + DefaultQuotaSizeIncrease);
DatabaseTracker::tracker().setQuota(origin.get(), newQuota);
page->chrome()->client()->exceededDatabaseQuota(m_database->document()->frame(), m_database->stringIdentifier());
unsigned long long newQuota = DatabaseTracker::tracker().quotaForOrigin(origin.get());
// If the new quota ended up being larger than the old quota, we will retry the statement.
if (newQuota > currentQuota)
......
......@@ -116,8 +116,7 @@ public:
virtual void print(Frame*) { }
virtual unsigned long long requestQuotaIncreaseForNewDatabase(Frame*, SecurityOrigin*, const String&, unsigned long long) { return 0; }
virtual unsigned long long requestQuotaIncreaseForDatabaseOperation(Frame