Fix build with ENABLE(DATABASE_PROCESS) and !ENABLE(INDEXED_DATABASE)
authorossy@webkit.org <ossy@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 2 Sep 2015 11:58:36 +0000 (11:58 +0000)
committerossy@webkit.org <ossy@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 2 Sep 2015 11:58:36 +0000 (11:58 +0000)
https://bugs.webkit.org/show_bug.cgi?id=146550

Patch by Emanuele Aina <emanuele.aina@collabora.com> on 2015-09-02
Reviewed by Brady Eidson.

Given that INDEXED_DATABASE at the moment is the only user of
DATABASE_PROCESS, their guards got inevitably mixed up with various
levels of consistency. Since the --no-indexed-database flag from
build-webkit leaves DATABASE_PROCESS enabled, this resulted in build
failures.

* DatabaseProcess/DatabaseProcess.cpp:
* DatabaseProcess/DatabaseToWebProcessConnection.cpp:
* Shared/Databases/DatabaseProcessCreationParameters.cpp:
* Shared/Databases/DatabaseProcessCreationParameters.h:
* UIProcess/WebProcessPool.cpp:
* WebProcess/Databases/WebToDatabaseProcessConnection.cpp:
* WebProcess/Databases/WebToDatabaseProcessConnection.h:
Add missing ENABLE(INDEXED_DATABASE) guards and moved the
misplaced ones.

* DatabaseProcess/DatabaseProcess.h:
Ditto, and also add a forward declaration for SecurityOriginData since
with INDEXED_DATABASE off SecurityOriginData.h is no longer included
by way of UniqueIDBDatabaseIdentifier.h.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@189244 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebKit2/ChangeLog
Source/WebKit2/DatabaseProcess/DatabaseProcess.cpp
Source/WebKit2/DatabaseProcess/DatabaseProcess.h
Source/WebKit2/DatabaseProcess/DatabaseToWebProcessConnection.cpp
Source/WebKit2/Shared/Databases/DatabaseProcessCreationParameters.cpp
Source/WebKit2/Shared/Databases/DatabaseProcessCreationParameters.h
Source/WebKit2/UIProcess/WebProcessPool.cpp
Source/WebKit2/WebProcess/Databases/WebToDatabaseProcessConnection.cpp
Source/WebKit2/WebProcess/Databases/WebToDatabaseProcessConnection.h

index 8bd68f7..9d145e2 100644 (file)
@@ -1,3 +1,31 @@
+2015-09-02  Emanuele Aina  <emanuele.aina@collabora.com>
+
+        Fix build with ENABLE(DATABASE_PROCESS) and !ENABLE(INDEXED_DATABASE)
+        https://bugs.webkit.org/show_bug.cgi?id=146550
+
+        Reviewed by Brady Eidson.
+
+        Given that INDEXED_DATABASE at the moment is the only user of
+        DATABASE_PROCESS, their guards got inevitably mixed up with various
+        levels of consistency. Since the --no-indexed-database flag from
+        build-webkit leaves DATABASE_PROCESS enabled, this resulted in build
+        failures.
+
+        * DatabaseProcess/DatabaseProcess.cpp:
+        * DatabaseProcess/DatabaseToWebProcessConnection.cpp:
+        * Shared/Databases/DatabaseProcessCreationParameters.cpp:
+        * Shared/Databases/DatabaseProcessCreationParameters.h:
+        * UIProcess/WebProcessPool.cpp:
+        * WebProcess/Databases/WebToDatabaseProcessConnection.cpp:
+        * WebProcess/Databases/WebToDatabaseProcessConnection.h:
+        Add missing ENABLE(INDEXED_DATABASE) guards and moved the
+        misplaced ones.
+
+        * DatabaseProcess/DatabaseProcess.h:
+        Ditto, and also add a forward declaration for SecurityOriginData since
+        with INDEXED_DATABASE off SecurityOriginData.h is no longer included
+        by way of UniqueIDBDatabaseIdentifier.h.
+
 2015-09-01  Brian Burg  <bburg@apple.com>
 
         Web Inspector: opt the Inspector process out of page visibility-based process suppression when running tests
index f7611d4..c8d8a3c 100644 (file)
@@ -95,6 +95,7 @@ void DatabaseProcess::didReceiveInvalidMessage(IPC::Connection&, IPC::StringRefe
     RunLoop::current().stop();
 }
 
+#if ENABLE(INDEXED_DATABASE)
 RefPtr<UniqueIDBDatabase> DatabaseProcess::getOrCreateUniqueIDBDatabase(const UniqueIDBDatabaseIdentifier& identifier)
 {
     auto addResult = m_idbDatabases.add(identifier, nullptr);
@@ -114,9 +115,11 @@ void DatabaseProcess::removeUniqueIDBDatabase(const UniqueIDBDatabase& database)
 
     m_idbDatabases.remove(identifier);
 }
+#endif
 
 void DatabaseProcess::initializeDatabaseProcess(const DatabaseProcessCreationParameters& parameters)
 {
+#if ENABLE(INDEXED_DATABASE)
     // *********
     // IMPORTANT: Do not change the directory structure for indexed databases on disk without first consulting a reviewer from Apple (<rdar://problem/17454712>)
     // *********
@@ -125,12 +128,15 @@ void DatabaseProcess::initializeDatabaseProcess(const DatabaseProcessCreationPar
     SandboxExtension::consumePermanently(parameters.indexedDatabaseDirectoryExtensionHandle);
 
     ensureIndexedDatabaseRelativePathExists(StringImpl::empty());
+#endif
 }
 
+#if ENABLE(INDEXED_DATABASE)
 void DatabaseProcess::ensureIndexedDatabaseRelativePathExists(const String& relativePath)
 {
     postDatabaseTask(createAsyncTask(*this, &DatabaseProcess::ensurePathExists, absoluteIndexedDatabasePathFromDatabaseRelativePath(relativePath)));
 }
+#endif
 
 void DatabaseProcess::ensurePathExists(const String& path)
 {
@@ -140,12 +146,14 @@ void DatabaseProcess::ensurePathExists(const String& path)
         LOG_ERROR("Failed to make all directories for path '%s'", path.utf8().data());
 }
 
+#if ENABLE(INDEXED_DATABASE)
 String DatabaseProcess::absoluteIndexedDatabasePathFromDatabaseRelativePath(const String& relativePath)
 {
     // FIXME: pathByAppendingComponent() was originally designed to append individual atomic components.
     // We don't have a function designed to append a multi-component subpath, but we should.
     return pathByAppendingComponent(m_indexedDatabaseDirectory, relativePath);
 }
+#endif
 
 void DatabaseProcess::postDatabaseTask(std::unique_ptr<AsyncTask> task)
 {
@@ -224,6 +232,7 @@ void DatabaseProcess::fetchWebsiteData(SessionID, uint64_t websiteDataTypes, uin
         parentProcessConnection()->send(Messages::DatabaseProcessProxy::DidFetchWebsiteData(callbackID, websiteData), 0);
     }));
 
+#if ENABLE(INDEXED_DATABASE)
     if (websiteDataTypes & WebsiteDataTypeIndexedDBDatabases) {
         // FIXME: Pick the right database store based on the session ID.
         postDatabaseTask(std::make_unique<AsyncTask>([callbackAggregator, websiteDataTypes, this] {
@@ -236,6 +245,7 @@ void DatabaseProcess::fetchWebsiteData(SessionID, uint64_t websiteDataTypes, uin
             });
         }));
     }
+#endif
 }
 
 void DatabaseProcess::deleteWebsiteData(WebCore::SessionID, uint64_t websiteDataTypes, std::chrono::system_clock::time_point modifiedSince, uint64_t callbackID)
@@ -260,6 +270,7 @@ void DatabaseProcess::deleteWebsiteData(WebCore::SessionID, uint64_t websiteData
         parentProcessConnection()->send(Messages::DatabaseProcessProxy::DidDeleteWebsiteData(callbackID), 0);
     }));
 
+#if ENABLE(INDEXED_DATABASE)
     if (websiteDataTypes & WebsiteDataTypeIndexedDBDatabases) {
         postDatabaseTask(std::make_unique<AsyncTask>([this, callbackAggregator, modifiedSince] {
 
@@ -267,6 +278,7 @@ void DatabaseProcess::deleteWebsiteData(WebCore::SessionID, uint64_t websiteData
             RunLoop::main().dispatch([callbackAggregator] { });
         }));
     }
+#endif
 }
 
 void DatabaseProcess::deleteWebsiteDataForOrigins(WebCore::SessionID, uint64_t websiteDataTypes, const Vector<SecurityOriginData>& securityOriginDatas, uint64_t callbackID)
@@ -291,6 +303,7 @@ void DatabaseProcess::deleteWebsiteDataForOrigins(WebCore::SessionID, uint64_t w
         parentProcessConnection()->send(Messages::DatabaseProcessProxy::DidDeleteWebsiteDataForOrigins(callbackID), 0);
     }));
 
+#if ENABLE(INDEXED_DATABASE)
     if (websiteDataTypes & WebsiteDataTypeIndexedDBDatabases) {
         Vector<RefPtr<WebCore::SecurityOrigin>> securityOrigins;
         for (const auto& securityOriginData : securityOriginDatas)
@@ -302,8 +315,10 @@ void DatabaseProcess::deleteWebsiteDataForOrigins(WebCore::SessionID, uint64_t w
             RunLoop::main().dispatch([callbackAggregator] { });
         }));
     }
+#endif
 }
 
+#if ENABLE(INDEXED_DATABASE)
 Vector<RefPtr<WebCore::SecurityOrigin>> DatabaseProcess::indexedDatabaseOrigins()
 {
     if (m_indexedDatabaseDirectory.isEmpty())
@@ -319,7 +334,9 @@ Vector<RefPtr<WebCore::SecurityOrigin>> DatabaseProcess::indexedDatabaseOrigins(
 
     return securityOrigins;
 }
+#endif
 
+#if ENABLE(INDEXED_DATABASE)
 static void removeAllDatabasesForOriginPath(const String& originPath, std::chrono::system_clock::time_point modifiedSince)
 {
     // FIXME: We should also close/invalidate any live handles to the database files we are about to delete.
@@ -373,6 +390,7 @@ void DatabaseProcess::deleteIndexedDatabaseEntriesModifiedSince(std::chrono::sys
     for (auto& originPath : originPaths)
         removeAllDatabasesForOriginPath(originPath, modifiedSince);
 }
+#endif
 
 #if !PLATFORM(COCOA)
 void DatabaseProcess::initializeProcess(const ChildProcessInitializationParameters&)
index 7ad6d68..82634c4 100644 (file)
@@ -43,6 +43,7 @@ class DatabaseToWebProcessConnection;
 class UniqueIDBDatabase;
 
 struct DatabaseProcessCreationParameters;
+struct SecurityOriginData;
 
 class DatabaseProcess : public ChildProcess {
     WTF_MAKE_NONCOPYABLE(DatabaseProcess);
@@ -51,6 +52,7 @@ public:
     static DatabaseProcess& singleton();
     ~DatabaseProcess();
 
+#if ENABLE(INDEXED_DATABASE)
     const String& indexedDatabaseDirectory() const { return m_indexedDatabaseDirectory; }
 
     RefPtr<UniqueIDBDatabase> getOrCreateUniqueIDBDatabase(const UniqueIDBDatabaseIdentifier&);
@@ -58,6 +60,7 @@ public:
 
     void ensureIndexedDatabaseRelativePathExists(const String&);
     String absoluteIndexedDatabasePathFromDatabaseRelativePath(const String&);
+#endif
 
     WorkQueue& queue() { return m_queue.get(); }
 
@@ -89,9 +92,11 @@ private:
     void deleteWebsiteData(WebCore::SessionID, uint64_t websiteDataTypes, std::chrono::system_clock::time_point modifiedSince, uint64_t callbackID);
     void deleteWebsiteDataForOrigins(WebCore::SessionID, uint64_t websiteDataTypes, const Vector<SecurityOriginData>& origins, uint64_t callbackID);
 
+#if ENABLE(INDEXED_DATABASE)
     Vector<RefPtr<WebCore::SecurityOrigin>> indexedDatabaseOrigins();
     void deleteIndexedDatabaseEntriesForOrigins(const Vector<RefPtr<WebCore::SecurityOrigin>>&);
     void deleteIndexedDatabaseEntriesModifiedSince(std::chrono::system_clock::time_point modifiedSince);
+#endif
 
     // For execution on work queue thread only
     void performNextDatabaseTask();
@@ -101,9 +106,11 @@ private:
 
     Ref<WorkQueue> m_queue;
 
+#if ENABLE(INDEXED_DATABASE)
     String m_indexedDatabaseDirectory;
 
     HashMap<UniqueIDBDatabaseIdentifier, RefPtr<UniqueIDBDatabase>> m_idbDatabases;
+#endif
 
     Deque<std::unique_ptr<AsyncTask>> m_databaseTasks;
     Lock m_databaseTaskMutex;
index e764670..988c318 100644 (file)
@@ -59,33 +59,39 @@ void DatabaseToWebProcessConnection::didReceiveMessage(IPC::Connection& connecti
         return;
     }
 
+#if ENABLE(INDEXED_DATABASE)
     if (decoder.messageReceiverName() == Messages::DatabaseProcessIDBConnection::messageReceiverName()) {
         IDBConnectionMap::iterator backendIterator = m_idbConnections.find(decoder.destinationID());
         if (backendIterator != m_idbConnections.end())
             backendIterator->value->didReceiveDatabaseProcessIDBConnectionMessage(connection, decoder);
         return;
     }
+#endif
 
     ASSERT_NOT_REACHED();
 }
 
 void DatabaseToWebProcessConnection::didReceiveSyncMessage(IPC::Connection& connection, IPC::MessageDecoder& decoder, std::unique_ptr<IPC::MessageEncoder>& reply)
 {
+#if ENABLE(INDEXED_DATABASE)
     if (decoder.messageReceiverName() == Messages::DatabaseProcessIDBConnection::messageReceiverName()) {
         IDBConnectionMap::iterator backendIterator = m_idbConnections.find(decoder.destinationID());
         if (backendIterator != m_idbConnections.end())
             backendIterator->value->didReceiveSyncDatabaseProcessIDBConnectionMessage(connection, decoder, reply);
         return;
     }
+#endif
 
     ASSERT_NOT_REACHED();
 }
 
 void DatabaseToWebProcessConnection::didClose(IPC::Connection&)
 {
+#if ENABLE(INDEXED_DATABASE)
     // The WebProcess has disconnected, close all of the connections associated with it
     while (!m_idbConnections.isEmpty())
         removeDatabaseProcessIDBConnection(m_idbConnections.begin()->key);
+#endif
 }
 
 void DatabaseToWebProcessConnection::didReceiveInvalidMessage(IPC::Connection&, IPC::StringReference messageReceiverName, IPC::StringReference messageName)
@@ -93,6 +99,7 @@ void DatabaseToWebProcessConnection::didReceiveInvalidMessage(IPC::Connection&,
 
 }
 
+#if ENABLE(INDEXED_DATABASE)
 void DatabaseToWebProcessConnection::establishIDBConnection(uint64_t serverConnectionIdentifier)
 {
     RefPtr<DatabaseProcessIDBConnection> idbConnection = DatabaseProcessIDBConnection::create(*this, serverConnectionIdentifier);
@@ -106,6 +113,7 @@ void DatabaseToWebProcessConnection::removeDatabaseProcessIDBConnection(uint64_t
     RefPtr<DatabaseProcessIDBConnection> idbConnection = m_idbConnections.take(serverConnectionIdentifier);
     idbConnection->disconnectedFromWebProcess();
 }
+#endif
 
 
 } // namespace WebKit
index 1ba3976..2aaf2c2 100644 (file)
@@ -26,7 +26,7 @@
 #include "config.h"
 #include "DatabaseProcessCreationParameters.h"
 
-#if ENABLE(INDEXED_DATABASE) && ENABLE(DATABASE_PROCESS)
+#if ENABLE(DATABASE_PROCESS)
 
 #include "ArgumentCoders.h"
 
@@ -38,20 +38,24 @@ DatabaseProcessCreationParameters::DatabaseProcessCreationParameters()
 
 void DatabaseProcessCreationParameters::encode(IPC::ArgumentEncoder& encoder) const
 {
+#if ENABLE(INDEXED_DATABASE)
     encoder << indexedDatabaseDirectory;
     encoder << indexedDatabaseDirectoryExtensionHandle;
+#endif
 }
 
 bool DatabaseProcessCreationParameters::decode(IPC::ArgumentDecoder& decoder, DatabaseProcessCreationParameters& result)
 {
+#if ENABLE(INDEXED_DATABASE)
     if (!decoder.decode(result.indexedDatabaseDirectory))
         return false;
     if (!decoder.decode(result.indexedDatabaseDirectoryExtensionHandle))
         return false;
+#endif
 
     return true;
 }
 
 } // namespace WebKit
 
-#endif // ENABLE(INDEXED_DATABASE) && ENABLE(DATABASE_PROCESS)
+#endif // ENABLE(DATABASE_PROCESS)
index b1044fa..0ac4a36 100644 (file)
@@ -30,7 +30,7 @@
 #include "SandboxExtension.h"
 #include <wtf/text/WTFString.h>
 
-#if ENABLE(INDEXED_DATABASE) && ENABLE(DATABASE_PROCESS)
+#if ENABLE(DATABASE_PROCESS)
 
 namespace IPC {
 class ArgumentDecoder;
@@ -45,11 +45,13 @@ struct DatabaseProcessCreationParameters {
     void encode(IPC::ArgumentEncoder&) const;
     static bool decode(IPC::ArgumentDecoder&, DatabaseProcessCreationParameters&);
 
+#if ENABLE(INDEXED_DATABASE)
     String indexedDatabaseDirectory;
     SandboxExtension::Handle indexedDatabaseDirectoryExtensionHandle;
+#endif
 };
 
 } // namespace WebKit
 
-#endif // ENABLE(INDEXED_DATABASE) && ENABLE(DATABASE_PROCESS)
+#endif // ENABLE(DATABASE_PROCESS)
 #endif // DatabaseProcessCreationParameters_h
index 44c5a63..d44dac0 100644 (file)
@@ -469,15 +469,16 @@ void WebProcessPool::ensureDatabaseProcess()
 
     m_databaseProcess = DatabaseProcessProxy::create(this);
 
-    ASSERT(!m_configuration->indexedDBDatabaseDirectory().isEmpty());
-
     // *********
     // IMPORTANT: Do not change the directory structure for indexed databases on disk without first consulting a reviewer from Apple (<rdar://problem/17454712>)
     // *********
     DatabaseProcessCreationParameters parameters;
+#if ENABLE(INDEXED_DATABASE)
+    ASSERT(!m_configuration->indexedDBDatabaseDirectory().isEmpty());
     parameters.indexedDatabaseDirectory = m_configuration->indexedDBDatabaseDirectory();
 
     SandboxExtension::createHandleForReadWriteDirectory(parameters.indexedDatabaseDirectory, parameters.indexedDatabaseDirectoryExtensionHandle);
+#endif
 
     m_databaseProcess->send(Messages::DatabaseProcess::InitializeDatabaseProcess(parameters), 0);
 }
index fc336f3..0059ae1 100644 (file)
@@ -33,7 +33,7 @@
 #include "WebProcess.h"
 #include <wtf/RunLoop.h>
 
-#if ENABLE(INDEXED_DATABASE)
+#if ENABLE(DATABASE_PROCESS)
 
 using namespace WebCore;
 
@@ -51,12 +51,14 @@ WebToDatabaseProcessConnection::~WebToDatabaseProcessConnection()
 
 void WebToDatabaseProcessConnection::didReceiveMessage(IPC::Connection& connection, IPC::MessageDecoder& decoder)
 {
+#if ENABLE(INDEXED_DATABASE)
     if (decoder.messageReceiverName() == Messages::WebIDBServerConnection::messageReceiverName()) {
         HashMap<uint64_t, WebIDBServerConnection*>::iterator connectionIterator = m_webIDBServerConnections.find(decoder.destinationID());
         if (connectionIterator != m_webIDBServerConnections.end())
             connectionIterator->value->didReceiveWebIDBServerConnectionMessage(connection, decoder);
         return;
     }
+#endif
     
     ASSERT_NOT_REACHED();
 }
@@ -70,6 +72,7 @@ void WebToDatabaseProcessConnection::didReceiveInvalidMessage(IPC::Connection&,
 {
 }
 
+#if ENABLE(INDEXED_DATABASE)
 void WebToDatabaseProcessConnection::registerWebIDBServerConnection(WebIDBServerConnection& connection)
 {
     ASSERT(!m_webIDBServerConnections.contains(connection.messageSenderDestinationID()));
@@ -85,7 +88,8 @@ void WebToDatabaseProcessConnection::removeWebIDBServerConnection(WebIDBServerCo
 
     m_webIDBServerConnections.remove(connection.messageSenderDestinationID());
 }
+#endif
 
 } // namespace WebKit
 
-#endif // ENABLE(INDEXED_DATABASE)
+#endif // ENABLE(DATABASE_PROCESS)
index c051585..61a7ca4 100644 (file)
@@ -31,7 +31,7 @@
 #include "MessageSender.h"
 #include <wtf/RefCounted.h>
 
-#if ENABLE(INDEXED_DATABASE)
+#if ENABLE(DATABASE_PROCESS)
 
 namespace WebKit {
 
@@ -48,8 +48,10 @@ public:
     
     IPC::Connection* connection() const { return m_connection.get(); }
 
+#if ENABLE(INDEXED_DATABASE)
     void registerWebIDBServerConnection(WebIDBServerConnection&);
     void removeWebIDBServerConnection(WebIDBServerConnection&);
+#endif
 
 private:
     WebToDatabaseProcessConnection(IPC::Connection::Identifier);
@@ -67,10 +69,12 @@ private:
 
     RefPtr<IPC::Connection> m_connection;
 
+#if ENABLE(INDEXED_DATABASE)
     HashMap<uint64_t, WebIDBServerConnection*> m_webIDBServerConnections;
+#endif
 };
 
 } // namespace WebKit
 
-#endif // ENABLE(INDEXED_DATABASE)
+#endif // ENABLE(DATABASE_PROCESS)
 #endif // WebToDatabaseProcessConnection_h