diff options
author | Steve Block <steveblock@google.com> | 2010-08-04 11:41:34 +0100 |
---|---|---|
committer | Steve Block <steveblock@google.com> | 2010-08-09 12:04:44 +0100 |
commit | db14019a23d96bc8a444b6576a5da8bd1cfbc8b0 (patch) | |
tree | 9f793c5b0f5e1f2aca8247158920e2c4bf962bbf /WebCore/storage | |
parent | bf916837aa84f1e4b00e6ed6268516c2acd27545 (diff) | |
download | external_webkit-db14019a23d96bc8a444b6576a5da8bd1cfbc8b0.zip external_webkit-db14019a23d96bc8a444b6576a5da8bd1cfbc8b0.tar.gz external_webkit-db14019a23d96bc8a444b6576a5da8bd1cfbc8b0.tar.bz2 |
Merge WebKit at r64523 : Initial merge by git.
Change-Id: Ibb796c6802e757b1d9b40f58205cfbe4da95fcd4
Diffstat (limited to 'WebCore/storage')
55 files changed, 1220 insertions, 195 deletions
diff --git a/WebCore/storage/AbstractDatabase.cpp b/WebCore/storage/AbstractDatabase.cpp index bcc5d06..7827ec8 100644 --- a/WebCore/storage/AbstractDatabase.cpp +++ b/WebCore/storage/AbstractDatabase.cpp @@ -474,6 +474,17 @@ void AbstractDatabase::incrementalVacuumIfNeeded() m_sqliteDatabase.runIncrementalVacuumCommand(); } +void AbstractDatabase::interrupt() +{ + m_sqliteDatabase.interrupt(); +} + +bool AbstractDatabase::isInterrupted() +{ + MutexLocker locker(m_sqliteDatabase.databaseMutex()); + return m_sqliteDatabase.isInterrupted(); +} + } // namespace WebCore #endif // ENABLE(DATABASE) diff --git a/WebCore/storage/AbstractDatabase.h b/WebCore/storage/AbstractDatabase.h index e302909..3d8d363 100644 --- a/WebCore/storage/AbstractDatabase.h +++ b/WebCore/storage/AbstractDatabase.h @@ -68,6 +68,8 @@ public: unsigned long long maximumSize() const; void incrementalVacuumIfNeeded(); + void interrupt(); + bool isInterrupted(); // FIXME: move all version-related methods to a DatabaseVersionTracker class bool versionMatchesExpected() const; diff --git a/WebCore/storage/DOMFileSystem.cpp b/WebCore/storage/DOMFileSystem.cpp new file mode 100644 index 0000000..19c75fc --- /dev/null +++ b/WebCore/storage/DOMFileSystem.cpp @@ -0,0 +1,53 @@ +/* + * Copyright (C) 2010 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 "DOMFileSystem.h" + +#if ENABLE(FILE_SYSTEM) + +#include "Entry.h" + +namespace WebCore { + +DOMFileSystem::DOMFileSystem(const String& name, const String& rootPath) + : m_rootPath(rootPath) + , m_name(name) +{ +} + +PassRefPtr<Entry> DOMFileSystem::root() +{ + return Entry::create(this, "/"); +} + +} // namespace + +#endif // ENABLE(FILE_SYSTEM) diff --git a/WebCore/storage/DOMFileSystem.h b/WebCore/storage/DOMFileSystem.h new file mode 100644 index 0000000..454205d --- /dev/null +++ b/WebCore/storage/DOMFileSystem.h @@ -0,0 +1,65 @@ +/* + * Copyright (C) 2010 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. + */ + +#ifndef DOMFileSystem_h +#define DOMFileSystem_h + +#if ENABLE(FILE_SYSTEM) + +#include "PlatformString.h" +#include <wtf/PassRefPtr.h> +#include <wtf/RefCounted.h> + +namespace WebCore { + +class Entry; + +class DOMFileSystem : public RefCounted<DOMFileSystem> { +public: + static PassRefPtr<DOMFileSystem> create(const String& name, const String& rootPath) + { + return adoptRef(new DOMFileSystem(name, rootPath)); + } + + const String& name() const { return m_name; } + PassRefPtr<Entry> root(); + +private: + DOMFileSystem(const String& name, const String& rootPath); + + String m_rootPath; + String m_name; +}; + +} // namespace + +#endif // ENABLE(FILE_SYSTEM) + +#endif // DOMFileSystem_h diff --git a/WebCore/storage/DOMFileSystem.idl b/WebCore/storage/DOMFileSystem.idl new file mode 100644 index 0000000..0241c4a --- /dev/null +++ b/WebCore/storage/DOMFileSystem.idl @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2010 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. + */ + +module storage { + interface [ + Conditional=FILE_SYSTEM + ] DOMFileSystem { + readonly attribute DOMString name; + readonly attribute Entry root; + }; +} diff --git a/WebCore/storage/DatabaseTracker.cpp b/WebCore/storage/DatabaseTracker.cpp index de38ec3..0764db0 100644 --- a/WebCore/storage/DatabaseTracker.cpp +++ b/WebCore/storage/DatabaseTracker.cpp @@ -235,6 +235,35 @@ void DatabaseTracker::databaseChanged(AbstractDatabase* database) originQuotaManager().markDatabase(database); } +void DatabaseTracker::interruptAllDatabasesForContext(const ScriptExecutionContext* context) +{ + Vector<RefPtr<AbstractDatabase> > openDatabases; + { + MutexLocker openDatabaseMapLock(m_openDatabaseMapGuard); + + if (!m_openDatabaseMap) + return; + + DatabaseNameMap* nameMap = m_openDatabaseMap->get(context->securityOrigin()); + if (!nameMap) + return; + + DatabaseNameMap::const_iterator dbNameMapEndIt = nameMap->end(); + for (DatabaseNameMap::const_iterator dbNameMapIt = nameMap->begin(); dbNameMapIt != dbNameMapEndIt; ++dbNameMapIt) { + DatabaseSet* databaseSet = dbNameMapIt->second; + DatabaseSet::const_iterator dbSetEndIt = databaseSet->end(); + for (DatabaseSet::const_iterator dbSetIt = databaseSet->begin(); dbSetIt != dbSetEndIt; ++dbSetIt) { + if ((*dbSetIt)->scriptExecutionContext() == context) + openDatabases.append(*dbSetIt); + } + } + } + + Vector<RefPtr<AbstractDatabase> >::const_iterator openDatabasesEndIt = openDatabases.end(); + for (Vector<RefPtr<AbstractDatabase> >::const_iterator openDatabasesIt = openDatabases.begin(); openDatabasesIt != openDatabasesEndIt; ++openDatabasesIt) + (*openDatabasesIt)->interrupt(); +} + String DatabaseTracker::originPath(SecurityOrigin* origin) const { return SQLiteFileSystem::appendDatabaseFileNameToPath(m_databaseDirectoryPath.threadsafeCopy(), origin->databaseIdentifier()); diff --git a/WebCore/storage/DatabaseTracker.h b/WebCore/storage/DatabaseTracker.h index 094ee66..1557f0a 100644 --- a/WebCore/storage/DatabaseTracker.h +++ b/WebCore/storage/DatabaseTracker.h @@ -78,6 +78,8 @@ public: unsigned long long getMaxSizeForDatabase(const AbstractDatabase*); void databaseChanged(AbstractDatabase*); + void interruptAllDatabasesForContext(const ScriptExecutionContext*); + private: DatabaseTracker(const String& databasePath); diff --git a/WebCore/storage/Entry.cpp b/WebCore/storage/Entry.cpp new file mode 100644 index 0000000..b882297 --- /dev/null +++ b/WebCore/storage/Entry.cpp @@ -0,0 +1,88 @@ +/* + * Copyright (C) 2010 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 "Entry.h" + +#if ENABLE(FILE_SYSTEM) + +#include "DOMFileSystem.h" +#include "EntryCallback.h" +#include "ErrorCallback.h" +#include "MetadataCallback.h" +#include "VoidCallback.h" + +namespace WebCore { + +Entry::Entry(PassRefPtr<DOMFileSystem> fileSystem, const String& fullPath, bool isDirectory) + : m_fileSystem(fileSystem) + , m_fullPath(fullPath) + , m_isDirectory(isDirectory) +{ + int index = fullPath.reverseFind("/"); + if (index != -1) + m_name = fullPath.substring(index); + else + m_name = fullPath; +} + +void Entry::getMetadata(ScriptExecutionContext*, PassRefPtr<MetadataCallback>, PassRefPtr<ErrorCallback>) +{ + // FIXME: to be implemented. +} + +void Entry::moveTo(ScriptExecutionContext*, PassRefPtr<Entry>, const String&, PassRefPtr<EntryCallback>, PassRefPtr<ErrorCallback>) +{ + // FIXME: to be implemented. +} + +void Entry::copyTo(ScriptExecutionContext*, PassRefPtr<Entry>, const String&, PassRefPtr<EntryCallback>, PassRefPtr<ErrorCallback>) +{ + // FIXME: to be implemented. +} + +void Entry::remove(ScriptExecutionContext*, PassRefPtr<VoidCallback>, PassRefPtr<ErrorCallback>) +{ + // FIXME: to be implemented. +} + +void Entry::getParent(ScriptExecutionContext*, PassRefPtr<EntryCallback>, PassRefPtr<ErrorCallback>) +{ + // FIXME: to be implemented. +} + +String Entry::toURI(const String&) +{ + // FIXME: to be implemented. + return String(); +} + +} // namespace WebCore + +#endif // ENABLE(FILE_SYSTEM) diff --git a/WebCore/storage/Entry.h b/WebCore/storage/Entry.h new file mode 100644 index 0000000..1cabe58 --- /dev/null +++ b/WebCore/storage/Entry.h @@ -0,0 +1,87 @@ +/* + * Copyright (C) 2010 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. + */ + +#ifndef Entry_h +#define Entry_h + +#if ENABLE(FILE_SYSTEM) + +#include "DOMFileSystem.h" +#include <wtf/PassRefPtr.h> +#include <wtf/RefCounted.h> + +namespace WebCore { + +class EntryCallback; +class ErrorCallback; +class MetadataCallback; +class ScriptExecutionContext; +class VoidCallback; + +class Entry : public RefCounted<Entry> { +public: + static PassRefPtr<Entry> create(PassRefPtr<DOMFileSystem> fileSystem, const String& fullPath, bool isDirectory = false) + { + return adoptRef(new Entry(fileSystem, fullPath, isDirectory)); + } + + virtual ~Entry() { } + + virtual bool isFile() const { return !m_isDirectory; } + virtual bool isDirectory() const { return m_isDirectory; } + + const String& fullPath() const { return m_fullPath; } + const String& name() const { return m_name; } + + DOMFileSystem* filesystem() const { return m_fileSystem.get(); } + + virtual void getMetadata(ScriptExecutionContext*, PassRefPtr<MetadataCallback> successCallback = 0, PassRefPtr<ErrorCallback> errorCallback = 0); + + virtual void moveTo(ScriptExecutionContext*, PassRefPtr<Entry> parent, const String& name = String(), PassRefPtr<EntryCallback> successCallback = 0, PassRefPtr<ErrorCallback> errorCallback = 0); + virtual void copyTo(ScriptExecutionContext*, PassRefPtr<Entry> parent, const String& name = String(), PassRefPtr<EntryCallback> successCallback = 0, PassRefPtr<ErrorCallback> errorCallback = 0); + virtual void remove(ScriptExecutionContext*, PassRefPtr<VoidCallback> successCallback = 0, PassRefPtr<ErrorCallback> errorCallback = 0); + virtual void getParent(ScriptExecutionContext*, PassRefPtr<EntryCallback> successCallback = 0, PassRefPtr<ErrorCallback> errorCallback = 0); + + virtual String toURI(const String& mimeType = String()); + +protected: + Entry(PassRefPtr<DOMFileSystem> fileSystem, const String& fullPath, bool isDirectory); + + RefPtr<DOMFileSystem> m_fileSystem; + String m_fullPath; // virtual path + String m_name; + bool m_isDirectory; +}; + +} // namespace WebCore + +#endif // ENABLE(FILE_SYSTEM) + +#endif // Entry_h diff --git a/WebCore/storage/Entry.idl b/WebCore/storage/Entry.idl new file mode 100644 index 0000000..972751e --- /dev/null +++ b/WebCore/storage/Entry.idl @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2010 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. + */ + +module storage { + interface [ + Conditional=FILE_SYSTEM + ] Entry { + readonly attribute boolean isFile; + readonly attribute boolean isDirectory; + readonly attribute DOMString name; + readonly attribute DOMString fullPath; + readonly attribute DOMFileSystem filesystem; + + [CallWith=ScriptExecutionContext] void moveTo(in Entry parent, in [Optional] DOMString name, in [Optional, Callback] EntryCallback successCallback, in [Optional, Callback] ErrorCallback errorCallback); + [CallWith=ScriptExecutionContext] void copyTo(in Entry parent, in [Optional] DOMString name, in [Optional, Callback] EntryCallback successCallback, in [Optional, Callback] ErrorCallback errorCallback); + DOMString toURI(in [Optional] DOMString mimeType); + [CallWith=ScriptExecutionContext] void remove(in [Optional, Callback] VoidCallback successCallback, in [Optional, Callback] ErrorCallback errorCallback); + [CallWith=ScriptExecutionContext] void getParent(in [Optional, Callback] EntryCallback successCallback, in [Optional, Callback] ErrorCallback errorCallback); + }; +} diff --git a/WebCore/storage/EntryCallback.h b/WebCore/storage/EntryCallback.h new file mode 100644 index 0000000..58aa34a --- /dev/null +++ b/WebCore/storage/EntryCallback.h @@ -0,0 +1,53 @@ +/* + * Copyright (C) 2010 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. + */ + +#ifndef EntryCallback_h +#define EntryCallback_h + +#if ENABLE(FILE_SYSTEM) + +#include <wtf/RefCounted.h> + +namespace WebCore { + +class Entry; +class ScriptExecutionContext; + +class EntryCallback : public RefCounted<EntryCallback> { +public: + virtual ~EntryCallback() { } + virtual bool handleEvent(ScriptExecutionContext*, Entry*) = 0; +}; + +} // namespace + +#endif // ENABLE(FILE_SYSTEM) + +#endif // EntryCallback_h diff --git a/WebCore/storage/EntryCallback.idl b/WebCore/storage/EntryCallback.idl new file mode 100644 index 0000000..bea3fd1 --- /dev/null +++ b/WebCore/storage/EntryCallback.idl @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2010 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. + */ + +module storage { + interface [ + Conditional=FILE_SYSTEM, + Callback + ] EntryCallback { + boolean handleEvent(in Entry entry); + }; +} diff --git a/WebCore/storage/ErrorCallback.h b/WebCore/storage/ErrorCallback.h new file mode 100644 index 0000000..8cddbc7 --- /dev/null +++ b/WebCore/storage/ErrorCallback.h @@ -0,0 +1,53 @@ +/* + * Copyright (C) 2010 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. + */ + +#ifndef ErrorCallback_h +#define ErrorCallback_h + +#if ENABLE(FILE_SYSTEM) + +#include <wtf/RefCounted.h> + +namespace WebCore { + +class FileError; +class ScriptExecutionContext; + +class ErrorCallback : public RefCounted<ErrorCallback> { +public: + virtual ~ErrorCallback() { } + virtual bool handleEvent(ScriptExecutionContext*, FileError*) = 0; +}; + +} // namespace + +#endif // ENABLE(FILE_SYSTEM) + +#endif // ErrorCallback_h diff --git a/WebCore/storage/ErrorCallback.idl b/WebCore/storage/ErrorCallback.idl new file mode 100644 index 0000000..fc7fa85 --- /dev/null +++ b/WebCore/storage/ErrorCallback.idl @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2010 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. + */ + +module storage { + interface [ + Conditional=FILE_SYSTEM, + Callback + ] ErrorCallback { + boolean handleEvent(in FileError error); + }; +} diff --git a/WebCore/storage/FileSystemCallback.h b/WebCore/storage/FileSystemCallback.h new file mode 100644 index 0000000..a3bf34d --- /dev/null +++ b/WebCore/storage/FileSystemCallback.h @@ -0,0 +1,53 @@ +/* + * Copyright (C) 2010 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. + */ + +#ifndef FileSystemCallback_h +#define FileSystemCallback_h + +#if ENABLE(FILE_SYSTEM) + +#include <wtf/RefCounted.h> + +namespace WebCore { + +class DOMFileSystem; +class ScriptExecutionContext; + +class FileSystemCallback : public RefCounted<FileSystemCallback> { +public: + virtual ~FileSystemCallback() { } + virtual bool handleEvent(ScriptExecutionContext*, DOMFileSystem*) = 0; +}; + +} // namespace + +#endif // ENABLE(FILE_SYSTEM) + +#endif // FileSystemCallback_h diff --git a/WebCore/storage/FileSystemCallback.idl b/WebCore/storage/FileSystemCallback.idl new file mode 100644 index 0000000..cf686ff --- /dev/null +++ b/WebCore/storage/FileSystemCallback.idl @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2010 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. + */ + +module storage { + interface [ + Conditional=FILE_SYSTEM, + Callback + ] FileSystemCallback { + boolean handleEvent(in DOMFileSystem fileSystem); + }; +} diff --git a/WebCore/storage/Flags.h b/WebCore/storage/Flags.h new file mode 100644 index 0000000..ffe3403 --- /dev/null +++ b/WebCore/storage/Flags.h @@ -0,0 +1,66 @@ +/* + * Copyright (C) 2010 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. + */ + +#ifndef Flags_h +#define Flags_h + +#if ENABLE(FILE_SYSTEM) + +#include <wtf/RefCounted.h> + +namespace WebCore { + +class Flags : public RefCounted<Flags> { +public: + static PassRefPtr<Flags> create(bool create = false, bool exclusive = false) + { + return adoptRef(new Flags(create, exclusive)); + } + + bool isCreate() const { return m_create; } + void setCreate(bool create) { m_create = create; } + bool isExclusive() const { return m_exclusive; } + void setExclusive(bool exclusive) { m_exclusive = exclusive; } + +private: + Flags(bool create, bool exclusive) + : m_create(create) + , m_exclusive(exclusive) + { + } + bool m_create; + bool m_exclusive; +}; + +} // namespace + +#endif // ENABLE(FILE_SYSTEM) + +#endif // Flags_h diff --git a/WebCore/storage/Flags.idl b/WebCore/storage/Flags.idl new file mode 100644 index 0000000..cfe73d2 --- /dev/null +++ b/WebCore/storage/Flags.idl @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2010 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. + */ + +module storage { + interface [ + Conditional=FILE_SYSTEM + ] Flags { + attribute boolean CREATE; + attribute boolean EXCLUSIVE; + }; +} diff --git a/WebCore/storage/IDBAny.cpp b/WebCore/storage/IDBAny.cpp index 9a18980..da0cb22 100644 --- a/WebCore/storage/IDBAny.cpp +++ b/WebCore/storage/IDBAny.cpp @@ -29,9 +29,9 @@ #if ENABLE(INDEXED_DATABASE) #include "IDBDatabaseRequest.h" -#include "IDBIndexRequest.h" +#include "IDBFactory.h" +#include "IDBIndex.h" #include "IDBObjectStoreRequest.h" -#include "IndexedDatabaseRequest.h" #include "SerializedScriptValue.h" namespace WebCore { @@ -56,10 +56,10 @@ PassRefPtr<IDBDatabaseRequest> IDBAny::idbDatabaseRequest() return m_idbDatabaseRequest; } -PassRefPtr<IDBIndexRequest> IDBAny::idbIndexRequest() +PassRefPtr<IDBIndex> IDBAny::idbIndex() { - ASSERT(m_type == IDBIndexRequestType); - return m_idbIndexRequest; + ASSERT(m_type == IDBIndexType); + return m_idbIndex; } PassRefPtr<IDBKey> IDBAny::idbKey() @@ -74,10 +74,10 @@ PassRefPtr<IDBObjectStoreRequest> IDBAny::idbObjectStoreRequest() return m_idbObjectStoreRequest; } -PassRefPtr<IndexedDatabaseRequest> IDBAny::indexedDatabaseRequest() +PassRefPtr<IDBFactory> IDBAny::idbFactory() { - ASSERT(m_type == IndexedDatabaseRequestType); - return m_indexedDatabaseRequest; + ASSERT(m_type == IDBFactoryType); + return m_idbFactory; } PassRefPtr<SerializedScriptValue> IDBAny::serializedScriptValue() @@ -99,11 +99,11 @@ void IDBAny::set(PassRefPtr<IDBDatabaseRequest> value) m_idbDatabaseRequest = value; } -void IDBAny::set(PassRefPtr<IDBIndexRequest> value) +void IDBAny::set(PassRefPtr<IDBIndex> value) { ASSERT(m_type == UndefinedType); m_type = IDBDatabaseRequestType; - m_idbIndexRequest = value; + m_idbIndex = value; } void IDBAny::set(PassRefPtr<IDBKey> value) @@ -120,11 +120,11 @@ void IDBAny::set(PassRefPtr<IDBObjectStoreRequest> value) m_idbObjectStoreRequest = value; } -void IDBAny::set(PassRefPtr<IndexedDatabaseRequest> value) +void IDBAny::set(PassRefPtr<IDBFactory> value) { ASSERT(m_type == UndefinedType); - m_type = IndexedDatabaseRequestType; - m_indexedDatabaseRequest = value; + m_type = IDBFactoryType; + m_idbFactory = value; } void IDBAny::set(PassRefPtr<SerializedScriptValue> value) diff --git a/WebCore/storage/IDBAny.h b/WebCore/storage/IDBAny.h index 77bba7c..a7859a1 100644 --- a/WebCore/storage/IDBAny.h +++ b/WebCore/storage/IDBAny.h @@ -35,10 +35,10 @@ namespace WebCore { class IDBDatabaseRequest; -class IDBIndexRequest; +class IDBIndex; class IDBKey; class IDBObjectStoreRequest; -class IndexedDatabaseRequest; +class IDBFactory; class SerializedScriptValue; class IDBAny : public RefCounted<IDBAny> { @@ -57,29 +57,29 @@ public: UndefinedType = 0, NullType, IDBDatabaseRequestType, - IDBIndexRequestType, + IDBFactoryType, + IDBIndexType, IDBKeyType, IDBObjectStoreRequestType, - IndexedDatabaseRequestType, SerializedScriptValueType }; Type type() const { return m_type; } // Use type() to figure out which one of these you're allowed to call. PassRefPtr<IDBDatabaseRequest> idbDatabaseRequest(); - PassRefPtr<IDBIndexRequest> idbIndexRequest(); + PassRefPtr<IDBFactory> idbFactory(); + PassRefPtr<IDBIndex> idbIndex(); PassRefPtr<IDBKey> idbKey(); PassRefPtr<IDBObjectStoreRequest> idbObjectStoreRequest(); - PassRefPtr<IndexedDatabaseRequest> indexedDatabaseRequest(); PassRefPtr<SerializedScriptValue> serializedScriptValue(); // Set can only be called once. void set(); // For "null". void set(PassRefPtr<IDBDatabaseRequest>); - void set(PassRefPtr<IDBIndexRequest>); + void set(PassRefPtr<IDBFactory>); + void set(PassRefPtr<IDBIndex>); void set(PassRefPtr<IDBKey>); void set(PassRefPtr<IDBObjectStoreRequest>); - void set(PassRefPtr<IndexedDatabaseRequest>); void set(PassRefPtr<SerializedScriptValue>); private: @@ -89,10 +89,10 @@ private: // Only one of the following should ever be in use at any given time. RefPtr<IDBDatabaseRequest> m_idbDatabaseRequest; - RefPtr<IDBIndexRequest> m_idbIndexRequest; + RefPtr<IDBFactory> m_idbFactory; + RefPtr<IDBIndex> m_idbIndex; RefPtr<IDBKey> m_idbKey; RefPtr<IDBObjectStoreRequest> m_idbObjectStoreRequest; - RefPtr<IndexedDatabaseRequest> m_indexedDatabaseRequest; RefPtr<SerializedScriptValue> m_serializedScriptValue; }; diff --git a/WebCore/storage/IDBCallbacks.h b/WebCore/storage/IDBCallbacks.h index 37fdc46..d79cdec 100644 --- a/WebCore/storage/IDBCallbacks.h +++ b/WebCore/storage/IDBCallbacks.h @@ -31,7 +31,7 @@ #include "IDBDatabase.h" #include "IDBDatabaseError.h" -#include "IDBIndex.h" +#include "IDBIndexBackendInterface.h" #include "IDBKey.h" #include "IDBObjectStore.h" #include "SerializedScriptValue.h" @@ -48,7 +48,7 @@ public: virtual void onError(PassRefPtr<IDBDatabaseError>) = 0; virtual void onSuccess() = 0; // For "null". virtual void onSuccess(PassRefPtr<IDBDatabase>) = 0; - virtual void onSuccess(PassRefPtr<IDBIndex>) = 0; + virtual void onSuccess(PassRefPtr<IDBIndexBackendInterface>) = 0; virtual void onSuccess(PassRefPtr<IDBKey>) = 0; virtual void onSuccess(PassRefPtr<IDBObjectStore>) = 0; virtual void onSuccess(PassRefPtr<SerializedScriptValue>) = 0; diff --git a/WebCore/storage/IDBDatabaseRequest.cpp b/WebCore/storage/IDBDatabaseRequest.cpp index fce2671..8a40e9e 100644 --- a/WebCore/storage/IDBDatabaseRequest.cpp +++ b/WebCore/storage/IDBDatabaseRequest.cpp @@ -27,9 +27,9 @@ #include "IDBDatabaseRequest.h" #include "IDBAny.h" +#include "IDBFactoryBackendInterface.h" #include "IDBObjectStoreRequest.h" #include "IDBRequest.h" -#include "IndexedDatabase.h" #include "ScriptExecutionContext.h" #if ENABLE(INDEXED_DATABASE) diff --git a/WebCore/storage/IndexedDatabaseRequest.cpp b/WebCore/storage/IDBFactory.cpp index c1c5515..d3a83a5 100644 --- a/WebCore/storage/IndexedDatabaseRequest.cpp +++ b/WebCore/storage/IDBFactory.cpp @@ -27,32 +27,33 @@ */ #include "config.h" -#include "IndexedDatabaseRequest.h" +#include "IDBFactory.h" +#include "DOMStringList.h" #include "Document.h" #include "ExceptionCode.h" #include "Frame.h" #include "IDBDatabase.h" +#include "IDBFactoryBackendInterface.h" #include "IDBKeyRange.h" #include "IDBRequest.h" -#include "IndexedDatabase.h" #if ENABLE(INDEXED_DATABASE) namespace WebCore { -IndexedDatabaseRequest::IndexedDatabaseRequest(IndexedDatabase* indexedDatabase) - : m_indexedDatabase(indexedDatabase) +IDBFactory::IDBFactory(IDBFactoryBackendInterface* factory) + : m_factoryBackend(factory) { // We pass a reference to this object before it can be adopted. relaxAdoptionRequirement(); } -IndexedDatabaseRequest::~IndexedDatabaseRequest() +IDBFactory::~IDBFactory() { } -PassRefPtr<IDBRequest> IndexedDatabaseRequest::open(ScriptExecutionContext* context, const String& name, const String& description) +PassRefPtr<IDBRequest> IDBFactory::open(ScriptExecutionContext* context, const String& name, const String& description) { if (!context->isDocument()) { // FIXME: make this work with workers. @@ -64,7 +65,7 @@ PassRefPtr<IDBRequest> IndexedDatabaseRequest::open(ScriptExecutionContext* cont return 0; RefPtr<IDBRequest> request = IDBRequest::create(document, IDBAny::create(this)); - m_indexedDatabase->open(name, description, request, document->securityOrigin(), document->frame()); + m_factoryBackend->open(name, description, request, document->securityOrigin(), document->frame()); return request; } diff --git a/WebCore/storage/IndexedDatabaseRequest.h b/WebCore/storage/IDBFactory.h index 57f8a78..61619b9 100644 --- a/WebCore/storage/IndexedDatabaseRequest.h +++ b/WebCore/storage/IDBFactory.h @@ -25,11 +25,12 @@ * (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 IndexedDatabaseRequest_h -#define IndexedDatabaseRequest_h +#ifndef IDBFactory_h +#define IDBFactory_h +#include "DOMStringList.h" #include "ExceptionCode.h" -#include "IndexedDatabase.h" +#include "IDBFactoryBackendInterface.h" #include "PlatformString.h" #include <wtf/PassRefPtr.h> #include <wtf/RefCounted.h> @@ -42,28 +43,28 @@ namespace WebCore { class IDBKey; class IDBKeyRange; class IDBRequest; -class IndexedDatabase; +class IDBFactoryBackendInterface; class ScriptExecutionContext; -class IndexedDatabaseRequest : public RefCounted<IndexedDatabaseRequest> { +class IDBFactory : public RefCounted<IDBFactory> { public: - static PassRefPtr<IndexedDatabaseRequest> create(IndexedDatabase* indexedDatabase) + static PassRefPtr<IDBFactory> create(IDBFactoryBackendInterface* factory) { - return adoptRef(new IndexedDatabaseRequest(indexedDatabase)); + return adoptRef(new IDBFactory(factory)); } - ~IndexedDatabaseRequest(); + ~IDBFactory(); PassRefPtr<IDBRequest> open(ScriptExecutionContext*, const String& name, const String& description); private: - IndexedDatabaseRequest(IndexedDatabase*); + IDBFactory(IDBFactoryBackendInterface*); - RefPtr<IndexedDatabase> m_indexedDatabase; + RefPtr<IDBFactoryBackendInterface> m_factoryBackend; }; } // namespace WebCore #endif -#endif // IndexedDatabaseRequest_h +#endif // IDBFactory_h diff --git a/WebCore/storage/IndexedDatabaseRequest.idl b/WebCore/storage/IDBFactory.idl index e6ee446..cd887f0 100644 --- a/WebCore/storage/IndexedDatabaseRequest.idl +++ b/WebCore/storage/IDBFactory.idl @@ -27,7 +27,7 @@ module storage { interface [ Conditional=INDEXED_DATABASE - ] IndexedDatabaseRequest { + ] IDBFactory { [CallWith=ScriptExecutionContext] IDBRequest open(in DOMString name, in DOMString description); }; diff --git a/WebCore/storage/IndexedDatabaseImpl.cpp b/WebCore/storage/IDBFactoryBackendImpl.cpp index e6af901..e965c3f 100644 --- a/WebCore/storage/IndexedDatabaseImpl.cpp +++ b/WebCore/storage/IDBFactoryBackendImpl.cpp @@ -27,8 +27,9 @@ */ #include "config.h" -#include "IndexedDatabaseImpl.h" +#include "IDBFactoryBackendImpl.h" +#include "DOMStringList.h" #include "IDBDatabaseImpl.h" #include "SecurityOrigin.h" #include <wtf/Threading.h> @@ -38,20 +39,20 @@ namespace WebCore { -PassRefPtr<IndexedDatabaseImpl> IndexedDatabaseImpl::create() +PassRefPtr<IDBFactoryBackendImpl> IDBFactoryBackendImpl::create() { - return adoptRef(new IndexedDatabaseImpl); + return adoptRef(new IDBFactoryBackendImpl); } -IndexedDatabaseImpl::IndexedDatabaseImpl() +IDBFactoryBackendImpl::IDBFactoryBackendImpl() { } -IndexedDatabaseImpl::~IndexedDatabaseImpl() +IDBFactoryBackendImpl::~IDBFactoryBackendImpl() { } -void IndexedDatabaseImpl::open(const String& name, const String& description, PassRefPtr<IDBCallbacks> callbacks, PassRefPtr<SecurityOrigin>, Frame*) +void IDBFactoryBackendImpl::open(const String& name, const String& description, PassRefPtr<IDBCallbacks> callbacks, PassRefPtr<SecurityOrigin>, Frame*) { RefPtr<IDBDatabase> database; IDBDatabaseMap::iterator it = m_databaseMap.find(name); diff --git a/WebCore/storage/IndexedDatabaseImpl.h b/WebCore/storage/IDBFactoryBackendImpl.h index b9520ee..bb28b6d 100644 --- a/WebCore/storage/IndexedDatabaseImpl.h +++ b/WebCore/storage/IDBFactoryBackendImpl.h @@ -25,10 +25,10 @@ * (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 IndexedDatabaseImpl_h -#define IndexedDatabaseImpl_h +#ifndef IDBFactoryBackendImpl_h +#define IDBFactoryBackendImpl_h -#include "IndexedDatabase.h" +#include "IDBFactoryBackendInterface.h" #include "StringHash.h" #include <wtf/HashMap.h> @@ -36,26 +36,28 @@ namespace WebCore { -class IndexedDatabaseImpl : public IndexedDatabase { +class DOMStringList; + +class IDBFactoryBackendImpl : public IDBFactoryBackendInterface { public: - static PassRefPtr<IndexedDatabaseImpl> create(); - virtual ~IndexedDatabaseImpl(); + static PassRefPtr<IDBFactoryBackendImpl> create(); + virtual ~IDBFactoryBackendImpl(); virtual void open(const String& name, const String& description, PassRefPtr<IDBCallbacks>, PassRefPtr<SecurityOrigin>, Frame*); private: - IndexedDatabaseImpl(); + IDBFactoryBackendImpl(); typedef HashMap<String, RefPtr<IDBDatabase> > IDBDatabaseMap; IDBDatabaseMap m_databaseMap; // We only create one instance of this class at a time. - static IndexedDatabaseImpl* indexedDatabaseImpl; + static IDBFactoryBackendImpl* idbFactoryBackendImpl; }; } // namespace WebCore #endif -#endif // IndexedDatabaseImpl_h +#endif // IDBFactoryBackendImpl_h diff --git a/WebCore/storage/IndexedDatabase.cpp b/WebCore/storage/IDBFactoryBackendInterface.cpp index a20974b..f1c0fb7 100644 --- a/WebCore/storage/IndexedDatabase.cpp +++ b/WebCore/storage/IDBFactoryBackendInterface.cpp @@ -26,9 +26,9 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "config.h" -#include "IndexedDatabase.h" +#include "IDBFactoryBackendInterface.h" -#include "IndexedDatabaseImpl.h" +#include "IDBFactoryBackendImpl.h" #if PLATFORM(CHROMIUM) #error "Chromium should not compile this file and instead define its own version of this factory that navigates the multi-process boundry." @@ -38,9 +38,9 @@ namespace WebCore { -PassRefPtr<IndexedDatabase> IndexedDatabase::create() +PassRefPtr<IDBFactoryBackendInterface> IDBFactoryBackendInterface::create() { - return IndexedDatabaseImpl::create(); + return IDBFactoryBackendImpl::create(); } } // namespace WebCore diff --git a/WebCore/storage/IndexedDatabase.h b/WebCore/storage/IDBFactoryBackendInterface.h index e6abf4a..ba18098 100644 --- a/WebCore/storage/IndexedDatabase.h +++ b/WebCore/storage/IDBFactoryBackendInterface.h @@ -25,8 +25,8 @@ * (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 IndexedDatabase_h -#define IndexedDatabase_h +#ifndef IDBFactoryBackendInterface_h +#define IDBFactoryBackendInterface_h #include "ExceptionCode.h" #include "IDBCallbacks.h" @@ -41,14 +41,14 @@ class Frame; class IDBDatabase; class SecurityOrigin; -// This class is shared by IndexedDatabaseRequest (async) and IndexedDatabaseSync (sync). -// This is implemented by IndexedDatabaseImpl and optionally others (in order to proxy +// This class is shared by IDBFactory (async) and IDBFactorySync (sync). +// This is implemented by IDBFactoryBackendImpl and optionally others (in order to proxy // calls across process barriers). All calls to these classes should be non-blocking and // trigger work on a background thread if necessary. -class IndexedDatabase : public ThreadSafeShared<IndexedDatabase> { +class IDBFactoryBackendInterface : public ThreadSafeShared<IDBFactoryBackendInterface> { public: - static PassRefPtr<IndexedDatabase> create(); - virtual ~IndexedDatabase() { } + static PassRefPtr<IDBFactoryBackendInterface> create(); + virtual ~IDBFactoryBackendInterface() { } virtual void open(const String& name, const String& description, PassRefPtr<IDBCallbacks>, PassRefPtr<SecurityOrigin>, Frame*) = 0; }; @@ -57,5 +57,5 @@ public: #endif -#endif // IndexedDatabase_h +#endif // IDBFactoryBackendInterface_h diff --git a/WebCore/storage/IDBIndexRequest.cpp b/WebCore/storage/IDBIndex.cpp index 30aee4b..62c1da8 100644 --- a/WebCore/storage/IDBIndexRequest.cpp +++ b/WebCore/storage/IDBIndex.cpp @@ -24,18 +24,18 @@ */ #include "config.h" -#include "IDBIndexRequest.h" +#include "IDBIndex.h" #if ENABLE(INDEXED_DATABASE) namespace WebCore { -IDBIndexRequest::IDBIndexRequest(PassRefPtr<IDBIndex> idbIndex) - : m_idbIndex(idbIndex) +IDBIndex::IDBIndex(PassRefPtr<IDBIndexBackendInterface> backend) + : m_backend(backend) { } -IDBIndexRequest::~IDBIndexRequest() +IDBIndex::~IDBIndex() { } diff --git a/WebCore/storage/IDBIndex.h b/WebCore/storage/IDBIndex.h index d0e8cab..5e716b7 100644 --- a/WebCore/storage/IDBIndex.h +++ b/WebCore/storage/IDBIndex.h @@ -26,21 +26,31 @@ #ifndef IDBIndex_h #define IDBIndex_h +#include "IDBIndexBackendInterface.h" #include "PlatformString.h" -#include <wtf/PassRefPtr.h> -#include <wtf/Threading.h> +#include <wtf/Forward.h> #if ENABLE(INDEXED_DATABASE) namespace WebCore { -class IDBIndex : public ThreadSafeShared<IDBIndex> { +class IDBIndex : public RefCounted<IDBIndex> { public: - virtual ~IDBIndex() { } + static PassRefPtr<IDBIndex> create(PassRefPtr<IDBIndexBackendInterface> backend) + { + return adoptRef(new IDBIndex(backend)); + } + ~IDBIndex(); - virtual String name() = 0; - virtual String keyPath() = 0; - virtual bool unique() = 0; + // Implement the IDL + String name() const { return m_backend->name(); } + String keyPath() const { return m_backend->keyPath(); } + bool unique() const { return m_backend->unique(); } + +private: + IDBIndex(PassRefPtr<IDBIndexBackendInterface>); + + RefPtr<IDBIndexBackendInterface> m_backend; }; } // namespace WebCore diff --git a/WebCore/storage/IDBIndexRequest.idl b/WebCore/storage/IDBIndex.idl index ad35f52..e796b03 100644 --- a/WebCore/storage/IDBIndexRequest.idl +++ b/WebCore/storage/IDBIndex.idl @@ -27,7 +27,7 @@ module storage { interface [ Conditional=INDEXED_DATABASE - ] IDBIndexRequest { + ] IDBIndex { // FIXME: Complete this file. readonly attribute DOMString name; diff --git a/WebCore/storage/IDBIndexImpl.cpp b/WebCore/storage/IDBIndexBackendImpl.cpp index f78939a..406e37f 100644 --- a/WebCore/storage/IDBIndexImpl.cpp +++ b/WebCore/storage/IDBIndexBackendImpl.cpp @@ -24,20 +24,20 @@ */ #include "config.h" -#include "IDBIndexImpl.h" +#include "IDBIndexBackendImpl.h" #if ENABLE(INDEXED_DATABASE) namespace WebCore { -IDBIndexImpl::IDBIndexImpl(const String& name, const String& keyPath, bool unique) +IDBIndexBackendImpl::IDBIndexBackendImpl(const String& name, const String& keyPath, bool unique) : m_name(name) , m_keyPath(keyPath) , m_unique(unique) { } -IDBIndexImpl::~IDBIndexImpl() +IDBIndexBackendImpl::~IDBIndexBackendImpl() { } diff --git a/WebCore/storage/IDBIndexImpl.h b/WebCore/storage/IDBIndexBackendImpl.h index b0034d5..ca3f01e 100644 --- a/WebCore/storage/IDBIndexImpl.h +++ b/WebCore/storage/IDBIndexBackendImpl.h @@ -23,30 +23,30 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef IDBIndexImpl_h -#define IDBIndexImpl_h +#ifndef IDBIndexBackendImpl_h +#define IDBIndexBackendImpl_h -#include "IDBIndex.h" +#include "IDBIndexBackendInterface.h" #if ENABLE(INDEXED_DATABASE) namespace WebCore { -class IDBIndexImpl : public IDBIndex { +class IDBIndexBackendImpl : public IDBIndexBackendInterface { public: - static PassRefPtr<IDBIndex> create(const String& name, const String& keyPath, bool unique) + static PassRefPtr<IDBIndexBackendImpl> create(const String& name, const String& keyPath, bool unique) { - return adoptRef(new IDBIndexImpl(name, keyPath, unique)); + return adoptRef(new IDBIndexBackendImpl(name, keyPath, unique)); } - virtual ~IDBIndexImpl(); + virtual ~IDBIndexBackendImpl(); - // Implements IDBIndex + // Implements IDBIndexBackendInterface. virtual String name() { return m_name; } virtual String keyPath() { return m_keyPath; } virtual bool unique() { return m_unique; } private: - IDBIndexImpl(const String& name, const String& keyPath, bool unique); + IDBIndexBackendImpl(const String& name, const String& keyPath, bool unique); String m_name; String m_keyPath; @@ -57,4 +57,4 @@ private: #endif -#endif // IDBIndexImpl_h +#endif // IDBIndexBackendImpl_h diff --git a/WebCore/storage/IDBIndexBackendInterface.h b/WebCore/storage/IDBIndexBackendInterface.h new file mode 100644 index 0000000..0d1ea34 --- /dev/null +++ b/WebCore/storage/IDBIndexBackendInterface.h @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2010 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: + * + * 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. + * + * 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. + */ + +#ifndef IDBIndexBackendInterface_h +#define IDBIndexBackendInterface_h + +#include "PlatformString.h" +#include <wtf/Forward.h> + +#if ENABLE(INDEXED_DATABASE) + +namespace WebCore { + +class IDBIndexBackendInterface : public ThreadSafeShared<IDBIndexBackendInterface> { +public: + virtual ~IDBIndexBackendInterface() { } + + virtual String name() = 0; + virtual String keyPath() = 0; + virtual bool unique() = 0; +}; + +} // namespace WebCore + +#endif + +#endif // IDBIndexBackendInterface_h diff --git a/WebCore/storage/IDBIndexRequest.h b/WebCore/storage/IDBIndexRequest.h deleted file mode 100644 index ce6fc57..0000000 --- a/WebCore/storage/IDBIndexRequest.h +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (C) 2010 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: - * - * 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. - * - * 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. - */ - -#ifndef IDBIndexRequest_h -#define IDBIndexRequest_h - -#include "IDBIndex.h" -#include "PlatformString.h" -#include <wtf/PassRefPtr.h> -#include <wtf/RefCounted.h> -#include <wtf/RefPtr.h> - -#if ENABLE(INDEXED_DATABASE) - -namespace WebCore { - -class IDBIndexRequest : public RefCounted<IDBIndexRequest> { -public: - static PassRefPtr<IDBIndexRequest> create(PassRefPtr<IDBIndex> idbIndex) - { - return adoptRef(new IDBIndexRequest(idbIndex)); - } - ~IDBIndexRequest(); - - // Implement the IDL - String name() const { return m_idbIndex->name(); } - String keyPath() const { return m_idbIndex->keyPath(); } - bool unique() const { return m_idbIndex->unique(); } - -private: - IDBIndexRequest(PassRefPtr<IDBIndex>); - - RefPtr<IDBIndex> m_idbIndex; -}; - -} // namespace WebCore - -#endif - -#endif // IDBIndexRequest_h diff --git a/WebCore/storage/IDBKeyRange.h b/WebCore/storage/IDBKeyRange.h index 9ce07af..5a426b7 100644 --- a/WebCore/storage/IDBKeyRange.h +++ b/WebCore/storage/IDBKeyRange.h @@ -49,6 +49,7 @@ public: { return adoptRef(new IDBKeyRange(left, right, flags)); } + ~IDBKeyRange() { } @@ -60,6 +61,7 @@ public: static PassRefPtr<IDBKeyRange> leftBound(PassRefPtr<IDBKey> bound, bool open = false); static PassRefPtr<IDBKeyRange> rightBound(PassRefPtr<IDBKey> bound, bool open = false); static PassRefPtr<IDBKeyRange> bound(PassRefPtr<IDBKey> left, PassRefPtr<IDBKey> right, bool openLeft = false, bool openRight = false); + private: IDBKeyRange(PassRefPtr<IDBKey> left, PassRefPtr<IDBKey> right, unsigned short flags); diff --git a/WebCore/storage/IDBObjectStore.h b/WebCore/storage/IDBObjectStore.h index e78e62a..4a53eb4 100644 --- a/WebCore/storage/IDBObjectStore.h +++ b/WebCore/storage/IDBObjectStore.h @@ -35,7 +35,7 @@ namespace WebCore { class DOMStringList; class IDBCallbacks; -class IDBIndex; +class IDBIndexBackendInterface; class IDBKey; class SerializedScriptValue; @@ -52,7 +52,7 @@ public: virtual void remove(PassRefPtr<IDBKey> key, PassRefPtr<IDBCallbacks>) = 0; virtual void createIndex(const String& name, const String& keyPath, bool unique, PassRefPtr<IDBCallbacks>) = 0; - virtual PassRefPtr<IDBIndex> index(const String& name) = 0; + virtual PassRefPtr<IDBIndexBackendInterface> index(const String& name) = 0; virtual void removeIndex(const String& name, PassRefPtr<IDBCallbacks>) = 0; }; diff --git a/WebCore/storage/IDBObjectStoreImpl.cpp b/WebCore/storage/IDBObjectStoreImpl.cpp index d678400..8c6444a 100755 --- a/WebCore/storage/IDBObjectStoreImpl.cpp +++ b/WebCore/storage/IDBObjectStoreImpl.cpp @@ -30,7 +30,7 @@ #include "IDBBindingUtilities.h" #include "IDBCallbacks.h" #include "IDBDatabaseException.h" -#include "IDBIndexImpl.h" +#include "IDBIndexBackendImpl.h" #include "IDBKeyTree.h" #if ENABLE(INDEXED_DATABASE) @@ -108,13 +108,13 @@ void IDBObjectStoreImpl::createIndex(const String& name, const String& keyPath, return; } - RefPtr<IDBIndex> index = IDBIndexImpl::create(name, keyPath, unique); + RefPtr<IDBIndexBackendInterface> index = IDBIndexBackendImpl::create(name, keyPath, unique); ASSERT(index->name() == name); m_indexes.set(name, index); callbacks->onSuccess(index.release()); } -PassRefPtr<IDBIndex> IDBObjectStoreImpl::index(const String& name) +PassRefPtr<IDBIndexBackendInterface> IDBObjectStoreImpl::index(const String& name) { return m_indexes.get(name); } diff --git a/WebCore/storage/IDBObjectStoreImpl.h b/WebCore/storage/IDBObjectStoreImpl.h index c4d2eb8..f2c2e03 100644 --- a/WebCore/storage/IDBObjectStoreImpl.h +++ b/WebCore/storage/IDBObjectStoreImpl.h @@ -53,7 +53,7 @@ public: void remove(PassRefPtr<IDBKey> key, PassRefPtr<IDBCallbacks>); void createIndex(const String& name, const String& keyPath, bool unique, PassRefPtr<IDBCallbacks>); - PassRefPtr<IDBIndex> index(const String& name); + PassRefPtr<IDBIndexBackendInterface> index(const String& name); void removeIndex(const String& name, PassRefPtr<IDBCallbacks>); private: @@ -63,7 +63,7 @@ private: String m_keyPath; bool m_autoIncrement; - typedef HashMap<String, RefPtr<IDBIndex> > IndexMap; + typedef HashMap<String, RefPtr<IDBIndexBackendInterface> > IndexMap; IndexMap m_indexes; typedef IDBKeyTree<SerializedScriptValue> Tree; diff --git a/WebCore/storage/IDBObjectStoreRequest.cpp b/WebCore/storage/IDBObjectStoreRequest.cpp index 3e095c1..0778214 100644 --- a/WebCore/storage/IDBObjectStoreRequest.cpp +++ b/WebCore/storage/IDBObjectStoreRequest.cpp @@ -28,7 +28,7 @@ #include "DOMStringList.h" #include "IDBAny.h" -#include "IDBIndexRequest.h" +#include "IDBIndex.h" #include "IDBKey.h" #include "SerializedScriptValue.h" #include <wtf/UnusedParam.h> @@ -94,11 +94,11 @@ PassRefPtr<IDBRequest> IDBObjectStoreRequest::createIndex(ScriptExecutionContext return request; } -PassRefPtr<IDBIndexRequest> IDBObjectStoreRequest::index(const String& name) +PassRefPtr<IDBIndex> IDBObjectStoreRequest::index(const String& name) { - RefPtr<IDBIndex> index = m_objectStore->index(name); + RefPtr<IDBIndexBackendInterface> index = m_objectStore->index(name); ASSERT(index); // FIXME: If this is null, we should raise a NOT_FOUND_ERR. - return IDBIndexRequest::create(index.release()); + return IDBIndex::create(index.release()); } PassRefPtr<IDBRequest> IDBObjectStoreRequest::removeIndex(ScriptExecutionContext* context, const String& name) diff --git a/WebCore/storage/IDBObjectStoreRequest.h b/WebCore/storage/IDBObjectStoreRequest.h index 86f64d6..bfd01f0 100644 --- a/WebCore/storage/IDBObjectStoreRequest.h +++ b/WebCore/storage/IDBObjectStoreRequest.h @@ -61,7 +61,7 @@ public: PassRefPtr<IDBRequest> remove(ScriptExecutionContext*, PassRefPtr<IDBKey> key); PassRefPtr<IDBRequest> createIndex(ScriptExecutionContext*, const String& name, const String& keyPath, bool unique = false); - PassRefPtr<IDBIndexRequest> index(const String& name); + PassRefPtr<IDBIndex> index(const String& name); PassRefPtr<IDBRequest> removeIndex(ScriptExecutionContext*, const String& name); private: diff --git a/WebCore/storage/IDBObjectStoreRequest.idl b/WebCore/storage/IDBObjectStoreRequest.idl index a816b73..6db6ad8 100644 --- a/WebCore/storage/IDBObjectStoreRequest.idl +++ b/WebCore/storage/IDBObjectStoreRequest.idl @@ -38,7 +38,7 @@ module storage { // FIXME: write openCursor [CallWith=ScriptExecutionContext] IDBRequest createIndex(in DOMString name, in [ConvertNullToNullString] DOMString keyPath, in [Optional] boolean unique); // FIXME: This needs to raise an IDBDatabaseException on errors. - IDBIndexRequest index(in DOMString name); + IDBIndex index(in DOMString name); [CallWith=ScriptExecutionContext] IDBRequest removeIndex(in DOMString name); readonly attribute DOMString name; diff --git a/WebCore/storage/IDBRequest.cpp b/WebCore/storage/IDBRequest.cpp index 78dd15a..b836cc3 100644 --- a/WebCore/storage/IDBRequest.cpp +++ b/WebCore/storage/IDBRequest.cpp @@ -36,7 +36,7 @@ #include "EventListener.h" #include "EventNames.h" #include "IDBDatabaseRequest.h" -#include "IDBIndexRequest.h" +#include "IDBIndex.h" #include "IDBErrorEvent.h" #include "IDBObjectStoreRequest.h" #include "IDBSuccessEvent.h" @@ -79,10 +79,10 @@ void IDBRequest::onSuccess(PassRefPtr<IDBDatabase> idbDatabase) m_result->set(IDBDatabaseRequest::create(idbDatabase)); } -void IDBRequest::onSuccess(PassRefPtr<IDBIndex> idbIndex) +void IDBRequest::onSuccess(PassRefPtr<IDBIndexBackendInterface> backend) { onEventCommon(); - m_result->set(IDBIndexRequest::create(idbIndex)); + m_result->set(IDBIndex::create(backend)); } void IDBRequest::onSuccess(PassRefPtr<IDBKey> idbKey) diff --git a/WebCore/storage/IDBRequest.h b/WebCore/storage/IDBRequest.h index c763d96..39f6a51 100644 --- a/WebCore/storage/IDBRequest.h +++ b/WebCore/storage/IDBRequest.h @@ -65,7 +65,7 @@ public: virtual void onError(PassRefPtr<IDBDatabaseError>); virtual void onSuccess(); // For "null". virtual void onSuccess(PassRefPtr<IDBDatabase>); - virtual void onSuccess(PassRefPtr<IDBIndex>); + virtual void onSuccess(PassRefPtr<IDBIndexBackendInterface>); virtual void onSuccess(PassRefPtr<IDBKey>); virtual void onSuccess(PassRefPtr<IDBObjectStore>); virtual void onSuccess(PassRefPtr<SerializedScriptValue>); diff --git a/WebCore/storage/Metadata.h b/WebCore/storage/Metadata.h new file mode 100644 index 0000000..0b06f90 --- /dev/null +++ b/WebCore/storage/Metadata.h @@ -0,0 +1,61 @@ +/* + * Copyright (C) 2010 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. + */ + +#ifndef Metadata_h +#define Metadata_h + +#if ENABLE(FILE_SYSTEM) + +#include <wtf/RefCounted.h> + +namespace WebCore { + +class Metadata : public RefCounted<Metadata> { +public: + static PassRefPtr<Metadata> create(double modificationTime) + { + return adoptRef(new Metadata(modificationTime)); + } + double modificationTime() const { return m_modificationTime; } + +private: + Metadata(double modificationTime) + : m_modificationTime(modificationTime) + { + } + + double m_modificationTime; +}; + +} // namespace + +#endif // ENABLE(FILE_SYSTEM) + +#endif // Metadata_h diff --git a/WebCore/storage/Metadata.idl b/WebCore/storage/Metadata.idl new file mode 100644 index 0000000..711fae8 --- /dev/null +++ b/WebCore/storage/Metadata.idl @@ -0,0 +1,37 @@ +/* + * Copyright (C) 2010 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. + */ + +module storage { + interface [ + Conditional=FILE_SYSTEM + ] Metadata { + readonly attribute double modificationTime; + }; +} diff --git a/WebCore/storage/MetadataCallback.h b/WebCore/storage/MetadataCallback.h new file mode 100644 index 0000000..96e4c91 --- /dev/null +++ b/WebCore/storage/MetadataCallback.h @@ -0,0 +1,53 @@ +/* + * Copyright (C) 2010 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. + */ + +#ifndef MetadataCallback_h +#define MetadataCallback_h + +#if ENABLE(FILE_SYSTEM) + +#include <wtf/RefCounted.h> + +namespace WebCore { + +class Metadata; +class ScriptExecutionContext; + +class MetadataCallback : public RefCounted<MetadataCallback> { +public: + virtual ~MetadataCallback() { } + virtual bool handleEvent(ScriptExecutionContext*, Metadata*) = 0; +}; + +} // namespace + +#endif // ENABLE(FILE_SYSTEM) + +#endif // MetadataCallback_h diff --git a/WebCore/storage/MetadataCallback.idl b/WebCore/storage/MetadataCallback.idl new file mode 100644 index 0000000..44ca180 --- /dev/null +++ b/WebCore/storage/MetadataCallback.idl @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2010 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. + */ + +module storage { + interface [ + Conditional=FILE_SYSTEM, + Callback + ] MetadataCallback { + boolean handleEvent(in Metadata metadata); + }; +} diff --git a/WebCore/storage/SQLStatement.cpp b/WebCore/storage/SQLStatement.cpp index 2d7d78e..9dd249a 100644 --- a/WebCore/storage/SQLStatement.cpp +++ b/WebCore/storage/SQLStatement.cpp @@ -78,7 +78,7 @@ bool SQLStatement::execute(Database* db) if (result != SQLResultOk) { LOG(StorageAPI, "Unable to verify correctness of statement %s - error %i (%s)", m_statement.ascii().data(), result, database->lastErrorMsg()); - m_error = SQLError::create(SQLError::SYNTAX_ERR, database->lastErrorMsg()); + m_error = SQLError::create(result == SQLResultInterrupt ? SQLError::DATABASE_ERR : SQLError::SYNTAX_ERR, database->lastErrorMsg()); return false; } @@ -86,7 +86,7 @@ bool SQLStatement::execute(Database* db) // If this is the case, they might be trying to do something fishy or malicious if (statement.bindParameterCount() != m_arguments.size()) { LOG(StorageAPI, "Bind parameter count doesn't match number of question marks"); - m_error = SQLError::create(SQLError::SYNTAX_ERR, "number of '?'s in statement string does not match argument count"); + m_error = SQLError::create(db->isInterrupted() ? SQLError::DATABASE_ERR : SQLError::SYNTAX_ERR, "number of '?'s in statement string does not match argument count"); return false; } diff --git a/WebCore/storage/SQLStatementSync.cpp b/WebCore/storage/SQLStatementSync.cpp index 7be3f50..e47919f 100644 --- a/WebCore/storage/SQLStatementSync.cpp +++ b/WebCore/storage/SQLStatementSync.cpp @@ -61,12 +61,12 @@ PassRefPtr<SQLResultSet> SQLStatementSync::execute(DatabaseSync* db, ExceptionCo SQLiteStatement statement(*database, m_statement); int result = statement.prepare(); if (result != SQLResultOk) { - ec = SQLException::SYNTAX_ERR; + ec = (result == SQLResultInterrupt ? SQLException::DATABASE_ERR : SQLException::SYNTAX_ERR); return 0; } if (statement.bindParameterCount() != m_arguments.size()) { - ec = SQLException::SYNTAX_ERR; + ec = (db->isInterrupted()? SQLException::DATABASE_ERR : SQLException::SYNTAX_ERR); return 0; } diff --git a/WebCore/storage/SQLTransaction.cpp b/WebCore/storage/SQLTransaction.cpp index e43d844..454ea63 100644 --- a/WebCore/storage/SQLTransaction.cpp +++ b/WebCore/storage/SQLTransaction.cpp @@ -146,17 +146,22 @@ const char* SQLTransaction::debugStepName(SQLTransaction::TransactionStepMethod } #endif -void SQLTransaction::checkAndHandleClosedDatabase() +void SQLTransaction::checkAndHandleClosedOrInterruptedDatabase() { - if (m_database->opened()) + if (m_database->opened() && !m_database->isInterrupted()) return; // If the database was stopped, don't do anything and cancel queued work - LOG(StorageAPI, "Database was stopped - cancelling work for this transaction"); + LOG(StorageAPI, "Database was stopped or interrupted - cancelling work for this transaction"); MutexLocker locker(m_statementMutex); m_statementQueue.clear(); m_nextStep = 0; + // Release the unneeded callbacks, to break reference cycles. + m_callback = 0; + m_successCallback = 0; + m_errorCallback = 0; + // The next steps should be executed only if we're on the DB thread. if (currentThread() != database()->scriptExecutionContext()->databaseThread()->getThreadID()) return; @@ -183,7 +188,7 @@ bool SQLTransaction::performNextStep() m_nextStep == &SQLTransaction::cleanupAfterSuccessCallback || m_nextStep == &SQLTransaction::cleanupAfterTransactionErrorCallback); - checkAndHandleClosedDatabase(); + checkAndHandleClosedOrInterruptedDatabase(); if (m_nextStep) (this->*m_nextStep)(); @@ -202,7 +207,7 @@ void SQLTransaction::performPendingCallback() m_nextStep == &SQLTransaction::deliverQuotaIncreaseCallback || m_nextStep == &SQLTransaction::deliverSuccessCallback); - checkAndHandleClosedDatabase(); + checkAndHandleClosedOrInterruptedDatabase(); if (m_nextStep) (this->*m_nextStep)(); @@ -292,6 +297,7 @@ void SQLTransaction::deliverTransactionCallback() m_executeSqlAllowed = true; shouldDeliverErrorCallback = !m_callback->handleEvent(m_database->scriptExecutionContext(), this); m_executeSqlAllowed = false; + m_callback = 0; } // Transaction Step 5 - If the transaction callback was null or raised an exception, jump to the error callback @@ -459,6 +465,7 @@ void SQLTransaction::postflightAndCommit() // If the commit failed, the transaction will still be marked as "in progress" if (m_sqliteTransaction->inProgress()) { + m_successCallback = 0; m_transactionError = SQLError::create(SQLError::DATABASE_ERR, "failed to commit the transaction"); handleTransactionError(false); return; @@ -473,7 +480,6 @@ void SQLTransaction::postflightAndCommit() m_database->transactionClient()->didCommitWriteTransaction(database()); // Now release our unneeded callbacks, to break reference cycles. - m_callback = 0; m_errorCallback = 0; // Transaction Step 10 - Deliver success callback, if there is one @@ -546,8 +552,10 @@ void SQLTransaction::deliverTransactionErrorCallback() // Transaction Step 12 - If exists, invoke error callback with the last // error to have occurred in this transaction. - if (m_errorCallback) + if (m_errorCallback) { m_errorCallback->handleEvent(m_database->scriptExecutionContext(), m_transactionError.get()); + m_errorCallback = 0; + } m_nextStep = &SQLTransaction::cleanupAfterTransactionErrorCallback; LOG(StorageAPI, "Scheduling cleanupAfterTransactionErrorCallback for transaction %p\n", this); @@ -579,10 +587,6 @@ void SQLTransaction::cleanupAfterTransactionErrorCallback() ASSERT(!m_database->sqliteDatabase().transactionInProgress()); m_nextStep = 0; - // Now release our callbacks, to break reference cycles. - m_callback = 0; - m_errorCallback = 0; - // Now release the lock on this database m_database->transactionCoordinator()->releaseLock(this); } diff --git a/WebCore/storage/SQLTransaction.h b/WebCore/storage/SQLTransaction.h index 5c62ca2..2eb200b 100644 --- a/WebCore/storage/SQLTransaction.h +++ b/WebCore/storage/SQLTransaction.h @@ -87,7 +87,7 @@ private: void enqueueStatement(PassRefPtr<SQLStatement>); - void checkAndHandleClosedDatabase(); + void checkAndHandleClosedOrInterruptedDatabase(); void acquireLock(); void openTransactionAndPreflight(); diff --git a/WebCore/storage/chromium/DatabaseTrackerChromium.cpp b/WebCore/storage/chromium/DatabaseTrackerChromium.cpp index aad4ed9..361e203 100644 --- a/WebCore/storage/chromium/DatabaseTrackerChromium.cpp +++ b/WebCore/storage/chromium/DatabaseTrackerChromium.cpp @@ -174,6 +174,35 @@ unsigned long long DatabaseTracker::getMaxSizeForDatabase(const AbstractDatabase return databaseSize + spaceAvailable; } +void DatabaseTracker::interruptAllDatabasesForContext(const ScriptExecutionContext* context) +{ + Vector<RefPtr<AbstractDatabase> > openDatabases; + { + MutexLocker openDatabaseMapLock(m_openDatabaseMapGuard); + + if (!m_openDatabaseMap) + return; + + DatabaseNameMap* nameMap = m_openDatabaseMap->get(context->securityOrigin()); + if (!nameMap) + return; + + DatabaseNameMap::const_iterator dbNameMapEndIt = nameMap->end(); + for (DatabaseNameMap::const_iterator dbNameMapIt = nameMap->begin(); dbNameMapIt != dbNameMapEndIt; ++dbNameMapIt) { + DatabaseSet* databaseSet = dbNameMapIt->second; + DatabaseSet::const_iterator dbSetEndIt = databaseSet->end(); + for (DatabaseSet::const_iterator dbSetIt = databaseSet->begin(); dbSetIt != dbSetEndIt; ++dbSetIt) { + if ((*dbSetIt)->scriptExecutionContext() == context) + openDatabases.append(*dbSetIt); + } + } + } + + Vector<RefPtr<AbstractDatabase> >::const_iterator openDatabasesEndIt = openDatabases.end(); + for (Vector<RefPtr<AbstractDatabase> >::const_iterator openDatabasesIt = openDatabases.begin(); openDatabasesIt != openDatabasesEndIt; ++openDatabasesIt) + (*openDatabasesIt)->interrupt(); +} + } #endif // ENABLE(DATABASE) diff --git a/WebCore/storage/chromium/IndexedDatabase.cpp b/WebCore/storage/chromium/IDBFactoryBackendInterface.cpp index 6f53f92..016cab0 100644 --- a/WebCore/storage/chromium/IndexedDatabase.cpp +++ b/WebCore/storage/chromium/IDBFactoryBackendInterface.cpp @@ -26,7 +26,7 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "config.h" -#include "IndexedDatabase.h" +#include "IDBFactoryBackendInterface.h" #include "ChromiumBridge.h" @@ -34,9 +34,9 @@ namespace WebCore { -PassRefPtr<IndexedDatabase> IndexedDatabase::create() +PassRefPtr<IDBFactoryBackendInterface> IDBFactoryBackendInterface::create() { - return ChromiumBridge::indexedDatabase(); + return ChromiumBridge::idbFactory(); } } // namespace WebCore |