Skip to content

Commit

Permalink
Merge r223423 - We should wrap the removal of information from the tr…
Browse files Browse the repository at this point in the history
…acker database in a transaction in DatabaseTracker::deleteOrigin()

https://bugs.webkit.org/show_bug.cgi?id=178274
<rdar://problem/34576132>

Patch by Maureen Daum <mdaum@apple.com> on 2017-10-16
Reviewed by Tim Horton.

* Modules/webdatabase/DatabaseTracker.cpp:
(WebCore::DatabaseTracker::deleteOrigin):
Wrap the removal of information from the tracker database in a transaction so that
we don't end up in a case where only one of the tables contains information about
an origin.
If anything goes wrong when we're modifying the tracker database, rollback the transaction
before bailing.
  • Loading branch information
Maureen Daum authored and carlosgcampos committed Oct 17, 2017
1 parent 069a1ef commit e025ead
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
16 changes: 16 additions & 0 deletions Source/WebCore/ChangeLog
@@ -1,3 +1,19 @@
2017-10-16 Maureen Daum <mdaum@apple.com>

We should wrap the removal of information from the tracker database in a transaction in DatabaseTracker::deleteOrigin()
https://bugs.webkit.org/show_bug.cgi?id=178274
<rdar://problem/34576132>

Reviewed by Tim Horton.

* Modules/webdatabase/DatabaseTracker.cpp:
(WebCore::DatabaseTracker::deleteOrigin):
Wrap the removal of information from the tracker database in a transaction so that
we don't end up in a case where only one of the tables contains information about
an origin.
If anything goes wrong when we're modifying the tracker database, rollback the transaction
before bailing.

2017-10-13 Brent Fulgham <bfulgham@apple.com>

Protect FrameView during style calculations
Expand Down
6 changes: 6 additions & 0 deletions Source/WebCore/Modules/webdatabase/DatabaseTracker.cpp
Expand Up @@ -42,6 +42,7 @@
#include "SecurityOriginHash.h"
#include "SQLiteFileSystem.h"
#include "SQLiteStatement.h"
#include "SQLiteTransaction.h"
#include <wtf/MainThread.h>
#include <wtf/NeverDestroyed.h>
#include <wtf/StdLibExtras.h>
Expand Down Expand Up @@ -842,6 +843,9 @@ bool DatabaseTracker::deleteOrigin(const SecurityOriginData& origin, DeletionMod
deleteOriginLockFor(origin);
doneDeletingOrigin(origin);

SQLiteTransaction transaction(m_database);
transaction.begin();

SQLiteStatement statement(m_database, "DELETE FROM Databases WHERE origin=?");
if (statement.prepare() != SQLITE_OK) {
LOG_ERROR("Unable to prepare deletion of databases from origin %s from tracker", origin.databaseIdentifier().utf8().data());
Expand All @@ -868,6 +872,8 @@ bool DatabaseTracker::deleteOrigin(const SecurityOriginData& origin, DeletionMod
return false;
}

transaction.commit();

SQLiteFileSystem::deleteEmptyDatabaseDirectory(originPath(origin));

bool isEmpty = true;
Expand Down

0 comments on commit e025ead

Please sign in to comment.