Backed out 2 changesets (bug 1603703) for xpc failures on test_storage_aggregates.js. CLOSED TREE

Backed out changeset 05dbbf7c379f (bug 1603703)
Backed out changeset a1e723439116 (bug 1603703)

--HG--
extra : rebase_source : 65d834f15b63fdd0ce5c90d2efd080e4841777aa
This commit is contained in:
Cosmin Sabou 2020-03-05 19:37:32 +02:00
Родитель 59143c98bb
Коммит 9ec8941cd4
10 изменённых файлов: 146 добавлений и 138 удалений

10
dom/cache/Connection.cpp поставляемый
Просмотреть файл

@ -98,9 +98,9 @@ Connection::ExecuteSimpleSQLAsync(const nsACString&,
}
NS_IMETHODIMP
Connection::RegisterFunction(const nsACString& aFunctionName,
int32_t aNumArguments,
nsCOMPtr<mozIStorageFunction> aFunction) {
Connection::CreateFunction(const nsACString& aFunctionName,
int32_t aNumArguments,
mozIStorageFunction* aFunction) {
// async methods are not supported
return NS_ERROR_NOT_IMPLEMENTED;
}
@ -114,8 +114,8 @@ Connection::CreateAggregateFunction(const nsACString& aFunctionName,
}
NS_IMETHODIMP
Connection::UnregisterFunction(const nsACString& aFunctionName) {
return mBase->UnregisterFunction(aFunctionName);
Connection::RemoveFunction(const nsACString& aFunctionName) {
return mBase->RemoveFunction(aFunctionName);
}
NS_IMETHODIMP

Просмотреть файл

@ -1908,7 +1908,7 @@ nsresult UpgradeSchemaFrom8To9_0(mozIStorageConnection* aConnection) {
NS_NAMED_LITERAL_CSTRING(compressorName, "compress");
rv = aConnection->RegisterFunction(compressorName, 1, compressor);
rv = aConnection->CreateFunction(compressorName, 1, compressor);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
@ -1926,7 +1926,7 @@ nsresult UpgradeSchemaFrom8To9_0(mozIStorageConnection* aConnection) {
return rv;
}
rv = aConnection->UnregisterFunction(compressorName);
rv = aConnection->RemoveFunction(compressorName);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
@ -2198,7 +2198,7 @@ nsresult UpgradeSchemaFrom11_0To12_0(mozIStorageConnection* aConnection) {
nsCOMPtr<mozIStorageFunction> encoder = new EncodeKeysFunction();
nsresult rv = aConnection->RegisterFunction(encoderName, 1, encoder);
nsresult rv = aConnection->CreateFunction(encoderName, 1, encoder);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
@ -2418,7 +2418,7 @@ nsresult UpgradeSchemaFrom11_0To12_0(mozIStorageConnection* aConnection) {
return rv;
}
rv = aConnection->UnregisterFunction(encoderName);
rv = aConnection->RemoveFunction(encoderName);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
@ -2847,29 +2847,32 @@ nsresult UpgradeSchemaFrom17_0To18_0Helper::DoUpgrade(
MOZ_ASSERT(!aOrigin.IsEmpty());
// Register the |upgrade_key| function.
RefPtr<UpgradeKeyFunction> updateFunction = new UpgradeKeyFunction();
NS_NAMED_LITERAL_CSTRING(upgradeKeyFunctionName, "upgrade_key");
nsresult rv = aConnection->RegisterFunction(
upgradeKeyFunctionName, 1, MakeAndAddRef<UpgradeKeyFunction>());
nsresult rv =
aConnection->CreateFunction(upgradeKeyFunctionName, 1, updateFunction);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
// Register the |insert_idv| function.
RefPtr<InsertIndexDataValuesFunction> insertIDVFunction =
new InsertIndexDataValuesFunction();
NS_NAMED_LITERAL_CSTRING(insertIDVFunctionName, "insert_idv");
rv = aConnection->RegisterFunction(
insertIDVFunctionName, 4, MakeAndAddRef<InsertIndexDataValuesFunction>());
rv = aConnection->CreateFunction(insertIDVFunctionName, 4, insertIDVFunction);
if (NS_WARN_IF(NS_FAILED(rv))) {
MOZ_ALWAYS_SUCCEEDS(
aConnection->UnregisterFunction(upgradeKeyFunctionName));
MOZ_ALWAYS_SUCCEEDS(aConnection->RemoveFunction(upgradeKeyFunctionName));
return rv;
}
rv = DoUpgradeInternal(aConnection, aOrigin);
MOZ_ALWAYS_SUCCEEDS(aConnection->UnregisterFunction(upgradeKeyFunctionName));
MOZ_ALWAYS_SUCCEEDS(aConnection->UnregisterFunction(insertIDVFunctionName));
MOZ_ALWAYS_SUCCEEDS(aConnection->RemoveFunction(upgradeKeyFunctionName));
MOZ_ALWAYS_SUCCEEDS(aConnection->RemoveFunction(insertIDVFunctionName));
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
@ -3491,7 +3494,7 @@ nsresult UpgradeSchemaFrom19_0To20_0(nsIFile* aFMDirectory,
NS_NAMED_LITERAL_CSTRING(functionName, "upgrade");
rv = aConnection->RegisterFunction(functionName, 2, std::move(function));
rv = aConnection->CreateFunction(functionName, 2, function);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
@ -3524,7 +3527,7 @@ nsresult UpgradeSchemaFrom19_0To20_0(nsIFile* aFMDirectory,
return rv;
}
rv = aConnection->UnregisterFunction(functionName);
rv = aConnection->RemoveFunction(functionName);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
@ -3698,10 +3701,12 @@ nsresult UpgradeSchemaFrom20_0To21_0(mozIStorageConnection* aConnection) {
AUTO_PROFILER_LABEL("UpgradeSchemaFrom20_0To21_0", DOM);
RefPtr<UpgradeIndexDataValuesFunction> function =
new UpgradeIndexDataValuesFunction();
NS_NAMED_LITERAL_CSTRING(functionName, "upgrade_idv");
nsresult rv = aConnection->RegisterFunction(
functionName, 1, MakeAndAddRef<UpgradeIndexDataValuesFunction>());
nsresult rv = aConnection->CreateFunction(functionName, 1, function);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
@ -3714,7 +3719,7 @@ nsresult UpgradeSchemaFrom20_0To21_0(mozIStorageConnection* aConnection) {
return rv;
}
rv = aConnection->UnregisterFunction(functionName);
rv = aConnection->RemoveFunction(functionName);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
@ -3864,9 +3869,9 @@ nsresult UpgradeSchemaFrom25_0To26_0(mozIStorageConnection* aConnection) {
nsCOMPtr<mozIStorageFunction> stripObsoleteAttributes =
new StripObsoleteOriginAttributesFunction();
nsresult rv = aConnection->RegisterFunction(functionName,
/* aNumArguments */ 1,
stripObsoleteAttributes);
nsresult rv = aConnection->CreateFunction(functionName,
/* aNumArguments */ 1,
stripObsoleteAttributes);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
@ -3879,7 +3884,7 @@ nsresult UpgradeSchemaFrom25_0To26_0(mozIStorageConnection* aConnection) {
return rv;
}
rv = aConnection->UnregisterFunction(functionName);
rv = aConnection->RemoveFunction(functionName);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
@ -10451,8 +10456,8 @@ nsresult DatabaseConnection::BeginWriteTransaction() {
new UpdateRefcountFunction(this, mFileManager->get());
rv = (*mStorageConnection)
->RegisterFunction(NS_LITERAL_CSTRING("update_refcount"),
/* aNumArguments */ 2, do_AddRef(function));
->CreateFunction(NS_LITERAL_CSTRING("update_refcount"),
/* aNumArguments */ 2, function);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
@ -10913,7 +10918,7 @@ void DatabaseConnection::Close() {
if (mUpdateRefcountFunction) {
MOZ_ALWAYS_SUCCEEDS(
(*mStorageConnection)
->UnregisterFunction(NS_LITERAL_CSTRING("update_refcount")));
->RemoveFunction(NS_LITERAL_CSTRING("update_refcount")));
mUpdateRefcountFunction = nullptr;
}
@ -23865,19 +23870,20 @@ nsresult CreateIndexOp::InsertDataFromObjectStore(
aConnection->GetStorageConnection();
MOZ_ASSERT(storageConnection);
RefPtr<UpdateIndexDataValuesFunction> updateFunction =
new UpdateIndexDataValuesFunction(this, aConnection);
NS_NAMED_LITERAL_CSTRING(updateFunctionName, "update_index_data_values");
nsresult rv = storageConnection->RegisterFunction(
updateFunctionName, 4,
MakeAndAddRef<UpdateIndexDataValuesFunction>(this, aConnection));
nsresult rv =
storageConnection->CreateFunction(updateFunctionName, 4, updateFunction);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
rv = InsertDataFromObjectStoreInternal(aConnection);
MOZ_ALWAYS_SUCCEEDS(
storageConnection->UnregisterFunction(updateFunctionName));
MOZ_ALWAYS_SUCCEEDS(storageConnection->RemoveFunction(updateFunctionName));
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;

Просмотреть файл

@ -7443,16 +7443,16 @@ nsresult PrepareDatastoreOp::DatabaseWork() {
nsCOMPtr<mozIStorageFunction> function = new CompressFunction();
rv = connection->RegisterFunction(NS_LITERAL_CSTRING("compress"), 1,
function);
rv =
connection->CreateFunction(NS_LITERAL_CSTRING("compress"), 1, function);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
function = new CompressibleFunction();
rv = connection->RegisterFunction(NS_LITERAL_CSTRING("compressible"), 1,
function);
rv = connection->CreateFunction(NS_LITERAL_CSTRING("compressible"), 1,
function);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
@ -7483,12 +7483,12 @@ nsresult PrepareDatastoreOp::DatabaseWork() {
return rv;
}
rv = connection->UnregisterFunction(NS_LITERAL_CSTRING("compress"));
rv = connection->RemoveFunction(NS_LITERAL_CSTRING("compress"));
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
rv = connection->UnregisterFunction(NS_LITERAL_CSTRING("compressible"));
rv = connection->RemoveFunction(NS_LITERAL_CSTRING("compressible"));
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
@ -9053,8 +9053,7 @@ nsresult QuotaClient::AboutToClearOrigins(
nsCOMPtr<mozIStorageFunction> function(
new MatchFunction(archivedOriginScope->GetPattern()));
rv = connection->RegisterFunction(NS_LITERAL_CSTRING("match"), 2,
function);
rv = connection->CreateFunction(NS_LITERAL_CSTRING("match"), 2, function);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
@ -9102,7 +9101,7 @@ nsresult QuotaClient::AboutToClearOrigins(
stmt = nullptr;
if (archivedOriginScope->IsPattern()) {
rv = connection->UnregisterFunction(NS_LITERAL_CSTRING("match"));
rv = connection->RemoveFunction(NS_LITERAL_CSTRING("match"));
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}

Просмотреть файл

@ -1133,7 +1133,7 @@ nsresult StorageDBThread::DBOperation::Perform(StorageDBThread* aThread) {
nsCOMPtr<mozIStorageFunction> patternMatchFunction(
new OriginAttrsPatternMatchSQLFunction(mOriginPattern));
rv = aThread->mWorkerConnection->RegisterFunction(
rv = aThread->mWorkerConnection->CreateFunction(
NS_LITERAL_CSTRING("ORIGIN_ATTRS_PATTERN_MATCH"), 1,
patternMatchFunction);
NS_ENSURE_SUCCESS(rv, rv);
@ -1151,7 +1151,7 @@ nsresult StorageDBThread::DBOperation::Perform(StorageDBThread* aThread) {
}
// Always remove the function
aThread->mWorkerConnection->UnregisterFunction(
aThread->mWorkerConnection->RemoveFunction(
NS_LITERAL_CSTRING("ORIGIN_ATTRS_PATTERN_MATCH"));
NS_ENSURE_SUCCESS(rv, rv);

Просмотреть файл

@ -328,7 +328,7 @@ nsresult Update(mozIStorageConnection* aWorkerConnection) {
nsCOMPtr<mozIStorageFunction> function1(new nsReverseStringSQLFunction());
NS_ENSURE_TRUE(function1, NS_ERROR_OUT_OF_MEMORY);
rv = aWorkerConnection->RegisterFunction(
rv = aWorkerConnection->CreateFunction(
NS_LITERAL_CSTRING("REVERSESTRING"), 1, function1);
NS_ENSURE_SUCCESS(rv, rv);
@ -365,8 +365,7 @@ nsresult Update(mozIStorageConnection* aWorkerConnection) {
NS_ENSURE_SUCCESS(rv, rv);
}
aWorkerConnection->UnregisterFunction(
NS_LITERAL_CSTRING("REVERSESTRING"));
aWorkerConnection->RemoveFunction(NS_LITERAL_CSTRING("REVERSESTRING"));
// Update the scoping to match the new implememntation: split to oa suffix
// and origin key First rename the old table, we want to remove some
@ -387,13 +386,13 @@ nsresult Update(mozIStorageConnection* aWorkerConnection) {
nsCOMPtr<mozIStorageFunction> oaSuffixFunc(new GetOriginParticular(
GetOriginParticular::ORIGIN_ATTRIBUTES_SUFFIX));
rv = aWorkerConnection->RegisterFunction(
rv = aWorkerConnection->CreateFunction(
NS_LITERAL_CSTRING("GET_ORIGIN_SUFFIX"), 1, oaSuffixFunc);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<mozIStorageFunction> originKeyFunc(
new GetOriginParticular(GetOriginParticular::ORIGIN_KEY));
rv = aWorkerConnection->RegisterFunction(
rv = aWorkerConnection->CreateFunction(
NS_LITERAL_CSTRING("GET_ORIGIN_KEY"), 1, originKeyFunc);
NS_ENSURE_SUCCESS(rv, rv);
@ -413,10 +412,9 @@ nsresult Update(mozIStorageConnection* aWorkerConnection) {
NS_LITERAL_CSTRING("DROP TABLE webappsstore2_old"));
NS_ENSURE_SUCCESS(rv, rv);
aWorkerConnection->UnregisterFunction(
aWorkerConnection->RemoveFunction(
NS_LITERAL_CSTRING("GET_ORIGIN_SUFFIX"));
aWorkerConnection->UnregisterFunction(
NS_LITERAL_CSTRING("GET_ORIGIN_KEY"));
aWorkerConnection->RemoveFunction(NS_LITERAL_CSTRING("GET_ORIGIN_KEY"));
rv = aWorkerConnection->SetSchemaVersion(1);
NS_ENSURE_SUCCESS(rv, rv);
@ -425,7 +423,7 @@ nsresult Update(mozIStorageConnection* aWorkerConnection) {
}
case 1: {
nsCOMPtr<mozIStorageFunction> oaStripAddonId(new StripOriginAddonId());
rv = aWorkerConnection->RegisterFunction(
rv = aWorkerConnection->CreateFunction(
NS_LITERAL_CSTRING("STRIP_ADDON_ID"), 1, oaStripAddonId);
NS_ENSURE_SUCCESS(rv, rv);
@ -435,8 +433,7 @@ nsresult Update(mozIStorageConnection* aWorkerConnection) {
"WHERE originAttributes LIKE '^%'"));
NS_ENSURE_SUCCESS(rv, rv);
aWorkerConnection->UnregisterFunction(
NS_LITERAL_CSTRING("STRIP_ADDON_ID"));
aWorkerConnection->RemoveFunction(NS_LITERAL_CSTRING("STRIP_ADDON_ID"));
rv = aWorkerConnection->SetSchemaVersion(2);
NS_ENSURE_SUCCESS(rv, rv);

10
netwerk/cache/nsDiskCacheDeviceSQL.cpp поставляемый
Просмотреть файл

@ -1163,8 +1163,8 @@ nsresult nsOfflineCacheDevice::InitWithSqlite(mozIStorageService* ss) {
mEvictionFunction = new nsOfflineCacheEvictionFunction(this);
if (!mEvictionFunction) return NS_ERROR_OUT_OF_MEMORY;
rv = mDB->RegisterFunction(NS_LITERAL_CSTRING("cache_eviction_observer"), 3,
do_AddRef(mEvictionFunction));
rv = mDB->CreateFunction(NS_LITERAL_CSTRING("cache_eviction_observer"), 3,
mEvictionFunction);
NS_ENSURE_SUCCESS(rv, rv);
// create all (most) of our statements up front
@ -2337,8 +2337,8 @@ nsresult nsOfflineCacheDevice::Evict(
nsresult rv;
rv = mDB->RegisterFunction(NS_LITERAL_CSTRING("ORIGIN_MATCH"), 1,
MakeAndAddRef<OriginMatch>(aPattern));
nsCOMPtr<mozIStorageFunction> function1(new OriginMatch(aPattern));
rv = mDB->CreateFunction(NS_LITERAL_CSTRING("ORIGIN_MATCH"), 1, function1);
NS_ENSURE_SUCCESS(rv, rv);
class AutoRemoveFunc {
@ -2346,7 +2346,7 @@ nsresult nsOfflineCacheDevice::Evict(
mozIStorageConnection* mDB;
explicit AutoRemoveFunc(mozIStorageConnection* aDB) : mDB(aDB) {}
~AutoRemoveFunc() {
mDB->UnregisterFunction(NS_LITERAL_CSTRING("ORIGIN_MATCH"));
mDB->RemoveFunction(NS_LITERAL_CSTRING("ORIGIN_MATCH"));
}
};
AutoRemoveFunc autoRemove(mDB);

Просмотреть файл

@ -1113,8 +1113,8 @@ OpenDBResult nsCookieService::TryInitDB(bool aRecreateDB) {
NS_NAMED_LITERAL_CSTRING(convertToOriginAttrsName,
"CONVERT_TO_ORIGIN_ATTRIBUTES");
rv = mDefaultDBState->syncConn->RegisterFunction(
convertToOriginAttrsName, 2, convertToOriginAttrs);
rv = mDefaultDBState->syncConn->CreateFunction(convertToOriginAttrsName,
2, convertToOriginAttrs);
NS_ENSURE_SUCCESS(rv, RESULT_RETRY);
rv = mDefaultDBState->syncConn->ExecuteSimpleSQL(NS_LITERAL_CSTRING(
@ -1128,8 +1128,8 @@ OpenDBResult nsCookieService::TryInitDB(bool aRecreateDB) {
"FROM moz_cookies_old"));
NS_ENSURE_SUCCESS(rv, RESULT_RETRY);
rv = mDefaultDBState->syncConn->UnregisterFunction(
convertToOriginAttrsName);
rv =
mDefaultDBState->syncConn->RemoveFunction(convertToOriginAttrsName);
NS_ENSURE_SUCCESS(rv, RESULT_RETRY);
// Drop old table
@ -1161,18 +1161,24 @@ OpenDBResult nsCookieService::TryInitDB(bool aRecreateDB) {
// Compute and populate the values of appId and inBrwoserElement from
// originAttributes.
nsCOMPtr<mozIStorageFunction> setAppId(
new SetAppIdFromOriginAttributesSQLFunction());
NS_ENSURE_TRUE(setAppId, RESULT_RETRY);
NS_NAMED_LITERAL_CSTRING(setAppIdName, "SET_APP_ID");
rv = mDefaultDBState->syncConn->RegisterFunction(
setAppIdName, 1,
MakeAndAddRef<SetAppIdFromOriginAttributesSQLFunction>());
rv = mDefaultDBState->syncConn->CreateFunction(setAppIdName, 1,
setAppId);
NS_ENSURE_SUCCESS(rv, RESULT_RETRY);
nsCOMPtr<mozIStorageFunction> setInBrowser(
new SetInBrowserFromOriginAttributesSQLFunction());
NS_ENSURE_TRUE(setInBrowser, RESULT_RETRY);
NS_NAMED_LITERAL_CSTRING(setInBrowserName, "SET_IN_BROWSER");
rv = mDefaultDBState->syncConn->RegisterFunction(
setInBrowserName, 1,
MakeAndAddRef<SetInBrowserFromOriginAttributesSQLFunction>());
rv = mDefaultDBState->syncConn->CreateFunction(setInBrowserName, 1,
setInBrowser);
NS_ENSURE_SUCCESS(rv, RESULT_RETRY);
rv = mDefaultDBState->syncConn->ExecuteSimpleSQL(NS_LITERAL_CSTRING(
@ -1180,10 +1186,10 @@ OpenDBResult nsCookieService::TryInitDB(bool aRecreateDB) {
"inBrowserElement = SET_IN_BROWSER(originAttributes);"));
NS_ENSURE_SUCCESS(rv, RESULT_RETRY);
rv = mDefaultDBState->syncConn->UnregisterFunction(setAppIdName);
rv = mDefaultDBState->syncConn->RemoveFunction(setAppIdName);
NS_ENSURE_SUCCESS(rv, RESULT_RETRY);
rv = mDefaultDBState->syncConn->UnregisterFunction(setInBrowserName);
rv = mDefaultDBState->syncConn->RemoveFunction(setInBrowserName);
NS_ENSURE_SUCCESS(rv, RESULT_RETRY);
COOKIE_LOGSTRING(LogLevel::Debug,

Просмотреть файл

@ -5,12 +5,6 @@
#include "nsISupports.idl"
%{C++
#include "nsCOMPtr.h"
%}
native nsCOMPtr_mozIStorageFunction(nsCOMPtr<mozIStorageFunction>);
interface mozIStorageAggregateFunction;
interface mozIStorageCompletionCallback;
interface mozIStorageFunction;
@ -260,7 +254,7 @@ interface mozIStorageAsyncConnection : nsISupports {
//// Functions
/**
* Register a new SQL function. If you use your connection on multiple threads,
* Create a new SQL function. If you use your connection on multiple threads,
* your function needs to be threadsafe, or it should only be called on one
* thread.
*
@ -271,12 +265,11 @@ interface mozIStorageAsyncConnection : nsISupports {
* variable-argument functions.
* @param aFunction
* The instance of mozIStorageFunction, which implements the function
* in question. Takes ownership of the passed function pointer, and
* discards it in case of an error.
* in question.
*/
void registerFunction(in AUTF8String aFunctionName,
void createFunction(in AUTF8String aFunctionName,
in long aNumArguments,
in nsCOMPtr_mozIStorageFunction aFunction);
in mozIStorageFunction aFunction);
/**
* Create a new SQL aggregate function. If you use your connection on
@ -296,12 +289,12 @@ interface mozIStorageAsyncConnection : nsISupports {
in long aNumArguments,
in mozIStorageAggregateFunction aFunction);
/**
* Unregisters a custom SQL function (simple or aggregate one).
* Delete custom SQL function (simple or aggregate one).
*
* @param aFunctionName
* The name of function to remove.
*/
void unregisterFunction(in AUTF8String aFunctionName);
void removeFunction(in AUTF8String aFunctionName);
/**
* Sets a progress handler. Only one handler can be registered at a time.

Просмотреть файл

@ -1587,7 +1587,7 @@ nsresult Connection::initializeClone(Connection* aClone, bool aReadOnly) {
if (data.type == Connection::FunctionInfo::SIMPLE) {
mozIStorageFunction* function =
static_cast<mozIStorageFunction*>(data.function.get());
rv = aClone->RegisterFunction(key, data.numArgs, function);
rv = aClone->CreateFunction(key, data.numArgs, function);
if (NS_FAILED(rv)) {
NS_WARNING("Failed to copy function to cloned connection");
}
@ -2055,9 +2055,9 @@ Connection::CreateTable(const char* aTableName, const char* aTableSchema) {
}
NS_IMETHODIMP
Connection::RegisterFunction(const nsACString& aFunctionName,
int32_t aNumArguments,
nsCOMPtr<mozIStorageFunction> aFunction) {
Connection::CreateFunction(const nsACString& aFunctionName,
int32_t aNumArguments,
mozIStorageFunction* aFunction) {
if (!connectionReady()) {
return NS_ERROR_NOT_INITIALIZED;
}
@ -2076,12 +2076,8 @@ Connection::RegisterFunction(const nsACString& aFunctionName,
SQLITE_ANY, aFunction, basicFunctionHelper, nullptr, nullptr);
if (srv != SQLITE_OK) return convertResultCode(srv);
// TODO (Bug 1620198): we can't use std::move(aFunction) here because
// FunctionInfo::function is a nsCOMPtr<nsISupports> to allow for either
// mozIStorageFunction or mozIStorageAggregateFunction. When
// mozIStorageAggregateFunction is removed, this can be changed.
FunctionInfo info = {aFunction.forget().take(),
Connection::FunctionInfo::SIMPLE, aNumArguments};
FunctionInfo info = {aFunction, Connection::FunctionInfo::SIMPLE,
aNumArguments};
mFunctions.Put(aFunctionName, info);
return NS_OK;
@ -2122,7 +2118,7 @@ Connection::CreateAggregateFunction(const nsACString& aFunctionName,
}
NS_IMETHODIMP
Connection::UnregisterFunction(const nsACString& aFunctionName) {
Connection::RemoveFunction(const nsACString& aFunctionName) {
if (!connectionReady()) {
return NS_ERROR_NOT_INITIALIZED;
}

Просмотреть файл

@ -370,9 +370,10 @@ namespace places {
/* static */
nsresult MatchAutoCompleteFunction::create(mozIStorageConnection* aDBConn) {
nsresult rv = aDBConn->RegisterFunction(
NS_LITERAL_CSTRING("autocomplete_match"), kArgIndexLength,
MakeAndAddRef<MatchAutoCompleteFunction>());
RefPtr<MatchAutoCompleteFunction> function = new MatchAutoCompleteFunction();
nsresult rv = aDBConn->CreateFunction(
NS_LITERAL_CSTRING("autocomplete_match"), kArgIndexLength, function);
NS_ENSURE_SUCCESS(rv, rv);
return NS_OK;
@ -548,9 +549,10 @@ MatchAutoCompleteFunction::OnFunctionCall(mozIStorageValueArray* aArguments,
/* static */
nsresult CalculateFrecencyFunction::create(mozIStorageConnection* aDBConn) {
nsresult rv =
aDBConn->RegisterFunction(NS_LITERAL_CSTRING("calculate_frecency"), -1,
MakeAndAddRef<CalculateFrecencyFunction>());
RefPtr<CalculateFrecencyFunction> function = new CalculateFrecencyFunction();
nsresult rv = aDBConn->CreateFunction(
NS_LITERAL_CSTRING("calculate_frecency"), -1, function);
NS_ENSURE_SUCCESS(rv, rv);
return NS_OK;
@ -758,9 +760,9 @@ CalculateFrecencyFunction::OnFunctionCall(mozIStorageValueArray* aArguments,
/* static */
nsresult GenerateGUIDFunction::create(mozIStorageConnection* aDBConn) {
RefPtr<GenerateGUIDFunction> function = new GenerateGUIDFunction();
nsresult rv =
aDBConn->RegisterFunction(NS_LITERAL_CSTRING("generate_guid"), 0,
MakeAndAddRef<GenerateGUIDFunction>());
aDBConn->CreateFunction(NS_LITERAL_CSTRING("generate_guid"), 0, function);
NS_ENSURE_SUCCESS(rv, rv);
return NS_OK;
@ -784,8 +786,9 @@ GenerateGUIDFunction::OnFunctionCall(mozIStorageValueArray* aArguments,
/* static */
nsresult IsValidGUIDFunction::create(mozIStorageConnection* aDBConn) {
return aDBConn->RegisterFunction(NS_LITERAL_CSTRING("is_valid_guid"), 1,
MakeAndAddRef<IsValidGUIDFunction>());
RefPtr<IsValidGUIDFunction> function = new IsValidGUIDFunction();
return aDBConn->CreateFunction(NS_LITERAL_CSTRING("is_valid_guid"), 1,
function);
}
NS_IMPL_ISUPPORTS(IsValidGUIDFunction, mozIStorageFunction)
@ -810,9 +813,9 @@ IsValidGUIDFunction::OnFunctionCall(mozIStorageValueArray* aArguments,
/* static */
nsresult GetUnreversedHostFunction::create(mozIStorageConnection* aDBConn) {
nsresult rv =
aDBConn->RegisterFunction(NS_LITERAL_CSTRING("get_unreversed_host"), 1,
MakeAndAddRef<GetUnreversedHostFunction>());
RefPtr<GetUnreversedHostFunction> function = new GetUnreversedHostFunction();
nsresult rv = aDBConn->CreateFunction(
NS_LITERAL_CSTRING("get_unreversed_host"), 1, function);
NS_ENSURE_SUCCESS(rv, rv);
return NS_OK;
@ -848,8 +851,9 @@ GetUnreversedHostFunction::OnFunctionCall(mozIStorageValueArray* aArguments,
/* static */
nsresult FixupURLFunction::create(mozIStorageConnection* aDBConn) {
nsresult rv = aDBConn->RegisterFunction(NS_LITERAL_CSTRING("fixup_url"), 1,
MakeAndAddRef<FixupURLFunction>());
RefPtr<FixupURLFunction> function = new FixupURLFunction();
nsresult rv =
aDBConn->CreateFunction(NS_LITERAL_CSTRING("fixup_url"), 1, function);
NS_ENSURE_SUCCESS(rv, rv);
return NS_OK;
@ -890,9 +894,10 @@ FixupURLFunction::OnFunctionCall(mozIStorageValueArray* aArguments,
/* static */
nsresult FrecencyNotificationFunction::create(mozIStorageConnection* aDBConn) {
nsresult rv =
aDBConn->RegisterFunction(NS_LITERAL_CSTRING("notify_frecency"), 5,
MakeAndAddRef<FrecencyNotificationFunction>());
RefPtr<FrecencyNotificationFunction> function =
new FrecencyNotificationFunction();
nsresult rv = aDBConn->CreateFunction(NS_LITERAL_CSTRING("notify_frecency"),
5, function);
NS_ENSURE_SUCCESS(rv, rv);
return NS_OK;
@ -938,9 +943,10 @@ FrecencyNotificationFunction::OnFunctionCall(mozIStorageValueArray* aArgs,
/* static */
nsresult StoreLastInsertedIdFunction::create(mozIStorageConnection* aDBConn) {
nsresult rv =
aDBConn->RegisterFunction(NS_LITERAL_CSTRING("store_last_inserted_id"), 2,
MakeAndAddRef<StoreLastInsertedIdFunction>());
RefPtr<StoreLastInsertedIdFunction> function =
new StoreLastInsertedIdFunction();
nsresult rv = aDBConn->CreateFunction(
NS_LITERAL_CSTRING("store_last_inserted_id"), 2, function);
NS_ENSURE_SUCCESS(rv, rv);
return NS_OK;
@ -987,8 +993,9 @@ StoreLastInsertedIdFunction::OnFunctionCall(mozIStorageValueArray* aArgs,
/* static */
nsresult GetQueryParamFunction::create(mozIStorageConnection* aDBConn) {
return aDBConn->RegisterFunction(NS_LITERAL_CSTRING("get_query_param"), 2,
MakeAndAddRef<GetQueryParamFunction>());
RefPtr<GetQueryParamFunction> function = new GetQueryParamFunction();
return aDBConn->CreateFunction(NS_LITERAL_CSTRING("get_query_param"), 2,
function);
}
NS_IMPL_ISUPPORTS(GetQueryParamFunction, mozIStorageFunction)
@ -1017,8 +1024,8 @@ GetQueryParamFunction::OnFunctionCall(mozIStorageValueArray* aArguments,
/* static */
nsresult HashFunction::create(mozIStorageConnection* aDBConn) {
return aDBConn->RegisterFunction(NS_LITERAL_CSTRING("hash"), -1,
MakeAndAddRef<HashFunction>());
RefPtr<HashFunction> function = new HashFunction();
return aDBConn->CreateFunction(NS_LITERAL_CSTRING("hash"), -1, function);
}
NS_IMPL_ISUPPORTS(HashFunction, mozIStorageFunction)
@ -1057,8 +1064,9 @@ HashFunction::OnFunctionCall(mozIStorageValueArray* aArguments,
/* static */
nsresult GetPrefixFunction::create(mozIStorageConnection* aDBConn) {
nsresult rv = aDBConn->RegisterFunction(NS_LITERAL_CSTRING("get_prefix"), 1,
MakeAndAddRef<GetPrefixFunction>());
RefPtr<GetPrefixFunction> function = new GetPrefixFunction();
nsresult rv =
aDBConn->CreateFunction(NS_LITERAL_CSTRING("get_prefix"), 1, function);
NS_ENSURE_SUCCESS(rv, rv);
return NS_OK;
@ -1089,9 +1097,9 @@ GetPrefixFunction::OnFunctionCall(mozIStorageValueArray* aArgs,
/* static */
nsresult GetHostAndPortFunction::create(mozIStorageConnection* aDBConn) {
nsresult rv =
aDBConn->RegisterFunction(NS_LITERAL_CSTRING("get_host_and_port"), 1,
MakeAndAddRef<GetHostAndPortFunction>());
RefPtr<GetHostAndPortFunction> function = new GetHostAndPortFunction();
nsresult rv = aDBConn->CreateFunction(NS_LITERAL_CSTRING("get_host_and_port"),
1, function);
NS_ENSURE_SUCCESS(rv, rv);
return NS_OK;
@ -1126,9 +1134,10 @@ GetHostAndPortFunction::OnFunctionCall(mozIStorageValueArray* aArgs,
/* static */
nsresult StripPrefixAndUserinfoFunction::create(
mozIStorageConnection* aDBConn) {
nsresult rv = aDBConn->RegisterFunction(
NS_LITERAL_CSTRING("strip_prefix_and_userinfo"), 1,
MakeAndAddRef<StripPrefixAndUserinfoFunction>());
RefPtr<StripPrefixAndUserinfoFunction> function =
new StripPrefixAndUserinfoFunction();
nsresult rv = aDBConn->CreateFunction(
NS_LITERAL_CSTRING("strip_prefix_and_userinfo"), 1, function);
NS_ENSURE_SUCCESS(rv, rv);
return NS_OK;
@ -1161,9 +1170,10 @@ StripPrefixAndUserinfoFunction::OnFunctionCall(mozIStorageValueArray* aArgs,
/* static */
nsresult IsFrecencyDecayingFunction::create(mozIStorageConnection* aDBConn) {
nsresult rv =
aDBConn->RegisterFunction(NS_LITERAL_CSTRING("is_frecency_decaying"), 0,
MakeAndAddRef<IsFrecencyDecayingFunction>());
RefPtr<IsFrecencyDecayingFunction> function =
new IsFrecencyDecayingFunction();
nsresult rv = aDBConn->CreateFunction(
NS_LITERAL_CSTRING("is_frecency_decaying"), 0, function);
NS_ENSURE_SUCCESS(rv, rv);
return NS_OK;
@ -1196,8 +1206,9 @@ IsFrecencyDecayingFunction::OnFunctionCall(mozIStorageValueArray* aArgs,
/* static */
nsresult SqrtFunction::create(mozIStorageConnection* aDBConn) {
nsresult rv = aDBConn->RegisterFunction(NS_LITERAL_CSTRING("sqrt"), 1,
MakeAndAddRef<SqrtFunction>());
RefPtr<SqrtFunction> function = new SqrtFunction();
nsresult rv =
aDBConn->CreateFunction(NS_LITERAL_CSTRING("sqrt"), 1, function);
NS_ENSURE_SUCCESS(rv, rv);
return NS_OK;
}
@ -1229,9 +1240,9 @@ SqrtFunction::OnFunctionCall(mozIStorageValueArray* aArgs,
/* static */
nsresult NoteSyncChangeFunction::create(mozIStorageConnection* aDBConn) {
nsresult rv =
aDBConn->RegisterFunction(NS_LITERAL_CSTRING("note_sync_change"), 0,
MakeAndAddRef<NoteSyncChangeFunction>());
RefPtr<NoteSyncChangeFunction> function = new NoteSyncChangeFunction();
nsresult rv = aDBConn->CreateFunction(NS_LITERAL_CSTRING("note_sync_change"),
0, function);
NS_ENSURE_SUCCESS(rv, rv);
return NS_OK;