зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1657551 - Part 6: Have a static ConcurrentStatementsHolder::Create function that handles errors returned from mozIStorageConnection::AsyncClone and transform some MOZ_ASSERT into NS_ENSURE_SUCCESS. r=mak
Depends on D163050 Differential Revision: https://phabricator.services.mozilla.com/D163083
This commit is contained in:
Родитель
ccf7f72677
Коммит
e073cbb0b6
|
@ -1577,7 +1577,7 @@ nsresult Connection::initializeClone(Connection* aClone, bool aReadOnly) {
|
|||
{
|
||||
nsCOMPtr<mozIStorageStatement> stmt;
|
||||
rv = CreateStatement("PRAGMA database_list"_ns, getter_AddRefs(stmt));
|
||||
MOZ_ASSERT(NS_SUCCEEDED(rv));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
bool hasResult = false;
|
||||
while (stmt && NS_SUCCEEDED(stmt->ExecuteStep(&hasResult)) && hasResult) {
|
||||
nsAutoCString name;
|
||||
|
@ -1590,12 +1590,11 @@ nsresult Connection::initializeClone(Connection* aClone, bool aReadOnly) {
|
|||
nsCOMPtr<mozIStorageStatement> attachStmt;
|
||||
rv = aClone->CreateStatement("ATTACH DATABASE :path AS "_ns + name,
|
||||
getter_AddRefs(attachStmt));
|
||||
MOZ_ASSERT(NS_SUCCEEDED(rv));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
rv = attachStmt->BindUTF8StringByName("path"_ns, path);
|
||||
MOZ_ASSERT(NS_SUCCEEDED(rv));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
rv = attachStmt->Execute();
|
||||
MOZ_ASSERT(NS_SUCCEEDED(rv),
|
||||
"couldn't re-attach database to cloned connection");
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1619,13 +1618,13 @@ nsresult Connection::initializeClone(Connection* aClone, bool aReadOnly) {
|
|||
pragmaQuery.Append(pragma);
|
||||
nsCOMPtr<mozIStorageStatement> stmt;
|
||||
rv = CreateStatement(pragmaQuery, getter_AddRefs(stmt));
|
||||
MOZ_ASSERT(NS_SUCCEEDED(rv));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
bool hasResult = false;
|
||||
if (stmt && NS_SUCCEEDED(stmt->ExecuteStep(&hasResult)) && hasResult) {
|
||||
pragmaQuery.AppendLiteral(" = ");
|
||||
pragmaQuery.AppendInt(stmt->AsInt32(0));
|
||||
rv = aClone->ExecuteSimpleSQL(pragmaQuery);
|
||||
MOZ_ASSERT(NS_SUCCEEDED(rv));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1474,10 +1474,17 @@ class ConcurrentStatementsHolder final : public mozIStorageCompletionCallback {
|
|||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
explicit ConcurrentStatementsHolder(mozIStorageConnection* aDBConn)
|
||||
: mShutdownWasInvoked(false) {
|
||||
DebugOnly<nsresult> rv = aDBConn->AsyncClone(true, this);
|
||||
MOZ_ASSERT(NS_SUCCEEDED(rv));
|
||||
ConcurrentStatementsHolder() : mShutdownWasInvoked(false) {}
|
||||
|
||||
static RefPtr<ConcurrentStatementsHolder> Create(
|
||||
mozIStorageConnection* aDBConn) {
|
||||
RefPtr<ConcurrentStatementsHolder> holder =
|
||||
new ConcurrentStatementsHolder();
|
||||
nsresult rv = aDBConn->AsyncClone(true, holder);
|
||||
if (NS_FAILED(rv)) {
|
||||
return nullptr;
|
||||
}
|
||||
return holder;
|
||||
}
|
||||
|
||||
NS_IMETHOD Complete(nsresult aStatus, nsISupports* aConnection) override {
|
||||
|
@ -1555,7 +1562,10 @@ nsresult History::QueueVisitedStatement(RefPtr<VisitedQuery> aQuery) {
|
|||
if (!mConcurrentStatementsHolder) {
|
||||
mozIStorageConnection* dbConn = GetDBConn();
|
||||
NS_ENSURE_STATE(dbConn);
|
||||
mConcurrentStatementsHolder = new ConcurrentStatementsHolder(dbConn);
|
||||
mConcurrentStatementsHolder = ConcurrentStatementsHolder::Create(dbConn);
|
||||
if (!mConcurrentStatementsHolder) {
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
}
|
||||
mConcurrentStatementsHolder->QueueVisitedStatement(std::move(aQuery));
|
||||
return NS_OK;
|
||||
|
|
Загрузка…
Ссылка в новой задаче