summaryrefslogtreecommitdiffstats
path: root/webkit/port
diff options
context:
space:
mode:
authoraa@google.com <aa@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-09-04 21:46:35 +0000
committeraa@google.com <aa@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-09-04 21:46:35 +0000
commit3112de422e881a3f7770c55778605bb5aedd1ca9 (patch)
tree69a930cb653f0457112457b495c8e4f1a17ae8ff /webkit/port
parent4293995b8250b2acf3cd305f76a2ce8130d5bda3 (diff)
downloadchromium_src-3112de422e881a3f7770c55778605bb5aedd1ca9.zip
chromium_src-3112de422e881a3f7770c55778605bb5aedd1ca9.tar.gz
chromium_src-3112de422e881a3f7770c55778605bb5aedd1ca9.tar.bz2
gAdds the files that implement the HTML5 Database API to the
project. Also adds stubs for the integration with the renderer. Right now, the integration is done by just replacing two key cpp files: DatabaseTracker and OriginQuotaManager. Once this all gets up and running, I'll circle back and think about the changes necessary to WebCore to do a more elegant integration. Review URL: http://codereview.chromium.org/601 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@1737 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/port')
-rw-r--r--webkit/port/page/inspector/InspectorController.cpp21
-rw-r--r--webkit/port/storage/DatabaseTracker.cpp89
-rw-r--r--webkit/port/storage/OriginQuotaManager.cpp60
3 files changed, 170 insertions, 0 deletions
diff --git a/webkit/port/page/inspector/InspectorController.cpp b/webkit/port/page/inspector/InspectorController.cpp
index a34ad33..35c052f 100644
--- a/webkit/port/page/inspector/InspectorController.cpp
+++ b/webkit/port/page/inspector/InspectorController.cpp
@@ -89,10 +89,15 @@
#endif
#include <wtf/RefCounted.h>
+// TODO(aa): Implement database inspection and remove this macro.
+#define ENABLE_DATABASE_INSPECTION 0
+
#if ENABLE(DATABASE)
#include "Database.h"
+#if ENABLE_DATABASE_INSPECTION
#include "JSDatabase.h"
#endif
+#endif
#if USE(JAVASCRIPTCORE_BINDINGS)
using namespace KJS;
@@ -477,6 +482,7 @@ protected:
#if ENABLE(DATABASE)
struct InspectorDatabaseResource : public RefCounted<InspectorDatabaseResource> {
+#if ENABLE_DATABASE_INSPECTION
static PassRefPtr<InspectorDatabaseResource> create(Database* database, const String& domain, const String& name, const String& version)
{
// Apple changed the default refcount to 1: http://trac.webkit.org/changeset/30406
@@ -518,6 +524,7 @@ private:
, scriptObject(0)
{
}
+#endif
};
#endif
@@ -908,6 +915,7 @@ void InspectorController::search(Node* node, const String& target) {
#endif
#if ENABLE(DATABASE)
+#if ENABLE_DATABASE_INSPECTION
static JSValueRef databaseTableNames(JSContextRef ctx, JSObjectRef /*function*/, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
{
InspectorController* controller = reinterpret_cast<InspectorController*>(JSObjectGetPrivate(thisObject));
@@ -962,6 +970,7 @@ static JSValueRef databaseTableNames(JSContextRef ctx, JSObjectRef /*function*/,
return result;
}
#endif
+#endif
#if USE(JAVASCRIPTCORE_BINDINGS)
static JSValueRef inspectedWindow(JSContextRef ctx, JSObjectRef /*function*/, JSObjectRef thisObject, size_t /*argumentCount*/, const JSValueRef[] /*arguments[]*/, JSValueRef* /*exception*/)
@@ -1447,8 +1456,10 @@ void InspectorController::windowScriptObjectAvailable()
{ "detach", detach, kJSPropertyAttributeNone },
{ "search", search, kJSPropertyAttributeNone },
#if ENABLE(DATABASE)
+#if ENABLE_DATABASE_INSPECTION
{ "databaseTableNames", databaseTableNames, kJSPropertyAttributeNone },
#endif
+#endif
{ "inspectedWindow", inspectedWindow, kJSPropertyAttributeNone },
{ "localizedStringsURL", localizedStrings, kJSPropertyAttributeNone },
{ "platform", platform, kJSPropertyAttributeNone },
@@ -2193,10 +2204,12 @@ void InspectorController::populateScriptObjects()
addScriptConsoleMessage(m_consoleMessages[i]);
#if ENABLE(DATABASE)
+#if ENABLE_DATABASE_INSPECTION
DatabaseResourcesSet::iterator databasesEnd = m_databaseResources.end();
for (DatabaseResourcesSet::iterator it = m_databaseResources.begin(); it != databasesEnd; ++it)
addDatabaseScriptResource((*it).get());
#endif
+#endif
}
#elif USE(V8_BINDING)
void InspectorController::populateScriptObjects()
@@ -2212,6 +2225,7 @@ void InspectorController::populateScriptObjects()
#endif
#if ENABLE(DATABASE)
+#if ENABLE_DATABASE_INSPECTION
JSObjectRef InspectorController::addDatabaseScriptResource(InspectorDatabaseResource* resource)
{
ASSERT_ARG(resource, resource);
@@ -2306,6 +2320,7 @@ void InspectorController::removeDatabaseScriptResource(InspectorDatabaseResource
HANDLE_EXCEPTION(exception);
}
#endif
+#endif
#if USE(JAVASCRIPTCORE_BINDINGS)
void InspectorController::addScriptConsoleMessage(const ConsoleMessage* message)
@@ -2434,12 +2449,14 @@ void InspectorController::resetScriptObjects()
}
#if ENABLE(DATABASE)
+#if ENABLE_DATABASE_INSPECTION
DatabaseResourcesSet::iterator databasesEnd = m_databaseResources.end();
for (DatabaseResourcesSet::iterator it = m_databaseResources.begin(); it != databasesEnd; ++it) {
InspectorDatabaseResource* resource = (*it).get();
resource->setScriptObject(0, 0);
}
#endif
+#endif
#if USE(JAVASCRIPTCORE_BINDINGS)
callSimpleFunction(m_scriptContext, m_scriptObject, "reset");
@@ -2486,8 +2503,10 @@ void InspectorController::didCommitLoad(DocumentLoader* loader)
m_consoleMessages.clear();
#if ENABLE(DATABASE)
+#if ENABLE_DATABASE_INSPECTION
m_databaseResources.clear();
#endif
+#endif
if (windowVisible()) {
resetScriptObjects();
@@ -2729,6 +2748,7 @@ void InspectorController::resourceRetrievedByXMLHttpRequest(unsigned long identi
#if ENABLE(DATABASE)
void InspectorController::didOpenDatabase(Database* database, const String& domain, const String& name, const String& version)
{
+#if ENABLE_DATABASE_INSPECTION
if (!enabled())
return;
@@ -2738,6 +2758,7 @@ void InspectorController::didOpenDatabase(Database* database, const String& doma
if (windowVisible())
addDatabaseScriptResource(resource.get());
+#endif
}
#endif
diff --git a/webkit/port/storage/DatabaseTracker.cpp b/webkit/port/storage/DatabaseTracker.cpp
new file mode 100644
index 0000000..e4e1ccb
--- /dev/null
+++ b/webkit/port/storage/DatabaseTracker.cpp
@@ -0,0 +1,89 @@
+/*
+ * 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
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. 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.
+ * 3. Neither the name of Apple Computer, Inc. ("Apple") 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 APPLE AND ITS 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 APPLE OR ITS 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 "DatabaseTracker.h"
+#include "OriginQuotaManager.h"
+
+using namespace std;
+
+namespace WebCore {
+
+OriginQuotaManager& DatabaseTracker::originQuotaManager()
+{
+ return *m_quotaManager;
+}
+
+DatabaseTracker& DatabaseTracker::tracker()
+{
+ static DatabaseTracker tracker;
+ return tracker;
+}
+
+DatabaseTracker::DatabaseTracker()
+ : m_client(0)
+ , m_proposedDatabase(0)
+#ifndef NDEBUG
+ , m_thread(currentThread())
+#endif
+{
+}
+
+bool DatabaseTracker::canEstablishDatabase(Document* document, const String& name, const String& displayName, unsigned long estimatedSize)
+{
+ return true;
+}
+
+String DatabaseTracker::fullPathForDatabase(SecurityOrigin* origin, const String& name, bool createIfNotExists)
+{
+ return "";
+}
+
+void DatabaseTracker::setDatabaseDetails(SecurityOrigin* origin, const String& name, const String& displayName, unsigned long estimatedSize)
+{
+}
+
+void DatabaseTracker::addOpenDatabase(Database* database)
+{
+}
+
+void DatabaseTracker::removeOpenDatabase(Database* database)
+{
+}
+
+unsigned long long DatabaseTracker::quotaForOrigin(SecurityOrigin* origin)
+{
+ return 0;
+}
+
+void DatabaseTracker::scheduleNotifyDatabaseChanged(SecurityOrigin* origin, const String& name)
+{
+}
+
+
+} // namespace WebCore
diff --git a/webkit/port/storage/OriginQuotaManager.cpp b/webkit/port/storage/OriginQuotaManager.cpp
new file mode 100644
index 0000000..d069bc1
--- /dev/null
+++ b/webkit/port/storage/OriginQuotaManager.cpp
@@ -0,0 +1,60 @@
+/*
+ * 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
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. 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.
+ * 3. Neither the name of Apple Computer, Inc. ("Apple") 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 APPLE AND ITS 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 APPLE OR ITS 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 "OriginQuotaManager.h"
+
+#include "Database.h"
+#include "OriginUsageRecord.h"
+
+namespace WebCore {
+
+OriginQuotaManager::OriginQuotaManager()
+{
+}
+
+void OriginQuotaManager::lock()
+{
+ m_usageRecordGuard.lock();
+}
+
+void OriginQuotaManager::unlock()
+{
+ m_usageRecordGuard.unlock();
+}
+
+void OriginQuotaManager::markDatabase(Database* database)
+{
+}
+
+unsigned long long OriginQuotaManager::diskUsage(SecurityOrigin* origin) const
+{
+ return 0;
+}
+
+
+}