Diff
Modified: trunk/Source/WebCore/ChangeLog (164050 => 164051)
--- trunk/Source/WebCore/ChangeLog 2014-02-13 21:26:01 UTC (rev 164050)
+++ trunk/Source/WebCore/ChangeLog 2014-02-13 21:37:59 UTC (rev 164051)
@@ -1,3 +1,29 @@
+2014-02-12 Timothy Hatcher <timo...@apple.com>
+
+ Enable inspection of recently used IndexedDB databases.
+
+ https://bugs.webkit.org/show_bug.cgi?id=128687
+
+ Reviewed by Brady Eidson & Joseph Pecoraro.
+
+ * Modules/indexeddb/IDBFactory.cpp:
+ (WebCore::IDBFactory::getDatabaseNames):
+ * Modules/indexeddb/IDBFactoryBackendInterface.h:
+ * Modules/indexeddb/leveldb/IDBFactoryBackendLevelDB.cpp:
+ (WebCore::IDBFactoryBackendLevelDB::getDatabaseNames):
+ * Modules/indexeddb/leveldb/IDBFactoryBackendLevelDB.h:
+ Fix up the arguments passed to getDatabaseNames.
+
+ * WebCore.xcodeproj/project.pbxproj:
+ Make DOMStringList.h private so WebKit2 can use it.
+
+ * inspector/InspectorIndexedDBAgent.cpp:
+ Modernize the loops and remove some PLATFORM(COCOA) ifdefs to
+ compile the code.
+
+ * inspector/protocol/IndexedDB.json: Use number for version to
+ allow larger values instead of clamping to int.
+
2014-02-13 Chang Shu <c...@webkit.org>
Copying (createMarkup) wrapping text results in space between wrapped lines stripped.
Modified: trunk/Source/WebCore/Modules/indexeddb/IDBFactory.cpp (164050 => 164051)
--- trunk/Source/WebCore/Modules/indexeddb/IDBFactory.cpp 2014-02-13 21:26:01 UTC (rev 164050)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBFactory.cpp 2014-02-13 21:37:59 UTC (rev 164051)
@@ -103,7 +103,7 @@
}
RefPtr<IDBRequest> request = IDBRequest::create(context, IDBAny::create(this), 0);
- m_backend->getDatabaseNames(request, context->securityOrigin(), context, getIndexedDBDatabasePath(context));
+ m_backend->getDatabaseNames(request, *(context->securityOrigin()), *(context->topOrigin()), context, getIndexedDBDatabasePath(context));
return request;
}
Modified: trunk/Source/WebCore/Modules/indexeddb/IDBFactoryBackendInterface.h (164050 => 164051)
--- trunk/Source/WebCore/Modules/indexeddb/IDBFactoryBackendInterface.h 2014-02-13 21:26:01 UTC (rev 164050)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBFactoryBackendInterface.h 2014-02-13 21:37:59 UTC (rev 164051)
@@ -59,7 +59,7 @@
static PassRefPtr<IDBFactoryBackendInterface> create(const String& databaseDirectoryIdentifier);
virtual ~IDBFactoryBackendInterface() { }
- virtual void getDatabaseNames(PassRefPtr<IDBCallbacks>, PassRefPtr<SecurityOrigin>, ScriptExecutionContext*, const String& dataDir) = 0;
+ virtual void getDatabaseNames(PassRefPtr<IDBCallbacks>, const SecurityOrigin& openingOrigin, const SecurityOrigin& mainFrameOrigin, ScriptExecutionContext*, const String& dataDir) = 0;
virtual void open(const String& name, uint64_t version, int64_t transactionId, PassRefPtr<IDBCallbacks>, PassRefPtr<IDBDatabaseCallbacks>, const SecurityOrigin& openingOrigin, const SecurityOrigin& mainFrameOrigin) = 0;
virtual void deleteDatabase(const String& name, const SecurityOrigin& openingOrigin, const SecurityOrigin& mainFrameOrigin, PassRefPtr<IDBCallbacks>, ScriptExecutionContext*, const String& dataDir) = 0;
Modified: trunk/Source/WebCore/Modules/indexeddb/leveldb/IDBFactoryBackendLevelDB.cpp (164050 => 164051)
--- trunk/Source/WebCore/Modules/indexeddb/leveldb/IDBFactoryBackendLevelDB.cpp 2014-02-13 21:26:01 UTC (rev 164050)
+++ trunk/Source/WebCore/Modules/indexeddb/leveldb/IDBFactoryBackendLevelDB.cpp 2014-02-13 21:37:59 UTC (rev 164051)
@@ -84,11 +84,10 @@
m_databaseBackendMap.remove(uniqueIdentifier);
}
-void IDBFactoryBackendLevelDB::getDatabaseNames(PassRefPtr<IDBCallbacks> callbacks, PassRefPtr<SecurityOrigin> securityOrigin, ScriptExecutionContext*, const String& dataDirectory)
+void IDBFactoryBackendLevelDB::getDatabaseNames(PassRefPtr<IDBCallbacks> callbacks, const SecurityOrigin& openingOrigin, const SecurityOrigin&, ScriptExecutionContext*, const String& dataDirectory)
{
- ASSERT(securityOrigin);
LOG(StorageAPI, "IDBFactoryBackendLevelDB::getDatabaseNames");
- RefPtr<IDBBackingStoreLevelDB> backingStore = openBackingStore(*securityOrigin, dataDirectory);
+ RefPtr<IDBBackingStoreLevelDB> backingStore = openBackingStore(*openingOrigin, dataDirectory);
if (!backingStore) {
callbacks->onError(IDBDatabaseError::create(IDBDatabaseException::UnknownError, "Internal error opening backing store for indexedDB.webkitGetDatabaseNames."));
return;
Modified: trunk/Source/WebCore/Modules/indexeddb/leveldb/IDBFactoryBackendLevelDB.h (164050 => 164051)
--- trunk/Source/WebCore/Modules/indexeddb/leveldb/IDBFactoryBackendLevelDB.h 2014-02-13 21:26:01 UTC (rev 164050)
+++ trunk/Source/WebCore/Modules/indexeddb/leveldb/IDBFactoryBackendLevelDB.h 2014-02-13 21:37:59 UTC (rev 164051)
@@ -58,7 +58,7 @@
// Notifications from weak pointers.
virtual void removeIDBDatabaseBackend(const String& uniqueIdentifier) override final;
- virtual void getDatabaseNames(PassRefPtr<IDBCallbacks>, PassRefPtr<SecurityOrigin>, ScriptExecutionContext*, const String& dataDir) override final;
+ virtual void getDatabaseNames(PassRefPtr<IDBCallbacks>, const SecurityOrigin& openingOrigin, const SecurityOrigin& mainFrameOrigin, ScriptExecutionContext*, const String& dataDir) override final;
virtual void open(const String& name, uint64_t version, int64_t transactionId, PassRefPtr<IDBCallbacks>, PassRefPtr<IDBDatabaseCallbacks>, const SecurityOrigin& openingOrigin, const SecurityOrigin& mainFrameOrigin) override final;
virtual void deleteDatabase(const String& name, const SecurityOrigin& openingOrigin, const SecurityOrigin& mainFrameOrigin, PassRefPtr<IDBCallbacks>, ScriptExecutionContext*, const String& dataDir) override final;
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (164050 => 164051)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2014-02-13 21:26:01 UTC (rev 164050)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2014-02-13 21:37:59 UTC (rev 164051)
@@ -5388,7 +5388,7 @@
C5160EEA1004543A00A7CEE2 /* StorageAreaImpl.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C5160EE81004543A00A7CEE2 /* StorageAreaImpl.cpp */; };
C5160EEB1004543A00A7CEE2 /* StorageAreaImpl.h in Headers */ = {isa = PBXBuildFile; fileRef = C5160EE91004543A00A7CEE2 /* StorageAreaImpl.h */; };
C5278B0C17F212EA003A2998 /* PlatformPasteboardIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = C5278B0B17F212EA003A2998 /* PlatformPasteboardIOS.mm */; };
- C544274B11A57E7A0063A749 /* DOMStringList.h in Headers */ = {isa = PBXBuildFile; fileRef = C544274911A57E7A0063A749 /* DOMStringList.h */; };
+ C544274B11A57E7A0063A749 /* DOMStringList.h in Headers */ = {isa = PBXBuildFile; fileRef = C544274911A57E7A0063A749 /* DOMStringList.h */; settings = {ATTRIBUTES = (Private, ); }; };
C55610F111A704EB00B82D27 /* DOMStringList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C55610F011A704EB00B82D27 /* DOMStringList.cpp */; };
C55C7BA11718AFBA001327E4 /* RenderThemeIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = C55C7BA01718AFBA001327E4 /* RenderThemeIOS.mm */; };
C55E38BF10040D5D00A56BDB /* StorageNamespaceImpl.h in Headers */ = {isa = PBXBuildFile; fileRef = C55E38BB10040D5D00A56BDB /* StorageNamespaceImpl.h */; };
Modified: trunk/Source/WebCore/inspector/InspectorIndexedDBAgent.cpp (164050 => 164051)
--- trunk/Source/WebCore/inspector/InspectorIndexedDBAgent.cpp 2014-02-13 21:26:01 UTC (rev 164050)
+++ trunk/Source/WebCore/inspector/InspectorIndexedDBAgent.cpp 2014-02-13 21:37:59 UTC (rev 164051)
@@ -238,7 +238,6 @@
return idbIndex;
}
-#if !PLATFORM(COCOA)
static PassRefPtr<KeyPath> keyPathFromIDBKeyPath(const IDBKeyPath& idbKeyPath)
{
RefPtr<KeyPath> keyPath;
@@ -265,7 +264,6 @@
return keyPath.release();
}
-#endif // !PLATFORM(COCOA)
class DatabaseLoader : public ExecutableWithDatabase {
public:
@@ -278,9 +276,6 @@
virtual void execute(PassRefPtr<IDBDatabase> prpDatabase) override
{
-#if PLATFORM(COCOA)
- ASSERT_UNUSED(prpDatabase, prpDatabase);
-#else
RefPtr<IDBDatabase> idbDatabase = prpDatabase;
if (!requestCallback()->isActive())
return;
@@ -289,14 +284,10 @@
RefPtr<Inspector::TypeBuilder::Array<Inspector::TypeBuilder::IndexedDB::ObjectStore>> objectStores = Inspector::TypeBuilder::Array<Inspector::TypeBuilder::IndexedDB::ObjectStore>::create();
- for (IDBDatabaseMetadata::ObjectStoreMap::const_iterator it = databaseMetadata.objectStores.begin(); it != databaseMetadata.objectStores.end(); ++it) {
- const IDBObjectStoreMetadata& objectStoreMetadata = it->value;
-
+ for (const IDBObjectStoreMetadata& objectStoreMetadata : databaseMetadata.objectStores.values()) {
RefPtr<Inspector::TypeBuilder::Array<Inspector::TypeBuilder::IndexedDB::ObjectStoreIndex>> indexes = Inspector::TypeBuilder::Array<Inspector::TypeBuilder::IndexedDB::ObjectStoreIndex>::create();
- for (IDBObjectStoreMetadata::IndexMap::const_iterator it = objectStoreMetadata.indexes.begin(); it != objectStoreMetadata.indexes.end(); ++it) {
- const IDBIndexMetadata& indexMetadata = it->value;
-
+ for (const IDBIndexMetadata& indexMetadata : objectStoreMetadata.indexes.values()) {
RefPtr<ObjectStoreIndex> objectStoreIndex = ObjectStoreIndex::create()
.setName(indexMetadata.name)
.setKeyPath(keyPathFromIDBKeyPath(indexMetadata.keyPath))
@@ -310,16 +301,16 @@
.setKeyPath(keyPathFromIDBKeyPath(objectStoreMetadata.keyPath))
.setAutoIncrement(objectStoreMetadata.autoIncrement)
.setIndexes(indexes);
+
objectStores->addItem(objectStore);
}
+
RefPtr<DatabaseWithObjectStores> result = DatabaseWithObjectStores::create()
.setName(databaseMetadata.name)
- .setIntVersion(databaseMetadata.version)
- .setVersion(String::number(databaseMetadata.version))
+ .setVersion(databaseMetadata.version)
.setObjectStores(objectStores);
m_requestCallback->sendSuccess(result);
-#endif // PLATFORM(COCOA)
}
virtual RequestCallback* requestCallback() override { return m_requestCallback.get(); }
Modified: trunk/Source/WebCore/inspector/protocol/IndexedDB.json (164050 => 164051)
--- trunk/Source/WebCore/inspector/protocol/IndexedDB.json 2014-02-13 21:26:01 UTC (rev 164050)
+++ trunk/Source/WebCore/inspector/protocol/IndexedDB.json 2014-02-13 21:37:59 UTC (rev 164051)
@@ -7,8 +7,7 @@
"description": "Database with an array of object stores.",
"properties": [
{ "name": "name", "type": "string", "description": "Database name." },
- { "name": "version", "type": "string", "description": "Deprecated string database version." },
- { "name": "intVersion", "type": "integer", "description": "Integer database version." },
+ { "name": "version", "type": "number", "description": "Database version." },
{ "name": "objectStores", "type": "array", "items": { "$ref": "ObjectStore" }, "description": "Object stores in this database." }
]
},
Modified: trunk/Source/WebKit2/ChangeLog (164050 => 164051)
--- trunk/Source/WebKit2/ChangeLog 2014-02-13 21:26:01 UTC (rev 164050)
+++ trunk/Source/WebKit2/ChangeLog 2014-02-13 21:37:59 UTC (rev 164051)
@@ -1,3 +1,24 @@
+2014-02-12 Timothy Hatcher <timo...@apple.com>
+
+ Enable inspection of recently used IndexedDB databases.
+
+ https://bugs.webkit.org/show_bug.cgi?id=128687
+
+ Reviewed by Brady Eidson & Joseph Pecoraro.
+
+ * WebProcess/Databases/IndexedDB/WebIDBFactoryBackend.cpp:
+ (WebKit::sharedRecentDatabaseNameMap):
+ (WebKit::combinedSecurityOriginIdentifier):
+ (WebKit::WebIDBFactoryBackend::WebIDBFactoryBackend):
+ (WebKit::WebIDBFactoryBackend::getDatabaseNames):
+ (WebKit::WebIDBFactoryBackend::open):
+ (WebKit::WebIDBFactoryBackend::deleteDatabase):
+ Keep track of recently used database names per security-origin pair.
+ Implement getDatabaseNames to return the recently used names.
+
+ * WebProcess/Databases/IndexedDB/WebIDBFactoryBackend.h:
+ Fix up the arguments passed to getDatabaseNames.
+
2014-02-13 Anders Carlsson <ander...@apple.com>
Fix build.
Modified: trunk/Source/WebKit2/WebProcess/Databases/IndexedDB/WebIDBFactoryBackend.cpp (164050 => 164051)
--- trunk/Source/WebKit2/WebProcess/Databases/IndexedDB/WebIDBFactoryBackend.cpp 2014-02-13 21:26:01 UTC (rev 164050)
+++ trunk/Source/WebKit2/WebProcess/Databases/IndexedDB/WebIDBFactoryBackend.cpp 2014-02-13 21:37:59 UTC (rev 164051)
@@ -32,6 +32,7 @@
#include "WebIDBServerConnection.h"
#include "WebProcess.h"
#include "WebToDatabaseProcessConnection.h"
+#include <WebCore/DOMStringList.h>
#include <WebCore/IDBCallbacks.h>
#include <WebCore/IDBCursorBackend.h>
#include <WebCore/IDBDatabaseCallbacks.h>
@@ -56,19 +57,59 @@
return databaseBackendMap;
}
+static HashMap<String, HashSet<String>>& sharedRecentDatabaseNameMap()
+{
+ static NeverDestroyed<HashMap<String, HashSet<String>>> recentDatabaseNameMap;
+ return recentDatabaseNameMap;
+}
+
+static String combinedSecurityOriginIdentifier(const WebCore::SecurityOrigin& openingOrigin, const WebCore::SecurityOrigin& mainFrameOrigin)
+{
+ StringBuilder stringBuilder;
+
+ String originString = openingOrigin.toString();
+ if (originString == "null")
+ return String();
+ stringBuilder.append(originString);
+ stringBuilder.append("_");
+
+ originString = mainFrameOrigin.toString();
+ if (originString == "null")
+ return String();
+ stringBuilder.append(originString);
+
+ return stringBuilder.toString();
+}
+
WebIDBFactoryBackend::WebIDBFactoryBackend(const String&)
{
}
-
WebIDBFactoryBackend::~WebIDBFactoryBackend()
{
}
-void WebIDBFactoryBackend::getDatabaseNames(PassRefPtr<IDBCallbacks>, PassRefPtr<SecurityOrigin>, ScriptExecutionContext*, const String&)
+void WebIDBFactoryBackend::getDatabaseNames(PassRefPtr<IDBCallbacks> callbacks, const SecurityOrigin& openingOrigin, const SecurityOrigin& mainFrameOrigin, ScriptExecutionContext* context, const String&)
{
- LOG_ERROR("IDBFactory::getDatabaseNames is no longer exposed to the web as _javascript_ API and should be removed. It will be once we move the Web Inspector away of of it.");
- notImplemented();
+ LOG(IDB, "WebIDBFactoryBackend::getDatabaseNames");
+
+ String securityOriginIdentifier = combinedSecurityOriginIdentifier(openingOrigin, mainFrameOrigin);
+ if (securityOriginIdentifier.isEmpty()) {
+ callbacks->onError(IDBDatabaseError::create(IDBDatabaseException::InvalidAccessError, ASCIILiteral("Document is not allowed to use Indexed Databases")));
+ return;
+ }
+
+ auto recentNameIterator = sharedRecentDatabaseNameMap().find(securityOriginIdentifier);
+ if (recentNameIterator == sharedRecentDatabaseNameMap().end())
+ return;
+
+ RefPtr<DOMStringList> databaseNames = DOMStringList::create();
+
+ HashSet<String>& foundNames = recentNameIterator->value;
+ for (const String& name : foundNames)
+ databaseNames->append(name);
+
+ callbacks->onSuccess(databaseNames.release());
}
void WebIDBFactoryBackend::open(const String& databaseName, uint64_t version, int64_t transactionId, PassRefPtr<IDBCallbacks> callbacks, PassRefPtr<IDBDatabaseCallbacks> databaseCallbacks, const SecurityOrigin& openingOrigin, const SecurityOrigin& mainFrameOrigin)
@@ -82,6 +123,17 @@
return;
}
+ String securityOriginIdentifier = combinedSecurityOriginIdentifier(openingOrigin, mainFrameOrigin);
+ ASSERT(!securityOriginIdentifier.isEmpty());
+
+ auto recentNameIterator = sharedRecentDatabaseNameMap().find(securityOriginIdentifier);
+ if (recentNameIterator == sharedRecentDatabaseNameMap().end()) {
+ HashSet<String> names;
+ names.add(databaseName);
+ sharedRecentDatabaseNameMap().set(securityOriginIdentifier, names);
+ } else
+ recentNameIterator->value.add(databaseName);
+
IDBDatabaseBackendMap::iterator it = sharedDatabaseBackendMap().find(databaseIdentifier);
RefPtr<IDBDatabaseBackend> databaseBackend;
@@ -106,6 +158,16 @@
return;
}
+ String securityOriginIdentifier = combinedSecurityOriginIdentifier(openingOrigin, mainFrameOrigin);
+ ASSERT(!securityOriginIdentifier.isEmpty());
+
+ auto recentNameIterator = sharedRecentDatabaseNameMap().find(securityOriginIdentifier);
+ if (recentNameIterator != sharedRecentDatabaseNameMap().end()) {
+ recentNameIterator->value.remove(databaseName);
+ if (recentNameIterator->value.isEmpty())
+ sharedRecentDatabaseNameMap().remove(recentNameIterator);
+ }
+
// If there's already a connection to the database, delete it directly.
IDBDatabaseBackendMap::iterator it = sharedDatabaseBackendMap().find(databaseIdentifier);
if (it != sharedDatabaseBackendMap().end()) {
Modified: trunk/Source/WebKit2/WebProcess/Databases/IndexedDB/WebIDBFactoryBackend.h (164050 => 164051)
--- trunk/Source/WebKit2/WebProcess/Databases/IndexedDB/WebIDBFactoryBackend.h 2014-02-13 21:26:01 UTC (rev 164050)
+++ trunk/Source/WebKit2/WebProcess/Databases/IndexedDB/WebIDBFactoryBackend.h 2014-02-13 21:37:59 UTC (rev 164051)
@@ -39,7 +39,7 @@
virtual ~WebIDBFactoryBackend();
- virtual void getDatabaseNames(PassRefPtr<WebCore::IDBCallbacks>, PassRefPtr<WebCore::SecurityOrigin>, WebCore::ScriptExecutionContext*, const String& dataDir) override;
+ virtual void getDatabaseNames(PassRefPtr<WebCore::IDBCallbacks>, const WebCore::SecurityOrigin& openingOrigin, const WebCore::SecurityOrigin& mainFrameOrigin, WebCore::ScriptExecutionContext*, const String& dataDir) override;
virtual void open(const String& name, uint64_t version, int64_t transactionId, PassRefPtr<WebCore::IDBCallbacks>, PassRefPtr<WebCore::IDBDatabaseCallbacks>, const WebCore::SecurityOrigin& openingOrigin, const WebCore::SecurityOrigin& mainFrameOrigin) override;
virtual void deleteDatabase(const String& name, const WebCore::SecurityOrigin& openingOrigin, const WebCore::SecurityOrigin& mainFrameOrigin, PassRefPtr<WebCore::IDBCallbacks>, WebCore::ScriptExecutionContext*, const String& dataDir) override;