Switch indexeddb to use supplemental IDL for DOMWindow

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

Patch by Mark Pilgrim <pilgrim@chromium.org> on 2012-01-20
Reviewed by Adam Barth.

No new tests required, all existing tests pass.

* Modules/indexeddb: Added.
* Modules/indexeddb/DOMWindowIndexedDatabase.cpp: Added. webkitIndexedDB() method previously in DOMWindow.cpp
(WebCore::DOMWindowIndexedDatabase::DOMWindowIndexedDatabase):
(WebCore::DOMWindowIndexedDatabase::~DOMWindowIndexedDatabase):
(WebCore::DOMWindowIndexedDatabase::webkitIndexedDB):
* Modules/indexeddb/DOMWindowIndexedDatabase.h: Added.
* Modules/indexeddb/DOMWindowIndexedDatabase.idl: Added. attributes previously in DOMWindow.idl
* WebCore.gyp/WebCore.gyp: add Modules/indexeddb/ directory
* WebCore.gypi: add Modules/indexeddb/*
* page/DOMWindow.cpp: remove webkitIndexedDB() method, add accessor methods for m_idbFactory
(WebCore::DOMWindow::getIDBFactory):
(WebCore::DOMWindow::setIDBFactory):
* page/DOMWindow.h:
* page/DOMWindow.idl:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@105569 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent b9a30e1b
2012-01-20 Mark Pilgrim <pilgrim@chromium.org>
Switch indexeddb to use supplemental IDL for DOMWindow
https://bugs.webkit.org/show_bug.cgi?id=76723
Reviewed by Adam Barth.
No new tests required, all existing tests pass.
* Modules/indexeddb: Added.
* Modules/indexeddb/DOMWindowIndexedDatabase.cpp: Added. webkitIndexedDB() method previously in DOMWindow.cpp
(WebCore::DOMWindowIndexedDatabase::DOMWindowIndexedDatabase):
(WebCore::DOMWindowIndexedDatabase::~DOMWindowIndexedDatabase):
(WebCore::DOMWindowIndexedDatabase::webkitIndexedDB):
* Modules/indexeddb/DOMWindowIndexedDatabase.h: Added.
* Modules/indexeddb/DOMWindowIndexedDatabase.idl: Added. attributes previously in DOMWindow.idl
* WebCore.gyp/WebCore.gyp: add Modules/indexeddb/ directory
* WebCore.gypi: add Modules/indexeddb/*
* page/DOMWindow.cpp: remove webkitIndexedDB() method, add accessor methods for m_idbFactory
(WebCore::DOMWindow::getIDBFactory):
(WebCore::DOMWindow::setIDBFactory):
* page/DOMWindow.h:
* page/DOMWindow.idl:
2012-01-20 David Levin <levin@chromium.org>
Allow isContextThread to be called while in ~ScriptExecutionContext.
/*
* Copyright (C) 2011, 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 INC. 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 INC. 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 "DOMWindowIndexedDatabase.h"
#if ENABLE(INDEXED_DATABASE)
#include "DOMWindow.h"
#include "Document.h"
#include "IDBFactory.h"
#include "Page.h"
#include "PageGroup.h"
#include "SecurityOrigin.h"
namespace WebCore {
DOMWindowIndexedDatabase::DOMWindowIndexedDatabase()
{
}
DOMWindowIndexedDatabase::~DOMWindowIndexedDatabase()
{
}
IDBFactory* DOMWindowIndexedDatabase::webkitIndexedDB(DOMWindow* window)
{
Document* document = window->document();
if (!document)
return 0;
Page* page = document->page();
if (!page)
return 0;
if (!document->securityOrigin()->canAccessDatabase())
return 0;
if (!window->idbFactory() && window->isCurrentlyDisplayedInFrame())
window->setIDBFactory(IDBFactory::create(page->group().idbFactory()));
return window->idbFactory();
}
} // namespace WebCore
#endif // ENABLE(INDEXED_DATABASE)
/*
* Copyright (C) 2011, 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 INC. 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 INC. 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 DOMWindowIndexedDatabase_h
#define DOMWindowIndexedDatabase_h
#if ENABLE(INDEXED_DATABASE)
namespace WebCore {
class IDBFactory;
class DOMWindow;
class DOMWindowIndexedDatabase {
public:
static IDBFactory* webkitIndexedDB(DOMWindow*);
private:
DOMWindowIndexedDatabase();
~DOMWindowIndexedDatabase();
};
} // namespace WebCore
#endif // ENABLE(INDEXED_DATABASE)
#endif // DOMWindowIndexedDatabase_h
/*
* Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
* Copyright (C) 2011 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 COMPUTER, INC. ``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 COMPUTER, INC. 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 window {
interface [
Conditional=INDEXED_DATABASE,
Supplemental=DOMWindow
] DOMWindowIndexedDatabase {
readonly attribute IDBFactory webkitIndexedDB;
attribute IDBCursorConstructor webkitIDBCursor;
attribute IDBDatabaseConstructor webkitIDBDatabase;
attribute IDBDatabaseErrorConstructor webkitIDBDatabaseError;
attribute IDBDatabaseExceptionConstructor webkitIDBDatabaseException;
attribute IDBFactoryConstructor webkitIDBFactory;
attribute IDBIndexConstructor webkitIDBIndex;
attribute IDBKeyRangeConstructor webkitIDBKeyRange;
attribute IDBObjectStoreConstructor webkitIDBObjectStore;
attribute IDBRequestConstructor webkitIDBRequest;
attribute IDBTransactionConstructor webkitIDBTransaction;
};
}
......@@ -53,6 +53,7 @@
'../..',
'../Modules/gamepad',
'../Modules/intents',
'../Modules/indexeddb',
'../accessibility',
'../accessibility/chromium',
'../bindings',
......
......@@ -1148,6 +1148,7 @@
'Modules/gamepad/Gamepad.idl',
'Modules/gamepad/GamepadList.idl',
'Modules/gamepad/NavigatorGamepad.idl',
'Modules/indexeddb/DOMWindowIndexedDatabase.idl',
'Modules/intents/DOMWindowIntents.idl',
'Modules/intents/Intent.idl',
'Modules/intents/IntentResultCallback.idl',
......@@ -1701,6 +1702,8 @@
'Modules/gamepad/GamepadList.h',
'Modules/gamepad/NavigatorGamepad.cpp',
'Modules/gamepad/NavigatorGamepad.h',
'Modules/indexeddb/DOMWindowIndexedDatabase.cpp',
'Modules/indexeddb/DOMWindowIndexedDatabase.h',
'Modules/intents/Intent.cpp',
'Modules/intents/Intent.h',
'Modules/intents/IntentRequest.cpp',
......
......@@ -750,22 +750,9 @@ void DOMWindow::resetGeolocation()
}
#if ENABLE(INDEXED_DATABASE)
IDBFactory* DOMWindow::webkitIndexedDB() const
void DOMWindow::setIDBFactory(PassRefPtr<IDBFactory> idbFactory)
{
Document* document = this->document();
if (!document)
return 0;
Page* page = document->page();
if (!page)
return 0;
if (!document->securityOrigin()->canAccessDatabase())
return 0;
if (!m_idbFactory && isCurrentlyDisplayedInFrame())
m_idbFactory = IDBFactory::create(page->group().idbFactory());
return m_idbFactory.get();
m_idbFactory = idbFactory;
}
#endif
......
......@@ -372,10 +372,6 @@ namespace WebCore {
void webkitResolveLocalFileSystemURL(const String&, PassRefPtr<EntryCallback>, PassRefPtr<ErrorCallback>);
#endif
#if ENABLE(INDEXED_DATABASE)
IDBFactory* webkitIndexedDB() const;
#endif
#if ENABLE(NOTIFICATIONS)
NotificationCenter* webkitNotifications() const;
// Renders webkitNotifications object safely inoperable, disconnects
......@@ -416,6 +412,11 @@ namespace WebCore {
// by the document that is currently active in m_frame.
bool isCurrentlyDisplayedInFrame() const;
#if ENABLE(INDEXED_DATABASE)
IDBFactory* idbFactory() { return m_idbFactory.get(); }
void setIDBFactory(PassRefPtr<IDBFactory>);
#endif
private:
explicit DOMWindow(Frame*);
......
......@@ -172,20 +172,6 @@ module window {
#if defined(ENABLE_NOTIFICATIONS) && ENABLE_NOTIFICATIONS
readonly attribute [EnabledAtRuntime] NotificationCenter webkitNotifications;
#endif
#if defined(ENABLE_INDEXED_DATABASE) && ENABLE_INDEXED_DATABASE
readonly attribute IDBFactory webkitIndexedDB;
attribute IDBCursorConstructor webkitIDBCursor;
attribute IDBDatabaseConstructor webkitIDBDatabase;
attribute IDBDatabaseErrorConstructor webkitIDBDatabaseError;
attribute IDBDatabaseExceptionConstructor webkitIDBDatabaseException;
attribute IDBFactoryConstructor webkitIDBFactory;
attribute IDBIndexConstructor webkitIDBIndex;
attribute IDBKeyRangeConstructor webkitIDBKeyRange;
attribute IDBObjectStoreConstructor webkitIDBObjectStore;
attribute IDBRequestConstructor webkitIDBRequest;
attribute IDBTransactionConstructor webkitIDBTransaction;
#endif
#if defined(ENABLE_FILE_SYSTEM) && ENABLE_FILE_SYSTEM
const unsigned short TEMPORARY = 0;
const unsigned short PERSISTENT = 1;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment