/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
// Attempt to reuse the connection opened by a previous Action. if (aOptionalData) {
conn = aOptionalData->GetConnection();
}
// If there is no previous Action, then we must open one. if (!conn) {
QM_TRY_UNWRAP(conn,
OpenConnection(*aDirectoryMetadata, *dbDir, aMaybeCipherKey),
QM_VOID, resolveErr);
MOZ_DIAGNOSTIC_ASSERT(conn);
// Save this connection in the shared Data object so later Actions can // use it. This avoids opening a new connection for every Action. if (aOptionalData) { // Since we know this connection will be around for as long as the // Cache is open, use our special wrapped connection class. This // will let us perform certain operations once the Cache origin // is closed.
nsCOMPtr<mozIStorageConnection> wrapped = new Connection(conn);
aOptionalData->SetConnection(wrapped);
}
}
// Use our default file:// protocol handler directly to construct the database // URL. This avoids any problems if a plugin registers a custom file:// // handler. If such a custom handler used javascript, then we would have a // bad time running off the main thread here. auto handler = MakeRefPtr<nsFileProtocolHandler>();
QM_TRY(MOZ_TO_RESULT(handler->Init()));
// There is nothing else we can do to recover. Also, this data // can be deleted by QuotaManager at any time anyways.
QM_TRY(MOZ_TO_RESULT(WipeDatabase(aDirectoryMetadata, aDBFile)));
// Check the schema to make sure it is not too old.
QM_TRY_INSPECT(const int32_t& schemaVersion,
MOZ_TO_RESULT_INVOKE_MEMBER(conn, GetSchemaVersion)); if (schemaVersion > 0 && schemaVersion < db::kFirstShippedSchemaVersion) { // Close existing connection before wiping database.
conn = nullptr;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.