Diff
Modified: trunk/LayoutTests/ChangeLog (200162 => 200163)
--- trunk/LayoutTests/ChangeLog 2016-04-27 23:53:08 UTC (rev 200162)
+++ trunk/LayoutTests/ChangeLog 2016-04-28 01:16:28 UTC (rev 200163)
@@ -1,3 +1,16 @@
+2016-04-27 Brady Eidson <beid...@apple.com>
+
+ Modern IDB: Implement native IDBFactory.getAllDatabaseNames for WebInspector.
+ https://bugs.webkit.org/show_bug.cgi?id=157072
+
+ Reviewed by Alex Christensen.
+
+ Add more to this test and re-enable it.
+
+ * TestExpectations:
+ * inspector/indexeddb/requestDatabaseNames-expected.txt:
+ * inspector/indexeddb/requestDatabaseNames.html:
+
2016-04-27 Simon Fraser <simon.fra...@apple.com>
Test gardening; update results of tests that are marked as flakey.
Modified: trunk/LayoutTests/TestExpectations (200162 => 200163)
--- trunk/LayoutTests/TestExpectations 2016-04-27 23:53:08 UTC (rev 200162)
+++ trunk/LayoutTests/TestExpectations 2016-04-28 01:16:28 UTC (rev 200163)
@@ -926,9 +926,6 @@
storage/indexeddb/modern/transaction-scheduler-6.html [ Skip ]
storage/indexeddb/transaction-coordination-within-database.html [ Skip ]
-# Inspector doesn't support modern IDB yet
-webkit.org/b/154686 inspector/indexeddb/requestDatabaseNames.html [ Skip ]
-
# These two IDB tests are, by their nature, very slow
# Skip these until we have a fix for webkit.org/b/155041
storage/indexeddb/modern/exceed-open-file-limit.html [ Skip ]
Modified: trunk/LayoutTests/inspector/indexeddb/requestDatabaseNames-expected.txt (200162 => 200163)
--- trunk/LayoutTests/inspector/indexeddb/requestDatabaseNames-expected.txt 2016-04-27 23:53:08 UTC (rev 200162)
+++ trunk/LayoutTests/inspector/indexeddb/requestDatabaseNames-expected.txt 2016-04-28 01:16:28 UTC (rev 200163)
@@ -1,5 +1,7 @@
CONSOLE MESSAGE: line 10: Created Database 'Database1'
CONSOLE MESSAGE: line 10: Created Database 'Database2'
+CONSOLE MESSAGE: line 10: Created Database 'ቍ'
+CONSOLE MESSAGE: line 10: Created Database '𐍆'
PASS: No IndexedDB databases should exist initially
Created Database 'Database1'
@@ -8,4 +10,10 @@
Created Database 'Database2'
PASS: Two IndexedDB databases should exist
["Database1","Database2"]
+Created Database 'ቍ'
+PASS: Two IndexedDB databases should exist
+["Database1","Database2","ቍ"]
+Created Database '𐍆'
+PASS: Four IndexedDB databases should exist
+["Database1","Database2","ቍ","𐍆"]
Modified: trunk/LayoutTests/inspector/indexeddb/requestDatabaseNames.html (200162 => 200163)
--- trunk/LayoutTests/inspector/indexeddb/requestDatabaseNames.html 2016-04-27 23:53:08 UTC (rev 200162)
+++ trunk/LayoutTests/inspector/indexeddb/requestDatabaseNames.html 2016-04-28 01:16:28 UTC (rev 200163)
@@ -55,6 +55,29 @@
InspectorTest.expectNoError(error);
InspectorTest.expectThat(names.length === 2, "Two IndexedDB databases should exist");
InspectorTest.log(JSON.stringify(names));
+ InspectorTest.evaluateInPage("createDatabase('\u124d')");
+ });
+ }
+ },
+ {
+ action: function() {
+ IndexedDBAgent.requestDatabaseNames(WebInspector.frameResourceManager.mainFrame.securityOrigin, function(error, names) {
+ InspectorTest.expectNoError(error);
+ InspectorTest.expectThat(names.length === 3, "Two IndexedDB databases should exist");
+ InspectorTest.log(JSON.stringify(names));
+ InspectorTest.evaluateInPage("createDatabase('\ud800\udf46')");
+ });
+ }
+ },
+ {
+ action: function() {
+ IndexedDBAgent.requestDatabaseNames(WebInspector.frameResourceManager.mainFrame.securityOrigin, function(error, names) {
+ for (n in names)
+ alert(names.n);
+
+ InspectorTest.expectNoError(error);
+ InspectorTest.expectThat(names.length === 4, "Four IndexedDB databases should exist");
+ InspectorTest.log(JSON.stringify(names));
next();
});
}
Modified: trunk/Source/WTF/ChangeLog (200162 => 200163)
--- trunk/Source/WTF/ChangeLog 2016-04-27 23:53:08 UTC (rev 200162)
+++ trunk/Source/WTF/ChangeLog 2016-04-28 01:16:28 UTC (rev 200163)
@@ -1,3 +1,19 @@
+2016-04-27 Brady Eidson <beid...@apple.com>
+
+ Modern IDB: Implement native IDBFactory.getAllDatabaseNames for WebInspector.
+ https://bugs.webkit.org/show_bug.cgi?id=157072
+
+ Reviewed by Alex Christensen.
+
+ Moved these Hex Digit utilities from WebCore URL code (???),
+ and add a checked version of getting the hex digit value.
+
+ * wtf/HexNumber.h:
+ (WTF::isHexDigit):
+ (WTF::uncheckedHexDigit):
+ (WTF::hexDigitValue):
+ (WTF::uncheckedHexDigitValue):
+
2016-04-25 Ryosuke Niwa <rn...@webkit.org>
Remove the build flag for template elements
Modified: trunk/Source/WTF/wtf/HexNumber.h (200162 => 200163)
--- trunk/Source/WTF/wtf/HexNumber.h 2016-04-27 23:53:08 UTC (rev 200162)
+++ trunk/Source/WTF/wtf/HexNumber.h 2016-04-28 01:16:28 UTC (rev 200163)
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2011 Research In Motion Limited. All rights reserved.
+ * Copyright (C) 2016 Apple Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -17,8 +18,7 @@
* Boston, MA 02110-1301, USA.
*/
-#ifndef HexNumber_h
-#define HexNumber_h
+#pragma once
#include <wtf/text/StringConcatenate.h>
@@ -111,6 +111,54 @@
destination.append(result.data(), result.size());
}
+
+inline bool isHexDigit(char c)
+{
+ return (c >= '0' && c <= '9') || (c >= 'A' && c <= 'F') || (c >= 'a' && c <= 'f');
+}
+
+inline char uncheckedHexDigit(int i)
+{
+ if (i < 0 || i > 16)
+ return '0';
+
+ return (i >= 10) ? i - 10 + 'A' : i + '0';
+}
+
+inline bool hexDigitValue(char c, char& result)
+{
+ if (c >= '0' && c <= '9') {
+ result = c - '0';
+ return true;
+ }
+
+ if (c >= 'A' && c <= 'F') {
+ result = c - 'A' + 10;
+ return true;
+ }
+
+ if (c >= 'a' && c <= 'f') {
+ result = c - 'a' + 10;
+ return true;
+ }
+
+ return false;
+}
+
+inline int uncheckedHexDigitValue(char c)
+{
+ if (c >= '0' && c <= '9')
+ return c - '0';
+
+ if (c >= 'A' && c <= 'F')
+ return c - 'A' + 10;
+
+ if (c >= 'a' && c <= 'f')
+ return c - 'a' + 10;
+
+ return 0;
+}
+
} // namespace WTF
using WTF::appendByteAsHex;
@@ -119,5 +167,7 @@
using WTF::placeByteAsHex;
using WTF::placeByteAsHexCompressIfPossible;
using WTF::Lowercase;
-
-#endif // HexNumber_h
+using WTF::isHexDigit;
+using WTF::uncheckedHexDigit;
+using WTF::hexDigitValue;
+using WTF::uncheckedHexDigitValue;
Modified: trunk/Source/WebCore/ChangeLog (200162 => 200163)
--- trunk/Source/WebCore/ChangeLog 2016-04-27 23:53:08 UTC (rev 200162)
+++ trunk/Source/WebCore/ChangeLog 2016-04-28 01:16:28 UTC (rev 200163)
@@ -1,3 +1,92 @@
+2016-04-27 Brady Eidson <beid...@apple.com>
+
+ Modern IDB: Implement native IDBFactory.getAllDatabaseNames for WebInspector.
+ https://bugs.webkit.org/show_bug.cgi?id=157072
+
+ Reviewed by Alex Christensen.
+
+ No new tests (Covered by changes to existing test).
+
+ Implement a new "getAllDatabaseNames" call on IDBFactory.
+
+ It is not exposed to the DOM, and is meant solely for internal WebInspector use.
+
+ * Modules/indexeddb/DOMWindowIndexedDatabase.h: Export some stuff to WebCoreTestSupport
+
+ * Modules/indexeddb/IDBDatabase.cpp:
+ (WebCore::IDBDatabase::createObjectStore):
+
+ * Modules/indexeddb/IDBDatabaseIdentifier.cpp:
+ (WebCore::IDBDatabaseIdentifier::databaseDirectoryRelativeToRoot):
+ * Modules/indexeddb/IDBDatabaseIdentifier.h:
+
+ * Modules/indexeddb/IDBFactory.cpp:
+ (WebCore::IDBFactory::getAllDatabaseNames):
+ * Modules/indexeddb/IDBFactory.h:
+
+ * Modules/indexeddb/client/IDBConnectionProxy.cpp:
+ (WebCore::IDBClient::IDBConnectionProxy::getAllDatabaseNames):
+ * Modules/indexeddb/client/IDBConnectionProxy.h:
+
+ * Modules/indexeddb/client/IDBConnectionToServer.cpp:
+ (WebCore::IDBClient::IDBConnectionToServer::getAllDatabaseNames):
+ (WebCore::IDBClient::IDBConnectionToServer::didGetAllDatabaseNames):
+ * Modules/indexeddb/client/IDBConnectionToServer.h:
+ * Modules/indexeddb/client/IDBConnectionToServerDelegate.h:
+
+ * Modules/indexeddb/server/IDBConnectionToClient.cpp:
+ (WebCore::IDBServer::IDBConnectionToClient::didGetAllDatabaseNames):
+ * Modules/indexeddb/server/IDBConnectionToClient.h:
+ * Modules/indexeddb/server/IDBConnectionToClientDelegate.h:
+
+ * Modules/indexeddb/server/IDBServer.cpp:
+ (WebCore::IDBServer::IDBServer::getAllDatabaseNames):
+ (WebCore::IDBServer::IDBServer::performGetAllDatabaseNames): Do the actual work of getting
+ the appropriate directory listing and converting the paths to database names.
+ (WebCore::IDBServer::IDBServer::didGetAllDatabaseNames):
+ * Modules/indexeddb/server/IDBServer.h:
+
+ * Modules/indexeddb/server/SQLiteIDBBackingStore.cpp:
+ (WebCore::IDBServer::SQLiteIDBBackingStore::databaseNameFromEncodedFilename): Helper for IDBServer.
+ * Modules/indexeddb/server/SQLiteIDBBackingStore.h:
+
+ * Modules/indexeddb/shared/InProcessIDBServer.cpp:
+ (WebCore::InProcessIDBServer::getAllDatabaseNames):
+ (WebCore::InProcessIDBServer::didGetAllDatabaseNames):
+ * Modules/indexeddb/shared/InProcessIDBServer.h:
+
+ * inspector/InspectorIndexedDBAgent.cpp:
+ (WebCore::InspectorIndexedDBAgent::requestDatabaseNames): Use the new IDBFactory API to
+ asynchronously get the list of database names.
+
+ * platform/CrossThreadCopier.cpp:
+ (WebCore::SecurityOriginData>::copy):
+ (WebCore::Vector<String>>::copy):
+ * platform/CrossThreadCopier.h:
+
+ * platform/FileSystem.cpp:
+ (WebCore::decodeFromFilename): Perform the reverse of encodeForFilename.
+ * platform/FileSystem.h:
+
+ * platform/cf/FileSystemCF.cpp:
+ (WebCore::stringFromFileSystemRepresentation):
+
+ * platform/glib/FileSystemGlib.cpp:
+ (WebCore::stringFromFileSystemRepresentation):
+
+ * platform/posix/FileSystemPOSIX.cpp:
+ (WebCore::lastComponentOfPathIgnoringTrailingSlash): Utility for peeling off the last component
+ of a multi-component path.
+ (WebCore::listDirectory): This was broken when returning filenames with UTF in them. Fix it.
+
+ * platform/mac/WebCoreNSURLExtras.mm: Move the static hex digit utility functions to WTF.
+ (WebCore::userVisibleString):
+ (WebCore::isUserVisibleURL):
+ (WebCore::isHexDigit): Deleted.
+ (WebCore::hexDigit): Deleted.
+ (WebCore::hexDigitValue): Deleted.
+
+
2016-04-27 Enrica Casucci <enr...@apple.com>
Refactor findExplodedTextNodeAtPoint to move core functionality in RenderBlockFlow.
Modified: trunk/Source/WebCore/Modules/indexeddb/DOMWindowIndexedDatabase.h (200162 => 200163)
--- trunk/Source/WebCore/Modules/indexeddb/DOMWindowIndexedDatabase.h 2016-04-27 23:53:08 UTC (rev 200162)
+++ trunk/Source/WebCore/Modules/indexeddb/DOMWindowIndexedDatabase.h 2016-04-28 01:16:28 UTC (rev 200163)
@@ -44,7 +44,7 @@
static DOMWindowIndexedDatabase* from(DOMWindow*);
- static IDBFactory* indexedDB(DOMWindow&);
+ WEBCORE_EXPORT static IDBFactory* indexedDB(DOMWindow&);
void disconnectFrameForDocumentSuspension() override;
void reconnectFrameFromDocumentSuspension(Frame*) override;
Modified: trunk/Source/WebCore/Modules/indexeddb/IDBDatabase.cpp (200162 => 200163)
--- trunk/Source/WebCore/Modules/indexeddb/IDBDatabase.cpp 2016-04-27 23:53:08 UTC (rev 200162)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBDatabase.cpp 2016-04-28 01:16:28 UTC (rev 200163)
@@ -97,7 +97,7 @@
RefPtr<WebCore::IDBObjectStore> IDBDatabase::createObjectStore(const String& name, const IDBKeyPath& keyPath, bool autoIncrement, ExceptionCodeWithMessage& ec)
{
- LOG(IndexedDB, "IDBDatabase::createObjectStore");
+ LOG(IndexedDB, "IDBDatabase::createObjectStore - (%s %s)", m_info.name().utf8().data(), name.utf8().data());
ASSERT(!m_versionChangeTransaction || m_versionChangeTransaction->isVersionChange());
Modified: trunk/Source/WebCore/Modules/indexeddb/IDBDatabaseIdentifier.cpp (200162 => 200163)
--- trunk/Source/WebCore/Modules/indexeddb/IDBDatabaseIdentifier.cpp 2016-04-27 23:53:08 UTC (rev 200162)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBDatabaseIdentifier.cpp 2016-04-28 01:16:28 UTC (rev 200163)
@@ -59,13 +59,18 @@
String IDBDatabaseIdentifier::databaseDirectoryRelativeToRoot(const String& rootDirectory) const
{
- String mainFrameDirectory = pathByAppendingComponent(rootDirectory, m_mainFrameOrigin.securityOrigin()->databaseIdentifier());
+ return databaseDirectoryRelativeToRoot(m_mainFrameOrigin, m_openingOrigin, rootDirectory);
+}
+String IDBDatabaseIdentifier::databaseDirectoryRelativeToRoot(const SecurityOriginData& topLevelOrigin, const SecurityOriginData& openingOrigin, const String& rootDirectory)
+{
+ String mainFrameDirectory = pathByAppendingComponent(rootDirectory, topLevelOrigin.securityOrigin()->databaseIdentifier());
+
// If the opening origin and main frame origins are the same, there is no partitioning.
- if (m_openingOrigin == m_mainFrameOrigin)
+ if (openingOrigin == topLevelOrigin)
return mainFrameDirectory;
- return pathByAppendingComponent(mainFrameDirectory, m_openingOrigin.securityOrigin()->databaseIdentifier());
+ return pathByAppendingComponent(mainFrameDirectory, openingOrigin.securityOrigin()->databaseIdentifier());
}
#ifndef NDEBUG
Modified: trunk/Source/WebCore/Modules/indexeddb/IDBDatabaseIdentifier.h (200162 => 200163)
--- trunk/Source/WebCore/Modules/indexeddb/IDBDatabaseIdentifier.h 2016-04-27 23:53:08 UTC (rev 200162)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBDatabaseIdentifier.h 2016-04-28 01:16:28 UTC (rev 200163)
@@ -93,6 +93,7 @@
const String& databaseName() const { return m_databaseName; }
String databaseDirectoryRelativeToRoot(const String& rootDirectory) const;
+ static String databaseDirectoryRelativeToRoot(const SecurityOriginData& topLevelOrigin, const SecurityOriginData& openingOrigin, const String& rootDirectory);
template<class Encoder> void encode(Encoder&) const;
template<class Decoder> static bool decode(Decoder&, IDBDatabaseIdentifier&);
Modified: trunk/Source/WebCore/Modules/indexeddb/IDBFactory.cpp (200162 => 200163)
--- trunk/Source/WebCore/Modules/indexeddb/IDBFactory.cpp 2016-04-27 23:53:08 UTC (rev 200162)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBFactory.cpp 2016-04-28 01:16:28 UTC (rev 200163)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2015 Apple Inc. All rights reserved.
+ * Copyright (C) 2015, 2016 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -159,6 +159,11 @@
return first->compare(second.get());
}
+void IDBFactory::getAllDatabaseNames(const SecurityOrigin& mainFrameOrigin, const SecurityOrigin& openingOrigin, std::function<void (const Vector<String>&)> callback)
+{
+ m_connectionProxy->getAllDatabaseNames(mainFrameOrigin, openingOrigin, callback);
+}
+
} // namespace WebCore
#endif // ENABLE(INDEXED_DATABASE)
Modified: trunk/Source/WebCore/Modules/indexeddb/IDBFactory.h (200162 => 200163)
--- trunk/Source/WebCore/Modules/indexeddb/IDBFactory.h 2016-04-27 23:53:08 UTC (rev 200162)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBFactory.h 2016-04-28 01:16:28 UTC (rev 200163)
@@ -27,9 +27,11 @@
#if ENABLE(INDEXED_DATABASE)
+#include <functional>
#include <wtf/Forward.h>
#include <wtf/Ref.h>
#include <wtf/ThreadSafeRefCounted.h>
+#include <wtf/Vector.h>
namespace JSC {
class JSValue;
@@ -39,6 +41,7 @@
class IDBOpenDBRequest;
class ScriptExecutionContext;
+class SecurityOrigin;
struct ExceptionCodeWithMessage;
@@ -58,6 +61,8 @@
short cmp(ScriptExecutionContext&, JSC::JSValue first, JSC::JSValue second, ExceptionCodeWithMessage&);
+ WEBCORE_EXPORT void getAllDatabaseNames(const SecurityOrigin& mainFrameOrigin, const SecurityOrigin& openingOrigin, std::function<void (const Vector<String>&)>);
+
private:
explicit IDBFactory(IDBClient::IDBConnectionProxy&);
Modified: trunk/Source/WebCore/Modules/indexeddb/client/IDBConnectionProxy.cpp (200162 => 200163)
--- trunk/Source/WebCore/Modules/indexeddb/client/IDBConnectionProxy.cpp 2016-04-27 23:53:08 UTC (rev 200162)
+++ trunk/Source/WebCore/Modules/indexeddb/client/IDBConnectionProxy.cpp 2016-04-28 01:16:28 UTC (rev 200163)
@@ -82,6 +82,15 @@
return WTFMove(request);
}
+void IDBConnectionProxy::getAllDatabaseNames(const SecurityOrigin& mainFrameOrigin, const SecurityOrigin& openingOrigin, std::function<void (const Vector<String>&)> callback)
+{
+ // This method is only meant to be called by the web inspector on the main thread.
+ RELEASE_ASSERT(isMainThread());
+
+ m_connectionToServer.getAllDatabaseNames(mainFrameOrigin, openingOrigin, callback);
+}
+
+
} // namesapce IDBClient
} // namespace WebCore
Modified: trunk/Source/WebCore/Modules/indexeddb/client/IDBConnectionProxy.h (200162 => 200163)
--- trunk/Source/WebCore/Modules/indexeddb/client/IDBConnectionProxy.h 2016-04-27 23:53:08 UTC (rev 200162)
+++ trunk/Source/WebCore/Modules/indexeddb/client/IDBConnectionProxy.h 2016-04-28 01:16:28 UTC (rev 200163)
@@ -28,13 +28,17 @@
#if ENABLE(INDEXED_DATABASE)
#include "IDBConnectionToServer.h"
+#include <functional>
#include <wtf/RefPtr.h>
+#include <wtf/Vector.h>
+#include <wtf/text/WTFString.h>
namespace WebCore {
class IDBDatabaseIdentifier;
class IDBOpenDBRequest;
class ScriptExecutionContext;
+class SecurityOrigin;
namespace IDBClient {
@@ -57,6 +61,8 @@
void ref();
void deref();
+ void getAllDatabaseNames(const SecurityOrigin& mainFrameOrigin, const SecurityOrigin& openingOrigin, std::function<void (const Vector<String>&)>);
+
private:
IDBConnectionToServer& m_connectionToServer;
uint64_t m_serverConnectionIdentifier;
Modified: trunk/Source/WebCore/Modules/indexeddb/client/IDBConnectionToServer.cpp (200162 => 200163)
--- trunk/Source/WebCore/Modules/indexeddb/client/IDBConnectionToServer.cpp 2016-04-27 23:53:08 UTC (rev 200162)
+++ trunk/Source/WebCore/Modules/indexeddb/client/IDBConnectionToServer.cpp 2016-04-28 01:16:28 UTC (rev 200163)
@@ -411,6 +411,23 @@
return m_pendingTransactions.contains(identifier) || m_committingTransactions.contains(identifier) || m_abortingTransactions.contains(identifier);
}
+void IDBConnectionToServer::getAllDatabaseNames(const SecurityOrigin& mainFrameOrigin, const SecurityOrigin& openingOrigin, std::function<void (const Vector<String>&)> callback)
+{
+ static uint64_t callbackID = 0;
+
+ m_getAllDatabaseNamesCallbacks.add(++callbackID, WTFMove(callback));
+
+ m_delegate->getAllDatabaseNames(SecurityOriginData::fromSecurityOrigin(mainFrameOrigin), SecurityOriginData::fromSecurityOrigin(openingOrigin), callbackID);
+}
+
+void IDBConnectionToServer::didGetAllDatabaseNames(uint64_t callbackID, const Vector<String>& databaseNames)
+{
+ auto callback = m_getAllDatabaseNamesCallbacks.take(callbackID);
+ ASSERT(callback);
+
+ callback(databaseNames);
+}
+
} // namespace IDBClient
} // namespace WebCore
Modified: trunk/Source/WebCore/Modules/indexeddb/client/IDBConnectionToServer.h (200162 => 200163)
--- trunk/Source/WebCore/Modules/indexeddb/client/IDBConnectionToServer.h 2016-04-27 23:53:08 UTC (rev 200162)
+++ trunk/Source/WebCore/Modules/indexeddb/client/IDBConnectionToServer.h 2016-04-28 01:16:28 UTC (rev 200163)
@@ -123,6 +123,9 @@
void registerDatabaseConnection(IDBDatabase&);
void unregisterDatabaseConnection(IDBDatabase&);
+ void getAllDatabaseNames(const SecurityOrigin& mainFrameOrigin, const SecurityOrigin& openingOrigin, std::function<void (const Vector<String>&)>);
+ WEBCORE_EXPORT void didGetAllDatabaseNames(uint64_t callbackID, const Vector<String>& databaseNames);
+
private:
IDBConnectionToServer(IDBConnectionToServerDelegate&);
@@ -140,6 +143,8 @@
HashMap<IDBResourceIdentifier, RefPtr<IDBTransaction>> m_abortingTransactions;
HashMap<IDBResourceIdentifier, RefPtr<TransactionOperation>> m_activeOperations;
+ HashMap<uint64_t, std::function<void (const Vector<String>&)>> m_getAllDatabaseNamesCallbacks;
+
std::unique_ptr<IDBConnectionProxy> m_proxy;
};
Modified: trunk/Source/WebCore/Modules/indexeddb/client/IDBConnectionToServerDelegate.h (200162 => 200163)
--- trunk/Source/WebCore/Modules/indexeddb/client/IDBConnectionToServerDelegate.h 2016-04-27 23:53:08 UTC (rev 200162)
+++ trunk/Source/WebCore/Modules/indexeddb/client/IDBConnectionToServerDelegate.h 2016-04-28 01:16:28 UTC (rev 200163)
@@ -42,6 +42,8 @@
class IDBTransactionInfo;
class IDBValue;
+struct SecurityOriginData;
+
namespace IndexedDB {
enum class ObjectStoreOverwriteMode;
}
@@ -77,6 +79,8 @@
virtual void abortOpenAndUpgradeNeeded(uint64_t databaseConnectionIdentifier, const IDBResourceIdentifier& transactionIdentifier) = 0;
virtual void didFireVersionChangeEvent(uint64_t databaseConnectionIdentifier, const IDBResourceIdentifier& requestIdentifier) = 0;
+ virtual void getAllDatabaseNames(const SecurityOriginData& mainFrameOrigin, const SecurityOriginData& openingOrigin, uint64_t callbackID) = 0;
+
virtual void ref() = 0;
virtual void deref() = 0;
};
Modified: trunk/Source/WebCore/Modules/indexeddb/server/IDBConnectionToClient.cpp (200162 => 200163)
--- trunk/Source/WebCore/Modules/indexeddb/server/IDBConnectionToClient.cpp 2016-04-27 23:53:08 UTC (rev 200162)
+++ trunk/Source/WebCore/Modules/indexeddb/server/IDBConnectionToClient.cpp 2016-04-28 01:16:28 UTC (rev 200163)
@@ -138,6 +138,11 @@
m_delegate->notifyOpenDBRequestBlocked(requestIdentifier, oldVersion, newVersion);
}
+void IDBConnectionToClient::didGetAllDatabaseNames(uint64_t callbackID, const Vector<String>& databaseNames)
+{
+ m_delegate->didGetAllDatabaseNames(callbackID, databaseNames);
+}
+
} // namespace IDBServer
} // namespace WebCore
Modified: trunk/Source/WebCore/Modules/indexeddb/server/IDBConnectionToClient.h (200162 => 200163)
--- trunk/Source/WebCore/Modules/indexeddb/server/IDBConnectionToClient.h 2016-04-27 23:53:08 UTC (rev 200162)
+++ trunk/Source/WebCore/Modules/indexeddb/server/IDBConnectionToClient.h 2016-04-28 01:16:28 UTC (rev 200163)
@@ -69,6 +69,8 @@
void notifyOpenDBRequestBlocked(const IDBResourceIdentifier& requestIdentifier, uint64_t oldVersion, uint64_t newVersion);
+ void didGetAllDatabaseNames(uint64_t callbackID, const Vector<String>& databaseNames);
+
private:
IDBConnectionToClient(IDBConnectionToClientDelegate&);
Modified: trunk/Source/WebCore/Modules/indexeddb/server/IDBConnectionToClientDelegate.h (200162 => 200163)
--- trunk/Source/WebCore/Modules/indexeddb/server/IDBConnectionToClientDelegate.h 2016-04-27 23:53:08 UTC (rev 200162)
+++ trunk/Source/WebCore/Modules/indexeddb/server/IDBConnectionToClientDelegate.h 2016-04-28 01:16:28 UTC (rev 200163)
@@ -28,6 +28,9 @@
#if ENABLE(INDEXED_DATABASE)
+#include <wtf/Vector.h>
+#include <wtf/text/WTFString.h>
+
namespace WebCore {
class IDBError;
@@ -64,6 +67,8 @@
virtual void didStartTransaction(const IDBResourceIdentifier& transactionIdentifier, const IDBError&) = 0;
virtual void notifyOpenDBRequestBlocked(const IDBResourceIdentifier& requestIdentifier, uint64_t oldVersion, uint64_t newVersion) = 0;
+ virtual void didGetAllDatabaseNames(uint64_t callbackID, const Vector<String>& databaseNames) = 0;
+
virtual void ref() = 0;
virtual void deref() = 0;
};
Modified: trunk/Source/WebCore/Modules/indexeddb/server/IDBServer.cpp (200162 => 200163)
--- trunk/Source/WebCore/Modules/indexeddb/server/IDBServer.cpp 2016-04-27 23:53:08 UTC (rev 200162)
+++ trunk/Source/WebCore/Modules/indexeddb/server/IDBServer.cpp 2016-04-28 01:16:28 UTC (rev 200163)
@@ -28,6 +28,7 @@
#if ENABLE(INDEXED_DATABASE)
+#include "CrossThreadCopier.h"
#include "IDBRequestData.h"
#include "IDBResultData.h"
#include "Logging.h"
@@ -376,6 +377,35 @@
databaseConnection->didFireVersionChangeEvent(requestIdentifier);
}
+void IDBServer::getAllDatabaseNames(uint64_t serverConnectionIdentifier, const SecurityOriginData& mainFrameOrigin, const SecurityOriginData& openingOrigin, uint64_t callbackID)
+{
+ postDatabaseTask(createCrossThreadTask(*this, &IDBServer::performGetAllDatabaseNames, serverConnectionIdentifier, mainFrameOrigin, openingOrigin, callbackID));
+}
+
+void IDBServer::performGetAllDatabaseNames(uint64_t serverConnectionIdentifier, const SecurityOriginData& mainFrameOrigin, const SecurityOriginData& openingOrigin, uint64_t callbackID)
+{
+ String directory = IDBDatabaseIdentifier::databaseDirectoryRelativeToRoot(mainFrameOrigin, openingOrigin, m_databaseDirectoryPath);
+
+ Vector<String> entries = listDirectory(directory, ASCIILiteral("*"));
+ Vector<String> databases;
+ databases.reserveInitialCapacity(entries.size());
+ for (auto& entry : entries) {
+ String encodedName = lastComponentOfPathIgnoringTrailingSlash(entry);
+ databases.uncheckedAppend(SQLiteIDBBackingStore::databaseNameFromEncodedFilename(encodedName));
+ }
+
+ postDatabaseTaskReply(createCrossThreadTask(*this, &IDBServer::didGetAllDatabaseNames, serverConnectionIdentifier, callbackID, databases));
+}
+
+void IDBServer::didGetAllDatabaseNames(uint64_t serverConnectionIdentifier, uint64_t callbackID, const Vector<String>& databaseNames)
+{
+ auto connection = m_connectionMap.get(serverConnectionIdentifier);
+ if (!connection)
+ return;
+
+ connection->didGetAllDatabaseNames(callbackID, databaseNames);
+}
+
void IDBServer::postDatabaseTask(std::unique_ptr<CrossThreadTask>&& task)
{
ASSERT(isMainThread());
Modified: trunk/Source/WebCore/Modules/indexeddb/server/IDBServer.h (200162 => 200163)
--- trunk/Source/WebCore/Modules/indexeddb/server/IDBServer.h 2016-04-27 23:53:08 UTC (rev 200162)
+++ trunk/Source/WebCore/Modules/indexeddb/server/IDBServer.h 2016-04-28 01:16:28 UTC (rev 200163)
@@ -82,6 +82,8 @@
WEBCORE_EXPORT void abortOpenAndUpgradeNeeded(uint64_t databaseConnectionIdentifier, const IDBResourceIdentifier& transactionIdentifier);
WEBCORE_EXPORT void didFireVersionChangeEvent(uint64_t databaseConnectionIdentifier, const IDBResourceIdentifier& requestIdentifier);
+ WEBCORE_EXPORT void getAllDatabaseNames(uint64_t serverConnectionIdentifier, const SecurityOriginData& mainFrameOrigin, const SecurityOriginData& openingOrigin, uint64_t callbackID);
+
void postDatabaseTask(std::unique_ptr<CrossThreadTask>&&);
void postDatabaseTaskReply(std::unique_ptr<CrossThreadTask>&&);
@@ -100,6 +102,9 @@
UniqueIDBDatabase& getOrCreateUniqueIDBDatabase(const IDBDatabaseIdentifier&);
+ void performGetAllDatabaseNames(uint64_t serverConnectionIdentifier, const SecurityOriginData& mainFrameOrigin, const SecurityOriginData& openingOrigin, uint64_t callbackID);
+ void didGetAllDatabaseNames(uint64_t serverConnectionIdentifier, uint64_t callbackID, const Vector<String>& databaseNames);
+
static void databaseThreadEntry(void*);
void databaseRunLoop();
void handleTaskRepliesOnMainThread();
Modified: trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBBackingStore.cpp (200162 => 200163)
--- trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBBackingStore.cpp 2016-04-27 23:53:08 UTC (rev 200162)
+++ trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBBackingStore.cpp 2016-04-28 01:16:28 UTC (rev 200163)
@@ -659,6 +659,17 @@
return databaseInfo;
}
+String SQLiteIDBBackingStore::databaseNameFromEncodedFilename(const String& encodedName)
+{
+ if (equal(encodedName, ASCIILiteral("%00")))
+ return { };
+
+ String partiallyDecoded = encodedName;
+ partiallyDecoded.replace(ASCIILiteral("%2E"), ASCIILiteral("."));
+
+ return decodeFromFilename(partiallyDecoded);
+}
+
String SQLiteIDBBackingStore::filenameForDatabaseName() const
{
ASSERT(!m_identifier.databaseName().isNull());
Modified: trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBBackingStore.h (200162 => 200163)
--- trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBBackingStore.h 2016-04-27 23:53:08 UTC (rev 200162)
+++ trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBBackingStore.h 2016-04-28 01:16:28 UTC (rev 200163)
@@ -87,6 +87,8 @@
IDBError getBlobRecordsForObjectStoreRecord(int64_t objectStoreRecord, Vector<String>& blobURLs, Vector<String>& blobFilePaths);
+ static String databaseNameFromEncodedFilename(const String&);
+
private:
String filenameForDatabaseName() const;
String fullDatabasePath() const;
Modified: trunk/Source/WebCore/Modules/indexeddb/shared/InProcessIDBServer.cpp (200162 => 200163)
--- trunk/Source/WebCore/Modules/indexeddb/shared/InProcessIDBServer.cpp 2016-04-27 23:53:08 UTC (rev 200162)
+++ trunk/Source/WebCore/Modules/indexeddb/shared/InProcessIDBServer.cpp 2016-04-28 01:16:28 UTC (rev 200163)
@@ -401,6 +401,22 @@
});
}
+void InProcessIDBServer::getAllDatabaseNames(const SecurityOriginData& mainFrameOrigin, const SecurityOriginData& openingOrigin, uint64_t callbackID)
+{
+ RefPtr<InProcessIDBServer> protector(this);
+ RunLoop::current().dispatch([this, protector, mainFrameOrigin, openingOrigin, callbackID] {
+ m_server->getAllDatabaseNames(m_connectionToServer->identifier(), mainFrameOrigin, openingOrigin, callbackID);
+ });
+}
+
+void InProcessIDBServer::didGetAllDatabaseNames(uint64_t callbackID, const Vector<String>& databaseNames)
+{
+ RefPtr<InProcessIDBServer> protector(this);
+ RunLoop::current().dispatch([this, protector, callbackID, databaseNames] {
+ m_connectionToServer->didGetAllDatabaseNames(callbackID, databaseNames);
+ });
+}
+
void InProcessIDBServer::accessToTemporaryFileComplete(const String& path)
{
deleteFile(path);
Modified: trunk/Source/WebCore/Modules/indexeddb/shared/InProcessIDBServer.h (200162 => 200163)
--- trunk/Source/WebCore/Modules/indexeddb/shared/InProcessIDBServer.h 2016-04-27 23:53:08 UTC (rev 200162)
+++ trunk/Source/WebCore/Modules/indexeddb/shared/InProcessIDBServer.h 2016-04-28 01:16:28 UTC (rev 200163)
@@ -75,6 +75,7 @@
void databaseConnectionClosed(uint64_t databaseConnectionIdentifier) final;
void abortOpenAndUpgradeNeeded(uint64_t databaseConnectionIdentifier, const IDBResourceIdentifier& transactionIdentifier) final;
void didFireVersionChangeEvent(uint64_t databaseConnectionIdentifier, const IDBResourceIdentifier& requestIdentifier) final;
+ void getAllDatabaseNames(const SecurityOriginData& mainFrameOrigin, const SecurityOriginData& openingOrigin, uint64_t callbackID) final;
// IDBConnectionToClient
uint64_t identifier() const override;
@@ -96,6 +97,7 @@
void fireVersionChangeEvent(IDBServer::UniqueIDBDatabaseConnection&, const IDBResourceIdentifier& requestIdentifier, uint64_t requestedVersion) final;
void didStartTransaction(const IDBResourceIdentifier& transactionIdentifier, const IDBError&) final;
void notifyOpenDBRequestBlocked(const IDBResourceIdentifier& requestIdentifier, uint64_t oldVersion, uint64_t newVersion) final;
+ void didGetAllDatabaseNames(uint64_t callbackID, const Vector<String>& databaseNames) final;
void ref() override { RefCounted<InProcessIDBServer>::ref(); }
void deref() override { RefCounted<InProcessIDBServer>::deref(); }
Modified: trunk/Source/WebCore/inspector/InspectorIndexedDBAgent.cpp (200162 => 200163)
--- trunk/Source/WebCore/inspector/InspectorIndexedDBAgent.cpp 2016-04-27 23:53:08 UTC (rev 200162)
+++ trunk/Source/WebCore/inspector/InspectorIndexedDBAgent.cpp 2016-04-28 01:16:28 UTC (rev 200163)
@@ -90,62 +90,6 @@
namespace {
-#if 0 // IDBFactory::getDatabaseNames isn't implemented any more. Disable this for now.
-
-class GetDatabaseNamesCallback : public EventListener {
- WTF_MAKE_NONCOPYABLE(GetDatabaseNamesCallback);
-public:
- static Ref<GetDatabaseNamesCallback> create(Ref<RequestDatabaseNamesCallback>&& requestCallback, const String& securityOrigin)
- {
- return adoptRef(*new GetDatabaseNamesCallback(WTFMove(requestCallback), securityOrigin));
- }
-
- virtual ~GetDatabaseNamesCallback() { }
-
- bool operator==(const EventListener& other) override
- {
- return this == &other;
- }
-
- void handleEvent(ScriptExecutionContext*, Event* event) override
- {
- if (!m_requestCallback->isActive())
- return;
- if (event->type() != eventNames().successEvent) {
- m_requestCallback->sendFailure("Unexpected event type.");
- return;
- }
-
- IDBRequest* idbRequest = static_cast<IDBRequest*>(event->target());
- ExceptionCodeWithMessage ec;
- RefPtr<IDBAny> requestResult = idbRequest->result(ec);
- if (ec.code) {
- m_requestCallback->sendFailure("Could not get result in callback.");
- return;
- }
- if (requestResult->type() != IDBAny::Type::DOMStringList) {
- m_requestCallback->sendFailure("Unexpected result type.");
- return;
- }
-
- RefPtr<DOMStringList> databaseNamesList = requestResult->domStringList();
- Ref<Inspector::Protocol::Array<String>> databaseNames = Inspector::Protocol::Array<String>::create();
- for (size_t i = 0; i < databaseNamesList->length(); ++i)
- databaseNames->addItem(databaseNamesList->item(i));
- m_requestCallback->sendSuccess(WTFMove(databaseNames));
- }
-
-private:
- GetDatabaseNamesCallback(Ref<RequestDatabaseNamesCallback>&& requestCallback, const String& securityOrigin)
- : EventListener(EventListener::CPPEventListenerType)
- , m_requestCallback(WTFMove(requestCallback))
- , m_securityOrigin(securityOrigin) { }
- Ref<RequestDatabaseNamesCallback> m_requestCallback;
- String m_securityOrigin;
-};
-
-#endif
-
class ExecutableWithDatabase : public RefCounted<ExecutableWithDatabase> {
public:
ExecutableWithDatabase(ScriptExecutionContext* context)
@@ -512,29 +456,34 @@
void InspectorIndexedDBAgent::requestDatabaseNames(ErrorString& errorString, const String& securityOrigin, Ref<RequestDatabaseNamesCallback>&& requestCallback)
{
- UNUSED_PARAM(errorString);
- UNUSED_PARAM(securityOrigin);
- requestCallback->sendFailure("Could not obtain database names.");
-
-#if 0 // IDBFactory::getDatabaseNames isn't implemented any more. Disable this for now.
Frame* frame = m_pageAgent->findFrameWithSecurityOrigin(securityOrigin);
Document* document = assertDocument(errorString, frame);
if (!document)
return;
+ auto* openingOrigin = document->securityOrigin();
+ if (!openingOrigin)
+ return;
+
+ auto* topOrigin = document->topOrigin();
+ if (!topOrigin)
+ return;
+
IDBFactory* idbFactory = assertIDBFactory(errorString, document);
if (!idbFactory)
return;
- ExceptionCode ec = 0;
- RefPtr<IDBRequest> idbRequest = idbFactory->getDatabaseNames(*document, ec);
- if (!idbRequest || ec) {
- requestCallback->sendFailure("Could not obtain database names.");
- return;
- }
+ RefPtr<RequestDatabaseNamesCallback> callback = WTFMove(requestCallback);
+ idbFactory->getAllDatabaseNames(*topOrigin, *openingOrigin, [callback](const Vector<String>& databaseNames) {
+ if (!callback->isActive())
+ return;
- idbRequest->addEventListener(eventNames().successEvent, GetDatabaseNamesCallback::create(WTFMove(requestCallback), document->securityOrigin()->toRawString()), false);
-#endif
+ Ref<Inspector::Protocol::Array<String>> databaseNameArray = Inspector::Protocol::Array<String>::create();
+ for (auto& databaseName : databaseNames)
+ databaseNameArray->addItem(databaseName);
+
+ callback->sendSuccess(WTFMove(databaseNameArray));
+ });
}
void InspectorIndexedDBAgent::requestDatabase(ErrorString& errorString, const String& securityOrigin, const String& databaseName, Ref<RequestDatabaseCallback>&& requestCallback)
Modified: trunk/Source/WebCore/platform/CrossThreadCopier.cpp (200162 => 200163)
--- trunk/Source/WebCore/platform/CrossThreadCopier.cpp 2016-04-27 23:53:08 UTC (rev 200162)
+++ trunk/Source/WebCore/platform/CrossThreadCopier.cpp 2016-04-28 01:16:28 UTC (rev 200163)
@@ -36,6 +36,7 @@
#include "ResourceError.h"
#include "ResourceRequest.h"
#include "ResourceResponse.h"
+#include "SecurityOriginData.h"
#include "SerializedScriptValue.h"
#include "SessionID.h"
#include "ThreadSafeDataBuffer.h"
@@ -84,6 +85,11 @@
return response.copyData();
}
+CrossThreadCopierBase<false, false, SecurityOriginData>::Type CrossThreadCopierBase<false, false, SecurityOriginData>::copy(const SecurityOriginData& originData)
+{
+ return originData.isolatedCopy();
+}
+
CrossThreadCopierBase<false, false, SessionID>::Type CrossThreadCopierBase<false, false, SessionID>::copy(const SessionID& sessionID)
{
return sessionID;
@@ -94,6 +100,16 @@
return ThreadSafeDataBuffer(buffer);
}
+CrossThreadCopierBase<false, false, Vector<String>>::Type CrossThreadCopierBase<false, false, Vector<String>>::copy(const Vector<String>& strings)
+{
+ Vector<String> result;
+ result.reserveInitialCapacity(strings.size());
+ for (auto& string : strings)
+ result.uncheckedAppend(string.isolatedCopy());
+
+ return result;
+}
+
#if ENABLE(INDEXED_DATABASE)
IndexedDB::TransactionMode CrossThreadCopierBase<false, false, IndexedDB::TransactionMode>::copy(const IndexedDB::TransactionMode& mode)
Modified: trunk/Source/WebCore/platform/CrossThreadCopier.h (200162 => 200163)
--- trunk/Source/WebCore/platform/CrossThreadCopier.h 2016-04-27 23:53:08 UTC (rev 200162)
+++ trunk/Source/WebCore/platform/CrossThreadCopier.h 2016-04-28 01:16:28 UTC (rev 200163)
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2009, 2010 Google Inc. All rights reserved.
+ * Copyright (C) 2014, 2015, 2016 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -35,6 +36,7 @@
#include <wtf/PassRefPtr.h>
#include <wtf/RefPtr.h>
#include <wtf/Threading.h>
+#include <wtf/text/WTFString.h>
namespace WebCore {
@@ -48,6 +50,7 @@
class ThreadSafeDataBuffer;
struct CrossThreadResourceResponseData;
struct CrossThreadResourceRequestData;
+struct SecurityOriginData;
struct ThreadableLoaderOptions;
struct CrossThreadCopierBaseHelper {
@@ -134,6 +137,11 @@
static Type copy(const ResourceResponse&);
};
+template<> struct CrossThreadCopierBase<false, false, SecurityOriginData> {
+ typedef SecurityOriginData Type;
+ static Type copy(const SecurityOriginData&);
+};
+
template<> struct CrossThreadCopierBase<false, false, SessionID> {
typedef SessionID Type;
static Type copy(const SessionID&);
@@ -144,6 +152,11 @@
static Type copy(const ThreadSafeDataBuffer&);
};
+template<> struct CrossThreadCopierBase<false, false, Vector<String>> {
+ typedef Vector<String> Type;
+ static Type copy(const Vector<String>&);
+};
+
#if ENABLE(INDEXED_DATABASE)
namespace IndexedDB {
enum class TransactionMode;
Modified: trunk/Source/WebCore/platform/FileSystem.cpp (200162 => 200163)
--- trunk/Source/WebCore/platform/FileSystem.cpp 2016-04-27 23:53:08 UTC (rev 200162)
+++ trunk/Source/WebCore/platform/FileSystem.cpp 2016-04-28 01:16:28 UTC (rev 200163)
@@ -130,6 +130,87 @@
return result.toString();
}
+String decodeFromFilename(const String& inputString)
+{
+ unsigned length = inputString.length();
+ if (!length)
+ return inputString;
+
+ StringBuilder result;
+ result.reserveCapacity(length);
+
+ for (unsigned i = 0; i < length; ++i) {
+ if (inputString[i] != '%') {
+ result.append(inputString[i]);
+ continue;
+ }
+
+ // If the input string is a valid encoded filename, it must be at least 2 characters longer
+ // than the current index to account for this percent encoded value.
+ if (i + 2 >= length)
+ return { };
+
+ if (inputString[i+1] != '+') {
+ char value;
+ if (!hexDigitValue(inputString[i + 1], value))
+ return { };
+ LChar character = value << 4;
+
+ if (!hexDigitValue(inputString[i + 2], value))
+ return { };
+
+ result.append(character | value);
+ continue;
+ }
+
+ // If the input string is a valid encoded filename, it must be at least 5 characters longer
+ // than the current index to account for this percent encoded value.
+ if (i + 5 >= length)
+ return { };
+
+ char value;
+ if (!hexDigitValue(inputString[i + 2], value))
+ return { };
+ UChar character = value << 12;
+
+ if (!hexDigitValue(inputString[i + 3], value))
+ return { };
+ character = character | (value << 8);
+
+ if (!hexDigitValue(inputString[i + 4], value))
+ return { };
+ character = character | (value << 4);
+
+ if (!hexDigitValue(inputString[i + 5], value))
+ return { };
+
+ result.append(character | value);
+ }
+
+ return result.toString();
+}
+
+String lastComponentOfPathIgnoringTrailingSlash(const String& path)
+{
+#if PLATFORM(WIN)
+ char pathSeperator = '\\';
+#else
+ char pathSeperator = '/';
+#endif
+
+ auto position = path.reverseFind(pathSeperator);
+ if (position == notFound)
+ return path;
+
+ size_t endOfSubstring = path.length() - 1;
+ if (position == endOfSubstring) {
+ --endOfSubstring;
+ position = path.reverseFind(pathSeperator, endOfSubstring);
+ }
+
+ return path.substring(position + 1, endOfSubstring - position);
+}
+
bool appendFileContentsToFileHandle(const String& path, PlatformFileHandle& target)
{
auto source = openFile(path, OpenForRead);
Modified: trunk/Source/WebCore/platform/FileSystem.h (200162 => 200163)
--- trunk/Source/WebCore/platform/FileSystem.h 2016-04-27 23:53:08 UTC (rev 200162)
+++ trunk/Source/WebCore/platform/FileSystem.h 2016-04-28 01:16:28 UTC (rev 200163)
@@ -146,6 +146,7 @@
WEBCORE_EXPORT bool getFileCreationTime(const String&, time_t& result); // Not all platforms store file creation time.
bool getFileMetadata(const String&, FileMetadata&);
WEBCORE_EXPORT String pathByAppendingComponent(const String& path, const String& component);
+String lastComponentOfPathIgnoringTrailingSlash(const String& path);
WEBCORE_EXPORT bool makeAllDirectories(const String& path);
String homeDirectoryPath();
WEBCORE_EXPORT String pathGetFileName(const String&);
@@ -159,6 +160,7 @@
WEBCORE_EXPORT Vector<String> listDirectory(const String& path, const String& filter = String());
WEBCORE_EXPORT CString fileSystemRepresentation(const String&);
+String stringFromFileSystemRepresentation(const char*);
inline bool isHandleValid(const PlatformFileHandle& handle) { return handle != invalidPlatformFileHandle; }
@@ -194,6 +196,7 @@
// Encode a string for use within a file name.
WEBCORE_EXPORT String encodeForFileName(const String&);
+String decodeFromFilename(const String&);
#if USE(CF)
RetainPtr<CFURLRef> pathAsURL(const String&);
Modified: trunk/Source/WebCore/platform/cf/FileSystemCF.cpp (200162 => 200163)
--- trunk/Source/WebCore/platform/cf/FileSystemCF.cpp 2016-04-27 23:53:08 UTC (rev 200162)
+++ trunk/Source/WebCore/platform/cf/FileSystemCF.cpp 2016-04-28 01:16:28 UTC (rev 200163)
@@ -29,6 +29,7 @@
#include "config.h"
#include "FileSystem.h"
+#include <CoreFoundation/CFString.h>
#include <wtf/RetainPtr.h>
#include <wtf/text/CString.h>
#include <wtf/text/WTFString.h>
@@ -54,6 +55,11 @@
return CString(buffer.data(), strlen(buffer.data()));
}
+String stringFromFileSystemRepresentation(const char* fileSystemRepresentation)
+{
+ return adoptCF(CFStringCreateWithFileSystemRepresentation(kCFAllocatorDefault, fileSystemRepresentation)).get();
+}
+
RetainPtr<CFURLRef> pathAsURL(const String& path)
{
CFURLPathStyle pathStyle;
Modified: trunk/Source/WebCore/platform/glib/FileSystemGlib.cpp (200162 => 200163)
--- trunk/Source/WebCore/platform/glib/FileSystemGlib.cpp 2016-04-27 23:53:08 UTC (rev 200162)
+++ trunk/Source/WebCore/platform/glib/FileSystemGlib.cpp 2016-04-28 01:16:28 UTC (rev 200163)
@@ -54,6 +54,11 @@
#endif
}
+String stringFromFileSystemRepresentation(const char* fileSystemRepresentation)
+{
+ return filenameToString(fileSystemRepresentation);
+}
+
static GUniquePtr<char> unescapedFilename(const String& path)
{
if (path.isEmpty())
Modified: trunk/Source/WebCore/platform/mac/WebCoreNSURLExtras.mm (200162 => 200163)
--- trunk/Source/WebCore/platform/mac/WebCoreNSURLExtras.mm 2016-04-27 23:53:08 UTC (rev 200162)
+++ trunk/Source/WebCore/platform/mac/WebCoreNSURLExtras.mm 2016-04-28 01:16:28 UTC (rev 200163)
@@ -32,6 +32,7 @@
#import "WebCoreNSURLExtras.h"
#import "WebCoreSystemInterface.h"
#import <functional>
+#import <wtf/HexNumber.h>
#import <wtf/ObjcRuntimeExtras.h>
#import <wtf/RetainPtr.h>
#import <wtf/Vector.h>
@@ -718,34 +719,6 @@
return [mutableCopy autorelease];
}
-static BOOL isHexDigit(char c)
-{
- return (c >= '0' && c <= '9') || (c >= 'A' && c <= 'F') || (c >= 'a' && c <= 'f');
-}
-
-static char hexDigit(int i)
-{
- if (i < 0 || i > 16)
- return '0';
-
- return (i >= 10) ? i - 10 + 'A' : i += '0';
-}
-
-static int hexDigitValue(char c)
-{
- if (c >= '0' && c <= '9')
- return c - '0';
-
- if (c >= 'A' && c <= 'F')
- return c - 'A' + 10;
-
- if (c >= 'a' && c <= 'f')
- return c - 'a' + 10;
-
- LOG_ERROR("illegal hex digit");
- return 0;
-}
-
static NSString *stringByTrimmingWhitespace(NSString *string)
{
NSMutableString *trimmed = [[string mutableCopy] autorelease];
@@ -831,8 +804,8 @@
UInt8 c = inBytes[i];
if (c <= 0x20 || c >= 0x7f) {
*p++ = '%';
- *p++ = hexDigit(c >> 4);
- *p++ = hexDigit(c & 0xf);
+ *p++ = uncheckedHexDigit(c >> 4);
+ *p++ = uncheckedHexDigit(c & 0xf);
outLength += 3;
} else {
*p++ = c;
@@ -926,8 +899,8 @@
if (c <= 0x20 || c >= 0x7f) {
char escaped[3];
escaped[0] = '%';
- escaped[1] = hexDigit(c >> 4);
- escaped[2] = hexDigit(c & 0xf);
+ escaped[1] = uncheckedHexDigit(c >> 4);
+ escaped[2] = uncheckedHexDigit(c & 0xf);
[resultData appendBytes:escaped length:3];
} else {
char b[1];
@@ -1038,8 +1011,8 @@
for (CFIndex j = 0; j < offset; ++j) {
outBuffer.append('%');
- outBuffer.append(hexDigit(utf8Buffer[j] >> 4));
- outBuffer.append(hexDigit(utf8Buffer[j] & 0xf));
+ outBuffer.append(uncheckedHexDigit(utf8Buffer[j] >> 4));
+ outBuffer.append(uncheckedHexDigit(utf8Buffer[j] & 0xf));
}
} else {
UChar utf16Buffer[2];
@@ -1071,7 +1044,7 @@
unsigned char c = p[i];
// unescape escape sequences that indicate bytes greater than 0x7f
if (c == '%' && (i + 1 < length && isHexDigit(p[i + 1])) && i + 2 < length && isHexDigit(p[i + 2])) {
- unsigned char u = (hexDigitValue(p[i + 1]) << 4) | hexDigitValue(p[i + 2]);
+ unsigned char u = (uncheckedHexDigitValue(p[i + 1]) << 4) | uncheckedHexDigitValue(p[i + 2]);
if (u > 0x7f) {
// unescape
*q++ = u;
@@ -1108,8 +1081,8 @@
unsigned char c = *p;
if (c > 0x7f) {
*q++ = '%';
- *q++ = hexDigit(c >> 4);
- *q++ = hexDigit(c & 0xf);
+ *q++ = uncheckedHexDigit(c >> 4);
+ *q++ = uncheckedHexDigit(c & 0xf);
} else
*q++ = *p;
p++;
@@ -1152,7 +1125,7 @@
valid = NO;
break;
} else if (c == '%' && (i + 1 < length && isHexDigit(p[i + 1])) && i + 2 < length && isHexDigit(p[i + 2])) {
- unsigned char u = (hexDigitValue(p[i + 1]) << 4) | hexDigitValue(p[i + 2]);
+ unsigned char u = (uncheckedHexDigitValue(p[i + 1]) << 4) | uncheckedHexDigitValue(p[i + 2]);
if (u > 0x7f) {
valid = NO;
break;
Modified: trunk/Source/WebCore/platform/posix/FileSystemPOSIX.cpp (200162 => 200163)
--- trunk/Source/WebCore/platform/posix/FileSystemPOSIX.cpp 2016-04-27 23:53:08 UTC (rev 200162)
+++ trunk/Source/WebCore/platform/posix/FileSystemPOSIX.cpp 2016-04-28 01:16:28 UTC (rev 200163)
@@ -301,8 +301,8 @@
Vector<String> listDirectory(const String& path, const String& filter)
{
Vector<String> entries;
- CString cpath = path.utf8();
- CString cfilter = filter.utf8();
+ CString cpath = fileSystemRepresentation(path);
+ CString cfilter = fileSystemRepresentation(filter);
DIR* dir = opendir(cpath.data());
if (dir) {
struct dirent* dp;
@@ -312,10 +312,16 @@
continue;
if (fnmatch(cfilter.data(), name, 0))
continue;
- char filePath[1024];
+ char filePath[PATH_MAX];
if (static_cast<int>(sizeof(filePath) - 1) < snprintf(filePath, sizeof(filePath), "%s/%s", cpath.data(), name))
continue; // buffer overflow
- entries.append(filePath);
+
+ auto string = stringFromFileSystemRepresentation(filePath);
+
+ // Some file system representations cannot be represented as a UTF-16 string,
+ // so this string might be null.
+ if (!string.isNull())
+ entries.append(WTFMove(string));
}
closedir(dir);
}
Modified: trunk/Source/WebKit2/ChangeLog (200162 => 200163)
--- trunk/Source/WebKit2/ChangeLog 2016-04-27 23:53:08 UTC (rev 200162)
+++ trunk/Source/WebKit2/ChangeLog 2016-04-28 01:16:28 UTC (rev 200163)
@@ -1,3 +1,28 @@
+2016-04-27 Brady Eidson <beid...@apple.com>
+
+ Modern IDB: Implement native IDBFactory.getAllDatabaseNames for WebInspector.
+ https://bugs.webkit.org/show_bug.cgi?id=157072
+
+ Reviewed by Alex Christensen.
+
+ Handle the process hop for the new getAllDatabaseNames call.
+
+ * DatabaseProcess/IndexedDB/WebIDBConnectionToClient.cpp:
+ (WebKit::WebIDBConnectionToClient::didGetAllDatabaseNames):
+ (WebKit::WebIDBConnectionToClient::getAllDatabaseNames):
+ * DatabaseProcess/IndexedDB/WebIDBConnectionToClient.h:
+ * DatabaseProcess/IndexedDB/WebIDBConnectionToClient.messages.in:
+
+ * Shared/WebCrossThreadCopier.cpp:
+ (WebCore::SecurityOriginData>::copy): Deleted, as its in WebCore now.
+ * Shared/WebCrossThreadCopier.h:
+
+ * WebProcess/Databases/IndexedDB/WebIDBConnectionToServer.cpp:
+ (WebKit::WebIDBConnectionToServer::getAllDatabaseNames):
+ (WebKit::WebIDBConnectionToServer::didGetAllDatabaseNames):
+ * WebProcess/Databases/IndexedDB/WebIDBConnectionToServer.h:
+ * WebProcess/Databases/IndexedDB/WebIDBConnectionToServer.messages.in:
+
2016-04-27 Simon Fraser <simon.fra...@apple.com>
[iOS WK2] When determining tile size, check whether ancestor UIScrollViews are actually scrollable
Modified: trunk/Source/WebKit2/DatabaseProcess/IndexedDB/WebIDBConnectionToClient.cpp (200162 => 200163)
--- trunk/Source/WebKit2/DatabaseProcess/IndexedDB/WebIDBConnectionToClient.cpp 2016-04-27 23:53:08 UTC (rev 200162)
+++ trunk/Source/WebKit2/DatabaseProcess/IndexedDB/WebIDBConnectionToClient.cpp 2016-04-28 01:16:28 UTC (rev 200163)
@@ -174,6 +174,11 @@
send(Messages::WebIDBConnectionToServer::NotifyOpenDBRequestBlocked(requestIdentifier, oldVersion, newVersion));
}
+void WebIDBConnectionToClient::didGetAllDatabaseNames(uint64_t callbackID, const Vector<String>& databaseNames)
+{
+ send(Messages::WebIDBConnectionToServer::DidGetAllDatabaseNames(callbackID, databaseNames));
+}
+
void WebIDBConnectionToClient::deleteDatabase(const IDBRequestData& request)
{
DatabaseProcess::singleton().idbServer().deleteDatabase(request);
@@ -284,6 +289,11 @@
DatabaseProcess::singleton().idbServer().didFireVersionChangeEvent(databaseConnectionIdentifier, transactionIdentifier);
}
+void WebIDBConnectionToClient::getAllDatabaseNames(uint64_t serverConnectionIdentifier, const WebCore::SecurityOriginData& topOrigin, const WebCore::SecurityOriginData& openingOrigin, uint64_t callbackID)
+{
+ DatabaseProcess::singleton().idbServer().getAllDatabaseNames(serverConnectionIdentifier, topOrigin, openingOrigin, callbackID);
+}
+
} // namespace WebKit
#endif // ENABLE(INDEXED_DATABASE)
Modified: trunk/Source/WebKit2/DatabaseProcess/IndexedDB/WebIDBConnectionToClient.h (200162 => 200163)
--- trunk/Source/WebKit2/DatabaseProcess/IndexedDB/WebIDBConnectionToClient.h 2016-04-27 23:53:08 UTC (rev 200162)
+++ trunk/Source/WebKit2/DatabaseProcess/IndexedDB/WebIDBConnectionToClient.h 2016-04-28 01:16:28 UTC (rev 200163)
@@ -42,6 +42,7 @@
class IDBValue;
class SerializedScriptValue;
struct IDBKeyRangeData;
+struct SecurityOriginData;
}
namespace WebKit {
@@ -77,6 +78,8 @@
void didStartTransaction(const WebCore::IDBResourceIdentifier& transactionIdentifier, const WebCore::IDBError&) final;
void notifyOpenDBRequestBlocked(const WebCore::IDBResourceIdentifier& requestIdentifier, uint64_t oldVersion, uint64_t newVersion) final;
+ void didGetAllDatabaseNames(uint64_t callbackID, const Vector<String>& databaseNames) final;
+
void ref() override { RefCounted<WebIDBConnectionToClient>::ref(); }
void deref() override { RefCounted<WebIDBConnectionToClient>::deref(); }
@@ -103,6 +106,8 @@
void abortOpenAndUpgradeNeeded(uint64_t databaseConnectionIdentifier, const WebCore::IDBResourceIdentifier& transactionIdentifier);
void didFireVersionChangeEvent(uint64_t databaseConnectionIdentifier, const WebCore::IDBResourceIdentifier& requestIdentifier);
+ void getAllDatabaseNames(uint64_t serverConnectionIdentifier, const WebCore::SecurityOriginData& topOrigin, const WebCore::SecurityOriginData& openingOrigin, uint64_t callbackID);
+
void disconnectedFromWebProcess();
void didReceiveMessage(IPC::Connection&, IPC::MessageDecoder&);
Modified: trunk/Source/WebKit2/DatabaseProcess/IndexedDB/WebIDBConnectionToClient.messages.in (200162 => 200163)
--- trunk/Source/WebKit2/DatabaseProcess/IndexedDB/WebIDBConnectionToClient.messages.in 2016-04-27 23:53:08 UTC (rev 200162)
+++ trunk/Source/WebKit2/DatabaseProcess/IndexedDB/WebIDBConnectionToClient.messages.in 2016-04-28 01:16:28 UTC (rev 200163)
@@ -44,6 +44,7 @@
DatabaseConnectionClosed(uint64_t databaseConnectionIdentifier);
AbortOpenAndUpgradeNeeded(uint64_t databaseConnectionIdentifier, WebCore::IDBResourceIdentifier transactionIdentifier);
DidFireVersionChangeEvent(uint64_t databaseConnectionIdentifier, WebCore::IDBResourceIdentifier requestIdentifier);
+
+ GetAllDatabaseNames(uint64_t serverConnectionIdentifier, struct WebCore::SecurityOriginData topOrigin, struct WebCore::SecurityOriginData openingOrigin, uint64_t callbackID);
}
-
#endif // ENABLE(INDEXED_DATABASE) && ENABLE(DATABASE_PROCESS)
Modified: trunk/Source/WebKit2/Shared/WebCrossThreadCopier.cpp (200162 => 200163)
--- trunk/Source/WebKit2/Shared/WebCrossThreadCopier.cpp 2016-04-27 23:53:08 UTC (rev 200162)
+++ trunk/Source/WebKit2/Shared/WebCrossThreadCopier.cpp 2016-04-28 01:16:28 UTC (rev 200163)
@@ -28,7 +28,6 @@
#if ENABLE(INDEXED_DATABASE)
#include <WebCore/IDBKeyData.h>
-#include <WebCore/SecurityOriginData.h>
using namespace WebKit;
@@ -68,11 +67,6 @@
return result;
}
-SecurityOriginData CrossThreadCopierBase<false, false, SecurityOriginData>::copy(const SecurityOriginData& securityOriginData)
-{
- return securityOriginData.isolatedCopy();
-}
-
ASCIILiteral CrossThreadCopierBase<false, false, ASCIILiteral>::copy(const ASCIILiteral& literal)
{
return literal;
Modified: trunk/Source/WebKit2/Shared/WebCrossThreadCopier.h (200162 => 200163)
--- trunk/Source/WebKit2/Shared/WebCrossThreadCopier.h 2016-04-27 23:53:08 UTC (rev 200162)
+++ trunk/Source/WebKit2/Shared/WebCrossThreadCopier.h 2016-04-28 01:16:28 UTC (rev 200163)
@@ -52,10 +52,6 @@
}
};
-template<> struct CrossThreadCopierBase<false, false, WebCore::SecurityOriginData> {
- static WebCore::SecurityOriginData copy(const WebCore::SecurityOriginData& type);
-};
-
template<> struct CrossThreadCopierBase<false, false, Vector<char>> {
static Vector<char> copy(const Vector<char>&);
};
Modified: trunk/Source/WebKit2/WebProcess/Databases/IndexedDB/WebIDBConnectionToServer.cpp (200162 => 200163)
--- trunk/Source/WebKit2/WebProcess/Databases/IndexedDB/WebIDBConnectionToServer.cpp 2016-04-27 23:53:08 UTC (rev 200162)
+++ trunk/Source/WebKit2/WebProcess/Databases/IndexedDB/WebIDBConnectionToServer.cpp 2016-04-28 01:16:28 UTC (rev 200163)
@@ -182,6 +182,11 @@
send(Messages::WebIDBConnectionToClient::DidFireVersionChangeEvent(databaseConnectionIdentifier, requestIdentifier));
}
+void WebIDBConnectionToServer::getAllDatabaseNames(const WebCore::SecurityOriginData& topOrigin, const WebCore::SecurityOriginData& openingOrigin, uint64_t callbackID)
+{
+ send(Messages::WebIDBConnectionToClient::GetAllDatabaseNames(m_identifier, topOrigin, openingOrigin, callbackID));
+}
+
void WebIDBConnectionToServer::didDeleteDatabase(const IDBResultData& result)
{
m_connectionToServer->didDeleteDatabase(result);
@@ -283,6 +288,11 @@
m_connectionToServer->notifyOpenDBRequestBlocked(requestIdentifier, oldVersion, newVersion);
}
+void WebIDBConnectionToServer::didGetAllDatabaseNames(uint64_t callbackID, const Vector<String>& databaseNames)
+{
+ m_connectionToServer->didGetAllDatabaseNames(callbackID, databaseNames);
+}
+
} // namespace WebKit
#endif // ENABLE(INDEXED_DATABASE)
Modified: trunk/Source/WebKit2/WebProcess/Databases/IndexedDB/WebIDBConnectionToServer.h (200162 => 200163)
--- trunk/Source/WebKit2/WebProcess/Databases/IndexedDB/WebIDBConnectionToServer.h 2016-04-27 23:53:08 UTC (rev 200162)
+++ trunk/Source/WebKit2/WebProcess/Databases/IndexedDB/WebIDBConnectionToServer.h 2016-04-28 01:16:28 UTC (rev 200163)
@@ -65,6 +65,7 @@
void databaseConnectionClosed(uint64_t databaseConnectionIdentifier) final;
void abortOpenAndUpgradeNeeded(uint64_t databaseConnectionIdentifier, const WebCore::IDBResourceIdentifier& transactionIdentifier) final;
void didFireVersionChangeEvent(uint64_t databaseConnectionIdentifier, const WebCore::IDBResourceIdentifier& requestIdentifier) final;
+ void getAllDatabaseNames(const WebCore::SecurityOriginData& topOrigin, const WebCore::SecurityOriginData& openingOrigin, uint64_t callbackID) final;
void ref() override { RefCounted<WebIDBConnectionToServer>::ref(); }
void deref() override { RefCounted<WebIDBConnectionToServer>::deref(); }
@@ -89,6 +90,7 @@
void fireVersionChangeEvent(uint64_t uniqueDatabaseConnectionIdentifier, const WebCore::IDBResourceIdentifier& requestIdentifier, uint64_t requestedVersion);
void didStartTransaction(const WebCore::IDBResourceIdentifier& transactionIdentifier, const WebCore::IDBError&);
void notifyOpenDBRequestBlocked(const WebCore::IDBResourceIdentifier& requestIdentifier, uint64_t oldVersion, uint64_t newVersion);
+ void didGetAllDatabaseNames(uint64_t callbackID, const Vector<String>& databaseNames);
void didReceiveMessage(IPC::Connection&, IPC::MessageDecoder&);
Modified: trunk/Source/WebKit2/WebProcess/Databases/IndexedDB/WebIDBConnectionToServer.messages.in (200162 => 200163)
--- trunk/Source/WebKit2/WebProcess/Databases/IndexedDB/WebIDBConnectionToServer.messages.in 2016-04-27 23:53:08 UTC (rev 200162)
+++ trunk/Source/WebKit2/WebProcess/Databases/IndexedDB/WebIDBConnectionToServer.messages.in 2016-04-28 01:16:28 UTC (rev 200163)
@@ -44,6 +44,7 @@
DidStartTransaction(WebCore::IDBResourceIdentifier transactionIdentifier, WebCore::IDBError error)
NotifyOpenDBRequestBlocked(WebCore::IDBResourceIdentifier requestIdentifier, uint64_t oldVersion, uint64_t newVersion)
+ DidGetAllDatabaseNames(uint64_t callbackID, Vector<String> databaseNames)
}
#endif // ENABLE(INDEXED_DATABASE) && ENABLE(DATABASE_PROCESS)