Modified: trunk/Source/WebCore/ChangeLog (225684 => 225685)
--- trunk/Source/WebCore/ChangeLog 2017-12-08 18:37:08 UTC (rev 225684)
+++ trunk/Source/WebCore/ChangeLog 2017-12-08 19:01:04 UTC (rev 225685)
@@ -1,3 +1,14 @@
+2017-12-08 Chris Dumez <cdu...@apple.com>
+
+ Improve error handling in RegistrationDatabase
+ https://bugs.webkit.org/show_bug.cgi?id=180587
+
+ Reviewed by Brady Eidson.
+
+ * workers/service/server/RegistrationDatabase.cpp:
+ (WebCore::RegistrationDatabase::openSQLiteDatabase):
+ (WebCore::RegistrationDatabase::doPushChanges):
+
2017-12-07 Darin Adler <da...@apple.com>
Simplify and streamline some Color-related code to prepare for some Color/ExtendedColor work
Modified: trunk/Source/WebCore/workers/service/server/RegistrationDatabase.cpp (225684 => 225685)
--- trunk/Source/WebCore/workers/service/server/RegistrationDatabase.cpp 2017-12-08 18:37:08 UTC (rev 225684)
+++ trunk/Source/WebCore/workers/service/server/RegistrationDatabase.cpp 2017-12-08 19:01:04 UTC (rev 225685)
@@ -32,6 +32,7 @@
#include "Logging.h"
#include "RegistrationStore.h"
#include "SQLiteDatabase.h"
+#include "SQLiteFileSystem.h"
#include "SQLiteStatement.h"
#include "SQLiteTransaction.h"
#include <wtf/MainThread.h>
@@ -89,10 +90,12 @@
String errorMessage;
auto scopeExit = makeScopeExit([&, errorMessage = &errorMessage] {
ASSERT_UNUSED(errorMessage, !errorMessage->isNull());
- LOG_ERROR("Failed to open Service Worker registration database: %s", errorMessage->utf8().data());
+ RELEASE_LOG_ERROR(ServiceWorker, "Failed to open Service Worker registration database: %s", errorMessage->utf8().data());
m_database = nullptr;
postTaskReply(createCrossThreadTask(*this, &RegistrationDatabase::databaseFailedToOpen));
});
+
+ SQLiteFileSystem::ensureDatabaseDirectoryExists(m_databaseDirectory.isolatedCopy());
m_database = std::make_unique<SQLiteDatabase>();
if (!m_database->open(fullFilename)) {
@@ -206,7 +209,8 @@
void RegistrationDatabase::doPushChanges(Vector<ServiceWorkerContextData>&& datas)
{
- ASSERT(m_database);
+ if (!m_database)
+ return;
SQLiteTransaction transaction(*m_database);
transaction.begin();
@@ -213,7 +217,7 @@
SQLiteStatement sql(*m_database, ASCIILiteral("INSERT INTO Records VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)"));
if (sql.prepare() != SQLITE_OK) {
- LOG_ERROR("Failed to prepare statement to store registration data into records table (%i) - %s", m_database->lastError(), m_database->lastErrorMsg());
+ RELEASE_LOG_ERROR(ServiceWorker, "Failed to prepare statement to store registration data into records table (%i) - %s", m_database->lastError(), m_database->lastErrorMsg());
return;
}
@@ -223,7 +227,7 @@
if (sql.prepare() != SQLITE_OK
|| sql.bindText(1, data.registration.key.toDatabaseKey()) != SQLITE_OK
|| sql.step() != SQLITE_DONE) {
- LOG_ERROR("Failed to remove registration data from records table (%i) - %s", m_database->lastError(), m_database->lastErrorMsg());
+ RELEASE_LOG_ERROR(ServiceWorker, "Failed to remove registration data from records table (%i) - %s", m_database->lastError(), m_database->lastErrorMsg());
return;
}
@@ -240,7 +244,7 @@
|| sql.bindText(8, data.script) != SQLITE_OK
|| sql.bindText(9, workerTypeToString(data.workerType)) != SQLITE_OK
|| sql.step() != SQLITE_DONE) {
- LOG_ERROR("Failed to store registration data into records table (%i) - %s", m_database->lastError(), m_database->lastErrorMsg());
+ RELEASE_LOG_ERROR(ServiceWorker, "Failed to store registration data into records table (%i) - %s", m_database->lastError(), m_database->lastErrorMsg());
return;
}
}