Adding Chromium's DatabaseTracker implementation.
authordumi@chromium.org <dumi@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 13 Nov 2009 20:25:06 +0000 (20:25 +0000)
committerdumi@chromium.org <dumi@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 13 Nov 2009 20:25:06 +0000 (20:25 +0000)
Reviewed by Dimitri Glazkov.

https://bugs.webkit.org/show_bug.cgi?id=31440

WebCore:

* WebCore.gyp/WebCore.gyp:
* WebCore.gypi:
* storage/DatabaseTracker.h:
* storage/chromium/DatabaseTrackerChromium.cpp:
(WebCore::DatabaseTracker::fullPathForDatabase):
(WebCore::DatabaseTracker::getMaxSizeForDatabase):
* storage/chromium/QuotaTracker.cpp:
(WebCore::QuotaTracker::updateDatabaseSize):
* storage/chromium/QuotaTracker.h:

WebKit/chromium:

* WebKit.gyp:
* src/ChromeClientImpl.cpp:
(WebKit::ChromeClientImpl::exceededDatabaseQuota):
* src/DatabaseObserver.cpp: Added.
(WebCore::DatabaseObserver::databaseOpened):
(WebCore::DatabaseObserver::databaseModified):
(WebCore::DatabaseObserver::databaseClosed):
* src/WebDatabase.cpp:
(WebKit::WebDatabase::name):
(WebKit::WebDatabase::displayName):
(WebKit::WebDatabase::estimatedSize):
(WebKit::WebDatabase::securityOrigin):
(WebKit::WebDatabase::updateDatabaseSize):
* src/WebSecurityOrigin.cpp:
(WebKit::WebSecurityOrigin::toString):
(WebKit::WebSecurityOrigin::databaseIdentifier):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@50961 268f45cc-cd09-0410-ab3c-d52691b4dbfc

12 files changed:
WebCore/ChangeLog
WebCore/WebCore.gyp/WebCore.gyp
WebCore/WebCore.gypi
WebCore/storage/DatabaseTracker.h
WebCore/storage/chromium/DatabaseTrackerChromium.cpp
WebCore/storage/chromium/QuotaTracker.cpp
WebKit/chromium/ChangeLog
WebKit/chromium/WebKit.gyp
WebKit/chromium/src/ChromeClientImpl.cpp
WebKit/chromium/src/DatabaseObserver.cpp [new file with mode: 0644]
WebKit/chromium/src/WebDatabase.cpp
WebKit/chromium/src/WebSecurityOrigin.cpp

index 5503e1b5c93c711d8501ca8f9e9c38be41df4385..69087998e1c963a151f61362299906a05881d6b3 100644 (file)
@@ -1,3 +1,21 @@
+2009-11-12  Dumitru Daniliuc  <dumi@chromium.org>
+
+        Reviewed by Dimitri Glazkov.
+
+        Adding Chromium's DatabaseTracker implementation.
+
+        https://bugs.webkit.org/show_bug.cgi?id=31440
+
+        * WebCore.gyp/WebCore.gyp:
+        * WebCore.gypi:
+        * storage/DatabaseTracker.h:
+        * storage/chromium/DatabaseTrackerChromium.cpp:
+        (WebCore::DatabaseTracker::fullPathForDatabase):
+        (WebCore::DatabaseTracker::getMaxSizeForDatabase):
+        * storage/chromium/QuotaTracker.cpp:
+        (WebCore::QuotaTracker::updateDatabaseSize):
+        * storage/chromium/QuotaTracker.h:
+
 2009-11-13  Carol Szabo  <carol.szabo@nokia.com>
 
         Reviewed by Darin Adler.
index eb10eee763ceda6cc5ea7a3eb55549b62c328be3..f1788570e98a1b61d50a95f3c20dbad328fad9c3 100644 (file)
       '../rendering',
       '../rendering/style',
       '../storage',
+      '../storage/chromium',
       '../svg',
       '../svg/animation',
       '../svg/graphics',
 
         # Exclude some DB-related files.
         ['exclude', 'platform/sql/SQLiteFileSystem.cpp'],
+        ['exclude', 'storage/DatabaseTracker.cpp'],
+        ['exclude', 'storage/DatabaseTrackerClient.h'],
+        ['exclude', 'storage/OriginQuotaManager.cpp'],
+        ['exclude', 'storage/OriginQuotaManager.h'],
+        ['exclude', 'storage/OriginUsageRecord.cpp'],
+        ['exclude', 'storage/OriginUsageRecord.h'],
+        ['exclude', 'storage/SQLTransactionClient.cpp'],
       ],
       'sources!': [
         # A few things can't be excluded by patterns.  List them individually.
index 0bc9996b8d38508a963681d37316fb0b7a98e1e8..84c8811aa86856a9a7aed6a99dabd3da1cd1e7d4 100644 (file)
             'rendering/break_lines.h',
             'storage/ChangeVersionWrapper.cpp',
             'storage/ChangeVersionWrapper.h',
+            'storage/chromium/DatabaseObserver.h',
+            'storage/chromium/DatabaseTrackerChromium.cpp',
+            'storage/chromium/QuotaTracker.cpp',
+            'storage/chromium/QuotaTracker.h',
+            'storage/chromium/SQLTransactionClientChromium.cpp',
             'storage/Database.cpp',
             'storage/Database.h',
             'storage/DatabaseAuthorizer.cpp',
index 85e4858ad0ad709c9d1bf5d5f5e2c01ef0539b66..fd475a335181dd745a905546b2fb2a29aa99c933 100644 (file)
 
 #if ENABLE(DATABASE)
 
-#include "DatabaseDetails.h"
 #include "PlatformString.h"
+
+#if !PLATFORM(CHROMIUM)
+#include "DatabaseDetails.h"
 #include "SQLiteDatabase.h"
 #include "StringHash.h"
 #include <wtf/HashSet.h>
 #include <wtf/OwnPtr.h>
+#endif // !PLATFORM(CHROMIUM)
 
 namespace WebCore {
 
 class Database;
-class DatabaseTrackerClient;
 class Document;
-class OriginQuotaManager;
 class SecurityOrigin;
 
+#if !PLATFORM(CHROMIUM)
+class DatabaseTrackerClient;
+class OriginQuotaManager;
+
 struct SecurityOriginHash;
 struct SecurityOriginTraits;
+#endif // !PLATFORM(CHROMIUM)
 
 class DatabaseTracker {
 public:
-    void setDatabaseDirectoryPath(const String&);
-    const String& databaseDirectoryPath() const;
+    static DatabaseTracker& tracker();
 
     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 createIfDoesNotExist = true);
 
+    void addOpenDatabase(Database*);
+    void removeOpenDatabase(Database*);
+
+    unsigned long long getMaxSizeForDatabase(const Database*);
+
+private:
+    DatabaseTracker();
+
+#if !PLATFORM(CHROMIUM)
+public:
+    void setDatabaseDirectoryPath(const String&);
+    const String& databaseDirectoryPath() const;
+
     void origins(Vector<RefPtr<SecurityOrigin> >& result);
     bool databaseNamesForOrigin(SecurityOrigin*, Vector<String>& result);
 
     DatabaseDetails detailsForNameAndOrigin(const String&, SecurityOrigin*);
 
-    void addOpenDatabase(Database*);
-    void removeOpenDatabase(Database*);
-
     unsigned long long usageForDatabase(const String&, SecurityOrigin*);
     unsigned long long usageForOrigin(SecurityOrigin*);
     unsigned long long quotaForOrigin(SecurityOrigin*);
@@ -82,15 +97,10 @@ public:
 
     OriginQuotaManager& originQuotaManager();
 
-    static DatabaseTracker& tracker();
 
     bool hasEntryForOrigin(SecurityOrigin*);
 
-    unsigned long long getMaxSizeForDatabase(const Database*);
-
 private:
-    DatabaseTracker();
-
     String trackerDatabasePath() const;
     void openTrackerDatabase(bool createIfDoesNotExist);
 
@@ -130,6 +140,7 @@ private:
 
     static void scheduleForNotification();
     static void notifyDatabasesChanged(void*);
+#endif // !PLATFORM(CHROMIUM)
 };
 
 } // namespace WebCore
index 24ed642d6f619ee0f38bb5c721f79c95bd212687..e4b8178fafd779360cc7607105b0cab18b967ece 100644 (file)
@@ -40,6 +40,7 @@
 #include "SecurityOrigin.h"
 #include "SQLiteFileSystem.h"
 #include <wtf/HashSet.h>
+#include <wtf/StdLibExtras.h>
 
 namespace WebCore {
 
@@ -68,7 +69,7 @@ void DatabaseTracker::setDatabaseDetails(SecurityOrigin*, const String&, const S
 
 String DatabaseTracker::fullPathForDatabase(SecurityOrigin* origin, const String& name, bool)
 {
-    return origin->databaseIdentifier() + "/" + name;
+    return origin->databaseIdentifier() + "/" + name + "#";
 }
 
 void DatabaseTracker::addOpenDatabase(Database* database)
@@ -79,11 +80,13 @@ void DatabaseTracker::addOpenDatabase(Database* database)
 
 void DatabaseTracker::removeOpenDatabase(Database* database)
 {
-    ASSERT(isMainThread());
-    DatabaseObserver::databaseClosed(database);
+    // FIXME: once we know how to use this information, figure out
+    //        how to get this method called on the main thread
+    //ASSERT(isMainThread());
+    //DatabaseObserver::databaseClosed(database);
 }
 
-unsigned long long DatabaseTracker::getMaxSizeForDatabase(const Database* database) const
+unsigned long long DatabaseTracker::getMaxSizeForDatabase(const Database* database)
 {
     ASSERT(currentThread() == database->document()->databaseThread()->getThreadID());
     unsigned long long spaceAvailable = 0;
index 9d15d727c3dbeade7ee45632ae3e8b4bdbb7893b..b49639dffa01b58fee555c345ad97ab301885327 100644 (file)
@@ -56,7 +56,7 @@ void QuotaTracker::getDatabaseSizeAndSpaceAvailableToOrigin(
     *spaceAvailable = m_spaceAvailableToOrigins.get(originIdentifier);
 }
 
-void QuotaTracker::updateDatabaseSizeAndOriginSpace(
+void QuotaTracker::updateDatabaseSizeAndSpaceAvailableToOrigin(
     const String& originIdentifier, const String& databaseName,
     unsigned long long databaseSize, unsigned long long spaceAvailable)
 {
index d423521f9d46dcc9b731d793c5389be1a385cb22..4b69c0471ba2d4caf857f5bcbbcfa69e1240d92f 100644 (file)
@@ -1,3 +1,28 @@
+2009-11-12  Dumitru Daniliuc  <dumi@chromium.org>
+
+        Reviewed by Dimitri Glazkov.
+
+        Adding Chromium's DatabaseTracker implementation.
+
+        https://bugs.webkit.org/show_bug.cgi?id=31440
+
+        * WebKit.gyp:
+        * src/ChromeClientImpl.cpp:
+        (WebKit::ChromeClientImpl::exceededDatabaseQuota):
+        * src/DatabaseObserver.cpp: Added.
+        (WebCore::DatabaseObserver::databaseOpened):
+        (WebCore::DatabaseObserver::databaseModified):
+        (WebCore::DatabaseObserver::databaseClosed):
+        * src/WebDatabase.cpp:
+        (WebKit::WebDatabase::name):
+        (WebKit::WebDatabase::displayName):
+        (WebKit::WebDatabase::estimatedSize):
+        (WebKit::WebDatabase::securityOrigin):
+        (WebKit::WebDatabase::updateDatabaseSize):
+        * src/WebSecurityOrigin.cpp:
+        (WebKit::WebSecurityOrigin::toString):
+        (WebKit::WebSecurityOrigin::databaseIdentifier):
+
 2009-11-13  Yaar Schnitman  <yaar@chromium.org>
 
         Reviewed by Dimitri Glazkov.
index 64ad16b339c85ddbf8c4f835cd4ab33a623057dd..8550e5a503c0d763c422c72e4603512ceb34281a 100644 (file)
                 'src/ChromiumThreading.cpp',
                 'src/ContextMenuClientImpl.cpp',
                 'src/ContextMenuClientImpl.h',
+                'src/DatabaseObserver.cpp',
                 'src/DOMUtilitiesPrivate.cpp',
                 'src/DOMUtilitiesPrivate.h',
                 'src/DragClientImpl.cpp',
index f8163150ff796f82a8990cb51cc6580b8b8008cd..4e20124206e5b25f8fdc42c36d0a4f91238f4d64 100644 (file)
@@ -544,10 +544,7 @@ void ChromeClientImpl::print(Frame* frame)
 
 void ChromeClientImpl::exceededDatabaseQuota(Frame* frame, const String& databaseName)
 {
-    // set a reasonable quota for now -- 5Mb should be enough for anybody
-    // TODO(dglazkov): this should be configurable
-    SecurityOrigin* origin = frame->document()->securityOrigin();
-    DatabaseTracker::tracker().setQuota(origin, 1024 * 1024 * 5);
+    // Chromium users cannot currently change the default quota
 }
 
 #if ENABLE(OFFLINE_WEB_APPLICATIONS)
diff --git a/WebKit/chromium/src/DatabaseObserver.cpp b/WebKit/chromium/src/DatabaseObserver.cpp
new file mode 100644 (file)
index 0000000..54e93e1
--- /dev/null
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (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 "DatabaseObserver.h"
+
+#include "Database.h"
+#include "WebDatabase.h"
+#include "WebDatabaseObserver.h"
+
+using namespace WebKit;
+
+namespace WebCore {
+
+void DatabaseObserver::databaseOpened(Database* database)
+{
+    ASSERT(isMainThread());
+    WebDatabase::observer()->databaseOpened(WebDatabase(database));
+}
+
+void DatabaseObserver::databaseModified(Database* database)
+{
+    ASSERT(isMainThread());
+    WebDatabase::observer()->databaseModified(WebDatabase(database));
+}
+
+void DatabaseObserver::databaseClosed(Database* database)
+{
+    ASSERT(isMainThread());
+    WebDatabase::observer()->databaseClosed(WebDatabase(database));
+}
+
+} // namespace WebCore
index d702eafd4bca46a1623ec4e900263651438d8129..2cd36b6a173cff94b857e5a54bceb387ebeb42f1 100644 (file)
@@ -35,6 +35,7 @@
 #include "DatabaseThread.h"
 #include "Document.h"
 #include "KURL.h"
+#include "QuotaTracker.h"
 #include "SecurityOrigin.h"
 #include "WebDatabaseObserver.h"
 #include "WebString.h"
@@ -65,37 +66,26 @@ void WebDatabase::assign(const WebDatabase& other)
 
 WebString WebDatabase::name() const
 {
-    if (m_private)
-        return m_private->stringIdentifier();
-
-    return WebString::fromUTF8("null");
+    ASSERT(m_private);
+    return m_private->stringIdentifier();
 }
 
 WebString WebDatabase::displayName() const
 {
-// FIXME: add the Database::displayName() method.
-//     if (m_private)
-//         return m_private->displayName();
-
-    return WebString::fromUTF8("null");
+    ASSERT(m_private);
+    return m_private->displayName();
 }
 
 unsigned long WebDatabase::estimatedSize() const
 {
-// FIXME: add the Database::estimatedSize() method.
-//    if (m_private)
-//        return m_private->estimatedSize();
-
-    return -1;
+    ASSERT(m_private);
+    return m_private->estimatedSize();
 }
 
 WebSecurityOrigin WebDatabase::securityOrigin() const
 {
-// FIXME: add the Database::threadSafeSecurityOrigin() method.
-//     if (m_private)
-//         return WebSecurityOrigin(m_private->threadSafeSecurityOrigin());
-
-    return WebSecurityOrigin();
+    ASSERT(m_private);
+    return WebSecurityOrigin(m_private->securityOrigin());
 }
 
 void WebDatabase::setObserver(WebDatabaseObserver* observer)
@@ -112,9 +102,8 @@ void WebDatabase::updateDatabaseSize(
     const WebString& originIdentifier, const WebString& databaseName,
     unsigned long long databaseSize, unsigned long long spaceAvailable)
 {
-// FIXME: add the QuotaTracker class.
-//     WebCore::QuotaTracker::instance().updateDatabaseSize(
-//         originIdentifier, databaseName, databaseSize, spaceAvailable);
+    WebCore::QuotaTracker::instance().updateDatabaseSizeAndSpaceAvailableToOrigin(
+        originIdentifier, databaseName, databaseSize, spaceAvailable);
 }
 
 WebDatabase::WebDatabase(const WTF::PassRefPtr<Database>& database)
index 2adf3dbc1872461102236ae746f0086b21ed2983..3cf73642ae566a3e2b9f4ab2d864feaa3dc99ecd 100644 (file)
@@ -81,20 +81,14 @@ bool WebSecurityOrigin::isEmpty() const
 
 WebString WebSecurityOrigin::toString() const
 {
-    // FIXME: We should not support calling this method when m_private is null.
-    if (m_private)
-        return m_private->toString();
-
-    return WebString::fromUTF8("null");
+    ASSERT(m_private);
+    return m_private->toString();
 }
 
 WebString WebSecurityOrigin::databaseIdentifier()
 {
-    // FIXME: We should not support calling this method when m_private is null.
-    if (m_private)
-        return m_private->databaseIdentifier();
-
-    return WebString::fromUTF8("null");
+    ASSERT(m_private);
+    return m_private->databaseIdentifier();
 }
 
 WebSecurityOrigin::WebSecurityOrigin(const WTF::PassRefPtr<WebCore::SecurityOrigin>& origin)